# Class: scenenode

The SceneTree is a hierarchical SceneGraph organised as tree, containing scenenodes. The SceneTree is optimized for static data, for dynamic nodes better use actornodes, however the scenenodes can be changed in position and rotation just fine as well.
Retrieving world data can return wrong results, you need to wait one frame until they are uptodate or enforce a full tree updateall.
Compared to the other visual node types, scenenodes are automatically linked to the rootnode on creation, however this won't prevent garbagecollection.

## Hierarchy

    o-+ spatialnode
      o-+ scenenode

## Methods:

### Method overview:

- delete
- getroot
- localmatrix
- localpos
- localrotaxis
- localrotdeg
- localrotquat
- localrotrad
- new
- parent
- terrain
- transform
- updateall
- vistestbbox
- worldmatrix
- worldpos
- worldrotaxis
- worldrotdeg
- worldrotquat
- worldrotrad

new (string name,[boolean drawable],[float x,y,z])
  returns: ([scenenode s3d])
  creates a new scenenode with given position as local pos. By default has root as parent.
delete (scenenode)
  returns: ()
  removes the Node from the SceneTree and deletes it. withchildren defaults to false
getroot ()
  returns: (scenenode s3d)
  returns the root node. The root node can't be deleted nor modified
localmatrix (scenenode s3d,[matrix4x4])
  returns: ([matrix4x4])
  updates node's local matrix or returns it
localpos (scenenode s3d,[float x,y,z])
  returns: (float x,y,z)
  updates node's local position or returns it
localrotaxis (scenenode s3d,[float Xx,Xy,Xz, Yx,Yy,Yz, Zx,Zy,Zz])
  returns: ([float Xx,Xy,Xz, Yx,Yy,Yz, Zx,Zy,Zz])
  returns or sets local rotation axis, make sure they make a orthogonal basis.
localrotdeg (scenenode s3d,[float x,y,z])
  returns: (float x,y,z)
  updates node's local rotation or returns it in degrees
localrotquat (scenenode s3d,[float x,y,z,w])
  returns: (float x,y,z,w)
  updates node's local rotation or returns it as quaternion
localrotrad (scenenode s3d,[float x,y,z])
  returns: (float x,y,z)
  updates node's local rotation or returns it in radians
parent (scenenode s3d,[scenenode parent])
  returns: ([scenenode parent])
  return or sets parent. If parent is not a scenenode, the node becomes unlinked. ==parent will prevent gc of self, unless parent is root.
terrain (scenenode,[terrain]/[l3dterrain])
  returns: (terrain)
  returns or sets scenenode as terrain. Children will be put on terrain with local matrix Z as offset in height.
transform (scenenode self,float x,y,z)
  returns: (float x,y,z)
  transforms x,y,z with final matrix of the node into world coordinates
updateall ()
  returns: ()
  done automatically before rendering is done, but if you need uptodate world data, right after setting your scenenodes, call this function.
vistestbbox (scenenode self, [float minX,minY,minZ,maxX,maxY,maxZ])
  returns: ([float minX,minY,minZ,maxX,maxY,maxZ])
  sets/gets visibility testing boundingbox when scenenode is drawable
worldmatrix (scenenode s3d)
  returns: ([matrix4x4])
  returns node's world matrix
worldpos (scenenode s3d)
  returns: (float x,y,z)
  returns world position
worldrotaxis (scenenode s3d,[float Xx,Xy,Xz, Yx,Yy,Yz, Zx,Zy,Zz])
  returns: ([float Xx,Xy,Xz, Yx,Yy,Yz, Zx,Zy,Zz])
  returns or sets last world rotation axis, make sure they make a orthogonal basis.
worldrotdeg (scenenode s3d)
  returns: (float x,y,z)
  returns world rotation (degrees)
worldrotquat (scenenode s3d,[float x,y,z,w])
  returns: (float x,y,z,w)
  returns world rotation as quaternion
worldrotrad (scenenode s3d)
  returns: (float x,y,z)
  returns world rotation (radians)

## Inherited Methods: