GeometryPipeline

Content pipeline functions for geometries.
参考:

方法

static Cesium.GeometryPipeline.compressVertices(geometry)Geometry

Compresses and packs geometry normal attribute values to save memory.
参数名称 类型 描述信息
geometry Geometry The geometry to modify.
返回值:
The modified geometry argument, with its normals compressed and packed.
使用示例:
geometry = Cesium.GeometryPipeline.compressVertices(geometry);

static Cesium.GeometryPipeline.computeNormal(geometry)Geometry

Computes per-vertex normals for a geometry containing TRIANGLES by averaging the normals of all triangles incident to the vertex. The result is a new normal attribute added to the geometry. This assumes a counter-clockwise winding order.
参数名称 类型 描述信息
geometry Geometry The geometry to modify.
返回值:
The modified geometry argument with the computed normal attribute.
Throws:
使用示例:
Cesium.GeometryPipeline.computeNormal(geometry);

static Cesium.GeometryPipeline.computeTangentAndBitangent(geometry)Geometry

Computes per-vertex tangents and bitangents for a geometry containing TRIANGLES. The result is new tangent and bitangent attributes added to the geometry. This assumes a counter-clockwise winding order.

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

参数名称 类型 描述信息
geometry Geometry The geometry to modify.
返回值:
The modified geometry argument with the computed tangent and bitangent attributes.
Throws:
使用示例:
Cesium.GeometryPipeline.computeTangentAndBiTangent(geometry);

static Cesium.GeometryPipeline.createAttributeLocations(geometry)object

Creates an object that maps attribute names to unique locations (indices) for matching vertex attributes and shader programs.
参数名称 类型 描述信息
geometry Geometry The geometry, which is not modified, to create the object for.
返回值:
An object with attribute name / index pairs.
使用示例:
const attributeLocations = Cesium.GeometryPipeline.createAttributeLocations(geometry);
// Example output
// {
//   'position' : 0,
//   'normal' : 1
// }

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

Creates a new Geometry with LINES representing the provided attribute (attributeName) for the provided geometry. This is used to visualize vector attributes like normals, tangents, and bitangents.
参数名称 类型 默认值 描述信息
geometry Geometry The Geometry instance with the attribute.
attributeName string 'normal' 可选 The name of the attribute.
length number 10000.0 可选 The length of each line segment in meters. This can be negative to point the vector in the opposite direction.
返回值:
A new Geometry instance with line segments for the vector.
Throws:
  • DeveloperError : geometry.attributes must have an attribute with the same name as the attributeName parameter.
使用示例:
const geometry = Cesium.GeometryPipeline.createLineSegmentsForVectors(instance.geometry, 'bitangent', 100000.0);

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

Encodes floating-point geometry attribute values as two separate attributes to improve rendering precision.

This is commonly used to create high-precision position vertex attributes.

参数名称 类型 描述信息
geometry Geometry The geometry to modify.
attributeName string The name of the attribute.
attributeHighName string The name of the attribute for the encoded high bits.
attributeLowName string The name of the attribute for the encoded low bits.
返回值:
The modified geometry argument, with its encoded attribute.
Throws:
  • DeveloperError : geometry must have attribute matching the attributeName argument.
  • DeveloperError : The attribute componentDatatype must be ComponentDatatype.DOUBLE.
使用示例:
geometry = Cesium.GeometryPipeline.encodeAttribute(geometry, 'position3D', 'position3DHigh', 'position3DLow');

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

Splits a geometry into multiple geometries, if necessary, to ensure that indices in the indices fit into unsigned shorts. This is used to meet the WebGL requirements when unsigned int indices are not supported.

If the geometry does not have any indices, this function has no effect.

参数名称 类型 描述信息
geometry Geometry The geometry to be split into multiple geometries.
返回值:
An array of geometries, each with indices that fit into unsigned shorts.
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.
使用示例:
const geometries = Cesium.GeometryPipeline.fitToUnsignedShortIndices(geometry);

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

Projects a geometry's 3D position attribute to 2D, replacing the position attribute with separate position3D and position2D attributes.

If the geometry does not have a position, this function has no effect.

参数名称 类型 默认值 描述信息
geometry Geometry The geometry to modify.
attributeName string The name of the attribute.
attributeName3D string The name of the attribute in 3D.
attributeName2D string The name of the attribute in 2D.
projection object new GeographicProjection() 可选 The projection to use.
返回值:
The modified geometry argument with position3D and position2D attributes.
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.
使用示例:
geometry = Cesium.GeometryPipeline.projectTo2D(geometry, 'position', 'position3D', 'position2D');

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

Reorders a geometry's indices to achieve better performance from the GPU's post vertex-shader cache by using the Tipsify algorithm. If the geometry primitiveType is not TRIANGLES or the geometry does not have an indices, this function has no effect.
参数名称 类型 默认值 描述信息
geometry Geometry The geometry to modify.
cacheCapacity number 24 可选 The number of vertices that can be held in the GPU's vertex cache.
返回值:
The modified geometry argument, with its indices reordered for the post-vertex-shader cache.
Throws:
使用示例:
geometry = Cesium.GeometryPipeline.reorderForPostVertexCache(geometry);
参考:

static Cesium.GeometryPipeline.reorderForPreVertexCache(geometry)Geometry

Reorders a geometry's attributes and indices to achieve better performance from the GPU's pre-vertex-shader cache.
参数名称 类型 描述信息
geometry Geometry The geometry to modify.
返回值:
The modified geometry argument, with its attributes and indices reordered for the GPU's pre-vertex-shader cache.
Throws:
  • DeveloperError : Each attribute array in geometry.attributes must have the same number of attributes.
使用示例:
geometry = Cesium.GeometryPipeline.reorderForPreVertexCache(geometry);
参考:

static Cesium.GeometryPipeline.toWireframe(geometry)Geometry

Converts a geometry's triangle indices to line indices. If the geometry has an indices and its primitiveType is TRIANGLES, TRIANGLE_STRIP, TRIANGLE_FAN, it is converted to LINES; otherwise, the geometry is not changed.

This is commonly used to create a wireframe geometry for visual debugging.

参数名称 类型 描述信息
geometry Geometry The geometry to modify.
返回值:
The modified geometry argument, with its triangle indices converted to lines.
Throws:
  • DeveloperError : geometry.primitiveType must be TRIANGLES, TRIANGLE_STRIP, or TRIANGLE_FAN.
使用示例:
geometry = Cesium.GeometryPipeline.toWireframe(geometry);

static Cesium.GeometryPipeline.transformToWorldCoordinates(instance)GeometryInstance

Transforms a geometry instance to world coordinates. This changes the instance's modelMatrix to Matrix4.IDENTITY and transforms the following attributes if they are present: position, normal, tangent, and bitangent.
参数名称 类型 描述信息
instance GeometryInstance The geometry instance to modify.
返回值:
The modified instance argument, with its attributes transforms to world coordinates.
使用示例:
Cesium.GeometryPipeline.transformToWorldCoordinates(instance);