RD.SceneNode Class
SceneNode class to hold an scene item
Constructor
RD.SceneNode
()
Item Index
Methods
- addChild
- clear
- configure
- findNode
- fromMatrix
- getAllChildren
- getDistanceTo
- getGlobalMatrix
- getGlobalPoint
- getGlobalPosition
- getGlobalRotation
- getGlobalVector
- getLocalMatrix
- getLocalPoint
- getLocalVector
- getVisibleChildren
- propagate
- removeChild
- resetTransform
- rotate
- scale
- serialize
- setChildIndex
- setMesh
- setPivot
- setTexture
- translate
- updateGlobalMatrix
- updateLocalMatrix
- updateMatrices
Methods
clear
()
Remove all childs
configure
-
o
Configure this SceneNode to a state from an object (used with serialize)
Parameters:
-
o
Objectobject with the state of a SceneNode
findNode
-
id
Searchs the node and returns the first child node with the matching id, it is a recursive search so it is slow
Parameters:
-
id
Stringthe id of the node
Returns:
result node otherwise null
fromMatrix
-
m
-
[is_global=false]
updates position, rotation and scale from the matrix
Parameters:
-
m
Mat4the matrix
-
[is_global=false]
Bool optionalif the matrix is in global or local space
getAllChildren
-
result
Recursively retrieves all children nodes (this doesnt include itself)
Parameters:
-
result
Array[Optional] you can specify an array where all the children will be pushed
Returns:
all the children nodes
getDistanceTo
-
position
Returns the distance between the center of the node and the position in global coordinates
Parameters:
-
position
Vec3the point
Returns:
result
getGlobalMatrix
()
Mat4
Get transform global matrix (concatenating parents) (its a reference)
Returns:
matrix44
getGlobalPoint
-
v
-
[result=vec3]
Returns a point multiplied by the global matrix
Parameters:
-
v
Vec3the point
-
[result=vec3]
Vec3 optionalwhere to store the output
Returns:
result
getGlobalPosition
-
[result=optional]
-
[fast=optional]
Returns the node position in global coordinates
Parameters:
-
[result=optional]
Vec3 optionalwhere to store the output
-
[fast=optional]
Boolean optionaluses the current global amtrix without recomputing it, is faster but if the current matrix hasnt been updated the result will be wrong
Returns:
result
getGlobalRotation
-
[result=quat]
Get global rotation (concatenating parent rotations)
Parameters:
-
[result=quat]
Quat optionalquaternion to store the result
Returns:
resulting rotation in quaternion format
getGlobalVector
-
v
-
[result=vec3]
Returns a point rotated by the global matrix
Parameters:
-
v
Vec3the point
-
[result=vec3]
Vec3 optionalwhere to store the output
Returns:
result
getLocalMatrix
()
Mat4
Get transform local matrix
Returns:
matrix44
getLocalPoint
-
v
-
[result=vec3]
Returns a point multiplied by the local matrix
Parameters:
-
v
Vec3the point
-
[result=vec3]
Vec3 optionalwhere to store the output
Returns:
result
getLocalVector
-
v
-
[result=vec3]
Returns a point rotated by the local rotation
Parameters:
-
v
Vec3the point
-
[result=vec3]
Vec3 optionalwhere to store the output
Returns:
result
getVisibleChildren
-
[result=[]]
Recursively retrieves all children nodes taking into account visibility (flags.visible)
Parameters:
-
[result=[]]
Array optionalyou can specify an array where all the children will be pushed
Returns:
all the children nodes
propagate
-
method
-
params
calls a function in child nodes
Parameters:
-
method
Stringname
-
params
Arrayarray containing the params
removeChild
-
node
Remove a node from its children list
Parameters:
-
node
SceneNode
resetTransform
()
clears position, rotation and scale
rotate
-
angle_in_rad
-
axis
-
in_local
Rotate object (supports local or global but doesnt takes into account parent)
Parameters:
-
angle_in_rad
Number -
axis
Vec3 -
in_local
Booleanspecify if the axis is in local space or global space
scale
-
v
Scale object
Parameters:
-
v
Vec3
serialize
()
Object
Returns an object that represents the current state of this object an its children
Returns:
object
setChildIndex
-
child
-
index
Change the order inside the children, useful when rendering without Depth Test
Parameters:
-
child
RD.SceneNode -
index
Number
setMesh
-
mesh_name
sets the name of the mesh to be used to render the object
Parameters:
-
mesh_name
String | Meshalso it accepts a mesh itself
setPivot
-
pivot
Set the pivot point, 0,0,0 by default (WARNING: use flags.pivot = true to enable the use of the pivot)
Parameters:
-
pivot
Vec3local coordinate of the pivot point
setTexture
-
channel
-
texture
Sets the name of the mesh to be used to render the object
Parameters:
-
channel
Stringwhich channel to use (the texture will be uploaded to the shader with the name "u_" + channel + "_texture"
-
texture
Stringtexture name (textures are retrieved from the renderer.textures
translate
-
delta
Translate object in local space
Parameters:
-
delta
Vec3
updateGlobalMatrix
-
[fast=false]
-
[update_childs=false]
recomputes _global_matrix according to position, rotation and scaling
Parameters:
-
[fast=false]
Boolean optionalskips recomputation of parent, use it only if you are sure its already updated
-
[update_childs=false]
Boolean optionalupdate global matrix in childs too
updateLocalMatrix
()
recomputes _local_matrix according to position, rotation and scaling
updateMatrices
-
[fast=false]
recompute local and global matrix
Parameters:
-
[fast=false]
Bool optionaluses the global matrix as it is in the parent node instead of crawling all the ierarchy
Properties
color
Vec4
The color in RGBA format
Default: [1,1,1,1]
id
String
A unique identifier, useful to retrieve nodes by name
opacity
Number
This number is the 4� component of color but can be accessed directly
parentNode
SceneNode
The parent node where this node is attached
position
Vec3
The position relative to its parent in vec3 format
rotation
Quat
The orientation relative to its parent in quaternion format
scaling
Vec3
The scaling relative to its parent in vec3 format (default is [1,1,1])
scene
Scene
The scene where this node is attached
shader
String
the name of the shader in the shaders manager
texture
String
name of texture to use in the color channel (the same as SetTexture("color", name ))
uniforms
Vec3
The position relative to its parent