Layer in Anark Studio 2.5

Represents a layer in the scene.

Inherits from:

Instance Properties

name type description
active Boolean Should this asset be drawn? [from Asset]
behaviors Collection (read only) All Behavior objects attached under this asset. [from Asset]
cameras Collection (read only) All cameras attached to this object. [from Node]
clickable Boolean Can this object be clicked on? [from Node]
color Color Background color for the layer.
constructor Object A reference to the constructor class for the current object instance. [from Object]
context TimeContext (read only) The asset's local TimeContext object. [from Asset]
contextType Number Type of the TimeContext for this asset. [from Asset]
endLifeTime Number Ending time of the asset. [from Asset]
groups Collection (read only) All groups attached to this object. [from Node]
height Number Percentage height of the scene.
id Number (read only) Unique ID for the asset. [from Asset]
lastGlobalTransform Matrix (read only) Cumulative transformation applied to this object. [from Node]
lights Collection (read only) All lights attached to this node. [from Node]
models Collection (read only) All models attached to this node. [from Node]
music Collection (read only) All Music objects attached under this asset. [from Asset]
name String User-defined name for the asset. [from Asset]
opacity Number Opacity of the object. [from Node]
parent Object (read only) Parent object of this asset. [from Asset]
pivot Vector Pivot point location. [from Node]
pivotx Number Horizontal pivot location.
pivoty Number Vertical pivot location.
position Vector Location of the object. [from Node]
prototype Object The prototype for a class. [from Object]
rotation Rotation Rotation of the object. [from Node]
scale Vector Scale of the object. [from Node]
sounds Collection (read only) All Sounds objects attached under this asset. [from Asset]
startLifeTime Number Starting time of the asset. [from Asset]
transparentBackground Boolean Should this layer obscure layers behind it?
type String (read only) Type of the asset. [from Asset]
width Number Percentage width of the scene.
x Number Percentage across the scene to draw.
y Number Percentage down the scene to draw.

Instance Methods

name returns description
attach(assetObject) (none) Attach the argument underneath the asset. [from Asset]
copy() Asset Create a copy of the asset. [from Asset]
detach(assetObject) (none) Remove an asset from this asset. [from Asset]
hasOwnProperty(propertyOrMethodName) Boolean Determines if the object/instance itself has the named property or method. [from Object]
isPrototypeOf(instanceToTest) Boolean Determines if the calling object prototype is in the inheritance chain for the supplied argument. [from Object]
propertyIsEnumerable(propertyOrMethodName) Boolean Determines if the object/instance itself has a property or method of the supplied name which will appear in a for (prop in obj) enumeration. [from Object]
removeChildren() (none) Remove all children from this node. [from Node]
toLocaleString() String For most objects, the same as toString() unless explicitly overridden. [from Object]
toString() String Returns a string representation of the object. [from Object]
valueOf() String Returns the internal this value of the object. [from Object]

Description

The Layer object is a special type of group that can only be attached to the Scene. The scene is composed of a number of layers, each layer representing a collection of elements that are grouped together for exclusive display purposes.

Each time the scene is drawn, the layers are drawn in order from back to front, allowing for complex image composition capabilities. When a layer is created, it contains a default camera and a default light. The settings for the default camera and light can be changed, and new cameras and lights (and any other node type) can be created and attached; however, there can only be one active camera for a layer at a given time.

The layer is rendered as a full 3D scene from the viewpoint of its active camera. Layers are independent of other layers, such that the elements on successively ordered layers can never be obscured by elements on previous layers. This behavior allows robust functionality such as complex overlaid menuing systems and elegantly encapsulated media organization.

There are two types of object constructors for layers. The Library asset constructor creates a new instance of the object from a resource in the Anark Studio Library. The scripting object constructor creates an empty Layer object. Objects created via scripting are not available to the Anark Studio interface, but they do appear in the finished project.

Library asset constructor syntax

var theLayer = new Layer( "library://libraryAssetName" [, addToScene] );
libraryAssetName
required — A String with the name of the asset in the Anark Studio Library from which to create this object.
addToScene
optional — This Boolean flag specifies whether this layer will be added to the scene. Currently, true is the only valid setting. Omit this parameter to prevent the scene from being automatically added to the scene.

Scripting object constructor syntax

var theLayer = new Layer( [sceneGraphName] [, addToScene] );
sceneGraphName
optional — A String with the name for the new group in the scene graph.
addToScene
optional — This Boolean flag specifies whether this layer will be added to the scene. Currently, true is the only valid setting. Omit this parameter to prevent the scene from being automatically added to the scene.

Layer Examples

// Create a new layer.  
theLayer = new Layer( "BackgroundLayer");  

//Attach the layer to the scene.  
scene.attach( theLayer );  

// Add an existing model to a layer.  
theLayer.attach( theModel );

Arguments that are a Layer

name in method of object description
layerObject attach(layerObject) Scene The Layer object to attach.
layerObject detach(layerObject) Scene The Layer object to detach.