Geometry

new Cesium.Geometry(options)

具有构成顶点的属性和可选索引数据的几何表示 定义基元。 几何图形和 外观(描述阴影)、 可以分配给 Primitive 以进行可视化。 Primitive 可以 由许多异构 - 在许多情况下 - 几何图形创建以提高性能。

可以使用 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.
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

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

属性始终以非交错方式存储在 Geometry 中。

存在具有已知语义的保留属性名称。 以下属性 由 Geometry 创建(取决于提供的 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

以下属性名称通常不是由 Geometry 创建的,而是添加的 通过 PrimitiveGeometryPipeline 函数准备 用于渲染的几何体。

  • 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 - RGBA 颜色(标准化),通常来自 GeometryInstance#color。 32 位浮点。 每个属性 4 个组件。
  • pickColor - 用于拾取的 RGBA 颜色。 32 位浮点。 每个属性 4 个组件。

Example:
geometry.attributes.position = new Cesium.GeometryAttribute({
  componentDatatype : Cesium.ComponentDatatype.FLOAT,
  componentsPerAttribute : 3,
  values : new Float32Array(0)
});
See:
一个完全封闭几何体的可选边界球体。 这是 通常用于剔除。
Default Value: undefined

indices : Array|undefined

可选的索引数据 - 以及 Geometry#primitiveType - 确定几何体中的基元。
Default Value: undefined
几何体中基元的类型。 这通常是 PrimitiveType.TRIANGLES, 但可以根据特定几何图形而变化。
Default Value: PrimitiveType.TRIANGLES

Methods

static Cesium.Geometry.computeNumberOfVertices(geometry)number

计算几何图形中的顶点数。 运行时间与 相对于顶点中的属性数,而不是顶点数。
Name Type Description
geometry 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.