@cesium/engine 22.0.0 → 22.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/Build/ThirdParty/Workers/zip-web-worker.js +10 -7
  2. package/Build/Workers/chunk-23T2IPHV.js +55 -0
  3. package/Build/Workers/{chunk-VVZ667H6.js → chunk-2AM4E2WD.js} +2 -2
  4. package/Build/Workers/{chunk-XQ347YWU.js → chunk-2MWF4IES.js} +16 -14
  5. package/Build/Workers/{chunk-75HAJIDT.js → chunk-2RCIRXNI.js} +1 -1
  6. package/Build/Workers/{chunk-RQRODXVN.js → chunk-3YTMGEXW.js} +5 -1424
  7. package/Build/Workers/{chunk-N52ZRKUE.js → chunk-4BHWJWS3.js} +6 -6
  8. package/Build/Workers/{chunk-5T5SY63I.js → chunk-5JKH4AMT.js} +2 -2
  9. package/Build/Workers/{chunk-EJO3NKMS.js → chunk-6HKAPCSO.js} +1 -1
  10. package/Build/Workers/{chunk-BJSNGGBM.js → chunk-A53R2F2L.js} +4 -4
  11. package/Build/Workers/{chunk-H7B7FU2U.js → chunk-A6YFUGJO.js} +5 -5
  12. package/Build/Workers/{chunk-VCVA7BMD.js → chunk-AJYWXC6I.js} +4 -4
  13. package/Build/Workers/{chunk-3GL53OCU.js → chunk-AOIO5VUS.js} +276 -2277
  14. package/Build/Workers/{chunk-SZN34LQ5.js → chunk-B7JRBTT6.js} +10 -10
  15. package/Build/Workers/{chunk-726NINF5.js → chunk-CHNDJRYA.js} +20 -18
  16. package/Build/Workers/{chunk-L7U26FFD.js → chunk-CJOV55CW.js} +20 -18
  17. package/Build/Workers/{chunk-NE5JTQJP.js → chunk-COGPE5Z2.js} +10 -8
  18. package/Build/Workers/{chunk-XPVZWY4A.js → chunk-CW7W27IZ.js} +12 -8
  19. package/Build/Workers/{chunk-GYRDA3XK.js → chunk-DICY26ID.js} +20 -16
  20. package/Build/Workers/{chunk-AOM3FHBN.js → chunk-DMEFNTUV.js} +69 -7
  21. package/Build/Workers/{chunk-XZO6F23E.js → chunk-DQSJEOZY.js} +1 -1
  22. package/Build/Workers/{chunk-MXHRZHDF.js → chunk-GDU4RZSZ.js} +16 -36
  23. package/Build/Workers/{chunk-JDJAPBZP.js → chunk-GKWOUMYA.js} +1 -1
  24. package/Build/Workers/{chunk-OUBBMEWX.js → chunk-GTY4K4IA.js} +9 -7
  25. package/Build/Workers/{chunk-LWJXCI3F.js → chunk-H6Q7E4BQ.js} +8 -6
  26. package/Build/Workers/{chunk-YLXWC7OW.js → chunk-HHGOFZVQ.js} +7 -5
  27. package/Build/Workers/{chunk-34YXP222.js → chunk-HXKUEOOD.js} +5 -5
  28. package/Build/Workers/{chunk-EZ7NJXQN.js → chunk-I4REFVXB.js} +4 -4
  29. package/Build/Workers/{chunk-OE22564R.js → chunk-IL5F6WEE.js} +3 -3
  30. package/Build/Workers/{chunk-QSMIHPUM.js → chunk-JKXPC5HD.js} +2 -2
  31. package/Build/Workers/{chunk-7KAXDKRU.js → chunk-KKGD7HAW.js} +13 -11
  32. package/Build/Workers/{chunk-YLILBDWK.js → chunk-KROSQJUA.js} +2 -2
  33. package/Build/Workers/{chunk-NHZNMTIR.js → chunk-L4JLDVCM.js} +5 -5
  34. package/Build/Workers/{chunk-2D3GLFZD.js → chunk-LIYMRHGR.js} +15 -13
  35. package/Build/Workers/{chunk-P2H75UV5.js → chunk-MKMZHRB3.js} +16 -11
  36. package/Build/Workers/{chunk-KUB64XW6.js → chunk-MO25ZQ2I.js} +12 -10
  37. package/Build/Workers/{chunk-ECHAJNQJ.js → chunk-O6RZEKHZ.js} +12 -12
  38. package/Build/Workers/{chunk-5ZF53EY6.js → chunk-OOCGX2OD.js} +4 -4
  39. package/Build/Workers/{chunk-NGKF5NTR.js → chunk-OXFU5HNU.js} +13 -5
  40. package/Build/Workers/{chunk-FA3SCJDX.js → chunk-P5CGIJUY.js} +2 -2
  41. package/Build/Workers/{chunk-W4PIP5PG.js → chunk-QEANVUGT.js} +2 -2
  42. package/Build/Workers/{chunk-AARZSH4V.js → chunk-QFBCIX7J.js} +8 -6
  43. package/Build/Workers/{chunk-JZFU2LEM.js → chunk-QUAH3XOT.js} +4 -4
  44. package/Build/Workers/{chunk-6HBKE43B.js → chunk-RXZDTDIY.js} +13 -9
  45. package/Build/Workers/{chunk-LEFQBK6H.js → chunk-SPA2KPH3.js} +14 -12
  46. package/Build/Workers/chunk-TDSVSW5A.js +1460 -0
  47. package/Build/Workers/{chunk-A6JAFSZT.js → chunk-UG2DPFOL.js} +8 -6
  48. package/Build/Workers/{chunk-U4XMLGSR.js → chunk-URGEDZBS.js} +7 -7
  49. package/Build/Workers/{chunk-A4DPJIWS.js → chunk-V35NQOJC.js} +8 -6
  50. package/Build/Workers/chunk-W4XUEDU5.js +2058 -0
  51. package/Build/Workers/{chunk-7XEJGXX2.js → chunk-WB4TSSBQ.js} +779 -24
  52. package/Build/Workers/{chunk-RCCYW6E7.js → chunk-WTLYD4FE.js} +19 -15
  53. package/Build/Workers/{chunk-5B7VZQZY.js → chunk-Y4ALZ4SS.js} +9 -7
  54. package/Build/Workers/{chunk-KGLDJRSO.js → chunk-YF2NVO5B.js} +19 -13
  55. package/Build/Workers/{chunk-IGX772ZQ.js → chunk-YSYSXSHF.js} +1 -1
  56. package/Build/Workers/{chunk-M7HRE4QR.js → chunk-YX562XOB.js} +15 -11
  57. package/Build/Workers/{chunk-QCMRUVVF.js → chunk-YZWA5B4R.js} +15 -13
  58. package/Build/Workers/{chunk-U7CX3HHE.js → chunk-Z6DFT4D3.js} +15 -11
  59. package/Build/Workers/combineGeometry.js +24 -21
  60. package/Build/Workers/createBoxGeometry.js +18 -15
  61. package/Build/Workers/createBoxOutlineGeometry.js +16 -13
  62. package/Build/Workers/createCircleGeometry.js +28 -24
  63. package/Build/Workers/createCircleOutlineGeometry.js +21 -17
  64. package/Build/Workers/createCoplanarPolygonGeometry.js +35 -31
  65. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +33 -29
  66. package/Build/Workers/createCorridorGeometry.js +32 -28
  67. package/Build/Workers/createCorridorOutlineGeometry.js +30 -26
  68. package/Build/Workers/createCylinderGeometry.js +20 -17
  69. package/Build/Workers/createCylinderOutlineGeometry.js +20 -16
  70. package/Build/Workers/createEllipseGeometry.js +28 -24
  71. package/Build/Workers/createEllipseOutlineGeometry.js +21 -17
  72. package/Build/Workers/createEllipsoidGeometry.js +19 -16
  73. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -15
  74. package/Build/Workers/createFrustumGeometry.js +18 -15
  75. package/Build/Workers/createFrustumOutlineGeometry.js +18 -15
  76. package/Build/Workers/createGeometry.js +25 -21
  77. package/Build/Workers/createGroundPolylineGeometry.js +25 -21
  78. package/Build/Workers/createPlaneGeometry.js +16 -13
  79. package/Build/Workers/createPlaneOutlineGeometry.js +15 -12
  80. package/Build/Workers/createPolygonGeometry.js +35 -31
  81. package/Build/Workers/createPolygonOutlineGeometry.js +32 -28
  82. package/Build/Workers/createPolylineGeometry.js +27 -23
  83. package/Build/Workers/createPolylineVolumeGeometry.js +33 -29
  84. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +29 -25
  85. package/Build/Workers/createRectangleGeometry.js +30 -26
  86. package/Build/Workers/createRectangleOutlineGeometry.js +23 -19
  87. package/Build/Workers/createSimplePolylineGeometry.js +25 -21
  88. package/Build/Workers/createSphereGeometry.js +19 -16
  89. package/Build/Workers/createSphereOutlineGeometry.js +18 -15
  90. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  91. package/Build/Workers/createVectorTileClampedPolylines.js +16 -13
  92. package/Build/Workers/createVectorTileGeometries.js +24 -21
  93. package/Build/Workers/createVectorTilePoints.js +15 -12
  94. package/Build/Workers/createVectorTilePolygons.js +24 -20
  95. package/Build/Workers/createVectorTilePolylines.js +16 -13
  96. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -22
  97. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +26 -21
  98. package/Build/Workers/createVerticesFromHeightmap.js +26 -21
  99. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +24 -19
  100. package/Build/Workers/createWallGeometry.js +26 -22
  101. package/Build/Workers/createWallOutlineGeometry.js +25 -21
  102. package/Build/Workers/decodeDraco.js +10 -10
  103. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  104. package/Build/Workers/decodeI3S.js +13 -11
  105. package/Build/Workers/gaussianSplatSorter.js +4 -4
  106. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  107. package/Build/Workers/incrementallyBuildTerrainPicker.js +121 -0
  108. package/Build/Workers/transcodeKTX2.js +6 -6
  109. package/Build/Workers/transferTypedArrayTest.js +1 -1
  110. package/Build/Workers/upsampleQuantizedTerrainMesh.js +24 -20
  111. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -22
  112. package/Source/Core/AxisAlignedBoundingBox.js +36 -0
  113. package/Source/Core/Cesium3DTilesTerrainData.js +2 -0
  114. package/Source/Core/Cesium3DTilesTerrainGeometryProcessor.js +2 -0
  115. package/Source/Core/GoogleEarthEnterpriseTerrainData.js +1 -0
  116. package/Source/Core/HeightmapTerrainData.js +2 -0
  117. package/Source/Core/IntersectionTests.js +80 -0
  118. package/Source/Core/Ion.js +1 -1
  119. package/Source/Core/QuantizedMeshTerrainData.js +1 -0
  120. package/Source/Core/TerrainMesh.js +207 -0
  121. package/Source/Core/TerrainPicker.js +607 -0
  122. package/Source/Core/TexturePacker.js +27 -12
  123. package/Source/Core/Transforms.js +28 -19
  124. package/Source/DataSources/BillboardGraphics.js +1 -1
  125. package/Source/DataSources/BillboardVisualizer.js +7 -4
  126. package/Source/Renderer/Buffer.js +32 -0
  127. package/Source/Renderer/BufferUsage.js +3 -1
  128. package/Source/Renderer/Context.js +85 -7
  129. package/Source/Renderer/Sync.js +104 -0
  130. package/Source/Renderer/TextureAtlas.js +67 -27
  131. package/Source/Scene/ArcGisMapService.js +1 -1
  132. package/Source/Scene/Azure2DImageryProvider.js +96 -12
  133. package/Source/Scene/Billboard.js +75 -28
  134. package/Source/Scene/BillboardCollection.js +7 -2
  135. package/Source/Scene/BillboardTexture.js +56 -7
  136. package/Source/Scene/Globe.js +3 -1
  137. package/Source/Scene/GlobeSurfaceTile.js +18 -66
  138. package/Source/Scene/GlobeSurfaceTileProvider.js +11 -0
  139. package/Source/Scene/Google2DImageryProvider.js +10 -15
  140. package/Source/Scene/PickFramebuffer.js +124 -36
  141. package/Source/Scene/Picking.js +99 -17
  142. package/Source/Scene/Scene.js +36 -4
  143. package/Source/Scene/TerrainFillMesh.js +1 -0
  144. package/Source/Shaders/BillboardCollectionFS.glsl +22 -9
  145. package/Source/Shaders/BillboardCollectionFS.js +22 -9
  146. package/Source/ThirdParty/Workers/zip-web-worker.js +1 -1
  147. package/Source/ThirdParty/zip-module.wasm +0 -0
  148. package/Source/Workers/incrementallyBuildTerrainPicker.js +108 -0
  149. package/index.d.ts +207 -4
  150. package/index.js +28 -26
  151. package/package.json +2 -2
