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:
-
DeveloperError : geometry.indices 的长度必须大于 0 并且是 3 的倍数。
-
DeveloperError : geometry.primitiveType 必须是
PrimitiveType.TRIANGLES。
Example:
Cesium.GeometryPipeline.computeNormal(geometry);
static Cesium.GeometryPipeline.computeTangentAndBitangent(geometry) → Geometry
为包含
TRIANGLES 的几何体计算每个顶点的切线和副切线。
结果是新添加到几何体的 tangent 和 bitangent 属性。
这假设采用逆时针的缠绕顺序。
基于 Eric Lengyel 的 为任意网格计算切线空间基向量。
| Name | Type | Description |
|---|---|---|
geometry |
Geometry | 要修改的几何体。 |
Returns:
修改后的
geometry 参数,其中包含计算得出的 tangent 和 bitangent 属性。
Throws:
-
DeveloperError : geometry.indices 的长度必须大于 0 并且是 3 的倍数。
-
DeveloperError : geometry.primitiveType 必须是
PrimitiveType.TRIANGLES。
Example:
Cesium.GeometryPipeline.computeTangentAndBiTangent(geometry);
创建一个对象,将属性名称映射到唯一位置(索引),
用于匹配顶点属性和着色器程序。
| 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
| 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.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:
-
DeveloperError : geometry 必须具有与 attributeName 参数匹配的属性。
-
DeveloperError : 属性组件数据类型必须为 ComponentDatatype.DOUBLE。
-
DeveloperError : 无法将点投影到 2D。
Example:
geometry = Cesium.GeometryPipeline.projectTo2D(geometry, 'position', 'position3D', 'position2D');
static Cesium.GeometryPipeline.reorderForPostVertexCache(geometry, cacheCapacity) → Geometry
重新排序几何体的
indices,以通过使用 Tipsify 算法提高 GPU 的后顶点着色器缓存性能。如果几何体的 primitiveType
不是 TRIANGLES 或几何体没有 indices,则此函数不会产生效果。
| Name | Type | Default | Description |
|---|---|---|---|
geometry |
Geometry | 要修改的几何体。 | |
cacheCapacity |
number |
24
|
optional GPU 顶点缓存中可以容纳的顶点数量。 |
Returns:
修改后的
geometry 参数,其索引已为后顶点着色器缓存重新排序。
Throws:
-
DeveloperError : cacheCapacity 必须大于 2。
- 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
重新排序几何体的属性和
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);
