new ColorGeometryInstanceAttribute
Value and type information for per-instance geometry color.
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
red |
Number |
<optional> |
1.0 | The red component. |
green |
Number |
<optional> |
1.0 | The green component. |
blue |
Number |
<optional> |
1.0 | The blue component. |
alpha |
Number |
<optional> |
1.0 | The alpha component. |
Example
var instance = new GeometryInstance({ geometry : new BoxGeometry({ dimensions : new Cartesian3(1000000.0, 1000000.0, 500000.0) }), modelMatrix : Matrix4.multiplyByTranslation(Transforms.eastNorthUpToFixedFrame( ellipsoid.cartographicToCartesian(Cartographic.fromDegrees(-0.0, 0.0))), new Cartesian3(0.0, 0.0, 1000000.0)), id : 'box', attributes : { color : new ColorGeometryInstanceAttribute(red, green, blue, alpha) } });
Members
-
<readonly> componentDatatype :ComponentDatatype
-
The datatype of each component in the attribute, e.g., individual elements in ColorGeometryInstanceAttribute#value.
- Default Value:
-
<readonly> componentsPerAttribute :Number
-
The number of components in the attributes, i.e., ColorGeometryInstanceAttribute#value.
- Default Value:
- 4
-
<readonly> 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.- Default Value:
- true
-
value :Uint8Array
-
The values for the attributes stored in a typed array.
- Default Value:
- [255, 255, 255, 255]
Methods
-
<static> fromColor
-
Creates a new ColorGeometryInstanceAttribute instance given the provided Color.
Parameters:
Name Type Description color
Color The color. Throws:
DeveloperError : color is required.Returns:
ColorGeometryInstanceAttribute The new ColorGeometryInstanceAttribute instance.Example
var instance = new GeometryInstance({ geometry : // ... attributes : { color : ColorGeometryInstanceAttribute.fromColor(Color.CORNFLOWERBLUE), } });
-
<static> toValue
-
Converts a color to a typed array that can be used to assign a color attribute.
Parameters:
Name Type Argument Description color
Color The color. result
Uint8Array <optional>
The array to store the result in, if undefined a new instance will be created. Throws:
DeveloperError : color is required.Returns:
Uint8Array The modified result parameter or a new instance if result was undefined.Example
var attributes = primitive.getGeometryInstanceAttributes('an id'); attributes.color = ColorGeometryInstanceAttribute.toValue(Color.AQUA, attributes.color);