The GeometryInstance is the standard implementation of the Renderable Interface.
It owns a reference to a Geometry object and is usually attached to a SceneNode, either automatically during loading or via SceneNode.addRenderable().
Required scripts
The GeometryInstance object requires:
/*{{ javascript("jslib/geometry.js") }}*/
/*{{ javascript("jslib/utilities.js") }}*/
It also requires that a GraphicsDevice has been created before calling the GeometryInstance constructor.
Summary
Creates and returns a GeometryInstance object with passed in Geometry.
Syntax
var geometryInstance = GeometryInstance.create(geometry,
surface,
sharedMaterial);
Summary
Creates a GeometryInstance by cloning an existing GeometryInstance.
Syntax
var newGeometryInstance = geometryInstance.clone();
Summary
Get the world extents of the GeometryInstance.
This is only valid when attached to a SceneNode and the node has been updated.
Syntax
var extents = geometryInstance.getWorldExtents();
Returns an extents array.
Summary
User defined extents that replace the ones calculated from the Geometry and the SceneNode’s world transform.
Syntax
var customExtents = geometryInstance.getWorldExtents().slice();
var padding = 10;
customExtents[0] -= padding;
customExtents[1] -= padding;
customExtents[2] -= padding;
customExtents[3] += padding;
customExtents[4] += padding;
customExtents[5] += padding;
geometryInstance.addCustomWorldExtents(customExtents);
The GeometryInstance must be attached to a SceneNode. Even if the SceneNode moves the extents will not be recalculated. This can be used as an optimization for animated objects that are constrained to a location.
Summary
Remove previously attached custom world extents.
Syntax
geometryInstance.removeCustomWorldExtents();
Summary
Get previously attached world extents. Maybe undefined.
Syntax
var extents = geometryInstance.getCustomWorldExtents();
Returns an extents array.
Summary
Returns a whether the object has custom world extents.
Syntax
if (geometryInstance.hasCustomWorldExtents())
{
//...
}
Summary
Get the SceneNode the GeometryInstance is attached to.
Syntax
var node = geometryInstance.getNode();
Summary
Set the material.
Syntax
geometryInstance.setMaterial(material);
Summary
The TechniqueParameters object for this particular instance.
Syntax
geometryInstance.techniqueParameters.materialColor = color;