LayerSet
ClassUsed to describe a set of layers that an object belongs to or interacts with.
- Available on all platforms
Index
Properties
Methods
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()
staticall():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
| Parameter | Type |
|---|---|
other | LayerSet |
Returns
boolean
except()
except(
other):LayerSet
Returns a new LayerSet that contains layers present in this LayerSet but not present in other.
Parameters
| Parameter | Type |
|---|---|
other | LayerSet |
Returns
LayerSet
fromNumber()
staticfromNumber(layerId):LayerSet
Returns a new LayerSet based on the passed in number.
Parameters
| Parameter | Type |
|---|---|
layerId | number |
Returns
LayerSet
getTypeName()
staticgetTypeName():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
| Parameter | Type |
|---|---|
other | LayerSet |
Returns
LayerSet
isEmpty()
isEmpty():
boolean
Returns true if this LayerSet contains no layers.
Returns
boolean
makeUnique()
staticmakeUnique():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
| Parameter | Type |
|---|---|
other | LayerSet |
Returns
LayerSet
See also
- SceneObject
layerproperty - Camera
renderLayerproperty - LightSource
renderLayerproperty.