@@ -1,3 +1,14 @@
1
+ import SceneMode from "../Scene/SceneMode.js";
2
+ import Cartesian3 from "./Cartesian3.js";
3
+ import Cartographic from "./Cartographic.js";
4
+ import defined from "./defined.js";
5
+ import Ellipsoid from "./Ellipsoid.js";
6
+ import Matrix4 from "./Matrix4.js";
7
+ import OrientedBoundingBox from "./OrientedBoundingBox.js";
8
+ import TerrainPicker from "./TerrainPicker.js";
9
+ import Transforms from "./Transforms.js";
10
+ import VerticalExaggeration from "./VerticalExaggeration.js";
11
+
1
12
  /**
2
13
  * A mesh plus related metadata for a single tile of terrain. Instances of this type are
3
14
  * usually created from raw {@link TerrainData}.
@@ -15,6 +26,7 @@
15
26
  * @param {number} vertexCountWithoutSkirts The vertex count of the mesh not including skirts.
16
27
  * @param {number} minimumHeight The lowest height in the tile, in meters above the ellipsoid.
17
28
  * @param {number} maximumHeight The highest height in the tile, in meters above the ellipsoid.
29
+ * @param {Rectangle} rectangle The rectangle, in radians, covered by this tile.
18
30
  * @param {BoundingSphere} boundingSphere3D A bounding sphere that completely contains the tile.
19
31
  * @param {Cartesian3} occludeePointInScaledSpace The occludee point of the tile, represented in ellipsoid-
20
32
  * scaled space, and used for horizon culling. If this point is below the horizon,
@@ -37,6 +49,7 @@ function TerrainMesh(
37
49
  vertexCountWithoutSkirts,
38
50
  minimumHeight,
39
51
  maximumHeight,
52
+ rectangle,
40
53
  boundingSphere3D,
41
54
  occludeePointInScaledSpace,
42
55
  vertexStride,
@@ -101,6 +114,12 @@ function TerrainMesh(
101
114
  */
