new Cesium.Geometry(options)

带有形成顶点和可选索引数据的属性的几何表达式 defining primitives. Geometries and an Appearance, which describes the shading, can be assigned to a Primitive for visualization. A Primitive can 由许多不同的——在许多情况下——为性能而设置的几何图形.

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 The type of primitives in the geometry.
indices Uint16Array | Uint32Array optional 确定几何中原始的可选索引数据.
boundingSphere BoundingSphere optional 完全包围几何的可选边框 .
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

属性,构成几何的顶点. 此对象中的每个属性对应 a 包含属性数据的 GeometryAttribute .

属性总是被存储在几何中非间断.

有保留属性名称有著名的语义学. 以下属性 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.

以下属性名称一般不由几何创建,而是添加 to a Geometry by a Primitive or GeometryPipeline functions to prepare 用于渲染的几何图形.

  • 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.
  • position2DHigh - 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.

Example:
geometry.attributes.position = new Cesium.GeometryAttribute({
  componentDatatype : Cesium.ComponentDatatype.FLOAT,
  componentsPerAttribute : 3,
  values : new Float32Array(0)
});
See:

boundingSphere : BoundingSphere|undefined

完全附着几何的可选边框。 这是 通常用于 culling.
Default Value: undefined

indices : Array|undefined

Optional index data that - along with Geometry#primitiveType - 确定几何中的原始物.
Default Value: undefined

primitiveType : PrimitiveType|undefined

The type of primitives in the geometry. This is most often PrimitiveType.TRIANGLES, 但可以根据具体的几何特征而变化.
Default Value: PrimitiveType.TRIANGLES

Methods

static Cesium.Geometry.computeNumberOfVertices(geometry)number

计算几何中顶点的数量。 运行时间为线性 ,而不是顶点数.
Name Type Description
geometry Geometry The geometry.
Returns:
几何中顶数.
Example:
const numVertices = Cesium.Geometry.computeNumberOfVertices(geometry);
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.