@rtzh/engine 0.0.2 → 0.0.3

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 (113) hide show
  1. package/Source/Scene/GltfLoader.js +2 -2
  2. package/package.json +1 -1
  3. package/Build/ThirdParty/Workers/zip-web-worker.js +0 -640
  4. package/Build/Workers/chunk-245NZYCR.js +0 -124
  5. package/Build/Workers/chunk-25BA4527.js +0 -837
  6. package/Build/Workers/chunk-4HXPSZRC.js +0 -1483
  7. package/Build/Workers/chunk-4Z26IS65.js +0 -3514
  8. package/Build/Workers/chunk-55IROWAX.js +0 -139
  9. package/Build/Workers/chunk-56XTN5NJ.js +0 -1800
  10. package/Build/Workers/chunk-5VZISKJF.js +0 -629
  11. package/Build/Workers/chunk-5WAG5YKS.js +0 -368
  12. package/Build/Workers/chunk-66YGZWBI.js +0 -1317
  13. package/Build/Workers/chunk-6H33B6OL.js +0 -37
  14. package/Build/Workers/chunk-6LZBBEA7.js +0 -439
  15. package/Build/Workers/chunk-6XJO625E.js +0 -497
  16. package/Build/Workers/chunk-75UGCVME.js +0 -102
  17. package/Build/Workers/chunk-7B23DD46.js +0 -1054
  18. package/Build/Workers/chunk-7NCJH26L.js +0 -352
  19. package/Build/Workers/chunk-AIW5F22O.js +0 -352
  20. package/Build/Workers/chunk-AL22JVIA.js +0 -256
  21. package/Build/Workers/chunk-AVSQILVI.js +0 -75
  22. package/Build/Workers/chunk-B2VFNYD7.js +0 -280
  23. package/Build/Workers/chunk-BOV6T7FO.js +0 -44
  24. package/Build/Workers/chunk-DP76S3IQ.js +0 -1067
  25. package/Build/Workers/chunk-EDIUN7V3.js +0 -219
  26. package/Build/Workers/chunk-EKMWNF4U.js +0 -55
  27. package/Build/Workers/chunk-ELXGXAYS.js +0 -682
  28. package/Build/Workers/chunk-FVYRV2T6.js +0 -455
  29. package/Build/Workers/chunk-GDIBU55R.js +0 -778
  30. package/Build/Workers/chunk-HAY6YE7M.js +0 -97
  31. package/Build/Workers/chunk-I76SRIKN.js +0 -138
  32. package/Build/Workers/chunk-IELTSYPZ.js +0 -241
  33. package/Build/Workers/chunk-J4MIJCN5.js +0 -171
  34. package/Build/Workers/chunk-JFO3ELF3.js +0 -642
  35. package/Build/Workers/chunk-K4IMD7KH.js +0 -162
  36. package/Build/Workers/chunk-KFMCOG26.js +0 -692
  37. package/Build/Workers/chunk-KH2OWUUA.js +0 -163
  38. package/Build/Workers/chunk-KQIZ7AFF.js +0 -8366
  39. package/Build/Workers/chunk-KVE5EAPO.js +0 -398
  40. package/Build/Workers/chunk-OAOREOSO.js +0 -940
  41. package/Build/Workers/chunk-OFJRMGNX.js +0 -788
  42. package/Build/Workers/chunk-PLLZB3R4.js +0 -198
  43. package/Build/Workers/chunk-POY6ZE32.js +0 -2058
  44. package/Build/Workers/chunk-PV5B2YNB.js +0 -2719
  45. package/Build/Workers/chunk-Q2DXNFYW.js +0 -414
  46. package/Build/Workers/chunk-QWV2DM66.js +0 -1443
  47. package/Build/Workers/chunk-R73BHGGI.js +0 -305
  48. package/Build/Workers/chunk-S3AE3MZZ.js +0 -511
  49. package/Build/Workers/chunk-SBFTVHRW.js +0 -57
  50. package/Build/Workers/chunk-SOR7PD4V.js +0 -114
  51. package/Build/Workers/chunk-TO7TWUET.js +0 -476
  52. package/Build/Workers/chunk-TSAJNE4K.js +0 -101
  53. package/Build/Workers/chunk-TWF4XRZ6.js +0 -73
  54. package/Build/Workers/chunk-UTWLMOPM.js +0 -387
  55. package/Build/Workers/chunk-UYT2PBMV.js +0 -58
  56. package/Build/Workers/chunk-WAS3IHIQ.js +0 -288
  57. package/Build/Workers/chunk-WO5ZNC7S.js +0 -1045
  58. package/Build/Workers/chunk-X65Y2JSA.js +0 -55
  59. package/Build/Workers/chunk-XOVHLPKW.js +0 -299
  60. package/Build/Workers/chunk-YPGJSFOO.js +0 -1460
  61. package/Build/Workers/combineGeometry.js +0 -66
  62. package/Build/Workers/createBoxGeometry.js +0 -58
  63. package/Build/Workers/createBoxOutlineGeometry.js +0 -231
  64. package/Build/Workers/createCircleGeometry.js +0 -201
  65. package/Build/Workers/createCircleOutlineGeometry.js +0 -147
  66. package/Build/Workers/createCoplanarPolygonGeometry.js +0 -505
  67. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +0 -225
  68. package/Build/Workers/createCorridorGeometry.js +0 -1258
  69. package/Build/Workers/createCorridorOutlineGeometry.js +0 -563
  70. package/Build/Workers/createCylinderGeometry.js +0 -60
  71. package/Build/Workers/createCylinderOutlineGeometry.js +0 -231
  72. package/Build/Workers/createEllipseGeometry.js +0 -72
  73. package/Build/Workers/createEllipseOutlineGeometry.js +0 -65
  74. package/Build/Workers/createEllipsoidGeometry.js +0 -59
  75. package/Build/Workers/createEllipsoidOutlineGeometry.js +0 -61
  76. package/Build/Workers/createFrustumGeometry.js +0 -58
  77. package/Build/Workers/createFrustumOutlineGeometry.js +0 -234
  78. package/Build/Workers/createGeometry.js +0 -173
  79. package/Build/Workers/createGroundPolylineGeometry.js +0 -1602
  80. package/Build/Workers/createPlaneGeometry.js +0 -223
  81. package/Build/Workers/createPlaneOutlineGeometry.js +0 -124
  82. package/Build/Workers/createPolygonGeometry.js +0 -1404
  83. package/Build/Workers/createPolygonOutlineGeometry.js +0 -532
  84. package/Build/Workers/createPolylineGeometry.js +0 -491
  85. package/Build/Workers/createPolylineVolumeGeometry.js +0 -374
  86. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +0 -272
  87. package/Build/Workers/createRectangleGeometry.js +0 -1264
  88. package/Build/Workers/createRectangleOutlineGeometry.js +0 -476
  89. package/Build/Workers/createSimplePolylineGeometry.js +0 -397
  90. package/Build/Workers/createSphereGeometry.js +0 -116
  91. package/Build/Workers/createSphereOutlineGeometry.js +0 -116
  92. package/Build/Workers/createTaskProcessorWorker.js +0 -32
  93. package/Build/Workers/createVectorTileClampedPolylines.js +0 -492
  94. package/Build/Workers/createVectorTileGeometries.js +0 -387
  95. package/Build/Workers/createVectorTilePoints.js +0 -114
  96. package/Build/Workers/createVectorTilePolygons.js +0 -386
  97. package/Build/Workers/createVectorTilePolylines.js +0 -262
  98. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +0 -91
  99. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +0 -565
  100. package/Build/Workers/createVerticesFromHeightmap.js +0 -2254
  101. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +0 -499
  102. package/Build/Workers/createWallGeometry.js +0 -487
  103. package/Build/Workers/createWallOutlineGeometry.js +0 -335
  104. package/Build/Workers/decodeDraco.js +0 -369
  105. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +0 -2680
  106. package/Build/Workers/decodeI3S.js +0 -1339
  107. package/Build/Workers/gaussianSplatSorter.js +0 -62
  108. package/Build/Workers/gaussianSplatTextureGenerator.js +0 -68
  109. package/Build/Workers/incrementallyBuildTerrainPicker.js +0 -121
  110. package/Build/Workers/transcodeKTX2.js +0 -3463
  111. package/Build/Workers/transferTypedArrayTest.js +0 -41
  112. package/Build/Workers/upsampleQuantizedTerrainMesh.js +0 -820
  113. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +0 -95
@@ -1,788 +0,0 @@
1
- /**
2
- * @license
3
- * Cesium - https://github.com/CesiumGS/cesium
4
- * Version 0.0.1
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-6LZBBEA7.js";
29
- import {
30
- BoundingSphere_default
31
- } from "./chunk-OAOREOSO.js";
32
- import {
33
- Rectangle_default
34
- } from "./chunk-KQIZ7AFF.js";
35
- import {
36
- Matrix4_default
37
- } from "./chunk-POY6ZE32.js";
38
- import {
39
- ComponentDatatype_default
40
- } from "./chunk-AL22JVIA.js";
41
- import {
42
- Cartesian2_default,
43
- Cartographic_default,
44
- Ellipsoid_default
45
- } from "./chunk-YPGJSFOO.js";
46
- import {
47
- Cartesian3_default
48
- } from "./chunk-QWV2DM66.js";
49
- import {
50
- Math_default
51
- } from "./chunk-6XJO625E.js";
52
- import {
53
- Check_default,
54
- DeveloperError_default
55
- } from "./chunk-KH2OWUUA.js";
56
- import {
57
- defined_default
58
- } from "./chunk-AVSQILVI.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
- };