102
115
  this.maximumHeight = maximumHeight;
103
116
 
117
+ /**
118
+ * The rectangle, in radians, covered by this tile.
119
+ * @type {Rectangle}
120
+ */
121
+ this.rectangle = rectangle;
122
+
104
123
  /**
105
124
  * A bounding sphere that completely contains the tile.
106
125
  * @type {BoundingSphere}
@@ -150,5 +169,193 @@ function TerrainMesh(
150
169
  * @type {number[]|Uint8Array|Uint16Array|Uint32Array}
151
170
  */
152
171
  this.northIndicesWestToEast = northIndicesWestToEast;
172
+
173
+ /**
174
+ * The transform from model to world coordinates based on the terrain mesh's oriented bounding box.
175
+ * In 3D mode, this is computed from the oriented bounding box. In 2D and Columbus View modes,
176
+ * this is computed from the tile's rectangle's projected coordinates.
177
+ * @type {Matrix4}
178
+ */
179
+ this._transform = new Matrix4();
180
+
181
+ /**
182
+ * True if the transform needs to be recomputed (due to changes in exaggeration or scene mode).
183
+ * @type {boolean}
184
+ */
185
+ this._recomputeTransform = true;
186
+
187
+ /**
188
+ * The terrain picker for this mesh, used for ray intersection tests.
189
+ * @type {TerrainPicker}
190
+ */
191
+ this._terrainPicker = new TerrainPicker(vertices, indices, encoding);
153
192
  }
