一种几何表示法,具有构成顶点的属性和定义基元的可选索引数据。几何图形和描述阴影的
new Geometry(options)
Appearance可分配给Primitive进行可视化。APrimitive可以从许多异构(在许多情况下)几何结构中创建,以提高性能。几何图形可以使用GeometryPipeline中的函数进行转换和优化。
Parameters:
options
(Object)
| Name | Description |
|---|---|
options.attributes
GeometryAttributes
|
组成几何体顶点的属性。 |
options.primitiveType
PrimitiveType
default PrimitiveType.TRIANGLES
|
几何体中基本体的类型。 |
options.indices
(Uint16Array | Uint32Array)
|
用于确定几何体中基本体的可选索引数据。 |
options.boundingSphere
BoundingSphere
|
完全包围几何体的可选边界球体。 |
Example
// Create geometry with a position attribute and indexed lines.
var positions = new Float64Array([
0.0, 0.0, 0.0,
7500000.0, 0.0, 0.0,
0.0, 7500000.0, 0.0
]);
var geometry = new bmgl.Geometry({
attributes : {
position : new bmgl.GeometryAttribute({
componentDatatype : bmgl.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : positions
})
},
indices : new Uint16Array([0, 1, 1, 2, 2, 0]),
primitiveType : bmgl.PrimitiveType.LINES,
boundingSphere : bmgl.BoundingSphere.fromVertices(positions)
});
Members
attributes : GeometryAttributes
组成几何体顶点的属性。此对象中的每个属性对应于包含属性数据的
GeometryAttribute。属性始终不交错存储在几何图形中。
有保留的具有众所周知语义的属性名。以下属性由几何图形创建(取决于提供的VertexFormat)。
position-三维顶点位置。64位浮点(用于精度)。每个属性3个组件。见VertexFormat#position.normal-正常(标准化),通常用于照明。32位浮点。每个属性3个组件。见VertexFormat#normal.st-2d纹理坐标。32位浮点。每个属性2个组件。参见VertexFormat#st.bitangent-位范围(标准化),用于切线空间效果,如凹凸贴图。32位浮点。每个属性3个组件。参见VertexFormat#bitangent.tangent-切线(标准化),用于切线空间效果,如凹凸贴图。32位浮点。每个属性3个组件。请参见VertexFormat#tangent
以下属性名称通常不是由几何体创建的,而是由Primitive或GeometryPipeline函数添加到几何体以准备渲染几何体。
- {
position3DHigh-编码64位位置用GeometryPipeline.encodeAttribute计算的高32位。32位浮点。每个属性4个组件。 position3DLow-编码64位位置的低32位,用GeometryPipeline.encodeAttribute计算。32位浮点。每个属性4个组件。position3DHigh-使用GeometryPipeline.encodeAttribute计算的编码64位二维(Columbus视图)位置的高32位。32位浮点。每个属性4个组件。position2DLow-使用GeometryPipeline.encodeAttribute计算的编码64位二维(哥伦布视图)位置的低32位。32位浮点。每个属性4个组件。color-rgba颜色(标准化),通常从GeometryInstance#color开始。32位浮点。每个属性4个组件。pickColor-用于拾取的rgba颜色。32位浮点。每个属性4个组件。
-
Default Value:
undefined
See:
Example:
geometry.attributes.position = new bmgl.GeometryAttribute({
componentDatatype : bmgl.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : new Float32Array(0)
});
boundingSphere : BoundingSphere
完全包围几何体的可选边界球体。这通常用于剔除。
-
Default Value:
undefined
indices : Array
可选索引数据,与
Geometry#primitiveType一起确定几何体中的基本体。
-
Default Value:
undefined
primitiveType : PrimitiveType
几何体中基本体的类型。这通常是
PrimitiveType.TRIANGLES,但可以根据特定的几何图形变化。
-
Default Value:
undefined
Methods
(static) computeNumberOfVertices(geometry) → {Number}
计算几何体中的顶点数。运行时相对于顶点中的属性数是线性的,而不是顶点数。