GeometryAttribute

new Cesium.GeometryAttribute(options)

几何图形属性的值和类型信息。Geometry通常包含一个或多个属性。所有属性一起构成几何图形的顶点。
Name Type Description
options Object optional 对象,具有以下属性:
Name Type Default Description
componentDatatype ComponentDatatype optional 属性中每个分量的数据类型,例如:值中的单个元素。
componentsPerAttribute Number optional 一个介于1和4之间的数字,它定义了一个属性中分量的数量。
normalize Boolean false optionaltruecomponentDatatype为整数格式时, 表示当以浮点方式访问组件以进行绘制时,应将其映射到范围[0,1](无符号)或[- 1,1](有符号)。
values TypedArray optional 存储在类型化数组中的属性的值。
Throws:
  • DeveloperError : options.componentsPerAttribute 必须在1和4之间。
Example:
var geometry = new Cesium.Geometry({
  attributes : {
    position : new Cesium.GeometryAttribute({
      componentDatatype : Cesium.ComponentDatatype.FLOAT,
      componentsPerAttribute : 3,
      values : new Float32Array([
        0.0, 0.0, 0.0,
        7500000.0, 0.0, 0.0,
        0.0, 7500000.0, 0.0
      ])
    })
  },
  primitiveType : Cesium.PrimitiveType.LINE_LOOP
});
See:

Members

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

componentsPerAttribute : Number

一个介于1和4之间的数字,它定义了一个属性中分量的数量。 例如,具有x、y和z分量的位置属性将有3个,如代码示例所示。
Default Value: undefined
Example:
attribute.componentDatatype = Cesium.ComponentDatatype.FLOAT;
attribute.componentsPerAttribute = 3;
attribute.values = new Float32Array([
  0.0, 0.0, 0.0,
  7500000.0, 0.0, 0.0,
  0.0, 7500000.0, 0.0
]);

normalize : Boolean

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.values = new Uint8Array([
  Cesium.Color.floatToByte(color.red),
  Cesium.Color.floatToByte(color.green),
  Cesium.Color.floatToByte(color.blue),
  Cesium.Color.floatToByte(color.alpha)
]);

values : TypedArray

存储在类型化数组中的属性的值。 在代码示例中,values中每三个元素定义一个属性, 因为componentsPerAttribute为3。
Default Value: undefined
Example:
attribute.componentDatatype = Cesium.ComponentDatatype.FLOAT;
attribute.componentsPerAttribute = 3;
attribute.values = new Float32Array([
  0.0, 0.0, 0.0,
  7500000.0, 0.0, 0.0,
  0.0, 7500000.0, 0.0
]);