Menu - Top - Home - Donate to Me

Shape

Back to documentation index.

new Shape(mesh)

An object that associates a geometric mesh (the shape of the object) with a transformation matrix (which defines the object's position and size). See the "Creating Shapes" tutorial.

Parameters

Methods

Shape#copy()

Makes a copy of this object. The copied object will have its own version of the transform. The copied shape won't have a parent.

Return Value

A copy of this object. (Type: Shape)

Shape#getBounds()

Finds a bounding box that holds all vertices in this shape. The bounding box is not guaranteed to be the tightest, and the box will be transformed to world space using this object's transform.

Return Value

An array of six numbers describing an axis-aligned bounding box that fits all vertices in the shape. The first three numbers are the smallest-valued X, Y, and Z coordinates, and the last three are the largest-valued X, Y, and Z coordinates. If the shape has no vertices, returns the array [Inf, Inf, Inf, -Inf, -Inf, -Inf]. (Type: Array.<number>)

Shape#getMatrix()

Gets the transformation matrix used by this shape. See Transform#getMatrix.

Return Value

The current transformation matrix. (Type: Array.<number>)

Shape#getMeshBuffer()

Returns a reference to the mesh buffer used by this shape.

Return Value

Return value. (Type: MeshBuffer)

Shape#getTransform()

Returns the transform used by this shape object. The transform won't be copied.

Return Value

Return value. (Type: Transform)

Shape#getVisible()

Gets whether this shape will be drawn on rendering.

Return Value

True if this shape will be visible; otherwise, false. (Type: boolean)

Shape#primitiveCount()

Gets the number of primitives (triangles, lines, and points) composed by all shapes in this scene.

Return Value

Return value. (Type: number)

Shape#setPosition(x, [y], [z])

Sets the relative position of this shape from its original position. See Transform#setPosition

Parameters

Return Value

This object. (Type: Shape)

Examples

// Set the relative position to 2 units along X axis, 4 units along Y axis,
// and 5 units along Z axis
shape.setPosition(2,4,5);
// same, but passing an array
shape.setPosition([2,4,5]);

Shape#setQuaternion(quat)

Sets this object's rotation in the form of a quaternion. See Transform#setQuaternion.

Parameters

Return Value

This object. (Type: Shape)

Examples

// rotate the shape 40 units about X axis, 20 units about Y axis,
// and 50 units about Z axis
shape.setQuaternion(H3DU.MathUtil.quatFromTaitBryan(40,20,50));
// rotate the shape 20 units about Y axis
shape.setQuaternion(H3DU.MathUtil.quatFromAxisAngle(20,0,1,0));

Shape#setScale(x, [y], [z])

Sets the scale of this shape relative to its original size. See Transform#setScale

Parameters

Return Value

This object. (Type: Shape)

Examples

// scale the shape by 2x in all axes
shape.setScale(2,2,2);
// same, but passing an array
shape.setScale([2,2,2]);

Shape#setTransform(transform)

Sets this shape's transformation to a copy of the given transformation.

Parameters

Return Value

This object. (Type: Shape)

Shape#setVisible(value)

Sets whether this shape will be drawn on rendering.

Parameters

Return Value

This object. (Type: Shape)

Shape#vertexCount()

Gets the number of vertices composed by all shapes in this scene.

Return Value

Return value. (Type: number)

Back to documentation index.