具有形成顶点的属性和定义基元的可选索引数据的几何表示。几何形状和 A geometry representation with attributes forming vertices and optional index data defining primitives. Geometries and an
Appearance,它描述了阴影,可以分配给 , which describes the shading, can be assigned to a Primitive 用于可视化。一个 for visualization. A Primitive 可以从许多异构的(在许多情况下)几何形状中创建以提高性能。 can be created from many heterogeneous - in many cases - geometries for performance.
可以使用以下函数来转换和优化几何形状 Geometries can be transformed and optimized using functions in GeometryPipeline.
| 名称 Name | 类型 Type | 说明 Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
具有以下属性的对象: Object with the following properties:
|
示例: 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
属性,构成几何体的顶点。该对象中的每个属性都对应一个 Attributes, which make up the geometry's vertices. Each property in this object corresponds to a
GeometryAttribute 包含属性的数据。 containing the attribute's data.
属性始终以非交错方式存储在几何图形中。 Attributes are always stored non-interleaved in a Geometry.
有一些具有众所周知语义的保留属性名称。以下属性由几何体创建(取决于提供的 There are reserved attribute names with well-known semantics. The following attributes are created by a Geometry (depending on the provided VertexFormat.
position3D 顶点位置。 64 位浮点(用于精度)。每个属性 3 个组件。参见 - 3D vertex position. 64-bit floating-point (for precision). 3 components per attribute. SeeVertexFormat#position.normal正常(标准化),常用于照明。 32 位浮点。每个属性 3 个组件。参见 - Normal (normalized), commonly used for lighting. 32-bit floating-point. 3 components per attribute. SeeVertexFormat#normal.st2D 纹理坐标。 32 位浮点。每个属性 2 个组件。参见 - 2D texture coordinate. 32-bit floating-point. 2 components per attribute. SeeVertexFormat#st.bitangent双切线(标准化),用于切线空间效果,例如凹凸贴图。 32 位浮点。每个属性 3 个组件。参见 - Bitangent (normalized), used for tangent-space effects like bump mapping. 32-bit floating-point. 3 components per attribute. SeeVertexFormat#bitangent.tangent切线(标准化),用于切线空间效果,例如凹凸贴图。 32 位浮点。每个属性 3 个组件。参见 - Tangent (normalized), used for tangent-space effects like bump mapping. 32-bit floating-point. 3 components per attribute. SeeVertexFormat#tangent.
下面的属性名一般不是由Geometry创建的,而是由Geometry添加到Geometry中的 The following attribute names are generally not created by a Geometry, but are added to a Geometry by a Primitive or GeometryPipeline 准备渲染几何体的函数。 functions to prepare the geometry for rendering.
position3DHigh高 32 位用于编码 64 位位置计算 - High 32 bits for encoded 64-bit position computed withGeometryPipeline.encodeAttribute。 32 位浮点。每个属性 4 个组件。 . 32-bit floating-point. 4 components per attribute.position3DLow低 32 位用于编码 64 位位置计算 - Low 32 bits for encoded 64-bit position computed withGeometryPipeline.encodeAttribute。 32 位浮点。每个属性 4 个组件。 . 32-bit floating-point. 4 components per attribute.position2DHigh高 32 位用于编码 64 位 2D(哥伦布视图)位置,计算方法为 - High 32 bits for encoded 64-bit 2D (Columbus view) position computed withGeometryPipeline.encodeAttribute。 32 位浮点。每个属性 4 个组件。 . 32-bit floating-point. 4 components per attribute.position2DLow低 32 位用于编码 64 位 2D(哥伦布视图)位置计算 - Low 32 bits for encoded 64-bit 2D (Columbus view) position computed withGeometryPipeline.encodeAttribute。 32 位浮点。每个属性 4 个组件。 . 32-bit floating-point. 4 components per attribute.colorRGBA 颜色(标准化)通常来自 - RGBA color (normalized) usually fromGeometryInstance#color。 32 位浮点。每个属性 4 个组件。 . 32-bit floating-point. 4 components per attribute.pickColor用于拾取的 RGBA 颜色。 32 位浮点。每个属性 4 个组件。 - RGBA color used for picking. 32-bit floating-point. 4 components per attribute.
示例: Example:
geometry.attributes.position = new Cesium.GeometryAttribute({
componentDatatype : Cesium.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : new Float32Array(0)
});
另见: See:
boundingSphere : BoundingSphere|undefined
完全包围几何体的可选边界球体。这通常用于剔除。 An optional bounding sphere that fully encloses the geometry. This is commonly used for culling.
-
默认值: Default Value:
undefined
可选的索引数据 - 以及 Optional index data that - along with
Geometry#primitiveType 确定几何体中的基元。 - determines the primitives in the geometry.
-
默认值: Default Value:
undefined
primitiveType : PrimitiveType|undefined
几何体中图元的类型。这是最常见的 The type of primitives in the geometry. This is most often
PrimitiveType.TRIANGLES,但可以根据具体的几何形状而变化。 , but can varying based on the specific geometry.
-
默认值: Default Value:
PrimitiveType.TRIANGLES
方法 Methods
计算几何体中的顶点数。运行时间与顶点中的属性数量(而不是顶点数量)成线性关系。 Computes the number of vertices in a geometry. The runtime is linear with respect to the number of attributes in a vertex, not the number of vertices.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
geometry |
Geometry | 几何形状。 The geometry. |
返回: Returns:
几何体中的顶点数。 The number of vertices in the geometry.
示例: Example:
const numVertices = Cesium.Geometry.computeNumberOfVertices(geometry);
