A Layer represents a renderable subset of the scene. It can contain a list of mesh instances, lights and cameras, their render settings and also defines custom callbacks before, after or during rendering. Layers are organized inside LayerComposition in a desired order.

Constructors

Properties

id: number

A unique ID of the layer. Layer IDs are stored inside ModelComponent#layers, RenderComponent#layers, CameraComponent#layers, LightComponent#layers and ElementComponent#layers instead of names. Can be used in LayerComposition#getLayerById.

name: string

Name of the layer. Can be used in LayerComposition#getLayerByName.

onDisable: Function

Custom function that is called after the layer has been disabled. This happens when:

onEnable: Function

Custom function that is called after the layer has been enabled. This happens when:

Useful for allocating resources this layer will use (e.g. creating render targets).

opaqueSortMode: number

Defines the method used for sorting opaque (that is, not semi-transparent) mesh instances before rendering. Can be:

Defaults to SORTMODE_MATERIALMESH.

transparentSortMode: number

Defines the method used for sorting semi-transparent mesh instances before rendering. Can be:

Defaults to SORTMODE_BACK2FRONT.

Accessors

Methods

  • Adds an array of mesh instances to this layer.

    Parameters

    • meshInstances: MeshInstance[]

      Array of MeshInstance.

    • OptionalskipShadowCasters: boolean

      Set it to true if you don't want these mesh instances to cast shadows in this layer. Defaults to false.

    Returns void

  • Adds an array of mesh instances to this layer, but only as shadow casters (they will not be rendered anywhere, but only cast shadows on other objects).

    Parameters

    Returns void

  • Removes all mesh instances from this layer.

    Parameters

    • OptionalskipShadowCasters: boolean = false

      Set it to true if you want to continue the existing mesh instances to cast shadows. Defaults to false, which removes shadow casters as well.

    Returns void

  • Removes multiple mesh instances from this layer.

    Parameters

    • meshInstances: MeshInstance[]

      Array of MeshInstance. If they were added to this layer, they will be removed.

    • OptionalskipShadowCasters: boolean

      Set it to true if you want to still cast shadows from removed mesh instances or if they never did cast shadows before. Defaults to false.

    Returns void

  • Removes multiple mesh instances from the shadow casters list of this layer, meaning they will stop casting shadows.

    Parameters

    • meshInstances: MeshInstance[]

      Array of MeshInstance. If they were added to this layer, they will be removed.

    Returns void