几何图形表示为具有组织顶点的属性和定义图元的可选索引数据。
几何图形和描述着色的
Appearance可以分配给Primitive进行可视化。
Primitive可以由许多不同的几何图形(在许多情况下)创建,以提高性能。
可以使用GeometryPipeline中的函数对几何图形进行转换和优化。
| Name | Type | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
对象,具有以下属性:
|
Example:
// 使用位置属性和线索引创建几何图形。
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 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,其中包含属性的数据。
属性总是以非交插(non-interleaved)的方式存储在几何图形中。
保留具有众所周知语义的属性名称。以下属性由Geometry(取决于提供的VertexFormat)创建。
position- 3D顶点位置。64位浮点数(用于精度)。 每个属性3个分量。请参见VertexFormat#position。normal- 标准(标准化的), 通常用于光照。32位浮点数。每个属性3个分量。请参见VertexFormat#normal。st- 2D纹理坐标。32位浮点数。每个属性2个分量。请参见VertexFormat#st.bitangent- Bitangent(标准化的),用于切线空间(tangent-space)效果,如凹凸贴图(bump mapping)。32位浮点数。每个属性3个分量。请参见VertexFormat#bitangent。tangent- Tangent(标准化的),用于切线空间(tangent-space)效果,如凹凸贴图(bump mapping)。32位浮点数。每个属性3个分量。请参见VertexFormat#tangent。
以下属性名通常不是由Geometry创建的,而是由Primitive或GeometryPipeline函数添加到Geometry中,以便为渲染几何图形做好准备。
position3DHigh- 使用GeometryPipeline.encodeAttribute计算得出的已编码64位位置的高32位。32位浮点数。每个属性4个分量。position3DLow- 使用GeometryPipeline.encodeAttribute计算得出的已编码64位位置的低32位。32位浮点数。每个属性4个分量。position2DHigh- 使用GeometryPipeline.encodeAttribute计算得出的已编码的64位2D(Columbus view)位置的高32位。 32位浮点数。每个属性4个分量。position2DLow- 使用GeometryPipeline.encodeAttribute计算得出的已编码的64位2D(Columbus view)位置的低32位。 32位浮点数。每个属性4个分量。color- 通常从GeometryInstance#color而来的RGBA颜色(标准化)。32位浮点数。每个属性4个分量。pickColor- 用于拾取的RGBA颜色。32位浮点数。每个属性4个分量。
-
Default Value:
undefined
Example:
geometry.attributes.position = new Cesium.GeometryAttribute({
componentDatatype : Cesium.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : new Float32Array(0)
});
See:
boundingSphere : BoundingSphere
一个可选的包围球,完全包围几何图形。这是通常用于筛选(culling)。
-
Default Value:
undefined
可选的索引数据——与
Geometry#primitiveType一起——决定几何图形中的图元。
-
Default Value:
undefined
primitiveType : PrimitiveType
几何图形中的图元类型。这通常是
PrimitiveType.TRIANGLES,但可以根据具体的几何形状变化。
-
Default Value:
undefined
Methods
计算几何图形中的顶点数。运行时与顶点的属性数量有关,而与顶点的数量无关。
| Name | Type | Description |
|---|---|---|
geometry |
Geometry | 几何图形。 |
Returns:
几何图形中的顶点数。
Example:
var numVertices = Cesium.Geometry.computeNumberOfVertices(geometry);
