# ColorGeometryInstanceAttribute

#### new Cesium.ColorGeometryInstanceAttribute(red, green, blue, alpha)
engine/Source/Core/ColorGeometryInstanceAttribute.js 34

Value and type information for per-instance geometry color.

Name | Type | Default | Description
--- | --- | --- | ---
`red` | number | `1.0` | optional The red component.
`green` | number | `1.0` | optional The green component.
`blue` | number | `1.0` | optional The blue component.
`alpha` | number | `1.0` | optional The alpha component.

##### Example:

    const instance = new Cesium.GeometryInstance({
      geometry : Cesium.BoxGeometry.fromDimensions({
        dimensions : new Cesium.Cartesian3(1000000.0, 1000000.0, 500000.0)
      }),
      modelMatrix : Cesium.Matrix4.multiplyByTranslation(Cesium.Transforms.eastNorthUpToFixedFrame(
        Cesium.Cartesian3.fromDegrees(0.0, 0.0)), new Cesium.Cartesian3(0.0, 0.0, 1000000.0), new Cesium.Matrix4()),
      id : 'box',
      attributes : {
        color : new Cesium.ColorGeometryInstanceAttribute(red, green, blue, alpha)
      }
    });

##### See:

- GeometryInstance
- GeometryInstanceAttribute

### Members

#### readonly componentDatatype : ComponentDatatype
engine/Source/Core/ColorGeometryInstanceAttribute.js 67

The datatype of each component in the attribute, e.g., individual elements in `ColorGeometryInstanceAttribute#value`.

Default Value: ``ComponentDatatype.UNSIGNED_BYTE``

#### readonly componentsPerAttribute : number
engine/Source/Core/ColorGeometryInstanceAttribute.js 83

The number of components in the attributes, i.e., `ColorGeometryInstanceAttribute#value`.

Default Value: `4`

#### readonly normalize : boolean
engine/Source/Core/ColorGeometryInstanceAttribute.js 101

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.

Default Value: `true`

#### value : Uint8Array
engine/Source/Core/ColorGeometryInstanceAttribute.js 47

The values for the attributes stored in a typed array.

Default Value: `[255, 255, 255, 255]`

### Methods

#### static Cesium.ColorGeometryInstanceAttribute.equals(left, right) → boolean
engine/Source/Core/ColorGeometryInstanceAttribute.js 170

Compares the provided ColorGeometryInstanceAttributes and returns `true` if they are equal, `false` otherwise.

Name | Type | Description
--- | --- | ---
`left` | ColorGeometryInstanceAttribute | optional The first ColorGeometryInstanceAttribute.
`right` | ColorGeometryInstanceAttribute | optional The second ColorGeometryInstanceAttribute.

##### Returns:

`true` if left and right are equal, `false` otherwise.

#### static Cesium.ColorGeometryInstanceAttribute.fromColor(color) → ColorGeometryInstanceAttribute
engine/Source/Core/ColorGeometryInstanceAttribute.js 122

Creates a new `ColorGeometryInstanceAttribute` instance given the provided `Color`.

Name | Type | Description
--- | --- | ---
`color` | Color | The color.

##### Returns:

The new `ColorGeometryInstanceAttribute` instance.

##### Example:

    const instance = new Cesium.GeometryInstance({
      geometry : geometry,
      attributes : {
        color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.CORNFLOWERBLUE),
      }
    });

#### static Cesium.ColorGeometryInstanceAttribute.toValue(color, result) → Uint8Array
engine/Source/Core/ColorGeometryInstanceAttribute.js 149

Converts a color to a typed array that can be used to assign a color attribute.

Name | Type | Description
--- | --- | ---
`color` | Color | The color.
`result` | Uint8Array | optional The array to store the result in, if undefined a new instance will be created.

##### Returns:

The modified result parameter or a new instance if result was undefined.

##### Example:

    const attributes = primitive.getGeometryInstanceAttributes('an id');
    attributes.color = Cesium.ColorGeometryInstanceAttribute.toValue(Cesium.Color.AQUA, attributes.color);

Need help? The fastest way to get answers is from the community and team on the Cesium Forum.