由构成顶点的属性和定义图元的可选索引数据组成的几何表示。
几何体和描述着色的
Appearance 可以分配给 Primitive 进行可视化。
在许多情况下,一个 Primitive 可以由许多异构几何体创建,以提高性能。
可以使用 GeometryPipeline 中的函数对几何体进行变换和优化。
| Name | Type | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
具有以下属性的对象:
|
Example:
// 创建一个带有位置属性和索引线的几何体。
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,
几何体(取决于提供的 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- 通常来自GeometryInstance#color的RGBA颜色(归一化)。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);
