H3DU.SurfaceBuilder

Back to documentation index.

new H3DU.SurfaceBuilder()

An evaluator of surface evaluator objects for generating vertex attributes for a surface.

For more information, see the Parametric Curves and Parametric Surfaces tutorial.

Methods

H3DU.SurfaceBuilder#attribute(surface, semantic, [semanticIndex], [size])

Sets the parametric surface used to generate vertex attribute values.

Parameters

Return Value

This object. (Type: SurfaceBuilder)

Examples

The following example sets the surface function for texture coordinates to a linear evaluator. Thus, coordinates passed to the evalSurface method will be interpolated as direct texture coordinates.

surface.attribute({"evaluate":function(u,v) {
"use strict"; return [u,v] }},Semantic.TEXCOORD);

H3DU.SurfaceBuilder#clearVertices()

Clears the arrays of attribute values (such as positions and normals) and vertex indices generated so far. The attributes themselves will remain.

Return Value

This object. (Type: SurfaceBuilder)

H3DU.SurfaceBuilder#constantAttribute(constantValue, semantic, [semanticIndex])

Sets a value for an attribute semantic that will be the same for all future vertices generated by the "evalSurface" method.

Parameters

Return Value

This object. (Type: SurfaceBuilder)

Examples

This example sets the color to use for future vertices to be generated for the surface.

// Set color to red
surface.constantAttribute([1,0,0],"COLOR");

H3DU.SurfaceBuilder#constantColor(color, [semanticIndex])

Sets a value for a color attribute that will be the same for all future vertices generated by the "evalSurface" method.

Parameters

Return Value

This object. (Type: SurfaceBuilder)

Examples

This example sets the color to use for future vertices to be generated for the surface.

// Set color to red
surface.constantColor("red");

H3DU.SurfaceBuilder#evalSurface([mode], [un], [vn], [u1], [u2], [v1], [v2])

Generates the vertex attributes of the parametric surfaces.

Parameters

Return Value

This object. (Type: SurfaceBuilder)

H3DU.SurfaceBuilder#position(surface, [size])

Sets the parametric surface used to generate vertex positions.

Parameters

Return Value

This object. (Type: SurfaceBuilder)

H3DU.SurfaceBuilder#positionNormal(surface, [size])

Sets the parametric surface used to generate vertex positions and normals.

Parameters

Return Value

This object. (Type: SurfaceBuilder)

H3DU.SurfaceBuilder#positionNormalTexCoord(surface, [size])

Sets the parametric surface used to generate vertex positions and normals, and sets a surface evaluator that generates texture coordinates in the interval [0, 1] along the U and V axes of the surface.

Parameters

Return Value

This object. (Type: SurfaceBuilder)

H3DU.SurfaceBuilder#positionTexCoord(surface, [size])

Sets the parametric surface used to generate vertex positions, and sets a surface evaluator that generates texture coordinates in the interval [0, 1] along the U and V axes of the surface.

Parameters

Return Value

This object. (Type: SurfaceBuilder)

(static) H3DU.SurfaceBuilder.surfaceToBuffer(surface, [mode], [un], [vn], [u1], [u2], [v1], [v2])

Convenience method for creating a mesh buffer from a parametric surface. The mesh buffer will contain positions, vertex normals, and texture coordinates that cover the given surface.

Parameters

Return Value

The generated mesh buffer. (Type: MeshBuffer)

H3DU.SurfaceBuilder#texCoord(surface, [size])

Sets the parametric surface used to generate texture coordinates.

Parameters

Return Value

This object. (Type: SurfaceBuilder)

H3DU.SurfaceBuilder#toMeshBuffer()

Generates a mesh buffer containing the vertex attributes generated so far. The mesh buffer's primitive type will equal the last type passed to the "mode" parameter in the SurfaceBuilder.surfaceEval method.

Return Value

The generated mesh buffer. (Type: MeshBuffer)

Back to documentation index.