ColorGeometryInstanceAttribute

new Cesium.ColorGeometryInstanceAttribute(red, green, blue, alpha)

Value and type information for per-instance geometry color.
参数名称 类型 默认值 描述信息
red number 1.0 可选 The red component.
green number 1.0 可选 The green component.
blue number 1.0 可选 The blue component.
alpha number 1.0 可选 The alpha component.
使用示例:
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.ColorGeometryInstanceAttribute(red, green, blue, alpha)
  }
});
参考:

成员(属性)

The datatype of each component in the attribute, e.g., individual elements in ColorGeometryInstanceAttribute#value.
默认值: ComponentDatatype.UNSIGNED_BYTE

readonly componentsPerAttribute : number

The number of components in the attributes, i.e., ColorGeometryInstanceAttribute#value.
默认值: 4
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.
默认值: true
The values for the attributes stored in a typed array.
默认值: [255, 255, 255, 255]

方法

static Cesium.ColorGeometryInstanceAttribute.equals(left, right)boolean

Compares the provided ColorGeometryInstanceAttributes and returns true if they are equal, false otherwise.
参数名称 类型 描述信息
left ColorGeometryInstanceAttribute 可选 The first ColorGeometryInstanceAttribute.
right ColorGeometryInstanceAttribute 可选 The second ColorGeometryInstanceAttribute.
返回值:
true if left and right are equal, false otherwise.

static Cesium.ColorGeometryInstanceAttribute.fromColor(color)ColorGeometryInstanceAttribute

Creates a new ColorGeometryInstanceAttribute instance given the provided Color.
参数名称 类型 描述信息
color Color The color.
返回值:
The new ColorGeometryInstanceAttribute instance.
使用示例:
const instance = new Cesium.GeometryInstance({
  geometry : geometry,
  attributes : {
    color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.CORNFLOWERBLUE),
  }
});

static Cesium.ColorGeometryInstanceAttribute.toValue(color, result)Uint8Array

Converts a color to a typed array that can be used to assign a color attribute.
参数名称 类型 描述信息
color Color The color.
result Uint8Array 可选 The array to store the result in, if undefined a new instance will be created.
返回值:
The modified result parameter or a new instance if result was undefined.
使用示例:
const attributes = primitive.getGeometryInstanceAttributes('an id');
attributes.color = Cesium.ColorGeometryInstanceAttribute.toValue(Cesium.Color.AQUA, attributes.color);