SurfaceBuilder

Back to documentation index.

### new 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

### 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);

### 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)

### 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");

### 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");

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

Generates the vertex attributes of the parametric surfaces.

Parameters

Return Value

This object. (Type: SurfaceBuilder)

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

Sets the parametric surface used to generate vertex positions.

Parameters

Return Value

This object. (Type: SurfaceBuilder)

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

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

Parameters

Return Value

This object. (Type: SurfaceBuilder)

### 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)

### 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) 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)

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

Sets the parametric surface used to generate texture coordinates.

Parameters

Return Value

This object. (Type: SurfaceBuilder)

### 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.