Class: GeometryInstanceAttribute

GeometryInstanceAttribute

new GeometryInstanceAttribute(options)

Values and type information for per-instance geometry attributes.
Parameters:
Name Type Description
options Object Object with the following properties:
Properties
Name Type Attributes Default Description
componentDatatype ComponentDatatype <optional>
The datatype of each component in the attribute, e.g., individual elements in values.
componentsPerAttribute Number <optional>
A number between 1 and 4 that defines the number of components in an attributes.
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.
value Array.<Number> <optional>
The value for the attribute.
Source:
See:
Throws:
options.componentsPerAttribute must be between 1 and 4.
Type
DeveloperError
Example
var 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.GeometryInstanceAttribute({
      componentDatatype : Cesium.ComponentDatatype.UNSIGNED_BYTE,
      componentsPerAttribute : 4,
      normalize : true,
      value : [255, 255, 0, 255]
    })
  }
});

Members

componentDatatype :ComponentDatatype

The datatype of each component in the attribute, e.g., individual elements in GeometryInstanceAttribute#value.
Type:
Default Value:
  • undefined
Source:

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.
Type:
  • Number
Default Value:
  • undefined
Source:
Example
show : new Cesium.GeometryInstanceAttribute({
  componentDatatype : Cesium.ComponentDatatype.UNSIGNED_BYTE,
  componentsPerAttribute : 1,
  normalize : true,
  value : [1.0]
})

normalize :Boolean

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.

This is commonly used when storing colors using ComponentDatatype.UNSIGNED_BYTE.

Type:
  • Boolean
Default Value:
  • false
Source:
Example
attribute.componentDatatype = Cesium.ComponentDatatype.UNSIGNED_BYTE;
attribute.componentsPerAttribute = 4;
attribute.normalize = true;
attribute.value = [
  Cesium.Color.floatToByte(color.red),
  Cesium.Color.floatToByte(color.green),
  Cesium.Color.floatToByte(color.blue),
  Cesium.Color.floatToByte(color.alpha)
];

value :Array.<Number>

The values for the attributes stored in a typed array. In the code example, every three elements in values defines one attributes since componentsPerAttribute is 3.
Type:
  • Array.<Number>
Default Value:
  • undefined
Source:
Example
show : new Cesium.GeometryInstanceAttribute({
  componentDatatype : Cesium.ComponentDatatype.UNSIGNED_BYTE,
  componentsPerAttribute : 1,
  normalize : true,
  value : [1.0]
})