Geometry

new Cesium.Geometry(options)

具有形成顶点的属性和可选索引数据的几何表示 定义原语。几何图形和Appearance,它描述了阴影, 可分配给Primitive进行可视化。Primitive罐 从许多异构(在许多情况下)几何图形创建以获得性能。

Geometries can be transformed and optimized using functions in GeometryPipeline.

Name Type Description
options Object 具有以下属性的对象:
Name Type Default Description
attributes GeometryAttributes 属性,组成几何体的顶点。
primitiveType PrimitiveType PrimitiveType.TRIANGLES optional 几何体中基本体的类型。
indices Uint16Array | Uint32Array optional 确定几何体中基本体的可选索引数据。
boundingSphere BoundingSphere optional 完全封闭几何体的可选边界球体。
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 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

属性,它构成几何体的顶点。此对象中的每个属性对应于 GeometryAttribute包含属性数据。

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.

  • position - 3D vertex position. 64-bit floating-point (for precision). 3 components per attribute. See VertexFormat#position.
  • normal - Normal (normalized), commonly used for lighting. 32-bit floating-point. 3 components per attribute. See VertexFormat#normal.
  • st - 2D texture coordinate. 32-bit floating-point. 2 components per attribute. See VertexFormat#st.
  • bitangent - Bitangent (normalized), used for tangent-space effects like bump mapping. 32-bit floating-point. 3 components per attribute. See VertexFormat#bitangent.
  • tangent - Tangent (normalized), used for tangent-space effects like bump mapping. 32-bit floating-point. 3 components per attribute. See VertexFormat#tangent.

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 - High 32 bits for encoded 64-bit position computed with GeometryPipeline.encodeAttribute. 32-bit floating-point. 4 components per attribute.
  • position3DLow - Low 32 bits for encoded 64-bit position computed with GeometryPipeline.encodeAttribute. 32-bit floating-point. 4 components per attribute.
  • position3DHigh - High 32 bits for encoded 64-bit 2D (Columbus view) position computed with GeometryPipeline.encodeAttribute. 32-bit floating-point. 4 components per attribute.
  • position2DLow - Low 32 bits for encoded 64-bit 2D (Columbus view) position computed with GeometryPipeline.encodeAttribute. 32-bit floating-point. 4 components per attribute.
  • color - RGBA color (normalized) usually from GeometryInstance#color. 32-bit floating-point. 4 components per attribute.
  • pickColor - RGBA color used for picking. 32-bit floating-point. 4 components per attribute.
Default Value: undefined
Example:
geometry.attributes.position = new Cesium.GeometryAttribute({
  componentDatatype : Cesium.ComponentDatatype.FLOAT,
  componentsPerAttribute : 3,
  values : new Float32Array(0)
});
See:
完全封闭几何体的可选边界球体。这是 常用于扑杀。
Default Value: undefined

indices : Array

可选索引数据,连同Geometry#primitiveType- 确定几何体中的基本体。
Default Value: undefined
几何体中基本体的类型。通常是PrimitiveType.TRIANGLES, 但可以根据具体的几何结构而变化。
Default Value: undefined

Methods

static Cesium.Geometry.computeNumberOfVertices(geometry)Number

计算几何体中的顶点数。运行时与 与顶点的数目无关。
Name Type Description
geometry Geometry 几何学。
Returns:
几何体中的顶点数。
Example:
var numVertices = Cesium.Geometry.computeNumberOfVertices(geometry);