具有属性的几何表示,这些属性形成顶点,并可选的索引数据
定义图元。几何体和描述着色的
Appearance 可以分配给 Primitive 进行可视化。
一个 Primitive 可以从许多异构(在许多情况下)几何体中创建,以提高性能。
几何体可以使用 GeometryPipeline 中的函数进行变换和优化。
| Name | Type | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
具有以下属性的对象:
|
Example:
// Create geometry with a position attribute and indexed lines.
const positions = new Float64Array([
0.0, 0.0, 0.0,
7500000.0, 0.0, 0.0,
0.0, 7500000.0, 0.0
]);
const geometry = new Cesium.Geometry({
attributes : {
position : new Cesium.GeometryAttribute({
componentDatatype : Cesium.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : positions
})
},
indices : new Uint16Array([0, 1, 1, 2, 2, 0]),
primitiveType : Cesium.PrimitiveType.LINES,
boundingSphere : Cesium.BoundingSphere.fromVertices(positions)
});
Demo:
See:
Members
attributes : GeometryAttributes
属性,构成几何体的顶点。此对象中的每个属性对应于一个
GeometryAttribute,包含属性的数据。
属性始终以非交错的方式存储在几何体中。
有一些保留的属性名称具有众所周知的语义。以下属性
是由几何体创建的(具体取决于提供的 VertexFormat)。
position- 3D 顶点位置。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- 由GeometryPipeline.encodeAttribute计算的编码64位位置的高32位。32位浮点数。每个属性4个分量。position3DLow- 由GeometryPipeline.encodeAttribute计算的编码64位位置的低32位。32位浮点数。每个属性4个分量。position2DHigh- 由GeometryPipeline.encodeAttribute计算的编码64位2D(哥伦布视图)位置的高32位。32位浮点数。每个属性4个分量。position2DLow- 由GeometryPipeline.encodeAttribute计算的编码64位2D(哥伦布视图)位置的低32位。32位浮点数。每个属性4个分量。color- RGBA 颜色(归一化),通常来自GeometryInstance#color。32位浮点数。每个属性4个分量。pickColor- 用于拾取的 RGBA 颜色。32位浮点数。每个属性4个分量。
Example:
geometry.attributes.position = new Cesium.GeometryAttribute({
componentDatatype : Cesium.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : new Float32Array(0)
});
See:
boundingSphere : BoundingSphere|undefined
一个可选的包围球,完全包围几何体。通常用于剔除。
-
Default Value:
undefined
可选的索引数据 - 以及
Geometry#primitiveType -
决定几何体中的图元。
-
Default Value:
undefined
primitiveType : PrimitiveType|undefined
几何体中图元的类型。通常是
PrimitiveType.TRIANGLES,
但根据特定几何体可能会有所不同。
-
Default Value:
PrimitiveType.TRIANGLES
Methods
计算几何体中的顶点数量。运行时间与每个顶点中的属性数量成线性关系,而不是顶点的数量。
| Name | Type | Description |
|---|---|---|
geometry |
Geometry | 几何体。 |
Returns:
几何体中的顶点数量。
Example:
const numVertices = Cesium.Geometry.computeNumberOfVertices(geometry);
