Layers

A Layers object assigns an Object3D to 1 or more of 32 layers numbered 0 to 31 — internally the layers are stored as a bit mask.

This can be used to control visibility — an object must share a layer with a camera to be visible when that camera's view is rendered.

All classes that inherit from Object3D have an Object3D.layers property which is an instance of this class.

Default Layers

By default only channel 0 is enabled for all objects and cameras, however additional layers can be occupied by Verge3D to implement various features:

1 Left camera when using VR mode.
2 Right camera when using VR mode.
3 Reflection pass when using SSR postprocessing.
4 Object rendered after reflection pass when using SSR postprocessing.
5 Refraction pass when using SSR postprocessing.
6 Object rendered after refraction pass when using SSR postprocessing.
7 HiDPI render pass.

Constructor

Layers()

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

Properties

.mask : Integer

A bit mask storing which of the 32 layers this layers object is currently a member of.

Methods

.disable(layer : Integer)

layer — an integer from 0 to 31.

Remove membership of this layer.

.enable(layer : Integer)

layer — an integer from 0 to 31.

Add membership of this layer.

.set(layer : Integer)

layer — an integer from 0 to 31.

Set membership to layer, and remove membership all other layers.

.test(layers : Layers) → Boolean

layers — a Layers object.

Returns true if this and the passed layers object have at least one layer in common.

.isEnabled(layer : Integer) → Boolean

layer — an integer from 0 to 31.

Returns true if the given layer is enabled.

.toggle(layer : Integer)

layer — an integer from 0 to 31.

Toggle membership of layer.

.enableAll()

Add membership to all layers.

.disableAll()

Remove membership from all layers.

Source

For more info on how to obtain the source code of this module see this page.