Skip to main content
Version: 0.12.0 (latest)

UeLayers

The UeLayers class manages membership of an object in up to 32 layers (0 to 31), represented internally as a bitmask. By default, an object is assigned to layer 0.

Layers are used to control visibility: an object is visible to a camera only if the object's layers intersect with the camera's layers.

All classes inheriting from Object3D have a layers property which is an instance of this class.

Constructor​

new UeLayers()​

Creates a new Layers object with membership initially set to layer 0.

Properties​

PropertyTypeDescription
maskIntegerBitmask representing active layers (32 bits).

Methods​

MethodParametersReturnsDescription
disable(layer)numberselfRemoves membership from the specified layer (0 to 31).
enable(layer)numberselfAdds membership to the specified layer (0 to 31).
set(layer)numberselfSets membership to only the specified layer, removing all others.
test(layers)UeLayersBooleanReturns true if this Layers object shares at least one common layer with the given Layers object.
isEnabled(layer)numberBooleanReturns true if the specified layer is enabled.
toggle(layer)numberselfToggles membership of the specified layer.
enableAll()selfEnables membership in all 32 layers.
disableAll()selfDisables membership from all layers.

Example​

const layers = new UeLayers();
layers.enable(1);
layers.disable(0);
if (layers.isEnabled(1)) {
console.log("Layer 1 is enabled.");
}