new Cesium.GeometryInstanceAttribute(options)

每英寸几何属性的值和类型信息.
Name Type Description
options object 下列属性的对象 :
Name Type Default Description
componentDatatype ComponentDatatype 属性中每个元件的数据类型, e.g .,值中的单个元素.
componentsPerAttribute number 1到4之间的数字,用于定义一个属性中的组件数.
normalize boolean false optional Treal 组件Datatype 为整数格式时,表示组件作为渲染的浮点访问时,应当映射到范围[0](未签名)或[1](已签名).
value Array.<number> 属性值 .
Throws:
  • DeveloperError : options.componentsPerAttribute must be between 1 and 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

componentDatatype : ComponentDatatype

The datatype of each component in the attribute, e.g., individual elements in 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]
})

normalize : boolean

当 NT 0 true NT 1 和 NT 2 组件Datatype NT 3 是一个整数格式时, indicate that the components should be mapped to the range [0, 1] (unsigned) 或[-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>

输入数组中存储属性的值 。 在代码示例中, 在 NT 0 值 NT 1 中,每三个元素定义一个属性,因为 -NT~0~组件PerAttize NT~1~为3.
Example:
show : new Cesium.GeometryInstanceAttribute({
  componentDatatype : Cesium.ComponentDatatype.UNSIGNED_BYTE,
  componentsPerAttribute : 1,
  normalize : true,
  value : [1.0]
})
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.