deeptwins-cesium-engine 0.0.3 → 0.0.4

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 (116) hide show
  1. package/Build/Workers/chunk-25U3LB43.js +139 -0
  2. package/Build/Workers/chunk-2GSMCVKA.js +837 -0
  3. package/Build/Workers/chunk-3G3JCTFQ.js +101 -0
  4. package/Build/Workers/chunk-3GRIO7U2.js +162 -0
  5. package/Build/Workers/chunk-3ZQ33WD3.js +455 -0
  6. package/Build/Workers/chunk-4U7LLSJ4.js +288 -0
  7. package/Build/Workers/chunk-4ZMC542T.js +55 -0
  8. package/Build/Workers/chunk-57TENMAK.js +37 -0
  9. package/Build/Workers/chunk-5JCUBAVN.js +387 -0
  10. package/Build/Workers/chunk-5MAQRQUK.js +102 -0
  11. package/Build/Workers/chunk-5XRGC6C7.js +299 -0
  12. package/Build/Workers/chunk-63UAUZT6.js +414 -0
  13. package/Build/Workers/chunk-6BUOGRYV.js +2058 -0
  14. package/Build/Workers/chunk-7D5ZXLGY.js +163 -0
  15. package/Build/Workers/chunk-7N66TCUJ.js +1800 -0
  16. package/Build/Workers/chunk-AG6ARNCB.js +682 -0
  17. package/Build/Workers/chunk-ARXSS5JC.js +788 -0
  18. package/Build/Workers/chunk-BDVACEHF.js +778 -0
  19. package/Build/Workers/chunk-BU67FVEG.js +97 -0
  20. package/Build/Workers/chunk-BYC4YR4M.js +352 -0
  21. package/Build/Workers/chunk-CH66JW7J.js +629 -0
  22. package/Build/Workers/chunk-CV2CR5WA.js +114 -0
  23. package/Build/Workers/chunk-DGMXFRAL.js +1443 -0
  24. package/Build/Workers/chunk-EDP33VH5.js +1054 -0
  25. package/Build/Workers/chunk-F7AOI3UD.js +73 -0
  26. package/Build/Workers/chunk-FKKSB7ZT.js +8366 -0
  27. package/Build/Workers/chunk-FTK6K2HA.js +1483 -0
  28. package/Build/Workers/chunk-IUPJ4QGV.js +476 -0
  29. package/Build/Workers/chunk-K7Z6W3PJ.js +368 -0
  30. package/Build/Workers/chunk-KBCQ5JGP.js +57 -0
  31. package/Build/Workers/chunk-KKTCNH5B.js +398 -0
  32. package/Build/Workers/chunk-LCSOUDEK.js +58 -0
  33. package/Build/Workers/chunk-LE5B7M4M.js +642 -0
  34. package/Build/Workers/chunk-LPPTJ7CE.js +511 -0
  35. package/Build/Workers/chunk-M3CFFEB7.js +280 -0
  36. package/Build/Workers/chunk-NN52QO5J.js +497 -0
  37. package/Build/Workers/chunk-NO3BDHBF.js +241 -0
  38. package/Build/Workers/chunk-O2H3UW6F.js +256 -0
  39. package/Build/Workers/chunk-OLJ7MBC7.js +439 -0
  40. package/Build/Workers/chunk-OZMVAGFQ.js +2719 -0
  41. package/Build/Workers/chunk-P3S5BWX6.js +219 -0
  42. package/Build/Workers/chunk-PLQPDE4E.js +171 -0
  43. package/Build/Workers/chunk-PYMMZCF6.js +3514 -0
  44. package/Build/Workers/chunk-QIK67M72.js +692 -0
  45. package/Build/Workers/chunk-RDQU66WA.js +124 -0
  46. package/Build/Workers/chunk-S6YC56IM.js +940 -0
  47. package/Build/Workers/chunk-S7CL5IXE.js +138 -0
  48. package/Build/Workers/chunk-SCVFHATG.js +1317 -0
  49. package/Build/Workers/chunk-V3IFABPY.js +44 -0
  50. package/Build/Workers/chunk-VKRSYA3C.js +1067 -0
  51. package/Build/Workers/chunk-VXIA6U3E.js +75 -0
  52. package/Build/Workers/chunk-WKTTAMO3.js +305 -0
  53. package/Build/Workers/chunk-WMMHNRGJ.js +198 -0
  54. package/Build/Workers/chunk-WY6ZUQRU.js +55 -0
  55. package/Build/Workers/chunk-X33W4QLH.js +958 -0
  56. package/Build/Workers/chunk-ZB5XJVWP.js +1460 -0
  57. package/Build/Workers/chunk-ZNQU6MNK.js +352 -0
  58. package/Build/Workers/combineGeometry.js +24 -24
  59. package/Build/Workers/createBoxGeometry.js +18 -18
  60. package/Build/Workers/createBoxOutlineGeometry.js +16 -16
  61. package/Build/Workers/createCircleGeometry.js +26 -26
  62. package/Build/Workers/createCircleOutlineGeometry.js +19 -19
  63. package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
  64. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
  65. package/Build/Workers/createCorridorGeometry.js +29 -29
  66. package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
  67. package/Build/Workers/createCylinderGeometry.js +20 -20
  68. package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
  69. package/Build/Workers/createEllipseGeometry.js +26 -26
  70. package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
  71. package/Build/Workers/createEllipsoidGeometry.js +19 -19
  72. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
  73. package/Build/Workers/createFrustumGeometry.js +18 -18
  74. package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
  75. package/Build/Workers/createGeometry.js +24 -24
  76. package/Build/Workers/createGroundPolylineGeometry.js +22 -22
  77. package/Build/Workers/createPlaneGeometry.js +16 -16
  78. package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
  79. package/Build/Workers/createPolygonGeometry.js +32 -32
  80. package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
  81. package/Build/Workers/createPolylineGeometry.js +25 -25
  82. package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
  83. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
  84. package/Build/Workers/createRectangleGeometry.js +27 -27
  85. package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
  86. package/Build/Workers/createSimplePolylineGeometry.js +23 -23
  87. package/Build/Workers/createSphereGeometry.js +19 -19
  88. package/Build/Workers/createSphereOutlineGeometry.js +18 -18
  89. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  90. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  91. package/Build/Workers/createVectorTileGeometries.js +24 -24
  92. package/Build/Workers/createVectorTilePoints.js +13 -13
  93. package/Build/Workers/createVectorTilePolygons.js +22 -22
  94. package/Build/Workers/createVectorTilePolylines.js +14 -14
  95. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
  96. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
  97. package/Build/Workers/createVerticesFromHeightmap.js +22 -22
  98. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
  99. package/Build/Workers/createWallGeometry.js +24 -24
  100. package/Build/Workers/createWallOutlineGeometry.js +23 -23
  101. package/Build/Workers/decodeDraco.js +10 -10
  102. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  103. package/Build/Workers/decodeI3S.js +10 -10
  104. package/Build/Workers/gaussianSplatSorter.js +4 -4
  105. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  106. package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
  107. package/Build/Workers/transcodeKTX2.js +6 -6
  108. package/Build/Workers/transferTypedArrayTest.js +1 -1
  109. package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
  110. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
  111. package/README.md +1 -1
  112. package/Source/Scene/DerivedCommand.js +1 -1
  113. package/Source/Scene/VoxelContent.js +1 -1
  114. package/index.d.ts +1 -1
  115. package/index.js +9 -9
  116. package/package.json +7 -11
