Skip to main content

Editor.Model.LayerSet

Class

Represents an immutable set of scene layers, supporting set operations like union, intersection, and difference.

Index

Example

const allSet = Editor.Model.LayerSet.All;
const noneSet = Editor.Model.LayerSet.None;

console.log(`All set is empty: ${allSet.isEmpty()}`);
console.log(`None set is empty: ${noneSet.isEmpty()}`);
console.log(`All set mask: ${allSet.mask}`);

const setA = Editor.Model.LayerSet.fromId(Editor.Model.LayerId.Default);
const setB = Editor.Model.LayerSet.fromId(Editor.Model.LayerId.Ortho);

const union = setA.union(setB);
const intersection = setA.intersect(setB);
const difference = setA.except(setB);

console.log(`setA contains Default: ${setA.contains(Editor.Model.LayerSet.fromId(Editor.Model.LayerId.Default))}`);
console.log(`Union mask: ${union.mask}`);
console.log(`Intersection is empty: ${intersection.isEmpty()}`);
console.log(`Difference mask: ${difference.mask}`);

// Reconstruct a LayerSet from a raw bitmask
const fromMask = Editor.Model.LayerSet.fromMask(union.mask);
console.log(`fromMask equals union: ${fromMask.mask === union.mask}`);

const predefined = Editor.Model.LayerSet.PredefinedIds();
console.log(`Predefined ids mask: ${predefined.mask}`);

Properties

All

static All: LayerSet

A LayerSet containing all available layers.


mask

readonly mask: number

The underlying bitmask representing the set of active layers.


None

static None: LayerSet

An empty LayerSet containing no layers.

Methods

contains()

contains(other): boolean

Returns true if this set contains all layers in the given LayerSet.

Parameters

ParameterType
otherLayerSet

Returns

boolean


except()

except(other): LayerSet

Returns a new LayerSet with all layers from the given set removed.

Parameters

ParameterType
otherLayerSet

Returns

LayerSet


fromBit()

static fromBit(bit): LayerSet

Creates a LayerSet from a single bit index.

Parameters

ParameterType
bitnumber

Returns

LayerSet


fromId()

static fromId(layerId): LayerSet

Creates a LayerSet from a single LayerId.

Parameters

ParameterType
layerIdLayerId

Returns

LayerSet


fromMask()

static fromMask(mask): LayerSet

Creates a LayerSet from a raw bitmask value.

Parameters

ParameterType
masknumber

Returns

LayerSet


intersect()

intersect(other): LayerSet

Returns a new LayerSet containing only layers present in both sets.

Parameters

ParameterType
otherLayerSet

Returns

LayerSet


isEmpty()

isEmpty(): boolean

Returns true if this set contains no layers.

Returns

boolean


PredefinedIds()

static PredefinedIds(): LayerSet

Returns the collection of predefined layer identifiers.

Returns

LayerSet


toArray()

toArray(): LayerId[]

Returns an array of all LayerId values in this set.

Returns

LayerId[]


union()

union(other): LayerSet

Returns a new LayerSet combining all layers from both sets.

Parameters

ParameterType
otherLayerSet

Returns

LayerSet