new GeometryAttribute
Values and type information for geometry attributes. A Geometry generally contains one or more attributes. All attributes together form the geometry's vertices.
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
options.componentDatatype |
ComponentDatatype |
<optional> |
undefined | The datatype of each component in the attribute, e.g., individual elements in values. |
options.componentsPerAttribute |
Number |
<optional> |
undefined | A number between 1 and 4 that defines the number of components in an attributes. |
options.normalize |
Boolean |
<optional> |
false | When true and componentDatatype is an integer format, indicate that the components should be mapped to the range [0, 1] (unsigned) or [-1, 1] (signed) when they are accessed as floating-point for rendering. |
options.values |
Array |
<optional> |
undefined | The values for the attributes stored in a typed array. |
Throws:
-
DeveloperError : options.componentDatatype is required.
-
DeveloperError : options.componentsPerAttribute is required.
-
DeveloperError : options.componentsPerAttribute must be between 1 and 4.
-
DeveloperError : options.values is required.
Example
var geometry = new Geometry({ attributes : { position : new GeometryAttribute({ componentDatatype : ComponentDatatype.FLOAT, componentsPerAttribute : 3, values : [ 0.0, 0.0, 0.0, 7500000.0, 0.0, 0.0, 0.0, 7500000.0, 0.0 ] }) }, primitiveType : PrimitiveType.LINE_LOOP });
See:
Source:
Members
-
componentDatatype :ComponentDatatype
-
The datatype of each component in the attribute, e.g., individual elements in {@see GeometryAttribute#values}.
- Default Value:
- undefined
-
componentsPerAttribute :Number
-
A number between 1 and 4 that defines the number of components in an attributes. For example, a position attribute with x, y, and z components would have 3 as shown in the code example.
Example
attribute.componentDatatype : ComponentDatatype.FLOAT, attribute.componentsPerAttribute : 3, attribute.values = new Float32Array([ 0.0, 0.0, 0.0, 7500000.0, 0.0, 0.0, 0.0, 7500000.0, 0.0 ]);
- Default Value:
- undefined
-
normalize :Boolean
-
When
true
andcomponentDatatype
is an integer format, indicate that the components should be mapped to the range [0, 1] (unsigned) or [-1, 1] (signed) when they are accessed as floating-point for rendering.This is commonly used when storing colors using {@ ComponentDatatype.UNSIGNED_BYTE}.
Example
attribute.componentDatatype : ComponentDatatype.UNSIGNED_BYTE, attribute.componentsPerAttribute : 4, attribute.normalize = true; attribute.values = new Uint8Array([ Color.floatToByte(color.red) Color.floatToByte(color.green) Color.floatToByte(color.blue) Color.floatToByte(color.alpha) ]);
- Default Value:
- false
-
values :Array
-
The values for the attributes stored in a typed array. In the code example, every three elements in
values
defines one attributes sincecomponentsPerAttribute
is 3.Example
attribute.componentDatatype : ComponentDatatype.FLOAT, attribute.componentsPerAttribute : 3, attribute.values = new Float32Array([ 0.0, 0.0, 0.0, 7500000.0, 0.0, 0.0, 0.0, 7500000.0, 0.0 ]);
- Default Value:
- undefined