@@ -0,0 +1,788 @@
1
+ /**
2
+ * @license
3
+ * Cesium - https://github.com/CesiumGS/cesium
4
+ * Version 0.0.29
5
+ *
6
+ * Copyright 2011-2022 Cesium Contributors
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ *
20
+ * Columbus View (Pat. Pend.)
21
+ *
22
+ * Portions licensed separately.
23
+ * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
24
+ */
25
+
26
+ import {
27
+ AttributeCompression_default
28
+ } from "./chunk-OLJ7MBC7.js";
29
+ import {
30
+ BoundingSphere_default
31
+ } from "./chunk-S6YC56IM.js";
32
+ import {
33
+ Rectangle_default
34
+ } from "./chunk-FKKSB7ZT.js";
35
+ import {
36
+ Matrix4_default
37
+ } from "./chunk-6BUOGRYV.js";
38
+ import {
39
+ ComponentDatatype_default
40
+ } from "./chunk-O2H3UW6F.js";
41
+ import {
42
+ Cartesian2_default,
43
+ Cartographic_default,
44
+ Ellipsoid_default
45
+ } from "./chunk-ZB5XJVWP.js";
46
+ import {
47
+ Cartesian3_default
48
+ } from "./chunk-DGMXFRAL.js";
49
+ import {
50
+ Math_default
51
+ } from "./chunk-NN52QO5J.js";
52
+ import {
53
+ Check_default,
54
+ DeveloperError_default
55
+ } from "./chunk-7D5ZXLGY.js";
56
+ import {
57
+ defined_default
58
+ } from "./chunk-VXIA6U3E.js";
59
+
60
+ // packages/engine/Source/Core/EllipsoidalOccluder.js
61
+ function EllipsoidalOccluder(ellipsoid, cameraPosition) {
62
+ Check_default.typeOf.object("ellipsoid", ellipsoid);
63
+ this._ellipsoid = ellipsoid;
64
+ this._cameraPosition = new Cartesian3_default();
65
+ this._cameraPositionInScaledSpace = new Cartesian3_default();
66
+ this._distanceToLimbInScaledSpaceSquared = 0;
67
+ if (defined_default(cameraPosition)) {
68
+ this.cameraPosition = cameraPosition;
69
+ }
70
+ }
71
+ Object.defineProperties(EllipsoidalOccluder.prototype, {
72
+ /**
73
+ * Gets the occluding ellipsoid.
74
+ * @memberof EllipsoidalOccluder.prototype
75
+ * @type {Ellipsoid}
76
+ */
77
+ ellipsoid: {
78
+ get: function() {
79
+ return this._ellipsoid;
80
+ }
81
+ },
82
+ /**
83
+ * Gets or sets the position of the camera.
84
+ * @memberof EllipsoidalOccluder.prototype
85
+ * @type {Cartesian3}
86
+ */
87
+ cameraPosition: {
88
+ get: function() {
89
+ return this._cameraPosition;
90
+ },
91
+ set: function(cameraPosition) {
92
+ const ellipsoid = this._ellipsoid;
93
+ const cv = ellipsoid.transformPositionToScaledSpace(
94
+ cameraPosition,
95
+ this._cameraPositionInScaledSpace
96
+ );
97
+ const vhMagnitudeSquared = Cartesian3_default.magnitudeSquared(cv) - 1;
98
+ Cartesian3_default.clone(cameraPosition, this._cameraPosition);
99
+ this._cameraPositionInScaledSpace = cv;
100
+ this._distanceToLimbInScaledSpaceSquared = vhMagnitudeSquared;
101
+ }
102
+ }
103
+ });
104
+ var scratchCartesian = new Cartesian3_default();
105
+ EllipsoidalOccluder.prototype.isPointVisible = function(occludee) {
106
+ const ellipsoid = this._ellipsoid;
107
+ const occludeeScaledSpacePosition = ellipsoid.transformPositionToScaledSpace(
108
+ occludee,
109
+ scratchCartesian
110
+ );
111
+ return isScaledSpacePointVisible(
112
+ occludeeScaledSpacePosition,
113
+ this._cameraPositionInScaledSpace,
114
+ this._distanceToLimbInScaledSpaceSquared
115
+ );
116
+ };
117
+ EllipsoidalOccluder.prototype.isScaledSpacePointVisible = function(occludeeScaledSpacePosition) {
118
+ return isScaledSpacePointVisible(
119
+ occludeeScaledSpacePosition,
120
+ this._cameraPositionInScaledSpace,
121
+ this._distanceToLimbInScaledSpaceSquared
122
+ );
123
+ };
124
+ var scratchCameraPositionInScaledSpaceShrunk = new Cartesian3_default();
125
+ EllipsoidalOccluder.prototype.isScaledSpacePointVisiblePossiblyUnderEllipsoid = function(occludeeScaledSpacePosition, minimumHeight) {
126
+ const ellipsoid = this._ellipsoid;
127
+ let vhMagnitudeSquared;
128
+ let cv;
129
+ if (defined_default(minimumHeight) && minimumHeight < 0 && ellipsoid.minimumRadius > -minimumHeight) {
130
+ cv = scratchCameraPositionInScaledSpaceShrunk;
131
+ cv.x = this._cameraPosition.x / (ellipsoid.radii.x + minimumHeight);
132
+ cv.y = this._cameraPosition.y / (ellipsoid.radii.y + minimumHeight);
133
+ cv.z = this._cameraPosition.z / (ellipsoid.radii.z + minimumHeight);
134
+ vhMagnitudeSquared = cv.x * cv.x + cv.y * cv.y + cv.z * cv.z - 1;
135
+ } else {
136
+ cv = this._cameraPositionInScaledSpace;
137
+ vhMagnitudeSquared = this._distanceToLimbInScaledSpaceSquared;
138
+ }
139
+ return isScaledSpacePointVisible(
140
+ occludeeScaledSpacePosition,
141
+ cv,
142
+ vhMagnitudeSquared
143
+ );
144
+ };
145
+ EllipsoidalOccluder.prototype.computeHorizonCullingPoint = function(directionToPoint, positions, result) {
146
+ return computeHorizonCullingPointFromPositions(
147
+ this._ellipsoid,
148
+ directionToPoint,
149
+ positions,
150
+ result
151
+ );
152
+ };
153
+ var scratchEllipsoidShrunk = Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE);
154
+ EllipsoidalOccluder.prototype.computeHorizonCullingPointPossiblyUnderEllipsoid = function(directionToPoint, positions, minimumHeight, result) {
155
+ const possiblyShrunkEllipsoid = getPossiblyShrunkEllipsoid(
156
+ this._ellipsoid,
157
+ minimumHeight,
158
+ scratchEllipsoidShrunk
159
+ );
160
+ return computeHorizonCullingPointFromPositions(
161
+ possiblyShrunkEllipsoid,
162
+ directionToPoint,
163
+ positions,
164
+ result
165
+ );
166
+ };
167
+ EllipsoidalOccluder.prototype.computeHorizonCullingPointFromVertices = function(directionToPoint, vertices, stride, center, result) {
168
+ return computeHorizonCullingPointFromVertices(
169
+ this._ellipsoid,
170
+ directionToPoint,
171
+ vertices,
172
+ stride,
173
+ center,
174
+ result
175
+ );
176
+ };
177
+ EllipsoidalOccluder.prototype.computeHorizonCullingPointFromVerticesPossiblyUnderEllipsoid = function(directionToPoint, vertices, stride, center, minimumHeight, result) {
178
+ const possiblyShrunkEllipsoid = getPossiblyShrunkEllipsoid(
179
+ this._ellipsoid,
180
+ minimumHeight,
181
+ scratchEllipsoidShrunk
182
+ );
183
+ return computeHorizonCullingPointFromVertices(
184
+ possiblyShrunkEllipsoid,
185
+ directionToPoint,
186
+ vertices,
187
+ stride,
188
+ center,
189
+ result
190
+ );
191
+ };
192
+ var subsampleScratch = [];
193
+ EllipsoidalOccluder.prototype.computeHorizonCullingPointFromRectangle = function(rectangle, ellipsoid, result) {
194
+ Check_default.typeOf.object("rectangle", rectangle);
195
+ const positions = Rectangle_default.subsample(
196
+ rectangle,
197
+ ellipsoid,
198
+ 0,
199
+ subsampleScratch
200
+ );
201
+ const bs = BoundingSphere_default.fromPoints(positions);
202
+ if (Cartesian3_default.magnitude(bs.center) < 0.1 * ellipsoid.minimumRadius) {
203
+ return void 0;
204
+ }
205
+ return this.computeHorizonCullingPoint(bs.center, positions, result);
206
+ };
207
+ var scratchEllipsoidShrunkRadii = new Cartesian3_default();
208
+ function getPossiblyShrunkEllipsoid(ellipsoid, minimumHeight, result) {
209
+ if (defined_default(minimumHeight) && minimumHeight < 0 && ellipsoid.minimumRadius > -minimumHeight) {
210
+ const ellipsoidShrunkRadii = Cartesian3_default.fromElements(
211
+ ellipsoid.radii.x + minimumHeight,
212
+ ellipsoid.radii.y + minimumHeight,
213
+ ellipsoid.radii.z + minimumHeight,
214
+ scratchEllipsoidShrunkRadii
215
+ );
216
+ ellipsoid = Ellipsoid_default.fromCartesian3(ellipsoidShrunkRadii, result);
217
+ }
218
+ return ellipsoid;
219
+ }
220
+ function computeHorizonCullingPointFromPositions(ellipsoid, directionToPoint, positions, result) {
221
+ Check_default.typeOf.object("directionToPoint", directionToPoint);
222
+ Check_default.defined("positions", positions);
223
+ if (!defined_default(result)) {
224
+ result = new Cartesian3_default();
225
+ }
226
+ const scaledSpaceDirectionToPoint = computeScaledSpaceDirectionToPoint(
227
+ ellipsoid,
228
+ directionToPoint
229
+ );
230
+ let resultMagnitude = 0;
231
+ for (let i = 0, len = positions.length; i < len; ++i) {
232
+ const position = positions[i];
233
+ const candidateMagnitude = computeMagnitude(
234
+ ellipsoid,
235
+ position,
236
+ scaledSpaceDirectionToPoint
237
+ );
238
+ if (candidateMagnitude < 0) {
239
+ return void 0;
240
+ }
241
+ resultMagnitude = Math.max(resultMagnitude, candidateMagnitude);
242
+ }
243
+ return magnitudeToPoint(scaledSpaceDirectionToPoint, resultMagnitude, result);
244
+ }
245
+ var positionScratch = new Cartesian3_default();
246
+ function computeHorizonCullingPointFromVertices(ellipsoid, directionToPoint, vertices, stride, center, result) {
247
+ Check_default.typeOf.object("directionToPoint", directionToPoint);
248
+ Check_default.defined("vertices", vertices);
249
+ Check_default.typeOf.number("stride", stride);
250
+ if (!defined_default(result)) {
251
+ result = new Cartesian3_default();
252
+ }
253
+ stride = stride ?? 3;
254
+ center = center ?? Cartesian3_default.ZERO;
255
+ const scaledSpaceDirectionToPoint = computeScaledSpaceDirectionToPoint(
256
+ ellipsoid,
257
+ directionToPoint
258
+ );
259
+ let resultMagnitude = 0;
260
+ for (let i = 0, len = vertices.length; i < len; i += stride) {
261
+ positionScratch.x = vertices[i] + center.x;
262
+ positionScratch.y = vertices[i + 1] + center.y;
263
+ positionScratch.z = vertices[i + 2] + center.z;
264
+ const candidateMagnitude = computeMagnitude(
265
+ ellipsoid,
266
+ positionScratch,
267
+ scaledSpaceDirectionToPoint
268
+ );
269
+ if (candidateMagnitude < 0) {
270
+ return void 0;
271
+ }
272
+ resultMagnitude = Math.max(resultMagnitude, candidateMagnitude);
273
+ }
274
+ return magnitudeToPoint(scaledSpaceDirectionToPoint, resultMagnitude, result);
275
+ }
276
+ function isScaledSpacePointVisible(occludeeScaledSpacePosition, cameraPositionInScaledSpace, distanceToLimbInScaledSpaceSquared) {
277
+ const cv = cameraPositionInScaledSpace;
278
+ const vhMagnitudeSquared = distanceToLimbInScaledSpaceSquared;
279
+ const vt = Cartesian3_default.subtract(
280
+ occludeeScaledSpacePosition,
281
+ cv,
282
+ scratchCartesian
283
+ );
284
+ const vtDotVc = -Cartesian3_default.dot(vt, cv);
285
+ const isOccluded = vhMagnitudeSquared < 0 ? vtDotVc > 0 : vtDotVc > vhMagnitudeSquared && vtDotVc * vtDotVc / Cartesian3_default.magnitudeSquared(vt) > vhMagnitudeSquared;
286
+ return !isOccluded;
287
+ }
288
+ var scaledSpaceScratch = new Cartesian3_default();
289
+ var directionScratch = new Cartesian3_default();
290
+ function computeMagnitude(ellipsoid, position, scaledSpaceDirectionToPoint) {
291
+ const scaledSpacePosition = ellipsoid.transformPositionToScaledSpace(
292
+ position,
293
+ scaledSpaceScratch
294
+ );
295
+ let magnitudeSquared = Cartesian3_default.magnitudeSquared(scaledSpacePosition);
296
+ let magnitude = Math.sqrt(magnitudeSquared);
297
+ const direction = Cartesian3_default.divideByScalar(
298
+ scaledSpacePosition,
299
+ magnitude,
300
+ directionScratch
301
+ );
302
+ magnitudeSquared = Math.max(1, magnitudeSquared);
303
+ magnitude = Math.max(1, magnitude);
304
+ const cosAlpha = Cartesian3_default.dot(direction, scaledSpaceDirectionToPoint);
305
+ const sinAlpha = Cartesian3_default.magnitude(
306
+ Cartesian3_default.cross(direction, scaledSpaceDirectionToPoint, direction)
307
+ );
308
+ const cosBeta = 1 / magnitude;
309
+ const sinBeta = Math.sqrt(magnitudeSquared - 1) * cosBeta;
310
+ return 1 / (cosAlpha * cosBeta - sinAlpha * sinBeta);
311
+ }
312
+ function magnitudeToPoint(scaledSpaceDirectionToPoint, resultMagnitude, result) {
313
+ if (resultMagnitude <= 0 || resultMagnitude === 1 / 0 || resultMagnitude !== resultMagnitude) {
314
+ return void 0;
315
+ }
316
+ return Cartesian3_default.multiplyByScalar(
317
+ scaledSpaceDirectionToPoint,
318
+ resultMagnitude,
319
+ result
320
+ );
321
+ }
322
+ var directionToPointScratch = new Cartesian3_default();
323
+ function computeScaledSpaceDirectionToPoint(ellipsoid, directionToPoint) {
324
+ if (Cartesian3_default.equals(directionToPoint, Cartesian3_default.ZERO)) {
325
+ return directionToPoint;
326
+ }
327
+ ellipsoid.transformPositionToScaledSpace(
328
+ directionToPoint,
329
+ directionToPointScratch
330
+ );
331
+ return Cartesian3_default.normalize(directionToPointScratch, directionToPointScratch);
332
+ }
333
+ var EllipsoidalOccluder_default = EllipsoidalOccluder;
334
+
335
+ // packages/engine/Source/Core/VerticalExaggeration.js
336
+ var VerticalExaggeration = {};
337
+ VerticalExaggeration.getHeight = function(height, scale, relativeHeight) {
338
+ if (!Number.isFinite(scale)) {
339
+ throw new DeveloperError_default("scale must be a finite number.");
340
+ }
341
+ if (!Number.isFinite(relativeHeight)) {
342
+ throw new DeveloperError_default("relativeHeight must be a finite number.");
343
+ }
344
+ return (height - relativeHeight) * scale + relativeHeight;
345
+ };
346
+ var scratchCartographic = new Cartographic_default();
347
+ VerticalExaggeration.getPosition = function(position, ellipsoid, verticalExaggeration, verticalExaggerationRelativeHeight, result) {
348
+ const cartographic = ellipsoid.cartesianToCartographic(
349
+ position,
350
+ scratchCartographic
351
+ );
352
+ if (!defined_default(cartographic)) {
353
+ return Cartesian3_default.clone(position, result);
354
+ }
355
+ const newHeight = VerticalExaggeration.getHeight(
356
+ cartographic.height,
357
+ verticalExaggeration,
358
+ verticalExaggerationRelativeHeight
359
+ );
360
+ return Cartesian3_default.fromRadians(
361
+ cartographic.longitude,
362
+ cartographic.latitude,
363
+ newHeight,
364
+ ellipsoid,
365
+ result
366
+ );
367
+ };
368
+ var VerticalExaggeration_default = VerticalExaggeration;
369
+
370
+ // packages/engine/Source/Core/TerrainQuantization.js
371
+ var TerrainQuantization = {
372
+ /**
373
+ * The vertices are not compressed.
374
+ *
375
+ * @type {number}
376
+ * @constant
377
+ */
378
+ NONE: 0,
379
+ /**
380
+ * The vertices are compressed to 12 bits.
381
+ *
382
+ * @type {number}
383
+ * @constant
384
+ */
385
+ BITS12: 1
386
+ };
387
+ var TerrainQuantization_default = Object.freeze(TerrainQuantization);
388
+
389
+ // packages/engine/Source/Core/TerrainEncoding.js
390
+ var cartesian3Scratch = new Cartesian3_default();
391
+ var cartesian3DimScratch = new Cartesian3_default();
392
+ var cartesian2Scratch = new Cartesian2_default();
393
+ var matrix4Scratch = new Matrix4_default();
394
+ var matrix4Scratch2 = new Matrix4_default();
395
+ var SHIFT_LEFT_12 = Math.pow(2, 12);
396
+ function TerrainEncoding(center, axisAlignedBoundingBox, minimumHeight, maximumHeight, fromENU, hasVertexNormals, hasWebMercatorT, hasGeodeticSurfaceNormals, exaggeration, exaggerationRelativeHeight) {
397
+ let quantization = TerrainQuantization_default.NONE;
398
+ let toENU;
399
+ let matrix;
400
+ if (defined_default(axisAlignedBoundingBox) && defined_default(minimumHeight) && defined_default(maximumHeight) && defined_default(fromENU)) {
401
+ const minimum = axisAlignedBoundingBox.minimum;
402
+ const maximum = axisAlignedBoundingBox.maximum;
403
+ const dimensions = Cartesian3_default.subtract(
404
+ maximum,
405
+ minimum,
406
+ cartesian3DimScratch
407
+ );
408
+ const hDim = maximumHeight - minimumHeight;
409
+ const maxDim = Math.max(Cartesian3_default.maximumComponent(dimensions), hDim);
410
+ if (maxDim < SHIFT_LEFT_12 - 1) {
411
+ quantization = TerrainQuantization_default.BITS12;
412
+ } else {
413
+ quantization = TerrainQuantization_default.NONE;
414
+ }
415
+ let st = Matrix4_default.fromScale(dimensions, matrix4Scratch);
416
+ st = Matrix4_default.setTranslation(st, minimum, st);
417
+ let invSt = Matrix4_default.fromScale(
418
+ Cartesian3_default.fromElements(
419
+ 1 / dimensions.x,
420
+ 1 / dimensions.y,
421
+ 1 / dimensions.z,
422
+ cartesian3Scratch
423
+ ),
424
+ matrix4Scratch2
425
+ );
426
+ invSt = Matrix4_default.multiplyByTranslation(
427
+ invSt,
428
+ Cartesian3_default.negate(minimum, cartesian3Scratch),
429
+ invSt
430
+ );
431
+ matrix = Matrix4_default.clone(fromENU, new Matrix4_default());
432
+ let rtcOffset = Matrix4_default.getTranslation(fromENU, cartesian3Scratch);
433
+ rtcOffset = Cartesian3_default.subtract(rtcOffset, center, cartesian3Scratch);
434
+ matrix = Matrix4_default.setTranslation(matrix, rtcOffset, matrix);
435
+ matrix = Matrix4_default.multiply(matrix, st, matrix);
436
+ toENU = Matrix4_default.inverseTransformation(fromENU, new Matrix4_default());
437
+ toENU = Matrix4_default.multiply(invSt, toENU, toENU);
438
+ fromENU = Matrix4_default.multiply(fromENU, st, new Matrix4_default());
439
+ }
440
+ this.quantization = quantization;
441
+ this.minimumHeight = minimumHeight;
442
+ this.maximumHeight = maximumHeight;
443
+ this.center = Cartesian3_default.clone(center);
444
+ this.toScaledENU = toENU;
445
+ this.fromScaledENU = fromENU;
446
+ this.matrix = matrix;
447
+ this.hasVertexNormals = hasVertexNormals ?? false;
448
+ this.hasWebMercatorT = hasWebMercatorT ?? false;
449
+ this.hasGeodeticSurfaceNormals = hasGeodeticSurfaceNormals ?? false;
450
+ this.exaggeration = exaggeration ?? 1;
451
+ this.exaggerationRelativeHeight = exaggerationRelativeHeight ?? 0;
452
+ this.stride = 0;
453
+ this._offsetGeodeticSurfaceNormal = 0;
454
+ this._offsetVertexNormal = 0;
455
+ this._calculateStrideAndOffsets();
456
+ }
457
+ TerrainEncoding.prototype.encode = function(vertexBuffer, bufferIndex, position, uv, height, normalToPack, webMercatorT, geodeticSurfaceNormal) {
458
+ Check_default.typeOf.object("vertexBuffer", vertexBuffer);
459
+ Check_default.typeOf.number("bufferIndex", bufferIndex);
460
+ Check_default.typeOf.object("position", position);
461
+ Check_default.typeOf.object("uv", uv);
462
+ Check_default.typeOf.number("height", height);
463
+ const u = uv.x;
464
+ const v = uv.y;
465
+ if (this.quantization === TerrainQuantization_default.BITS12) {
466
+ position = Matrix4_default.multiplyByPoint(
467
+ this.toScaledENU,
468
+ position,
469
+ cartesian3Scratch
470
+ );
471
+ position.x = Math_default.clamp(position.x, 0, 1);
472
+ position.y = Math_default.clamp(position.y, 0, 1);
473
+ position.z = Math_default.clamp(position.z, 0, 1);
474
+ const hDim = this.maximumHeight - this.minimumHeight;
475
+ const h = Math_default.clamp((height - this.minimumHeight) / hDim, 0, 1);
476
+ Cartesian2_default.fromElements(position.x, position.y, cartesian2Scratch);
477
+ const compressed0 = AttributeCompression_default.compressTextureCoordinates(cartesian2Scratch);
478
+ Cartesian2_default.fromElements(position.z, h, cartesian2Scratch);
479
+ const compressed1 = AttributeCompression_default.compressTextureCoordinates(cartesian2Scratch);
480
+ Cartesian2_default.fromElements(u, v, cartesian2Scratch);
481
+ const compressed2 = AttributeCompression_default.compressTextureCoordinates(cartesian2Scratch);
482
+ vertexBuffer[bufferIndex++] = compressed0;
483
+ vertexBuffer[bufferIndex++] = compressed1;
484
+ vertexBuffer[bufferIndex++] = compressed2;
485
+ if (this.hasWebMercatorT) {
486
+ Cartesian2_default.fromElements(webMercatorT, 0, cartesian2Scratch);
487
+ const compressed3 = AttributeCompression_default.compressTextureCoordinates(cartesian2Scratch);
488
+ vertexBuffer[bufferIndex++] = compressed3;
489
+ }
490
+ } else {
491
+ vertexBuffer[bufferIndex++] = position.x - this.center.x;
492
+ vertexBuffer[bufferIndex++] = position.y - this.center.y;
493
+ vertexBuffer[bufferIndex++] = position.z - this.center.z;
494
+ vertexBuffer[bufferIndex++] = height;
495
+ vertexBuffer[bufferIndex++] = u;
496
+ vertexBuffer[bufferIndex++] = v;
497
+ if (this.hasWebMercatorT) {
498
+ vertexBuffer[bufferIndex++] = webMercatorT;
499
+ }
500
+ }
501
+ if (this.hasVertexNormals) {
502
+ vertexBuffer[bufferIndex++] = AttributeCompression_default.octPackFloat(normalToPack);
503
+ }
504
+ if (this.hasGeodeticSurfaceNormals) {
505
+ vertexBuffer[bufferIndex++] = geodeticSurfaceNormal.x;
506
+ vertexBuffer[bufferIndex++] = geodeticSurfaceNormal.y;
507
+ vertexBuffer[bufferIndex++] = geodeticSurfaceNormal.z;
508
+ }
509
+ return bufferIndex;
510
+ };
511
+ var scratchPosition = new Cartesian3_default();
512
+ var scratchGeodeticSurfaceNormal = new Cartesian3_default();
513
+ TerrainEncoding.prototype.addGeodeticSurfaceNormals = function(oldBuffer, newBuffer, ellipsoid) {
514
+ Check_default.typeOf.object("oldBuffer", oldBuffer);
515
+ Check_default.typeOf.object("newBuffer", newBuffer);
516
+ Check_default.typeOf.object("ellipsoid", ellipsoid);
517
+ if (this.hasGeodeticSurfaceNormals) {
518
+ return;
519
+ }
520
+ const oldStride = this.stride;
521
+ const vertexCount = oldBuffer.length / oldStride;
522
+ this.hasGeodeticSurfaceNormals = true;
523
+ this._calculateStrideAndOffsets();
524
+ const newStride = this.stride;
525
+ for (let index = 0; index < vertexCount; index++) {
526
+ for (let offset = 0; offset < oldStride; offset++) {
527
+ const oldIndex = index * oldStride + offset;
528
+ const newIndex = index * newStride + offset;
529
+ newBuffer[newIndex] = oldBuffer[oldIndex];
530
+ }
531
+ const position = this.decodePosition(newBuffer, index, scratchPosition);
532
+ const geodeticSurfaceNormal = ellipsoid.geodeticSurfaceNormal(
533
+ position,
534
+ scratchGeodeticSurfaceNormal
535
+ );
536
+ const bufferIndex = index * newStride + this._offsetGeodeticSurfaceNormal;
537
+ newBuffer[bufferIndex] = geodeticSurfaceNormal.x;
538
+ newBuffer[bufferIndex + 1] = geodeticSurfaceNormal.y;
539
+ newBuffer[bufferIndex + 2] = geodeticSurfaceNormal.z;
540
+ }
541
+ };
542
+ TerrainEncoding.prototype.removeGeodeticSurfaceNormals = function(oldBuffer, newBuffer) {
543
+ Check_default.typeOf.object("oldBuffer", oldBuffer);
544
+ Check_default.typeOf.object("newBuffer", newBuffer);
545
+ if (!this.hasGeodeticSurfaceNormals) {
546
+ return;
547
+ }
548
+ const oldStride = this.stride;
549
+ const vertexCount = oldBuffer.length / oldStride;
550
+ this.hasGeodeticSurfaceNormals = false;
551
+ this._calculateStrideAndOffsets();
552
+ const newStride = this.stride;
553
+ for (let index = 0; index < vertexCount; index++) {
554
+ for (let offset = 0; offset < newStride; offset++) {
555
+ const oldIndex = index * oldStride + offset;
556
+ const newIndex = index * newStride + offset;
557
+ newBuffer[newIndex] = oldBuffer[oldIndex];
558
+ }
559
+ }
560
+ };
561
+ TerrainEncoding.prototype.decodePosition = function(buffer, index, result) {
562
+ Check_default.typeOf.object("buffer", buffer);
563
+ Check_default.typeOf.number("index", index);
564
+ if (!defined_default(result)) {
565
+ result = new Cartesian3_default();
566
+ }
567
+ index *= this.stride;
568
+ if (this.quantization === TerrainQuantization_default.BITS12) {
569
+ const xy = AttributeCompression_default.decompressTextureCoordinates(
570
+ buffer[index],
571
+ cartesian2Scratch
572
+ );
573
+ result.x = xy.x;
574
+ result.y = xy.y;
575
+ const zh = AttributeCompression_default.decompressTextureCoordinates(
576
+ buffer[index + 1],
577
+ cartesian2Scratch
578
+ );
579
+ result.z = zh.x;
580
+ return Matrix4_default.multiplyByPoint(this.fromScaledENU, result, result);
581
+ }
582
+ result.x = buffer[index];
583
+ result.y = buffer[index + 1];
584
+ result.z = buffer[index + 2];
585
+ return Cartesian3_default.add(result, this.center, result);
586
+ };
587
+ TerrainEncoding.prototype.getExaggeratedPosition = function(buffer, index, result) {
588
+ result = this.decodePosition(buffer, index, result);
589
+ const exaggeration = this.exaggeration;
590
+ const exaggerationRelativeHeight = this.exaggerationRelativeHeight;
591
+ const hasExaggeration = exaggeration !== 1;
592
+ if (hasExaggeration && this.hasGeodeticSurfaceNormals) {
593
+ const geodeticSurfaceNormal = this.decodeGeodeticSurfaceNormal(
594
+ buffer,
595
+ index,
596
+ scratchGeodeticSurfaceNormal
597
+ );
598
+ const rawHeight = this.decodeHeight(buffer, index);
599
+ const heightDifference = VerticalExaggeration_default.getHeight(
600
+ rawHeight,
601
+ exaggeration,
602
+ exaggerationRelativeHeight
603
+ ) - rawHeight;
604
+ result.x += geodeticSurfaceNormal.x * heightDifference;
605
+ result.y += geodeticSurfaceNormal.y * heightDifference;
606
+ result.z += geodeticSurfaceNormal.z * heightDifference;
607
+ }
608
+ return result;
609
+ };
610
+ TerrainEncoding.prototype.decodeTextureCoordinates = function(buffer, index, result) {
611
+ Check_default.typeOf.object("buffer", buffer);
612
+ Check_default.typeOf.number("index", index);
613
+ if (!defined_default(result)) {
614
+ result = new Cartesian2_default();
615
+ }
616
+ index *= this.stride;
617
+ if (this.quantization === TerrainQuantization_default.BITS12) {
618
+ return AttributeCompression_default.decompressTextureCoordinates(
619
+ buffer[index + 2],
620
+ result
621
+ );
622
+ }
623
+ return Cartesian2_default.fromElements(buffer[index + 4], buffer[index + 5], result);
624
+ };
625
+ TerrainEncoding.prototype.decodeHeight = function(buffer, index) {
626
+ Check_default.typeOf.object("buffer", buffer);
627
+ Check_default.typeOf.number("index", index);
628
+ index *= this.stride;
629
+ if (this.quantization === TerrainQuantization_default.BITS12) {
630
+ const zh = AttributeCompression_default.decompressTextureCoordinates(
631
+ buffer[index + 1],
632
+ cartesian2Scratch
633
+ );
634
+ return zh.y * (this.maximumHeight - this.minimumHeight) + this.minimumHeight;
635
+ }
636
+ return buffer[index + 3];
637
+ };
638
+ TerrainEncoding.prototype.decodeWebMercatorT = function(buffer, index) {
639
+ Check_default.typeOf.object("buffer", buffer);
640
+ Check_default.typeOf.number("index", index);
641
+ index *= this.stride;
642
+ if (this.quantization === TerrainQuantization_default.BITS12) {
643
+ return AttributeCompression_default.decompressTextureCoordinates(
644
+ buffer[index + 3],
645
+ cartesian2Scratch
646
+ ).x;
647
+ }
648
+ return buffer[index + 6];
649
+ };
650
+ TerrainEncoding.prototype.getOctEncodedNormal = function(buffer, index, result) {
651
+ Check_default.typeOf.object("buffer", buffer);
652
+ Check_default.typeOf.number("index", index);
653
+ index = index * this.stride + this._offsetVertexNormal;
654
+ const temp = buffer[index] / 256;
655
+ const x = Math.floor(temp);
656
+ const y = (temp - x) * 256;
657
+ return Cartesian2_default.fromElements(x, y, result);
658
+ };
659
+ TerrainEncoding.prototype.decodeNormal = function(buffer, index, result) {
660
+ Check_default.typeOf.object("buffer", buffer);
661
+ Check_default.typeOf.number("index", index);
662
+ Check_default.typeOf.object("result", result);
663
+ const bufferIndex = index = index * this.stride + this._offsetVertexNormal;
664
+ return AttributeCompression_default.octDecodeFloat(buffer[bufferIndex], result);
665
+ };
666
+ TerrainEncoding.prototype.decodeGeodeticSurfaceNormal = function(buffer, index, result) {
667
+ Check_default.typeOf.object("buffer", buffer);
668
+ Check_default.typeOf.number("index", index);
669
+ Check_default.typeOf.object("result", result);
670
+ index = index * this.stride + this._offsetGeodeticSurfaceNormal;
671
+ result.x = buffer[index];
672
+ result.y = buffer[index + 1];
673
+ result.z = buffer[index + 2];
674
+ return result;
675
+ };
676
+ TerrainEncoding.prototype._calculateStrideAndOffsets = function() {
677
+ let vertexStride = 0;
678
+ switch (this.quantization) {
679
+ case TerrainQuantization_default.BITS12:
680
+ vertexStride += 3;
681
+ break;
682
+ default:
683
+ vertexStride += 6;
684
+ }
685
+ if (this.hasWebMercatorT) {
686
+ vertexStride += 1;
687
+ }
688
+ if (this.hasVertexNormals) {
689
+ this._offsetVertexNormal = vertexStride;
690
+ vertexStride += 1;
691
+ }
692
+ if (this.hasGeodeticSurfaceNormals) {
693
+ this._offsetGeodeticSurfaceNormal = vertexStride;
694
+ vertexStride += 3;
695
+ }
696
+ this.stride = vertexStride;
697
+ };
698
+ var attributesIndicesNone = {
699
+ position3DAndHeight: 0,
700
+ textureCoordAndEncodedNormals: 1,
701
+ geodeticSurfaceNormal: 2
702
+ };
703
+ var attributesIndicesBits12 = {
704
+ compressed0: 0,
705
+ compressed1: 1,
706
+ geodeticSurfaceNormal: 2
707
+ };
708
+ TerrainEncoding.prototype.getAttributes = function(buffer) {
709
+ Check_default.typeOf.object("buffer", buffer);
710
+ const datatype = ComponentDatatype_default.FLOAT;
711
+ const sizeInBytes = ComponentDatatype_default.getSizeInBytes(datatype);
712
+ const strideInBytes = this.stride * sizeInBytes;
713
+ let offsetInBytes = 0;
714
+ const attributes = [];
715
+ function addAttribute(index, componentsPerAttribute) {
716
+ attributes.push({
717
+ index,
718
+ vertexBuffer: buffer,
719
+ componentDatatype: datatype,
720
+ componentsPerAttribute,
721
+ offsetInBytes,
722
+ strideInBytes
723
+ });
724
+ offsetInBytes += componentsPerAttribute * sizeInBytes;
725
+ }
726
+ if (this.quantization === TerrainQuantization_default.NONE) {
727
+ addAttribute(attributesIndicesNone.position3DAndHeight, 4);
728
+ let componentsTexCoordAndNormals = 2;
729
+ componentsTexCoordAndNormals += this.hasWebMercatorT ? 1 : 0;
730
+ componentsTexCoordAndNormals += this.hasVertexNormals ? 1 : 0;
731
+ addAttribute(
732
+ attributesIndicesNone.textureCoordAndEncodedNormals,
733
+ componentsTexCoordAndNormals
734
+ );
735
+ if (this.hasGeodeticSurfaceNormals) {
736
+ addAttribute(attributesIndicesNone.geodeticSurfaceNormal, 3);
737
+ }
738
+ } else {
739
+ const usingAttribute0Component4 = this.hasWebMercatorT || this.hasVertexNormals;
740
+ const usingAttribute1Component1 = this.hasWebMercatorT && this.hasVertexNormals;
741
+ addAttribute(
742
+ attributesIndicesBits12.compressed0,
743
+ usingAttribute0Component4 ? 4 : 3
744
+ );
745
+ if (usingAttribute1Component1) {
746
+ addAttribute(attributesIndicesBits12.compressed1, 1);
747
+ }
748
+ if (this.hasGeodeticSurfaceNormals) {
749
+ addAttribute(attributesIndicesBits12.geodeticSurfaceNormal, 3);
750
+ }
751
+ }
752
+ return attributes;
753
+ };
754
+ TerrainEncoding.prototype.getAttributeLocations = function() {
755
+ if (this.quantization === TerrainQuantization_default.NONE) {
756
+ return attributesIndicesNone;
757
+ }
758
+ return attributesIndicesBits12;
759
+ };
760
+ TerrainEncoding.clone = function(encoding, result) {
761
+ if (!defined_default(encoding)) {
762
+ return void 0;
763
+ }
764
+ if (!defined_default(result)) {
765
+ result = new TerrainEncoding();
766
+ }
767
+ result.quantization = encoding.quantization;
768
+ result.minimumHeight = encoding.minimumHeight;
769
+ result.maximumHeight = encoding.maximumHeight;
770
+ result.center = Cartesian3_default.clone(encoding.center);
771
+ result.toScaledENU = Matrix4_default.clone(encoding.toScaledENU);
772
+ result.fromScaledENU = Matrix4_default.clone(encoding.fromScaledENU);
773
+ result.matrix = Matrix4_default.clone(encoding.matrix);
774
+ result.hasVertexNormals = encoding.hasVertexNormals;
775
+ result.hasWebMercatorT = encoding.hasWebMercatorT;
776
+ result.hasGeodeticSurfaceNormals = encoding.hasGeodeticSurfaceNormals;
777
+ result.exaggeration = encoding.exaggeration;
778
+ result.exaggerationRelativeHeight = encoding.exaggerationRelativeHeight;
779
+ result._calculateStrideAndOffsets();
780
+ return result;
781
+ };
782
+ var TerrainEncoding_default = TerrainEncoding;
783
+
784
+ export {
785
+ EllipsoidalOccluder_default,
786
+ VerticalExaggeration_default,
787
+ TerrainEncoding_default
788
+ };