Appearance
KBE3D / KBCore / Cesium / GeometryAttribute
类: GeometryAttribute
Values and type information for geometry attributes. A Geometry generally contains one or more attributes. All attributes together form the geometry's vertices.
示例
ts
const 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
});参数
Object with the following properties:
参数
The datatype of each component in the attribute, e.g., individual elements in values.
参数
A number between 1 and 4 that defines the number of components in an attributes.
参数
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.
参数
The values for the attributes stored in a typed array.
属性
componentDatatype
componentDatatype:
ComponentDatatype
The datatype of each component in the attribute, e.g., individual elements in GeometryAttribute#values.
componentsPerAttribute
componentsPerAttribute:
number
A number between 1 and 4 that defines the number of components in an attributes. For example, a position attribute with x, y, and z components would have 3 as shown in the code example.
示例
ts
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
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. <p> This is commonly used when storing colors using ComponentDatatype.UNSIGNED_BYTE. </p>
示例
ts
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
values:
number[] |Float32Array<ArrayBufferLike> |Int8Array<ArrayBufferLike> |Uint8Array<ArrayBufferLike> |Int16Array<ArrayBufferLike> |Uint16Array<ArrayBufferLike> |Int32Array<ArrayBufferLike> |Uint32Array<ArrayBufferLike> |Float64Array<ArrayBufferLike>
The values for the attributes stored in a typed array. In the code example, every three elements in <code>values</code> defines one attributes since <code>componentsPerAttribute</code> is 3.
示例
ts
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
]);构造函数
构造函数
new GeometryAttribute(
options?: {componentDatatype:ComponentDatatype;componentsPerAttribute:number;values:number[] |Float32Array<ArrayBufferLike> |Int8Array<ArrayBufferLike> |Uint8Array<ArrayBufferLike> |Int16Array<ArrayBufferLike> |Uint16Array<ArrayBufferLike> |Int32Array<ArrayBufferLike> |Uint32Array<ArrayBufferLike> |Float64Array<ArrayBufferLike>;normalize?:boolean; }):GeometryAttribute
参数
options?
componentDatatype
componentsPerAttribute
number
values
number[] | Float32Array<ArrayBufferLike> | Int8Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike>
normalize?
boolean
返回
GeometryAttribute
