Skip to content

KBE3D / KBCore / Cesium / ColorGeometryInstanceAttribute

类: ColorGeometryInstanceAttribute

Value and type information for per-instance geometry color.

示例

ts
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 red component.

参数

The green component.

参数

The blue component.

参数

The alpha component.

属性

value

value: Uint8Array

The values for the attributes stored in a typed array.


componentDatatype

readonly componentDatatype: ComponentDatatype

The datatype of each component in the attribute, e.g., individual elements in ColorGeometryInstanceAttribute#value.


componentsPerAttribute

readonly componentsPerAttribute: number

The number of components in the attributes, i.e., ColorGeometryInstanceAttribute#value.


normalize

readonly normalize: boolean

When <code>true</code> and <code>componentDatatype</code> 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.

方法

fromColor()

static fromColor(color: Color): ColorGeometryInstanceAttribute

Creates a new ColorGeometryInstanceAttribute instance given the provided Color.

参数

color

Color

The color.

返回

ColorGeometryInstanceAttribute

The new ColorGeometryInstanceAttribute instance.

示例

ts
const instance = new Cesium.GeometryInstance({
  geometry : geometry,
  attributes : {
    color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.CORNFLOWERBLUE),
  }
});

toValue()

static toValue(color: Color, result?: Uint8Array<ArrayBufferLike>): Uint8Array

Converts a color to a typed array that can be used to assign a color attribute.

参数

color

Color

The color.

result?

Uint8Array<ArrayBufferLike>

The array to store the result in, if undefined a new instance will be created.

返回

Uint8Array

The modified result parameter or a new instance if result was undefined.

示例

ts
const attributes = primitive.getGeometryInstanceAttributes('an id');
attributes.color = Cesium.ColorGeometryInstanceAttribute.toValue(Cesium.Color.AQUA, attributes.color);

equals()

static equals(left?: ColorGeometryInstanceAttribute, right?: ColorGeometryInstanceAttribute): boolean

Compares the provided ColorGeometryInstanceAttributes and returns <code>true</code> if they are equal, <code>false</code> otherwise.

参数

left?

ColorGeometryInstanceAttribute

The first ColorGeometryInstanceAttribute.

ColorGeometryInstanceAttribute

The second ColorGeometryInstanceAttribute.

返回

boolean

true if left and right are equal, false otherwise.

构造函数

构造函数

new ColorGeometryInstanceAttribute(red?: number, green?: number, blue?: number, alpha?: number): ColorGeometryInstanceAttribute

参数

red?

number

green?

number

blue?

number

alpha?

number

返回

ColorGeometryInstanceAttribute

KBE3D @3.0.0 Copyright © 2024-present KBE3D