Skip to main content

Matter

Class

Settings for the physical substance, such as friction and bounciness, of a collider.

  • 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 v169

Settings for the physical substance, such as friction and bounciness, of a collider. If unset, uses the default matter from the world settings.

Index

Example

// @input Physics.WorldComponent worldComponent
// @input Physics.Matter matter

script.matter.friction = 1;
var worldSettings = script.worldComponent.worldSettings;
worldSettings.defaultMatter = script.matter;

Extends

Properties

dynamicBounciness

dynamicBounciness: number

Bounciness, or restitution, for dynamic bodies. This is the proportion of energy preserved after a collision, in the range 0 to 1.

  • Dynamic bounciness should usually be less than 1.0, to prevent energy from accumulating excessively (there is a certain amount of energy gained due to collision response).
  • The effective bounciness for a collision is the product of both colliding objects. So if your bounciness setting appears to have no effect, it probably means the object it's colliding with has 0 bounciness.

Since

Lens Scripting Version 169

Default Value

0

friction

friction: number

Coefficient of friction.

  • The effective friction between two objects is the product of both objects' friction.
  • Typical ranges are between 0 and 1, but larger values (up to 10) are allowed. This may be used to increase the effective friction when colliding against another object with low friction.
  • This is a very simplified approximation of realistic friction, since it does not correctly take into account the combined surface characteristics of both objects. It also doesn't distinguish between static and dynamic friction.

Since

Lens Scripting Version 169

Default Value

0.5

name

name: string

The name of the Asset in Lens Studio.

Default Value

""

Inherited from

Asset.name


rollingFriction

rollingFriction: number

Friction applied to rolling objects. This isn't physically realistic, but helps prevent objects from rolling indefinitely.

Since

Lens Scripting Version 169

Default Value

0.02

spinningFriction

spinningFriction: number

Friction applied to spinning objects. This isn't physically realistic, but helps prevent objects from spinning indefinitely.

Since

Lens Scripting Version 169

Default Value

0.02

staticBounciness

staticBounciness: number

Bounciness (AKA restitution), for static colliders. This is the proportion of energy preserved after a collision, in the range 0 to 1.

  • Typically we use high bounciness for static colliders because they are unaffected by collision, and thus maximally preserve energy.
  • The effective bounciness for a collision is the product of both colliding objects. So if your bounciness setting appears to have no effect, it probably means the object it's colliding with has 0 bounciness.

Since

Lens Scripting Version 169

Default Value

1

uniqueIdentifier

readonly uniqueIdentifier: string

Since

Lens Scripting Version 176

Inherited from

Asset.uniqueIdentifier

Methods

getTypeName()

static getTypeName(): TypeName<Matter>

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<Matter>

Since

Lens Scripting Version 169

Overrides

Asset.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

Asset.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

Asset.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

Asset.isSame