Scripting API
LayersModule
LayersModule Overview

LayersModule

The LayersModule class provides access to layers. It allow dynamic creation
and destruction of layers, modifying layer properties such as render order,
as well as changing what layer a scene object is in.

Example

//==============================================================================
// The following example demonstrates how to create layer and move it to top of
// the rendering order (rendered last), and move scene object named "Object1"
// into it.
//
// Project Setup
// - Create scene object named "Object1"
//==============================================================================

// Load in the required modules
const Layers = require('Layers');
const Scene = require('Scene');

// Enable async/await in JS [part 1]
(async function() {
  // Create new layer
  const [newLayer, object1] = await Promise.all([
    Layers.create({name:'NewLayer',renderOrder:Layers.END_COUNT}),
    Scene.root.findFirst('Object1')
  ]);

  // Place object1 into newLayer
  await Promise.all([
    Layers.setLayer(object1, newLayer)
  ]);
// Enable async/await in JS [part 2]
})();

Properties

PropertyDescription
END_COUNT
(get) END_COUNT: undefined
(set) END_COUNT: undefined


END_COUNT may be used for 'count' parameter to move to top with moveUp(), or to the bottom with moveDown()

Methods

MethodDescription
create
create(properties: {hidden: boolean, name: string, renderOrder: number}): Promise<Layer>


Creates a new layer with specified properties
destroy
destroy(l: Layer, option: DestroyOption): Promise<void>


Destroy the specfied layer. Only layers created dynamically through 'create' may be destroyed.
findFirst
findFirst(name: string): Promise<Layer | null>


Finds the first layer of a specified name
findUsingPattern
findUsingPattern(namePattern: string, config?: {limit: number}): Promise<Array<Layer>>


Return layers whose name match the pattern specified
getAll
getAll(): Promise<Array<Layer>>


Returns an array of all layers
getLayer
getLayer(obj: SceneObjectBase): Promise<Layer | null>


Get the layer, if it has one, that the specified scene object belongs to
moveDown
moveDown(l: Layer, count: number): Promise<number>


Change the rendering order of a layer, moving it down so that it renders sooner. Returns new render order.
moveUp
moveUp(l: Layer, count: number): Promise<number>


Change the rendering order of a layer, moving it up so that it renders later. Returns new render order.
setLayer
setLayer(obj: SceneObjectBase, lyr: Layer): Promise<void>


Set the layer that a scene object should belong to