H3DU.CurveBuilder
An evaluator of curve evaluator objects for generating vertex attributes for a curve.
For more information, see the Parametric Curves and Parametric Surfaces tutorial.
Methods
- attribute
Sets the parametric curve used to generate vertex attribute values. - clearVertices
Clears the arrays of attribute values (such as positions and normals) and vertex indices generated so far. - constantAttribute
Sets a value for an attribute semantic that will be the same for all future vertices generated by the “evalCurve” method. - constantColor
Sets a value for a color attribute that will be the same for all future vertices generated by the “evalCurve” method. - curveToBuffer
Convenience method for creating a mesh buffer from a parametric curve. - evalCurve
Generates the vertex attributes of the parametric curves. - position
Sets the parametric curve used to generate vertex positions. - toMeshBuffer
Generates a mesh buffer containing the vertex attributes generated so far.
### H3DU.CurveBuilder#attribute(curve, semantic, [semanticIndex], [size])
Sets the parametric curve used to generate vertex attribute values.
Parameters
curve
(Type: Object)
A curve evaluator object that describes the parametric curve used to generate attribute values. U coordinates for the given curve correspond to U coordinates for the curve used to generate vertex positions.-
semantic
(Type: numberstring)
An attribute semantic, such as Semantic.POSITION, “POSITION”, or “TEXCOORD_0”. Throws an error if this value is a string and the string is invalid. semanticIndex
(Type: number) (optional)
The set index of the attribute for the given semantic. 0 is the first index of the attribute, 1 is the second, and so on. This is ignored if “name” is a string. If null, undefined, or omitted, the default is 0.size
(Type: number) (optional)
The number of elements in each position value. For example, if the attribute is 3-dimensional, this parameter is 3. If null, undefined, or omitted, the default is 3. Throws an error if this value is 0 or less.
Return Value
This object. (Type: CurveBuilder)
### H3DU.CurveBuilder#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: CurveBuilder)
### H3DU.CurveBuilder#constantAttribute(constantValue, semantic, [semanticIndex])
Sets a value for an attribute semantic that will be the same for all future vertices generated by the “evalCurve” method.
Parameters
-
constantValue
(Type: Objectnumber)
A constant value for the attribute semantic. -
semantic
(Type: numberstring)
An attribute semantic, such as Semantic.POSITION, “POSITION”, or “TEXCOORD_0”. Throws an error if this value is a string and the string is invalid. semanticIndex
(Type: number) (optional)
The set index of the attribute for the given semantic. 0 is the first index of the attribute, 1 is the second, and so on. This is ignored if “name” is a string. If null, undefined, or omitted, the default is 0.
Return Value
This object. (Type: CurveBuilder)
Examples
This example sets the color to use for future vertices to be generated for the curve.
// Set color to red curve.constantAttribute([1,0,0],"COLOR");
### H3DU.CurveBuilder#constantColor(color, [semanticIndex])
Sets a value for a color attribute that will be the same for all future vertices generated by the “evalCurve” method.
Parameters
-
color
(Type: Array.<number>number string)
A color vector or string identifying the constant color value. The alpha channel of the resulting color will be ignored. semanticIndex
(Type: number) (optional)
The set index of the attribute for the given semantic. 0 is the first index of the attribute, 1 is the second, and so on. If null, undefined, or omitted, the default is 0.
Return Value
This object. (Type: CurveBuilder)
Examples
This example sets the color to use for future vertices to be generated for the curve.
// Set color to red curve.constantColor("red");
### (static) H3DU.CurveBuilder.curveToBuffer(curve, [mode], [n], [u1], [u2])
Convenience method for creating a mesh buffer from a parametric curve. The mesh buffer will contain positions and vertex normals that cover the given surface.
Parameters
curve
(Type: Object)
A curve evaluator object that describes the parametric curve used to generate positions.mode
(Type: number) (optional)
If this value is MeshBuffer.LINES, or is null, undefined, or omitted, generates a series of lines defining the curve. If this value is MeshBuffer.POINTS, generates a series of points along the curve. For any other value, this method has no effect.n
(Type: number) (optional)
Number of subdivisions of the curve to be drawn. If null or undefined, a default is determined automatically based on the position curve’s arc length, or the distance taken by its path (or the default is 24 if no position curve was defined). If 0, this method has no effect. Throws an error if this value is less than 0.u1
(Type: number) (optional)
Starting point of the curve. Default is the starting coordinate given by the curve evaluator object, or 0 if not given.u2
(Type: number) (optional)
Ending point of the curve. Default is the ending coordinate given by the curve evaluator object, or 1 if not given.
Return Value
The generated mesh buffer. (Type: MeshBuffer)
### H3DU.CurveBuilder#evalCurve([mode], [n], [u1], [u2])
Generates the vertex attributes of the parametric curves.
Parameters
mode
(Type: number) (optional)
If this value is MeshBuffer.LINES, or is null, undefined, or omitted, generates a series of lines defining the curve. If this value is MeshBuffer.POINTS, generates a series of points along the curve. For any other value, this method has no effect.n
(Type: number) (optional)
Number of subdivisions of the curve to be drawn. If null or undefined, a default is determined automatically based on the position curve’s arc length, or the distance taken by its path (or the default is 24 if no position curve was defined). If 0, this method has no effect. Throws an error if this value is less than 0.u1
(Type: number) (optional)
Starting point of the curve. Default is the starting coordinate given by the curve evaluator object, or 0 if not given.u2
(Type: number) (optional)
Ending point of the curve. Default is the ending coordinate given by the curve evaluator object, or 1 if not given.
Return Value
This object. (Type: CurveBuilder)
### H3DU.CurveBuilder#position(curve, [size])
Sets the parametric curve used to generate vertex positions.
Parameters
curve
(Type: Object)
A curve evaluator object that describes the parametric curve used to generate positions.size
(Type: number) (optional)
The number of elements in each position value. For example, if the attribute is 3-dimensional, this parameter is 3. If null, undefined, or omitted, the default is 3. Throws an error if this value is 0 or less.
Return Value
This object. (Type: CurveBuilder)
### H3DU.CurveBuilder#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 CurveBuilder.curveEval method.
Return Value
The generated mesh buffer. (Type: MeshBuffer)