ShapeGroup
Represents a grouping of shapes. This object can hold both Shape objects and other ShapeGroup objects.
Methods
- addShape
Adds a 3D shape to this shape group, at the end of the list of shapes. - copy
Makes a copy of this shape group and the objects contained in it. - getBounds
Finds a bounding box that holds all vertices in this shape group. - getMatrix
Gets a copy of the transformation needed to transform this shape group’s coordinates to world coordinates. - getShape
Gets the shape or shape group located in this shape group at the given index. - getTransform
Gets a reference to the transform used by this shape group object. - getVisible
Gets whether this shape group will be drawn on rendering. - primitiveCount
Gets the number of primitives (triangles, lines, and points) composed by all shapes in this shape group. - removeShape
Removes all instances of a 3D shape from this shape group - setPosition
Sets the relative position of the shapes in this group from their original position. - setQuaternion
Sets this shape group’s rotation in the form of a glmath. - setScale
Sets the scale of this shape group relative to its original size. - setShape
Sets a shape or shape group at the given index in this shape group. - setTransform
Sets the transform used by this shape group to a copy of the given transform. - setVisible
Sets whether this shape group will be drawn on rendering. - shapeCount
Returns the number of shapes and/or shape groups that are direct children of this shape group. - vertexCount
Gets the number of vertices composed by all shapes in this shape group.
### ShapeGroup#addShape(shape)
Adds a 3D shape to this shape group, at the end of the list of shapes. Its reference, not a copy, will be stored in the list of shapes.
Parameters
-
shape
(Type: ShapeShapeGroup)
A 3D shape. Throws an error if null.
Return Value
This object. (Type: ShapeGroup)
Makes a copy of this shape group and the objects contained
in it. The copied object will
will have its own version of the transform and
visibility flag, and any objects contained in this one
will be copied using their copy()
method.
The copied shape group won’t have a parent.
Return Value
A copy of this shape group. (Type: ShapeGroup)
Finds a bounding box that holds all vertices in this shape group. The bounding box is not guaranteed to be the tightest, and the box will be in world space coordinates.
Return Value
An array of six numbers describing an axis-aligned bounding box that fits all vertices in the shape group. 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 group has no vertices, returns the array [Inf, Inf, Inf, -Inf, -Inf, -Inf]. (Type: Array.<number>)
Gets a copy of the transformation needed to transform this shape group’s coordinates to world coordinates.
Return Value
A 4 × 4 matrix. (Type: Transform)
### ShapeGroup#getShape(index)
Gets the shape or shape group located in this shape group at the given index.
Parameters
index
(Type: number)
Integer index, starting from 0, of the shape or shape group to set.
Return Value
The shape or shape group located in this shape group at the given index, or null if none is found there. (Type: Shape | ShapeGroup)
Gets a reference to the transform used by this shape group object.
Return Value
Return value. (Type: Transform)
Gets whether this shape group will be drawn on rendering.
Return Value
value True if this shape group will be visible; otherwise, false. (Type: boolean)
### ShapeGroup#primitiveCount()
Gets the number of primitives (triangles, lines, and points) composed by all shapes in this shape group.
Return Value
Return value. (Type: number)
### ShapeGroup#removeShape(shape)
Removes all instances of a 3D shape from this shape group
Parameters
-
shape
(Type: ShapeShapeGroup)
The 3D shape to remove.
Return Value
This object. (Type: ShapeGroup)
### ShapeGroup#setPosition(x, y, z)
Sets the relative position of the shapes in this group from their original position. See Transform#setPosition This method will modify this shape group’s transform rather than the transform for each shape in the group.
Parameters
-
x
(Type: numberArray.<number>)
X coordinate or a 3-element position array, as specified in Transform#setScale. y
(Type: number)
Y coordinate.z
(Type: number)
Z coordinate.
Return Value
This object. (Type: ShapeGroup)
### ShapeGroup#setQuaternion(quat)
Sets this shape group’s rotation in the form of a glmath. See Transform#setQuaternion. This method will modify this shape group’s transform rather than the transform for each shape in the group.
Parameters
quat
(Type: Array.<number>)
A four-element array describing the rotation.
Return Value
This object. (Type: ShapeGroup)
### ShapeGroup#setScale(x, y, z)
Sets the scale of this shape group relative to its original size. See Transform#setScale. This method will modify this shape group’s transform rather than the transform for each shape in the group.
Parameters
-
x
(Type: numberArray.<number>)
Scaling factor for this object’s width, or a 3-element scaling array, as specified in Transform#setScale. y
(Type: number)
Scaling factor for this object’s height.z
(Type: number)
Scaling factor for this object’s depth.
Return Value
This object. (Type: ShapeGroup)
### ShapeGroup#setShape(index, shape)
Sets a shape or shape group at the given index in this shape group.
Parameters
index
(Type: number)
Integer index, starting from 0, to set the shape or shape group at.-
shape
(Type: ShapeShapeGroup)
Shape object to set at the given index.
Return Value
This object. (Type: ShapeGroup)
### ShapeGroup#setTransform(transform)
Sets the transform used by this shape group to a copy of the given transform. Child shapes can set their own transforms, in which case the rendering process will multiply this shape group’s transform with the child shape’s transform as it renders the child shape.
Parameters
transform
(Type: Transform)
The transform to copy for the use of this shape group.
Return Value
Return value. (Type: Object)
### ShapeGroup#setVisible(value)
Sets whether this shape group will be drawn on rendering.
Parameters
value
(Type: boolean)
True if this shape group will be visible; otherwise, false.
Return Value
This object. (Type: ShapeGroup)
Returns the number of shapes and/or shape groups that are direct children of this shape group.
Return Value
Return value. (Type: number)
Gets the number of vertices composed by all shapes in this shape group.
Return Value
Return value. (Type: number)