Scene

clay. Scene

# new Scene()

Source:

Extends

Members

# __uid__ :number

Source:
Inherited From:
Type:
  • number

# autoUpdateLocalTransform :boolean

Source:
Inherited From:

If the local transform is update from SRT(scale, rotation, translation, which is position here) each frame

Type:
  • boolean

# getBoundingBox

Source:
Inherited From:

Get bounding box of node

# invisible :boolean

Source:
Inherited From:

If node and its chilren invisible

Type:
  • boolean

# isFrustumCulled

Source:

If an scene object is culled by camera frustum

Object can be a renderable or a light

# localTransform :clay.Matrix4

Source:
Inherited From:

Affine transform matrix relative to its parent node. Composited with position, rotation and scale.

Type:

# material :clay.Material

Source:

Global material of scene

Type:

# name :string

Source:
Inherited From:

Scene node name

Type:
  • string

# position :clay.Vector3

Source:
Inherited From:

Position relative to its parent node. aka translation.

Type:

# rotation :clay.Quaternion

Source:
Inherited From:

Rotation relative to its parent node. Represented by a quaternion

Type:

# scale :clay.Vector3

Source:
Inherited From:

Scale relative to its parent node

Type:

# (nullable) target :clay.Vector3

Source:
Inherited From:
Type:

# viewBoundingBoxLastFrame :clay.BoundingBox

Source:

Scene bounding box in view space. Used when camera needs to adujst the near and far plane automatically so that the view frustum contains the visible objects as tightly as possible. Notice: It is updated after rendering (in the step of frustum culling passingly). So may be not so accurate, but saves a lot of calculation

Type:

# worldTransform :clay.Matrix4

Source:
Inherited From:

Affine transform matrix relative to its root scene.

Type:

Methods

# add(node)

Source:
Inherited From:

Add a child node

Parameters:
Name Type Description
node clay.Node

# after(name, action, contextopt)

Source:
Inherited From:
Mixes In:

Alias of once('after' + name)

Parameters:
Name Type Attributes Description
name string
action function
context Object <optional>

# before(name, action, contextopt)

Source:
Inherited From:
Mixes In:

Alias of once('before' + name)

Parameters:
Name Type Attributes Description
name string
action function
context Object <optional>

# childAt(idx) → {clay.Node}

Source:
Inherited From:

Get child scene node at given index.

Parameters:
Name Type Description
idx number
Returns:
Type
clay.Node

# children() → {Array.<clay.Node>}

Source:
Inherited From:

Get a new created array of all children nodes

Returns:
Type
Array.<clay.Node>

# clone() → {Node}

Source:
Inherited From:

Clone a new node

Returns:
Type
Node

# cloneNode(node) → {clay.Node}

Source:

Clone a node and it's children, including mesh, camera, light, etc. Unlike using Node#clone. It will clone skeleton and remap the joints. Material will also be cloned.

Parameters:
Name Type Description
node clay.Node
Returns:
Type
clay.Node

# decomposeLocalTransform()

Source:
Inherited From:

Decompose the local transform to SRT

# decomposeWorldTransform()

Source:
Inherited From:

Decompose the world transform to SRT

# dispose()

Source:

Dispose self, clear all the scene objects But resources of gl like texuture, shader will not be disposed. Mostly you should use disposeScene method in Renderer to do dispose.

# eachChild(callback, contextopt)

Source:
Inherited From:

Traverse all children nodes.

WARN DON'T do add, remove operation in the callback during iteration.

Parameters:
Name Type Attributes Description
callback function
context Node <optional>

# error(action, contextopt)

Source:
Inherited From:
Mixes In:

Alias of on('error')

Parameters:
Name Type Attributes Description
action function
context Object <optional>

# getChildByName(name) → {clay.Node}

Source:
Inherited From:

Get first child with the given name

Parameters:
Name Type Description
name string
Returns:
Type
clay.Node

# getDescendantByName(name) → {clay.Node}

Source:
Inherited From:

Get first descendant have the given name

Parameters:
Name Type Description
name string
Returns:
Type
clay.Node

# getMainCamera()

Source:

Get main camera of the scene.

# getNode(name) → {Node}

Source:
Deprecated:
  • Yes

Get node by name

Parameters:
Name Type Description
name string
Returns:
Type
Node

# getParent() → {clay.Scene}

Source:
Inherited From:

Get parent node

Returns:
Type
clay.Scene

# getPath(rootNodeopt) → {string}

Source:
Inherited From:

Get query path, relative to rootNode(default is scene)

Parameters:
Name Type Attributes Description
rootNode clay.Node <optional>
Returns:
Type
string

