Skip to main content

LayerSet

Class

Used to describe a set of layers that an object belongs to or interacts with.

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

Index

Example

Check if a Camera will render this SceneObject

// @input Component.Camera camera

// Check if the camera will render this SceneObject
var cameraLayer = script.camera.renderLayer;
var objectLayer = script.getSceneObject().layer;

var intersection = cameraLayer.intersect(objectLayer);

if (intersection.isEmpty()) {
print("camera won't render this object");
} else {
print("camera will render this object");
}

Add this SceneObject's layer to a Camera's render layer, so that the camera will render it.

// @input Component.Camera camera

// Add this SceneObject's layer to a Camera's render layer
var objectLayer = script.getSceneObject().layer;
script.camera.renderLayer = script.camera.renderLayer.union(objectLayer);

Create a new LayerSet based on a number

// Create a LayerSet based on 0
var layerSet = LayerSet.fromNumber(0);

Properties

numbers

numbers: number[]

Default Value

[0]

Methods

all()

static all(): LayerSet

Returns a new LayerSet that contains every layer. This is the default value for LightSource.renderLayer and Camera.renderLayer.

Returns

LayerSet

Since

Lens Scripting Version 364

Example

// @input Component.Camera camera
script.camera.renderLayer = LayerSet.all();

contains()

contains(other): boolean

Returns true if all layers in the other LayerSet are also present in this one.

Parameters

ParameterType
otherLayerSet

Returns

boolean


except()

except(other): LayerSet

Returns a new LayerSet that contains layers present in this LayerSet but not present in other.

Parameters

ParameterType
otherLayerSet

Returns

LayerSet


fromNumber()

static fromNumber(layerId): LayerSet

Returns a new LayerSet based on the passed in number.

Parameters

ParameterType
layerIdnumber

Returns

LayerSet


getTypeName()

static getTypeName(): TypeName<LayerSet>

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


intersect()

intersect(other): LayerSet

Returns a new LayerSet that only contains layers present in both this LayerSet and other.

Parameters

ParameterType
otherLayerSet

Returns

LayerSet


isEmpty()

isEmpty(): boolean

Returns true if this LayerSet contains no layers.

Returns

boolean


makeUnique()

static makeUnique(): LayerSet

Creates a new LayerSet that is guaranteed to be empty and not intersect existing layers. This bypasses the normal 32 layer limit in Studio, allowing for around 65,000 unique layers.

Returns

LayerSet


toString()

toString(): string

Returns a string representation of this LayerSet.

Returns

string


union()

union(other): LayerSet

Returns a new LayerSet combining this LayerSet and other.

Parameters

ParameterType
otherLayerSet

Returns

LayerSet

See also