Camera

clay. Camera

# new Camera()

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

# frustum :clay.Frustum

Source:

Camera frustum in view space

Type:

# getBoundingBox

Source:
Inherited From:

Get bounding box of node

# invisible :boolean

Source:
Inherited From:

If node and its chilren invisible

Type:
  • boolean

# invProjectionMatrix :clay.Matrix4

Source:

Inverse of camera projection matrix

Type:

# localTransform :clay.Matrix4

Source:
Inherited From:

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

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:

# projectionMatrix :clay.Matrix4

Source:

Camera projection matrix

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:

# viewMatrix :clay.Matrix4

Source:

View matrix, equal to inverse of camera's world matrix

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>

# castRay(ndc, outopt) → {clay.Ray}

Source:

Cast a picking ray from camera near plane to far plane

Parameters:
Name Type Attributes Description
ndc clay.Vector2
out clay.Ray <optional>
Returns:
Type
clay.Ray

# 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

# decomposeLocalTransform()

Source:
Inherited From:

Decompose the local transform to SRT

# decomposeProjectionMatrix()

Source:

Decompose camera projection matrix

# decomposeWorldTransform()

Source:
Inherited From:

Decompose the world transform to SRT

# 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

# 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

# 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

# setName(name)

Source:
Inherited From:

Set the name of the scene node

Parameters:
Name Type Description
name string

# setProjectionMatrix(projectionMatrix)

Source:

Set camera projection matrix

Parameters:
Name Type Description
projectionMatrix clay.Matrix4

# setViewMatrix()

Source:

Set camera view matrix

# 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:
Overrides:

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

# updateProjectionMatrix()

Source:

Update projection matrix, called after update

# updateWorldTransform()

Source:
Inherited From:

Update world transform before whole scene is updated.