Table Of Contents

Previous topic

21.21. The ForwardRendering Object

Next topic

21.23. The GeometryInstance Object

This Page

21.22. The Geometry Object

A Geometry is a mesh usually referenced from a GeometryInstance that is attached to a SceneNode.

Geometry objects are usually created via Scene.load() but can be created procedurally.

Required scripts

The Geometry object requires:

/*{{ javascript("jslib/geometry.js") }}*/
/*{{ javascript("jslib/utilities.js") }}*/

21.22.1. Constructor

21.22.1.1. create

Summary

Creates and returns a Geometry object.

Syntax

var geometry = Geometry.create();

21.22.2. Properties

21.22.2.1. vertexBuffer

Summary

The VertexBuffer the geometry vertex data is stored in. The first used index is stored in baseIndex.

Syntax

var vertexBuffer = geometry.vertexBuffer;

21.22.2.2. baseIndex

Summary

The baseIndex is the first index in the vertexBuffer property of the geometry’s vertex data.

Syntax

var baseIndex = geometry.baseIndex;

21.22.2.3. semantics

Summary

The semantics of the vertex data stored in the vertexBuffer property.

Syntax

var semantics = geometry.semantics;

21.22.2.4. surfaces

Summary

The surfaces is a dictionary of named surfaces.

Syntax

var surfaces = geometry.surfaces;
for (var surface in surfaces)
{
    if (surfaces.hasOwnProperty(surface))
    {
        // ...
    }
}

21.22.2.5. type

Summary

The type is one of the geometryTypes. It is used in the Effects to find the relevant Technique for the vertex type.

Syntax

if ("rigid" === geometry.type)
{
    // ...
}

21.22.2.6. center

Summary

An array of 3 numbers for defining the center of the object’s bounding box.

Syntax

var center = geometry.center;

21.22.2.7. halfExtents

Summary

An array of 3 numbers for the half-extents of the object from the center.

Syntax

var minX = geometry.center[0] - geometry.halfExtents[0];

21.22.2.8. skeleton

Summary

The value is a skeleton object that is used in the skinning to find the matrices required to render the geometry.

This property is only defined if the type is skinned.

Syntax

var skeleton = geometry.skeleton;

21.22.2.9. reference

Summary

The reference object relating to this geometry. It is used by the Scene to manage a dictionary of Geometries.

Syntax

var reference = geometry.reference;

21.22.3. Methods

21.22.3.1. destroy

Summary

Free the resources attached to the object.

This is usually called automatically when a GeometryInstance is destroyed.

Syntax

geometry.destroy();