Menu - Top - Home - Donate to Me

H3DU.Shape

Back to documentation index.

H3DU.Shape(mesh)

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

NOTE: The default shader program assumes that all colors and the diffuse texture specified in this object are in companded sRGB.

Parameters

Methods

H3DU.Shape#copy()

Makes a copy of this object. The copied object will have its own version of the transform and material data, but any texture image data and mesh buffers will not be duplicated, but rather just references to them will be used. The copied shape won't have a parent.

Return Value

A copy of this object. (Type: H3DU.Shape)

H3DU.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>)

H3DU.Shape#getMaterial()

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

Return Value

Return value. (Type: H3DU.Material | H3DU.PbrMaterial)

H3DU.Shape#getMatrix()

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

Return Value

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

H3DU.Shape#getMeshBuffer()

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

Return Value

Return value. (Type: H3DU.MeshBuffer)

H3DU.Shape#getTransform()

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

Return Value

Return value. (Type: H3DU.Transform)

H3DU.Shape#getVisible()

Gets whether this shape will be drawn on rendering.

Return Value

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

H3DU.Shape#primitiveCount()

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

Return Value

Return value. (Type: number)

H3DU.Shape#setColor(r, g, b, [a])

Sets material parameters that give the shape a certain color. (If a material is already defined, sets its ambient and diffusion colors.) However, if the mesh defines its own colors, those colors will take precedence over the color given in this method.

Parameters

Return Value

This object. (Type: H3DU.Shape)

H3DU.Shape#setMaterial(material)

Sets this shape's material parameter object.

Parameters

Return Value

This object. (Type: H3DU.Shape)

H3DU.Shape#setPosition(x, y, z)

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

Parameters

Return Value

This object. (Type: H3DU.Shape)

H3DU.Shape#setQuaternion(quat)

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

Parameters

Return Value

This object. (Type: H3DU.Shape)

H3DU.Shape#setScale(x, y, z)

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

Parameters

Return Value

This object. (Type: H3DU.Shape)

H3DU.Shape#setShader(shader)

Sets this shape's material to a shader with the given URL.

Parameters

Return Value

This object. (Type: H3DU.Shape)

H3DU.Shape#setTexture(name)

Sets material parameters that give the shape a texture with the given URL.

Parameters

Return Value

This object. (Type: H3DU.Shape)

H3DU.Shape#setTextureAndColor(name, r, g, b, [a])

Sets this shape's material to the given texture, and its ambient and diffuse parameters to the given color.

Parameters

Return Value

This object. (Type: H3DU.Shape)

H3DU.Shape#setTransform(transform)

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

Parameters

Return Value

This object. (Type: H3DU.Shape)

H3DU.Shape#setVisible(value)

Sets whether this shape will be drawn on rendering.

Parameters

Return Value

This object. (Type: H3DU.Shape)

H3DU.Shape#vertexCount()

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

Return Value

Return value. (Type: number)

Back to documentation index.