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

See SceneObject's layer property, Camera's renderLayer property, and LightSource's renderLayer property.

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);
interface LayerSet {
    numbers: number[];
    contains(other: LayerSet): boolean;
    except(other: LayerSet): LayerSet;
    intersect(other: LayerSet): LayerSet;
    isEmpty(): boolean;
    toString(): string;
    union(other: LayerSet): LayerSet;
}

Properties

numbers: number[]

Methods

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

    Parameters

    Returns boolean

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

    Parameters

    Returns LayerSet

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

    Parameters

    Returns LayerSet

  • Returns true if this LayerSet contains no layers.

    Returns boolean

  • Returns a string representation of this LayerSet.

    Returns string

  • Returns a new LayerSet combining this LayerSet and other.

    Parameters

    Returns LayerSet