# getRenderList(camera) → {clay.Scene.RenderList}

Source:

Get render list. Used after clay.Scene#updateRenderList

Parameters:
Name Type Description
camera clay.Camera
Returns:
Type
clay.Scene.RenderList

# getScene() → {clay.Scene}

Source:
Inherited From:

Get the scene mounted

Returns:
Type
clay.Scene

# getWorldPosition(outopt) → {clay.Vector3}

Source:
Inherited From:

Get world position, extracted from world transform

Parameters:
Name Type Attributes Description
out clay.Vector3 <optional>
Returns:
Type
clay.Vector3

# has(name, action) → {boolean}

Source:
Inherited From:
Mixes In:

If registered the event handler

Parameters:
Name Type Description
name string
action function
Returns:
Type
boolean

# isAncestor(node)

Source:
Inherited From:

Return true if it is ancestor of the given scene node

Parameters:
Name Type Description
node clay.Node

# isRenderable() → {boolean}

Source:
Inherited From:

Return true if it is a renderable scene node, like Mesh and ParticleSystem

Returns:
Type
boolean

# isSkinnedMesh() → {boolean}

Source:
Inherited From:

If Node is a skinned mesh

Returns:
Type
boolean

# lookAt(target, upopt)

Source:
Inherited From:
See:
Parameters:
Name Type Attributes Description
target clay.Vector3
up clay.Vector3 <optional>

# off(action, contextopt)

Source:
Inherited From:
Mixes In:

Remove event listener

Parameters:
Name Type Attributes Description
action function
context Object <optional>

# on(name, action, contextopt)

Source:
Inherited From:
Mixes In:

Register event handler

Parameters:
Name Type Attributes Description
name string
action function
context Object <optional>

# once(name, action, contextopt)

Source:
Inherited From:
Mixes In:

Register event, event will only be triggered once and then removed

Parameters:
Name Type Attributes Description
name string
action function
context Object <optional>

# queryNode(path) → {clay.Node}

Source:
Inherited From:

Query descendant node by path

Example
node.queryNode('root/parent/child');
Parameters:
Name Type Description
path string
Returns:
Type
clay.Node

# remove(node)

Source:
Inherited From:

Remove the given child scene node

Parameters:
Name Type Description
node clay.Node

# removeAll()

Source:
Inherited From:

Remove all children

# rotateAround(point, axis, angle)

Source:
Inherited From:
See:

Rotate the node around a axis by angle degrees, axis passes through point

Parameters:
Name Type Description
point clay.Vector3

Center point

axis clay.Vector3

Center axis

angle number

Rotation angle

# setLocalTransform(matrix)

Source:
Inherited From:

Set the local transform and decompose to SRT

Parameters:
Name Type Description
matrix clay.Matrix4

# setMainCamera(camera)

Source:

Set main camera of the scene.

Parameters:
Name Type Description
camera claygl.Camera

# setName(name)

Source:
Inherited From:

Set the name of the scene node

Parameters:
Name Type Description
name string

# setWorldTransform(matrix)

Source:
Inherited From:

Set the world transform and decompose to SRT

Parameters:
Name Type Description
matrix clay.Matrix4

# success(action, contextopt)

Source:
Inherited From:
Mixes In:

Alias of on('success')

Parameters:
Name Type Attributes Description
action function
context Object <optional>

# traverse(callback, contextopt)

Source:
Inherited From:

Depth first traverse all its descendant scene nodes.

WARN Don't do add, remove operation in the callback during traverse.

Parameters:
Name Type Attributes Description
callback function
context Node <optional>

# trigger(name)

Source:
Inherited From:
Mixes In:

Trigger event

Parameters:
Name Type Description
name string

# update(forceUpdateWorld)

Source:
Inherited From:

Update local transform and world transform recursively

Parameters:
Name Type Description
forceUpdateWorld boolean

# updateLocalTransform()

Source:
Inherited From:

Update local transform from SRT Notice that local transform will not be updated if _dirty mark of position, rotation, scale is all false

# updateRenderList(camera, updateSceneBoundingBox) → {clay.Scene.RenderList}

Source:

Traverse the scene and add the renderable object to the render list. It needs camera for the frustum culling.

Parameters:
Name Type Description
camera clay.Camera
updateSceneBoundingBox boolean
Returns:
Type
clay.Scene.RenderList

# updateWorldTransform()

Source:
Inherited From:

Update world transform before whole scene is updated.

Type Definitions

# RenderList

Source:
Properties:
Name Type Description
opaque Array.<clay.Renderable>
transparent Array.<clay.Renderable>
Type:
  • Object