193
+
194
+ /**
195
+ * Get the terrain tile's model-to-world transform matrix for the given scene mode and projection.
196
+ * @param {SceneMode} mode The scene mode (3D, 2D, or Columbus View).
197
+ * @param {MapProjection} projection The map projection.
198
+ * @returns {Matrix4} The transform matrix.
199
+ * @private
200
+ */
201
+ TerrainMesh.prototype.getTransform = function (mode, projection) {
202
+ if (!this._recomputeTransform) {
203
+ return this._transform;
204
+ }
205
+ this._recomputeTransform = false;
206
+
207
+ if (!defined(mode) || mode === SceneMode.SCENE3D) {
208
+ return computeTransform(this, this._transform);
209
+ }
210
+
211
+ return computeTransform2D(this, projection, this._transform);
212
+ };
213
+
214
+ function computeTransform(mesh, result) {
215
+ const exaggeration = mesh.encoding.exaggeration;
216
+ const exaggerationRelativeHeight = mesh.encoding.exaggerationRelativeHeight;
217
+
218
+ const exaggeratedMinHeight = VerticalExaggeration.getHeight(
219
+ mesh.minimumHeight,
220
+ exaggeration,
221
+ exaggerationRelativeHeight,
222
+ );
223
+
224
+ const exaggeratedMaxHeight = VerticalExaggeration.getHeight(
225
+ mesh.maximumHeight,
226
+ exaggeration,
227
+ exaggerationRelativeHeight,
228
+ );
229
+
230
+ const obb = OrientedBoundingBox.fromRectangle(
231
+ mesh.rectangle,
232
+ exaggeratedMinHeight,
233
+ exaggeratedMaxHeight,
234
+ Ellipsoid.default,
235
+ mesh.orientedBoundingBox,
236
+ );
237
+
238
+ return OrientedBoundingBox.computeTransformation(obb, result);
239
+ }
240
+
241
+ const scratchSWCartesian = new Cartesian3();
242
+ const scratchNECartesian = new Cartesian3();
243
+ const scratchSWCartographic = new Cartographic();
244
+ const scratchNECartographic = new Cartographic();
245
+ const scratchScale2D = new Cartesian3();
246
+ const scratchCenter2D = new Cartesian3();
247
+
248
+ /**
249
+ * Get the terrain tile's model-to-world transform matrix for 2D or Columbus View modes.
250
+ * Assumes tiles in 2D are axis-aligned and still rectangular. (This is true for Web Mercator and Geographic projections.)
251
+ * @param {TerrainMesh} mesh The terrain mesh.
252
+ * @param {MapProjection} projection The map projection.
253
+ * @param {Matrix4} result The object in which to store the result.
254
+ * @returns {Matrix4} The transform matrix.
255
+ * @private
256
+ */
257
+ function computeTransform2D(mesh, projection, result) {
258
+ const exaggeration = mesh.encoding.exaggeration;
259
+ const exaggerationRelativeHeight = mesh.encoding.exaggerationRelativeHeight;
260
+
261
+ const exaggeratedMinHeight = VerticalExaggeration.getHeight(
262
+ mesh.minimumHeight,
263
+ exaggeration,
264
+ exaggerationRelativeHeight,
265
+ );
266
+
267
+ const exaggeratedMaxHeight = VerticalExaggeration.getHeight(
268
+ mesh.maximumHeight,
269
+ exaggeration,
270
+ exaggerationRelativeHeight,
271
+ );
272
+
273
+ const southwest = projection.project(
274
+ Cartographic.fromRadians(
275
+ mesh.rectangle.west,
276
+ mesh.rectangle.south,
277
+ 0,
278
+ scratchSWCartographic,
279
+ ),
280
+ scratchSWCartesian,
281
+ );
282
+
283
+ const northeast = projection.project(
284
+ Cartographic.fromRadians(
285
+ mesh.rectangle.east,
286
+ mesh.rectangle.north,
287
+ 0,
288
+ scratchNECartographic,
289
+ ),
290
+ scratchNECartesian,
291
+ );
292
+
293
+ const heightRange = exaggeratedMaxHeight - exaggeratedMinHeight;
294
+ const scale = Cartesian3.fromElements(
295
+ northeast.x - southwest.x,
296
+ northeast.y - southwest.y,
297
+ heightRange > 0 ? heightRange : 1.0, // Avoid zero scale
298
+ scratchScale2D,
299
+ );
300
+
301
+ const center = Cartesian3.fromElements(
302
+ southwest.x + scale.x * 0.5,
303
+ southwest.y + scale.y * 0.5,
304
+ exaggeratedMinHeight + scale.z * 0.5,
305
+ scratchCenter2D,
306
+ );
307
+
308
+ Matrix4.fromTranslation(center, result);
309
+ Matrix4.setScale(result, scale, result);
310
+ Matrix4.multiply(Transforms.SWIZZLE_3D_TO_2D_MATRIX, result, result);
311
+
312
+ return result;
313
+ }
314
+
315
+ /**
316
+ * Gives the point on this terrain tile where the given ray intersects
317
+ * @param {Ray} ray The ray to test for intersection.
318
+ * @param {boolean} cullBackFaces Whether to consider back-facing triangles as intersections.
319
+ * @param {SceneMode} mode The scene mode (3D, 2D, or Columbus View).
320
+ * @param {MapProjection} projection The map projection.
321
+ * @returns {Cartesian3} The point on the mesh where the ray intersects, or undefined if there is no intersection.
322
+ * @private
323
+ */
324
+ TerrainMesh.prototype.pick = function (ray, cullBackFaces, mode, projection) {
325
+ return this._terrainPicker.rayIntersect(
326
+ ray,
327
+ this.getTransform(mode, projection),
328
+ cullBackFaces,
329
+ mode,
330
+ projection,
331
+ );
332
+ };
333
+
334
+ /**
335
+ * Updates the terrain mesh to account for changes in vertical exaggeration.
336
+ * @param {Number} exaggeration A scalar used to exaggerate terrain.
337
+ * @param {Number} exaggerationRelativeHeight The relative height from which terrain is exaggerated.
338
+ * @private
339
+ */
340
+ TerrainMesh.prototype.updateExaggeration = function (
341
+ exaggeration,
342
+ exaggerationRelativeHeight,
343
+ ) {
344
+ // The encoding stored on the TerrainMesh references the updated exaggeration values already. This is just used
345
+ // to trigger a rebuild on the terrain picker.
346
+ this._terrainPicker._vertices = this.vertices;
347
+ this._terrainPicker.needsRebuild = true;
348
+ this._recomputeTransform = true;
349
+ };
350
+
351
+ /**
352
+ * Updates the terrain mesh to account for changes in scene mode.
353
+ * @param {SceneMode} mode The scene mode (3D, 2D, or Columbus View).
354
+ * @private
355
+ */
356
+ TerrainMesh.prototype.updateSceneMode = function (mode) {
357
+ this._terrainPicker.needsRebuild = true;
358
+ this._recomputeTransform = true;
359
+ };
360
+
154
361
  export default TerrainMesh;