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属性。 这假设了逆时针绕组顺序。
Name Type Description
geometry Geometry 要修改的几何体。
Returns:
具有计算TRIANGLES属性的修改后的 geometry 参数。
Throws:
Example:
Cesium.GeometryPipeline.computeNormal(geometry);

static Cesium.GeometryPipeline.computeTangentAndBitangent(geometry)Geometry

计算包含 TRIANGLES 的几何体的每顶点切线和双切线。 结果是新的 tangentbitangent 添加到几何体的属性。 这假设了逆时针绕组顺序。

Based on Computing Tangent Space Basis Vectors for an Arbitrary Mesh by Eric Lengyel.

Name Type Description
geometry Geometry 要修改的几何体。
Returns:
修改后的 geometry 参数替换为计算的 tangentbitangent 属性。
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);
// Example output
// {
//   'position' : 0,
//   'normal' : 1
// }

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

创建一个新的 Geometry,其中 LINES 表示提供的 属性 (attributeName) 为提供的几何图形。 这用于 可视化向量属性,如法线、切线和双切线。
Name Type Default Description
geometry Geometry 具有属性的 Geometry 实例。
attributeName string 'normal' optional 属性的名称。
length number 10000.0 optional 每条线段的长度,以米为单位。 这可以是负数,以将向量指向相反的方向。
Returns:
一个新的 Geometry 实例,其中包含向量的线段。
Throws:
  • DeveloperError : geometry.attributes must have an attribute with the same name as the attributeName parameter.
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 参数及其 encoded 属性。
Throws:
  • DeveloperError : geometry must have attribute matching the attributeName argument.
  • DeveloperError : The attribute componentDatatype must be ComponentDatatype.DOUBLE.
Example:
geometry = Cesium.GeometryPipeline.encodeAttribute(geometry, 'position3D', 'position3DHigh', 'position3DLow');

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

如有必要,将一个几何拆分为多个几何,以确保 indices适合 unsigned shorts。 这用于满足 WebGL 要求 当不支持 unsigned int 索引时。

如果几何图形没有任何索引,则此函数无效。

Name Type Description
geometry Geometry 要拆分为多个几何体的几何体。
Returns:
一个几何数组,每个几何都有适合无符号短文本的索引。
Throws:
  • DeveloperError : geometry.primitiveType must equal to PrimitiveType.TRIANGLES, PrimitiveType.LINES, or PrimitiveType.POINTS
  • DeveloperError : All geometry attribute lists must have the same number of attributes.
Example:
const geometries = Cesium.GeometryPipeline.fitToUnsignedShortIndices(geometry);

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

将几何体的 3D position属性投影到 2D ,替换position 属性具有单独的 position3Dposition2D 属性。

如果几何体没有position,则此功能无效。

Name Type Default Description
geometry Geometry 要修改的几何体。
attributeName string 属性的名称。
attributeName3D string 3D 属性的 3D 名称。
attributeName2D string 2D 2D 属性的名称。
projection object new GeographicProjection() optional 要使用的投影。
Returns:
具有 position3Dposition2D 属性的修改后的 geometry 参数。
Throws:
  • DeveloperError : geometry must have attribute matching the attributeName argument.
  • DeveloperError : The attribute componentDatatype must be ComponentDatatype.DOUBLE.
  • DeveloperError : Could not project a point to 2D.
Example:
geometry = Cesium.GeometryPipeline.projectTo2D(geometry, 'position', 'position3D', 'position2D');

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

对几何体的indices进行重新排序,以获得更好的 GPU 性能 使用 Tipsify 算法进行顶点着色器后缓存。 如果几何体 primitiveType 不是 TRIANGLES 或几何图形没有索引,则此函数无效。
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 : Each attribute array in geometry.attributes must have the same number of attributes.
Example:
geometry = Cesium.GeometryPipeline.reorderForPreVertexCache(geometry);
See:

static Cesium.GeometryPipeline.toWireframe(geometry)Geometry

将几何图形的三角形索引转换为线条索引。 如果几何图形具有索引 及其 primitiveTypeTRIANGLESTRIANGLE_STRIPTRIANGLE_FAN,它被转换为 LINES;否则,几何图形不会更改。

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

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

static Cesium.GeometryPipeline.transformToWorldCoordinates(实例)GeometryInstance

将几何体实例转换为世界坐标。 这会改变 实例的 modelMatrix 转换为 Matrix4.IDENTITY,并将 如果存在以下属性:positionnormaltangentbitangent 的 API 请求。
Name Type Description
实例 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.