几何图形的内容管道函数。 Content pipeline functions for geometries.
另见: See:
方法 Methods
static Cesium.GeometryPipeline.compressVertices(geometry) → Geometry
压缩和打包几何法线属性值以节省内存。 Compresses and packs geometry normal attribute values to save memory.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
geometry |
Geometry | 要修改的几何图形。 The geometry to modify. |
返回: Returns:
修改后的 The modified
geometry 参数,其法线被压缩和打包。 argument, with its normals compressed and packed.
示例: Example:
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.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
geometry |
Geometry | 要修改的几何图形。 The geometry to modify. |
返回: Returns:
修改后的 The modified
geometry 与计算得出的参数 argument with the computed normal attribute.
抛出: Throws:
-
DeveloperError :geometry.indices长度必须大于0并且是3的倍数。 : geometry.indices length must be greater than 0 and be a multiple of 3.
-
DeveloperError :geometry.primitiveType 必须是 : geometry.primitiveType must be
PrimitiveType.TRIANGLES.
示例: Example:
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.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
geometry |
Geometry | 要修改的几何图形。 The geometry to modify. |
返回: Returns:
修改后的 The modified
geometry 与计算得出的参数 argument with the computed tangent and bitangent attributes.
抛出: Throws:
-
DeveloperError :geometry.indices长度必须大于0并且是3的倍数。 : geometry.indices length must be greater than 0 and be a multiple of 3.
-
DeveloperError :geometry.primitiveType 必须是 : geometry.primitiveType must be
PrimitiveType.TRIANGLES.
示例: Example:
Cesium.GeometryPipeline.computeTangentAndBiTangent(geometry);
创建一个将属性名称映射到唯一位置(索引)的对象,以匹配顶点属性和着色器程序。 Creates an object that maps attribute names to unique locations (indices) for matching vertex attributes and shader programs.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
geometry |
Geometry | 用于创建对象的未修改的几何图形。 The geometry, which is not modified, to create the object for. |
返回: Returns:
具有属性名称/索引对的对象。 An object with attribute name / index pairs.
示例: Example:
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.
| 名称 Name | 类型 Type | 默认值 Default | 说明 Description |
|---|---|---|---|
geometry |
Geometry |
The Geometry 具有属性的实例。 instance with the attribute. |
|
attributeName |
string |
'normal'
|
可选 optional 属性的名称。 The name of the attribute. |
length |
number |
10000.0
|
可选 optional 每条线段的长度(以米为单位)。这可以是负数,使向量指向相反的方向。 The length of each line segment in meters. This can be negative to point the vector in the opposite direction. |
返回: Returns:
一个新的 A new
Geometry 向量线段的实例。 instance with line segments for the vector.
抛出: Throws:
-
DeveloperError :geometry.attributes 必须具有与 attributeName 参数同名的属性。 : 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
将浮点几何属性值编码为两个单独的属性以提高渲染精度。 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.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
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. |
返回: Returns:
修改后的 The modified
geometry 参数及其编码属性。 argument, with its encoded attribute.
抛出: Throws:
-
DeveloperError :几何图形必须具有与 attributeName 参数匹配的属性。 : geometry must have attribute matching the attributeName argument.
-
DeveloperError :属性组件数据类型必须是组件数据类型.DOUBLE。 : The attribute componentDatatype must be ComponentDatatype.DOUBLE.
示例: Example:
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 适合未签名的短裤。当不支持 unsigned int 索引时,这用于满足 WebGL 要求。 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.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
geometry |
Geometry | 要分割成多个几何体的几何体。 The geometry to be split into multiple geometries. |
返回: Returns:
一组几何图形,每个几何图形都有适合无符号短裤的索引。 An array of geometries, each with indices that fit into unsigned shorts.
抛出: Throws:
-
DeveloperError :geometry.primitiveType 必须等于 PrimitiveType.TRIANGLES、PrimitiveType.LINES 或 PrimitiveType.POINTS : 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 Projects a geometry's 3D
position 属性为 2D,替换 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.
| 名称 Name | 类型 Type | 默认值 Default | 说明 Description |
|---|---|---|---|
geometry |
Geometry | 要修改的几何图形。 The geometry to modify. | |
attributeName |
string | 属性的名称。 The name of the attribute. | |
attributeName3D |
string | 3D 属性的名称。 The name of the attribute in 3D. | |
attributeName2D |
string | 二维属性的名称。 The name of the attribute in 2D. | |
projection |
object |
new GeographicProjection()
|
可选 optional 要使用的投影。 The projection to use. |
返回: Returns:
修改后的 The modified
geometry 与争论 argument with position3D and position2D attributes.
抛出: Throws:
-
DeveloperError :几何图形必须具有与 attributeName 参数匹配的属性。 : geometry must have attribute matching the attributeName argument.
-
DeveloperError :属性组件数据类型必须是组件数据类型.DOUBLE。 : The attribute componentDatatype must be ComponentDatatype.DOUBLE.
-
DeveloperError :无法将点投影到 2D。 : Could not project a point to 2D.
示例: Example:
geometry = Cesium.GeometryPipeline.projectTo2D(geometry, 'position', 'position3D', 'position2D');
static Cesium.GeometryPipeline.reorderForPostVertexCache(geometry, cacheCapacity) → Geometry
重新排序几何体 Reorders a geometry's
indices 通过使用 Tipsify 算法,从 GPU 的后顶点着色器缓存获得更好的性能。如果几何 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.
| 名称 Name | 类型 Type | 默认值 Default | 说明 Description |
|---|---|---|---|
geometry |
Geometry | 要修改的几何图形。 The geometry to modify. | |
cacheCapacity |
number |
24
|
可选 optional GPU 顶点缓存中可以保存的顶点数。 The number of vertices that can be held in the GPU's vertex cache. |
返回: Returns:
修改后的 The modified
geometry 参数,其索引为后顶点着色器缓存重新排序。 argument, with its indices reordered for the post-vertex-shader cache.
抛出: Throws:
-
DeveloperError :cacheCapacity必须大于2。 : cacheCapacity must be greater than two.
- GeometryPipeline.reorderForPreVertexCache
- Fast Triangle Reordering for Vertex Locality and Reduced Overdraw 作者:桑德、内哈布和巴尔扎克 by Sander, Nehab, and Barczak
示例: Example:
geometry = Cesium.GeometryPipeline.reorderForPostVertexCache(geometry);
另见: See:
static Cesium.GeometryPipeline.reorderForPreVertexCache(geometry) → Geometry
重新排序几何体的属性并 Reorders a geometry's attributes and
indices 从 GPU 的预顶点着色器缓存获得更好的性能。 to achieve better performance from the GPU's pre-vertex-shader cache.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
geometry |
Geometry | 要修改的几何图形。 The geometry to modify. |
返回: Returns:
修改后的 The modified
geometry 参数,其属性和索引针对 GPU 的预顶点着色器缓存重新排序。 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.
示例: Example:
geometry = Cesium.GeometryPipeline.reorderForPreVertexCache(geometry);
另见: See:
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.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
geometry |
Geometry | 要修改的几何图形。 The geometry to modify. |
返回: Returns:
修改后的 The modified
geometry 参数,其三角形索引转换为线。 argument, with its triangle indices converted to lines.
抛出: Throws:
-
DeveloperError :geometry.primitiveType 必须是 TRIANGLES、TRIANGLE_STRIP 或 TRIANGLE_FAN。 : geometry.primitiveType must be TRIANGLES, TRIANGLE_STRIP, or TRIANGLE_FAN.
示例: Example:
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.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
instance |
GeometryInstance | 要修改的几何实例。 The geometry instance to modify. |
返回: Returns:
修改后的 The modified
instance 参数,其属性转换为世界坐标。 argument, with its attributes transforms to world coordinates.
示例: Example:
Cesium.GeometryPipeline.transformToWorldCoordinates(instance);
