GeometryInstanceAttribute

new Cesium.GeometryInstanceAttribute(options)

每个几何实例的属性的值和类型信息。
Name Type Description
options Object 对象,具有以下属性:
Name Type Default Description
componentDatatype ComponentDatatype 属性中每个分量的数据类型,例如值中的单个元素。
componentsPerAttribute Number 一个介于1和4之间的数字,它定义了一个属性中分量的数量。
normalize Boolean false optionaltruecomponentDatatype为整数格式时,表示当以浮点方式访问分量以进行渲染时,应将其映射到范围[0,1](无符号)或[- 1,1](有符号)。
value Array.<Number> 属性的值。
Throws:
  • DeveloperError : options.componentsPerAttribute 必须在1和4之间。
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]
    })
  }
});
See:

Members

属性中每个分量的数据类型,例如值中的单个元素。 GeometryInstanceAttribute#value.
Default Value: undefined

componentsPerAttribute : Number

一个介于1和4之间的数字,它定义了一个属性中分量的数量。 例如,具有x、y和z分量的位置属性将有3个,如代码示例所示。
Default Value: undefined
Example:
show : new Cesium.GeometryInstanceAttribute({
  componentDatatype : Cesium.ComponentDatatype.UNSIGNED_BYTE,
  componentsPerAttribute : 1,
  normalize : true,
  value : [1.0]
})
truecomponentDatatype为整数格式时,表示当以浮点方式访问分量以进行渲染时,应将其映射到范围[0,1](无符号)或[- 1,1](有符号)。

这通常在使用ComponentDatatype.UNSIGNED_BYTE存储颜色时使用。

Default Value: false
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>

存储在类型化数组中的属性的值。 在代码示例中,values中每个元素定义一个属性,因为componentsPerAttribute为 1。
Default Value: undefined
Example:
show : new Cesium.GeometryInstanceAttribute({
  componentDatatype : Cesium.ComponentDatatype.UNSIGNED_BYTE,
  componentsPerAttribute : 1,
  normalize : true,
  value : [1.0]
})