GeometryPipeline

几何体的内容管道函数。
See:

Methods

static Cesium.GeometryPipeline.compressVertices(geometry) → Geometry

压缩并打包几何体法线属性值以节省内存。
Name Type Description
geometry Geometry 要修改的几何体。
Returns:
修改后的geometry参数,其法线已压缩并打包。
Example:
geometry = Cesium.GeometryPipeline.compressVertices(geometry);

static Cesium.GeometryPipeline.computeNormal(geometry) → Geometry

通过平均所有入射到该顶点的三角形的法线,为包含TRIANGLES的几何体计算逐顶点法线。 结果是一个新的normal属性添加到几何体中。 这假设逆时针环绕顺序。
Name Type Description
geometry Geometry 要修改的几何体。
Returns:
修改后的geometry参数,带有计算出的normal属性。
Throws:
Example:
Cesium.GeometryPipeline.computeNormal(geometry);

static Cesium.GeometryPipeline.computeTangentAndBitangent(geometry) → Geometry

为包含TRIANGLES的几何体计算逐顶点切线和副切线。 结果是新的tangent和bitangent属性添加到几何体中。 这假设逆时针环绕顺序。

基于为任意网格计算切线空间基向量 by Eric Lengyel。

Name Type Description
geometry Geometry 要修改的几何体。
Returns:
修改后的geometry参数,带有计算出的tangent和bitangent属性。
Throws:
Example:
Cesium.GeometryPipeline.computeTangentAndBiTangent(geometry);

static Cesium.GeometryPipeline.createAttributeLocations(geometry) → object

创建一个对象,将属性名称映射到唯一位置(索引), 用于匹配顶点属性和着色器程序。
Name Type Description
geometry Geometry 要为其创建对象的几何体(不会被修改)。
Returns:
具有属性名称/索引对的对象。
Example:
const attributeLocations = Cesium.GeometryPipeline.createAttributeLocations(geometry);
// 示例输出
// {
//   'position' : 0,
//   'normal' : 1
// }

static Cesium.GeometryPipeline.createLineSegmentsForVectors(geometry, attributeName, length) → Geometry

创建一个新的Geometry,其中包含表示所提供属性(attributeName)的LINES。 这用于可视化向量属性,如法线、切线和副切线。
Name Type Default Description
geometry Geometry 具有该属性的Geometry实例。
attributeName string 'normal' optional 属性的名称。
length number 10000.0 optional 每个线段的长度(米)。可以为负数以使向量指向相反方向。
Returns:
一个新的Geometry实例,包含向量的线段。
Throws:
  • DeveloperError : geometry.attributes必须具有与attributeName参数同名的属性。
Example:
const geometry = Cesium.GeometryPipeline.createLineSegmentsForVectors(instance.geometry, 'bitangent', 100000.0);

static Cesium.GeometryPipeline.encodeAttribute(geometry, attributeName, attributeHighName, attributeLowName) → Geometry

将浮点几何体属性值编码为两个单独的属性,以提高渲染精度。

这通常用于创建高精度位置顶点属性。

Name Type Description
geometry Geometry 要修改的几何体。
attributeName string 属性的名称。
attributeHighName string 用于编码高位属性的名称。
attributeLowName string 用于编码低位属性的名称。
Returns:
修改后的geometry参数,带有其编码属性。
Throws:
  • DeveloperError : geometry必须具有与attributeName参数匹配的属性。
  • DeveloperError : 属性componentDatatype必须是ComponentDatatype.DOUBLE。
Example:
geometry = Cesium.GeometryPipeline.encodeAttribute(geometry, 'position3D', 'position3DHigh', 'position3DLow');

static Cesium.GeometryPipeline.fitToUnsignedShortIndices(geometry) → Array.<Geometry>

如有必要,将几何体拆分为多个几何体,以确保 indices中的索引适合无符号短整型。当不支持无符号整型索引时, 这用于满足WebGL要求。

如果几何体没有任何indices,则此函数不起作用。

Name Type Description
geometry Geometry 要拆分为多个几何体的几何体。
Returns:
几何体数组,每个几何体的索引都适合无符号短整型。
Throws:
  • DeveloperError : geometry.primitiveType必须等于PrimitiveType.TRIANGLES、PrimitiveType.LINES或PrimitiveType.POINTS
  • DeveloperError : 所有几何体属性列表必须具有相同数量的属性。
Example:
const geometries = Cesium.GeometryPipeline.fitToUnsignedShortIndices(geometry);

static Cesium.GeometryPipeline.projectTo2D(geometry, attributeName, attributeName3D, attributeName2D, projection) → Geometry

将几何体的3D position属性投影到2D,用单独的 position3D和position2D属性替换position属性。

如果几何体没有position,则此函数不起作用。

Name Type Default Description
geometry Geometry 要修改的几何体。
attributeName string 属性的名称。
attributeName3D string 3D中的属性名称。
attributeName2D string 2D中的属性名称。
projection object new GeographicProjection() optional 要使用的投影。
Returns:
修改后的geometry参数,带有position3D和position2D属性。
Throws:
Example:
geometry = Cesium.GeometryPipeline.projectTo2D(geometry, 'position', 'position3D', 'position2D');

static Cesium.GeometryPipeline.reorderForPostVertexCache(geometry, cacheCapacity) → Geometry

使用Tipsify算法重新排序几何体的indices,以通过GPU的 后顶点着色器缓存获得更好的性能。如果几何体primitiveType 不是TRIANGLES或几何体没有indices,则此函数不起作用。
Name Type Default Description
geometry Geometry 要修改的几何体。
cacheCapacity number 24 optional GPU顶点缓存中可以容纳的顶点数。
Returns:
修改后的geometry参数,其索引已为后顶点着色器缓存重新排序。
Throws:
Example:
geometry = Cesium.GeometryPipeline.reorderForPostVertexCache(geometry);
See:

static Cesium.GeometryPipeline.reorderForPreVertexCache(geometry) → Geometry

重新排序几何体的属性和indices,以通过GPU的预顶点着色器缓存获得更好的性能。
Name Type Description
geometry Geometry 要修改的几何体。
Returns:
修改后的geometry参数,其属性和索引已为GPU的预顶点着色器缓存重新排序。
Throws:
  • DeveloperError : geometry.attributes中的每个属性数组必须具有相同数量的属性。
Example:
geometry = Cesium.GeometryPipeline.reorderForPreVertexCache(geometry);
See:

static Cesium.GeometryPipeline.toWireframe(geometry) → Geometry

将几何体的三角形索引转换为线索引。如果几何体有indices 且其primitiveType为TRIANGLES、TRIANGLE_STRIP、 TRIANGLE_FAN,则将其转换为LINES;否则,几何体不变。

这通常用于创建用于视觉调试的线框几何体。

Name Type Description
geometry Geometry 要修改的几何体。
Returns:
修改后的geometry参数,其三角形索引已转换为线。
Throws:
  • DeveloperError : geometry.primitiveType必须是TRIANGLES、TRIANGLE_STRIP或TRIANGLE_FAN。
Example:
geometry = Cesium.GeometryPipeline.toWireframe(geometry);

static Cesium.GeometryPipeline.transformToWorldCoordinates(instance) → GeometryInstance

将几何体实例转换为世界坐标。这将实例的modelMatrix更改为Matrix4.IDENTITY, 并转换以下属性(如果存在):position、normal、 tangent和bitangent。
Name Type Description
instance GeometryInstance 要修改的几何体实例。
Returns:
修改后的instance参数,其属性已转换为世界坐标。
Example:
Cesium.GeometryPipeline.transformToWorldCoordinates(instance);
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.