PropertyOverrides
ClassOverrides material properties on a single visual, without affecting other visuals that use the same material.
- Available on all platforms
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 = undefinedorpass.key = null(384), ordelete pass.key(386). - A key inside an assigned object (
visual.mainPassOverrides = { a: 1, b: null }):nullremovesb(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] = nullordelete 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
Methods
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()
staticgetTypeName():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
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
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
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean