Skip to main content

VertexSimulationSettings

Class

Provides settings for vertex physics in the ClothVisual component.

  • Available on all platforms
Platform details: Snapchat, SPECS, Camera Kit Web, Camera Kit Mobile fully supported.

Platform details

  • Snapchat — Fully supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Fully supported.

  • Camera Kit Mobile — Fully supported.

Since Lens Scripting v149

Index

Example

//Create Cloth Visual Component
var clothVisual = script.getSceneObject().createComponent(ClothVisual.getTypeName());

// yellow vertex colors
var yellow = new vec4(1.0, 1.0, 0.0, 1.0);

// different color mask (picking which color channel to compare)
var colorMask = new vec4b(true, true, true, true);
var yellowIndices = [];

//Initialize ClothVisual Component
clothVisual.onInitialized = clothInitCallback;
clothVisual.updatePriority = 0;

function clothInitCallback(clothVisualArg) {
var yellowIndices = clothVisualArg.getPointIndicesByColor(yellow, colorMask);

// create a vertex settings and set specific simulation settings value on it
var vertexSettings = ClothVisual.createVertexSettings();
vertexSettings.stretchStiffness = 0.75;
vertexSettings.bendStiffness = 0.75;
vertexSettings.stretchStiffnessGlobalWeight = 0.0;
vertexSettings.bendStiffnessGlobalWeight = 0.0;

// set this vertex simulation settings to all the yellow vertices with
for (var i = 0; i < yellowIndices.length; i++) {
clothVisual.setVertexSettings(yellowIndices[i], vertexSettings);
}

// we can also use getVertexSettings(vertexIndex) and modify vertex settings.
clothVisual.resetSimulation();
}

Extends

Properties

bendStiffness

bendStiffness: number

Bend Stiffness value.

Since

Lens Scripting Version 149

Default Value

0

bendStiffnessGlobalWeight

bendStiffnessGlobalWeight: number

BendStiffness value weight on Global Simulation Settings for this vertex.

Since

Lens Scripting Version 149

Default Value

1

friction

friction: number

Friction value.

Since

Lens Scripting Version 149

Default Value

0

frictionGlobalWeight

frictionGlobalWeight: number

Friction value weight on Global Simulation Settings for this vertex.

Since

Lens Scripting Version 149

Default Value

1

mass

mass: number

Mass value.

Since

Lens Scripting Version 149

Default Value

0

massGlobalWeight

massGlobalWeight: number

Mass value weight on Global Simulation Settings for this vertex.

Since

Lens Scripting Version 149

Default Value

1

stretchStiffness

stretchStiffness: number

Stretch Stiffness value.

Since

Lens Scripting Version 149

Default Value

0

stretchStiffnessGlobalWeight

stretchStiffnessGlobalWeight: number

StretchStiffness value weight on Global Simulation Settings for this vertex.

Since

Lens Scripting Version 149

Default Value

1

Methods

getTypeName()

static getTypeName(): TypeName<VertexSimulationSettings>

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<VertexSimulationSettings>

Since

Lens Scripting Version 149

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


isSame()

isSame(other): boolean

Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame