Skip to main content

PropertyOverrides

Class

Overrides material properties on a single visual, without affecting other visuals that use the same material.

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

Overrides material properties on a single visual, without affecting other visuals that use the same material. Index it with a material number to get that material's MaterialPropertyOverrides. Used with MaterialMeshVisual.

delete overrides[0] removes all overrides of material 0 (Lens Scripting version 386). Assigning to a material (overrides[0] = ...) does nothing, so assign to its passes instead.

Ways to remove overrides, and the first Lens Scripting version each works in. On older versions a single key assigned undefined or null throws, and delete returns true but changes nothing.

  • A single key: pass.key = undefined or pass.key = null (384), or delete pass.key (386).
  • A key inside an assigned object (visual.mainPassOverrides = { a: 1, b: null }): null removes b (384). Earlier versions throw part-way through, with which keys were applied depending on the order of the keys.
  • A whole pass (overrides[m][p] = null or delete overrides[m][p]) or material (delete overrides[m]): 386. Handles you got for them stop affecting the visual.
  • Replacing the keys of the main pass: visual.mainPassOverrides = { ... } keeps only the keys you give, and = {} clears them. Both keep the handles you already have.
  • The main pass: visual.mainPassOverrides = null (386 when other overrides remain). This detaches handles you got earlier, so later writes through them are lost.

Reading mainPassOverrides, propertyOverrides[m] or propertyOverrides[m][p] creates empty overrides when there are none. delete visual.mainPassOverrides (the member itself) returns true and changes nothing.

Index

Example

//@input Component.MaterialMeshVisual visual
const overrides = script.visual.propertyOverrides;
overrides[0][0].baseColor = new vec4(1, 0, 0, 1);
overrides[0][0].baseColor = undefined; // removes one key (384)
delete overrides[0][0]; // removes pass 0 of material 0 (386)
delete overrides[0]; // removes material 0 (386)

Extends

Indexable

[index: string]: any

Methods

getTypeName()

static getTypeName(): TypeName<PropertyOverrides>

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

Since

Lens Scripting Version 304

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