幾何屬性的值和類型信息。
new GeometryAttribute(options)
Geometry
通常包含一個或多個屬性。所有屬性一起構(gòu)成幾何體的頂點。
Parameters:
options
(Object)
Name | Description |
---|---|
options.componentDatatype
ComponentDatatype
|
屬性中每個組件的數(shù)據(jù)類型,例如值中的單個元素。 |
options.componentsPerAttribute
Number
|
一個介于1和4之間的數(shù)字,用于定義屬性中組件的數(shù)量。 |
options.normalize
Boolean
default false
|
當(dāng)true 和componentDatatype 為整數(shù)格式時,表示當(dāng)組件作為浮點進(jìn)行渲染訪問時,應(yīng)將它們映射到范圍[0,1](無符號)或[-1,1](有符號)中。
|
options.values
TypedArray
|
存儲在類型化數(shù)組中的屬性值。 |
Example
var geometry = new bmgl.Geometry({
attributes : {
position : new bmgl.GeometryAttribute({
componentDatatype : bmgl.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 : bmgl.PrimitiveType.LINE_LOOP
});
Throws
-
DeveloperError : options.componentsPerAttribute必須介于1和4之間。
See:
Members
componentDatatype : ComponentDatatype
屬性中每個組件的數(shù)據(jù)類型,例如
GeometryAttribute#values
中的單個元素。
-
Default Value:
undefined
componentsPerAttribute : Number
一個介于1和4之間的數(shù)字,用于定義屬性中組件的數(shù)量。例如,具有x、y和z組件的位置屬性將有3個,如代碼示例所示。
-
Default Value:
undefined
Example:
attribute.componentDatatype = bmgl.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
當(dāng)
true
和componentDatatype
為整數(shù)格式時,表示當(dāng)組件作為浮點進(jìn)行渲染訪問時,應(yīng)將它們映射到范圍[0,1](無符號)或[-1,1](有符號)中。這通常在使用ComponentDatatype.UNSIGNED_BYTE
存儲顏色時使用。
-
Default Value:
false
Example:
attribute.componentDatatype = bmgl.ComponentDatatype.UNSIGNED_BYTE;
attribute.componentsPerAttribute = 4;
attribute.normalize = true;
attribute.values = new Uint8Array([
bmgl.Color.floatToByte(color.red),
bmgl.Color.floatToByte(color.green),
bmgl.Color.floatToByte(color.blue),
bmgl.Color.floatToByte(color.alpha)
]);
values : TypedArray
存儲在類型化數(shù)組中的屬性值。在代碼示例中,
values
中的每三個元素定義一個屬性,因為componentsPerAttribute
為3。
-
Default Value:
undefined
Example:
attribute.componentDatatype = bmgl.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
]);