GeometryInstanceAttribute

new Cesium.GeometryInstanceAttribute(options)

逐实例几何属性的数值与类型信息。
Name Type Description
options object 具有以下属性的对象:
Name Type Default Description
componentDatatype ComponentDatatype 属性中每个分量的数据类型,例如 values 中的各个元素。
componentsPerAttribute number 一个介于 1 到 4 之间的数字,定义属性中分量的数量。
normalize boolean false optional 当为 truecomponentDatatype 为整数格式时,表示这些分量在以浮点数形式访问用于渲染时,应被映射到范围 [0, 1](无符号)或 [-1, 1](有符号)。
value Array.<number> 该属性的值。
Throws:
  • DeveloperError : options.componentsPerAttribute 必须介于 1 到 4 之间。
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.GeometryInstanceAttribute({
      componentDatatype : Cesium.ComponentDatatype.UNSIGNED_BYTE,
      componentsPerAttribute : 4,
      normalize : true,
      value : [255, 255, 0, 255]
    })
  }
});
See:

Members

属性中每个分量的数据类型,例如 GeometryInstanceAttribute#value 中的各个元素。

componentsPerAttribute : number

一个介于 1 到 4 之间的数字,定义属性中分量的数量。 例如,具有 x、y、z 分量的位置属性在代码示例中将有 3 个分量。
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)
];
存储在类型化数组中的属性值。在代码示例中, 由于 componentsPerAttribute 为 3,values 中每三个元素定义一个属性。
Example:
show : new Cesium.GeometryInstanceAttribute({
  componentDatatype : Cesium.ComponentDatatype.UNSIGNED_BYTE,
  componentsPerAttribute : 1,
  normalize : true,
  value : [1.0]
})
需要帮助?获取答案的最快方式是在 Cesium 论坛 上向社区和团队提问。