cjcliffe edited this page Oct 25, 2011 · 7 revisions


The SceneObject class is a container used to represent an object in a Scene. A SceneObject can contain meshes, child SceneObjects or simply be a "Null" pointer or target for reference or animation.

SceneObject( obj_init )

obj_init may also be simply a Mesh to bind, undefined or null. CubicVR.get functionality is also supported for SceneObject.

Object Constructor:

var mySceneObject = new CubicVR.SceneObject({
  mesh: null,   // A [[Mesh]].
  name: null,   // Name of SceneObject for referencing/retrieval.
  motion: null, // A [[Motion]] for this SceneObject.
  position: [0.0, 0.0, 0.0],    // Position in [[Scene]] or relative to parent.
  rotation:  [0.0, 0.0, 0.0],   // Rotation in [[Scene]] or relative to parent.
  scale: [1.0,1.0,1.0],         // Scale in [[Scene]] or relative to parent.
  wireframe: false              // If mesh has edges render as wireframe if true.


bindChild( childSceneObject )

Bind another SceneObject as a child of this object. The child object's transformation becomes relative to the parent.


childSceneObject - Another SceneObject to bind as a child.



setWireframe( value )

If the mesh was created with buildWireframe:true or mesh.buildEdges() was called before compilation this will tell the SceneObject to render it as wireframe. Note this can be over-ridden to true at the Mesh or Scene level.


  • value : true to render the Mesh as wireframe, false otherwise.



getWireframe( )

Returns the current state of the SceneObject's wireframe flag.


true if set to wireframe, false if not.

getInstanceMaterials( )

Return an array of the current Mesh's materials as an instance. You can independently modify or replace the materials in the returned array to apply new materials to that specific instance of the Mesh.


getInstanceMaterial( name )

Return a specific material instanced by name. This will allow you to acquire and modify a specific material for the Mesh in the SceneObject that only applies to this specific instance.


  • name : A string name representing the "name" property of the Material. Alternately you can use the numeric index of the material.


A new instance of the Mesh's material referenced by name to be used for the SceneObject instance.

getAABB( )

Retrieve the SceneObject's current axis-aligned bounding box information. The AABB is just a bounding box that contains the SceneObject's mesh's transformed bounding box in world space.


Axis-aligned bounding box, format: [ [minX, minY, minZ] , [maxX, maxY, maxZ] ].