@gmgis/gm-sdk 1.12.5 → 2.0.2

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 (159) hide show
  1. package/dist/dist/index.js +1848 -0
  2. package/dist/gm.min.js +16983 -16483
  3. package/dist/index.js +1436 -1434
  4. package/dist/resources/ThirdParty/Workers/pako_deflate.min.js +1 -2
  5. package/dist/resources/ThirdParty/Workers/pako_inflate.min.js +1 -2
  6. package/dist/resources/ThirdParty/Workers/z-worker-pako.js +1 -1
  7. package/dist/resources/ThirdParty/google-earth-dbroot-parser.js +1 -8337
  8. package/dist/resources/ThirdParty/wasm_splats_bg.wasm +0 -0
  9. package/dist/resources/Workers/chunk-35SHYARM.js +26 -0
  10. package/dist/resources/Workers/chunk-37F5JSTI.js +26 -0
  11. package/dist/resources/Workers/chunk-3SSKC3VN.js +26 -0
  12. package/dist/resources/Workers/chunk-3W4GT7KQ.js +26 -0
  13. package/dist/resources/Workers/chunk-4IW2T6GF.js +26 -0
  14. package/dist/resources/Workers/chunk-5YEWO3HT.js +26 -0
  15. package/dist/resources/Workers/chunk-64RSHJUE.js +28 -0
  16. package/dist/resources/Workers/chunk-77IHZJJ3.js +26 -0
  17. package/dist/resources/Workers/chunk-7HTKERZY.js +26 -0
  18. package/dist/resources/Workers/{chunk-I2ITFFPX.js → chunk-A56XVLQR.js} +2 -13
  19. package/dist/resources/Workers/chunk-AJYK4IVJ.js +26 -0
  20. package/dist/resources/Workers/{chunk-PRGYLLJT.js → chunk-ARG42DC4.js} +2 -31
  21. package/dist/resources/Workers/chunk-AU7IKHOH.js +26 -0
  22. package/dist/resources/Workers/chunk-B4AA3ARO.js +26 -0
  23. package/dist/resources/Workers/chunk-CNCV5UL7.js +26 -0
  24. package/dist/resources/Workers/chunk-CYCB63OH.js +26 -0
  25. package/dist/resources/Workers/{chunk-DI5NGJUP.js → chunk-D6AA5QVT.js} +2 -20
  26. package/dist/resources/Workers/chunk-D6C66QON.js +26 -0
  27. package/dist/resources/Workers/chunk-DEPHB2WM.js +26 -0
  28. package/dist/resources/Workers/chunk-DMEY62ID.js +26 -0
  29. package/dist/resources/Workers/chunk-DQQ63PYM.js +26 -0
  30. package/dist/resources/Workers/chunk-ED5JPB3S.js +27 -0
  31. package/dist/resources/Workers/chunk-EZUYS2JF.js +26 -0
  32. package/dist/resources/Workers/chunk-FEVXJ54I.js +26 -0
  33. package/dist/resources/Workers/chunk-G5AGHVVC.js +26 -0
  34. package/dist/resources/Workers/{chunk-7JO7GPJN.js → chunk-GBYLG25F.js} +2 -15
  35. package/dist/resources/Workers/chunk-GILIDQNQ.js +26 -0
  36. package/dist/resources/Workers/chunk-HMIYSTF6.js +26 -0
  37. package/dist/resources/Workers/chunk-HTFSEEMT.js +26 -0
  38. package/dist/resources/Workers/chunk-HWXX4CWK.js +26 -0
  39. package/dist/resources/Workers/chunk-IYTZ52EY.js +26 -0
  40. package/dist/resources/Workers/chunk-J6UP6FLE.js +26 -0
  41. package/dist/resources/Workers/chunk-LEYMRMBK.js +27 -0
  42. package/dist/resources/Workers/chunk-M3MGYQSL.js +26 -0
  43. package/dist/resources/Workers/chunk-N4VJKXZS.js +26 -0
  44. package/dist/resources/Workers/chunk-NB3ML6JO.js +26 -0
  45. package/dist/resources/Workers/chunk-OFUUQVMR.js +26 -0
  46. package/dist/resources/Workers/chunk-OSW76XDF.js +26 -0
  47. package/dist/resources/Workers/chunk-PSPPBZWI.js +66 -0
  48. package/dist/resources/Workers/chunk-QN3VOORQ.js +26 -0
  49. package/dist/resources/Workers/chunk-QOUAJ6TL.js +26 -0
  50. package/dist/resources/Workers/chunk-RCV6KWXS.js +26 -0
  51. package/dist/resources/Workers/chunk-TCGIRNHN.js +26 -0
  52. package/dist/resources/Workers/chunk-U4IEOH5K.js +26 -0
  53. package/dist/resources/Workers/chunk-UP6I5URU.js +26 -0
  54. package/dist/resources/Workers/chunk-VTAIKJXX.js +26 -0
  55. package/dist/resources/Workers/chunk-VTBDSFTG.js +26 -0
  56. package/dist/resources/Workers/chunk-VW6VD53G.js +26 -0
  57. package/dist/resources/Workers/chunk-WGGIH7QW.js +26 -0
  58. package/dist/resources/Workers/chunk-WWA5PL4H.js +26 -0
  59. package/dist/resources/Workers/{chunk-6CHGCNMW.js → chunk-WZDE3RYP.js} +4 -34
  60. package/dist/resources/Workers/chunk-XRL4AVS5.js +26 -0
  61. package/dist/resources/Workers/combineGeometry.js +2 -40
  62. package/dist/resources/Workers/createBoxGeometry.js +2 -32
  63. package/dist/resources/Workers/createBoxOutlineGeometry.js +2 -209
  64. package/dist/resources/Workers/createCircleGeometry.js +2 -175
  65. package/dist/resources/Workers/createCircleOutlineGeometry.js +2 -121
  66. package/dist/resources/Workers/createCoplanarPolygonGeometry.js +2 -481
  67. package/dist/resources/Workers/createCoplanarPolygonOutlineGeometry.js +2 -199
  68. package/dist/resources/Workers/createCorridorGeometry.js +2 -1237
  69. package/dist/resources/Workers/createCorridorOutlineGeometry.js +2 -542
  70. package/dist/resources/Workers/createCylinderGeometry.js +2 -34
  71. package/dist/resources/Workers/createCylinderOutlineGeometry.js +2 -205
  72. package/dist/resources/Workers/createEllipseGeometry.js +2 -45
  73. package/dist/resources/Workers/createEllipseOutlineGeometry.js +2 -38
  74. package/dist/resources/Workers/createEllipsoidGeometry.js +2 -33
  75. package/dist/resources/Workers/createEllipsoidOutlineGeometry.js +2 -35
  76. package/dist/resources/Workers/createFrustumGeometry.js +2 -32
  77. package/dist/resources/Workers/createFrustumOutlineGeometry.js +2 -210
  78. package/dist/resources/Workers/createGeometry.js +2 -144
  79. package/dist/resources/Workers/createGroundPolylineGeometry.js +2 -1582
  80. package/dist/resources/Workers/createPlaneGeometry.js +2 -198
  81. package/dist/resources/Workers/createPlaneOutlineGeometry.js +2 -98
  82. package/dist/resources/Workers/createPolygonGeometry.js +2 -1381
  83. package/dist/resources/Workers/createPolygonOutlineGeometry.js +2 -509
  84. package/dist/resources/Workers/createPolylineGeometry.js +2 -470
  85. package/dist/resources/Workers/createPolylineVolumeGeometry.js +2 -354
  86. package/dist/resources/Workers/createPolylineVolumeOutlineGeometry.js +2 -251
  87. package/dist/resources/Workers/createRectangleGeometry.js +2 -1246
  88. package/dist/resources/Workers/createRectangleOutlineGeometry.js +2 -453
  89. package/dist/resources/Workers/createSimplePolylineGeometry.js +2 -374
  90. package/dist/resources/Workers/createSphereGeometry.js +2 -92
  91. package/dist/resources/Workers/createSphereOutlineGeometry.js +2 -92
  92. package/dist/resources/Workers/createTaskProcessorWorker.js +2 -8
  93. package/dist/resources/Workers/createVectorTileClampedPolylines.js +2 -466
  94. package/dist/resources/Workers/createVectorTileGeometries.js +2 -361
  95. package/dist/resources/Workers/createVectorTilePoints.js +2 -88
  96. package/dist/resources/Workers/createVectorTilePolygons.js +2 -359
  97. package/dist/resources/Workers/createVectorTilePolylines.js +2 -236
  98. package/dist/resources/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +2 -539
  99. package/dist/resources/Workers/createVerticesFromHeightmap.js +2 -2252
  100. package/dist/resources/Workers/createVerticesFromQuantizedTerrainMesh.js +2 -729
  101. package/dist/resources/Workers/createWallGeometry.js +2 -464
  102. package/dist/resources/Workers/createWallOutlineGeometry.js +2 -312
  103. package/dist/resources/Workers/decodeDraco.js +2 -345
  104. package/dist/resources/Workers/decodeGoogleEarthEnterprisePacket.js +2 -2642
  105. package/dist/resources/Workers/decodeI3S.js +2 -1319
  106. package/dist/resources/Workers/gaussianSplatSorter.js +26 -0
  107. package/dist/resources/Workers/gaussianSplatTextureGenerator.js +26 -0
  108. package/dist/resources/Workers/transcodeKTX2.js +29 -3360
  109. package/dist/resources/Workers/transferTypedArrayTest.js +2 -17
  110. package/dist/resources/Workers/upsampleQuantizedTerrainMesh.js +2 -793
  111. package/package.json +74 -74
  112. package/dist/resources/ThirdParty/Workers/basis_transcoder.js +0 -21
  113. package/dist/resources/Workers/chunk-26GA3JAM.js +0 -139
  114. package/dist/resources/Workers/chunk-27HUZ7SA.js +0 -305
  115. package/dist/resources/Workers/chunk-2ZGOQXYU.js +0 -171
  116. package/dist/resources/Workers/chunk-3Q2L65QU.js +0 -1258
  117. package/dist/resources/Workers/chunk-472HQ3EH.js +0 -100
  118. package/dist/resources/Workers/chunk-5ODQSF26.js +0 -101
  119. package/dist/resources/Workers/chunk-5OOFQLKF.js +0 -634
  120. package/dist/resources/Workers/chunk-5PTXS2GO.js +0 -10390
  121. package/dist/resources/Workers/chunk-76BYBWHP.js +0 -122
  122. package/dist/resources/Workers/chunk-7BMOHCPM.js +0 -390
  123. package/dist/resources/Workers/chunk-7KTQP4VB.js +0 -59
  124. package/dist/resources/Workers/chunk-7O373FFS.js +0 -665
  125. package/dist/resources/Workers/chunk-AD63PIY6.js +0 -163
  126. package/dist/resources/Workers/chunk-BHQJ2NT7.js +0 -353
  127. package/dist/resources/Workers/chunk-C6YYBQXW.js +0 -102
  128. package/dist/resources/Workers/chunk-CKY7HOHV.js +0 -287
  129. package/dist/resources/Workers/chunk-DHYHSFFJ.js +0 -73
  130. package/dist/resources/Workers/chunk-E27BLMDD.js +0 -115
  131. package/dist/resources/Workers/chunk-E63IIM5T.js +0 -75
  132. package/dist/resources/Workers/chunk-E6V6SQZW.js +0 -456
  133. package/dist/resources/Workers/chunk-EJZTDTUH.js +0 -138
  134. package/dist/resources/Workers/chunk-FDOV2LBJ.js +0 -220
  135. package/dist/resources/Workers/chunk-FIGIZHAQ.js +0 -684
  136. package/dist/resources/Workers/chunk-GESF4OXQ.js +0 -1800
  137. package/dist/resources/Workers/chunk-GGZJN2TI.js +0 -2717
  138. package/dist/resources/Workers/chunk-GNBFYG7F.js +0 -1481
  139. package/dist/resources/Workers/chunk-GWCFU2SA.js +0 -300
  140. package/dist/resources/Workers/chunk-IBLIYJZR.js +0 -196
  141. package/dist/resources/Workers/chunk-JW4FOI6M.js +0 -476
  142. package/dist/resources/Workers/chunk-K4GQUNB5.js +0 -262
  143. package/dist/resources/Workers/chunk-M3GMB5OP.js +0 -834
  144. package/dist/resources/Workers/chunk-MXIZJAPH.js +0 -629
  145. package/dist/resources/Workers/chunk-N5KJGGCM.js +0 -1073
  146. package/dist/resources/Workers/chunk-NGPPMXRM.js +0 -435
  147. package/dist/resources/Workers/chunk-O3E4OAOE.js +0 -511
  148. package/dist/resources/Workers/chunk-PGRPDNHG.js +0 -1048
  149. package/dist/resources/Workers/chunk-S6MRMMQU.js +0 -157
  150. package/dist/resources/Workers/chunk-SMDOP47J.js +0 -945
  151. package/dist/resources/Workers/chunk-TGONEMZO.js +0 -421
  152. package/dist/resources/Workers/chunk-TKVT5GQM.js +0 -781
  153. package/dist/resources/Workers/chunk-U72QNFOJ.js +0 -758
  154. package/dist/resources/Workers/chunk-VJZB3WAV.js +0 -963
  155. package/dist/resources/Workers/chunk-VU2MNO7L.js +0 -239
  156. package/dist/resources/Workers/chunk-XY4BATBS.js +0 -500
  157. package/dist/resources/Workers/chunk-YFXQECWV.js +0 -2857
  158. package/dist/resources/Workers/chunk-YSGTGQQO.js +0 -398
  159. package/dist/resources/Workers/chunk-YZ733KKS.js +0 -368
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @license
3
3
  * Cesium - https://github.com/CesiumGS/cesium
4
- * Version 1.122
4
+ * Version 1.132
5
5
  *
6
6
  * Copyright 2011-2022 Cesium Contributors
7
7
  *
@@ -23,795 +23,4 @@
23
23
  * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
24
24
  */
25
25
 
26
- import {
27
- EllipsoidalOccluder_default,
28
- TerrainEncoding_default
29
- } from "./chunk-U72QNFOJ.js";
30
- import {
31
- createTaskProcessorWorker_default
32
- } from "./chunk-5ODQSF26.js";
33
- import {
34
- OrientedBoundingBox_default
35
- } from "./chunk-M3GMB5OP.js";
36
- import {
37
- AttributeCompression_default
38
- } from "./chunk-NGPPMXRM.js";
39
- import "./chunk-CKY7HOHV.js";
40
- import "./chunk-S6MRMMQU.js";
41
- import "./chunk-3Q2L65QU.js";
42
- import "./chunk-2ZGOQXYU.js";
43
- import {
44
- IndexDatatype_default
45
- } from "./chunk-26GA3JAM.js";
46
- import {
47
- BoundingSphere_default
48
- } from "./chunk-VJZB3WAV.js";
49
- import {
50
- Rectangle_default
51
- } from "./chunk-5PTXS2GO.js";
52
- import "./chunk-K4GQUNB5.js";
53
- import {
54
- Cartesian2_default,
55
- Cartesian3_default,
56
- Cartographic_default,
57
- Ellipsoid_default
58
- } from "./chunk-YFXQECWV.js";
59
- import {
60
- Math_default
61
- } from "./chunk-XY4BATBS.js";
62
- import "./chunk-MXIZJAPH.js";
63
- import "./chunk-6CHGCNMW.js";
64
- import "./chunk-7JO7GPJN.js";
65
- import {
66
- Check_default,
67
- DeveloperError_default
68
- } from "./chunk-AD63PIY6.js";
69
- import {
70
- defined_default
71
- } from "./chunk-E63IIM5T.js";
72
-
73
- // packages/engine/Source/Core/Intersections2D.js
74
- var Intersections2D = {};
75
- Intersections2D.clipTriangleAtAxisAlignedThreshold = function(threshold, keepAbove, u0, u1, u2, result) {
76
- if (!defined_default(threshold)) {
77
- throw new DeveloperError_default("threshold is required.");
78
- }
79
- if (!defined_default(keepAbove)) {
80
- throw new DeveloperError_default("keepAbove is required.");
81
- }
82
- if (!defined_default(u0)) {
83
- throw new DeveloperError_default("u0 is required.");
84
- }
85
- if (!defined_default(u1)) {
86
- throw new DeveloperError_default("u1 is required.");
87
- }
88
- if (!defined_default(u2)) {
89
- throw new DeveloperError_default("u2 is required.");
90
- }
91
- if (!defined_default(result)) {
92
- result = [];
93
- } else {
94
- result.length = 0;
95
- }
96
- let u0Behind;
97
- let u1Behind;
98
- let u2Behind;
99
- if (keepAbove) {
100
- u0Behind = u0 < threshold;
101
- u1Behind = u1 < threshold;
102
- u2Behind = u2 < threshold;
103
- } else {
104
- u0Behind = u0 > threshold;
105
- u1Behind = u1 > threshold;
106
- u2Behind = u2 > threshold;
107
- }
108
- const numBehind = u0Behind + u1Behind + u2Behind;
109
- let u01Ratio;
110
- let u02Ratio;
111
- let u12Ratio;
112
- let u10Ratio;
113
- let u20Ratio;
114
- let u21Ratio;
115
- if (numBehind === 1) {
116
- if (u0Behind) {
117
- u01Ratio = (threshold - u0) / (u1 - u0);
118
- u02Ratio = (threshold - u0) / (u2 - u0);
119
- result.push(1);
120
- result.push(2);
121
- if (u02Ratio !== 1) {
122
- result.push(-1);
123
- result.push(0);
124
- result.push(2);
125
- result.push(u02Ratio);
126
- }
127
- if (u01Ratio !== 1) {
128
- result.push(-1);
129
- result.push(0);
130
- result.push(1);
131
- result.push(u01Ratio);
132
- }
133
- } else if (u1Behind) {
134
- u12Ratio = (threshold - u1) / (u2 - u1);
135
- u10Ratio = (threshold - u1) / (u0 - u1);
136
- result.push(2);
137
- result.push(0);
138
- if (u10Ratio !== 1) {
139
- result.push(-1);
140
- result.push(1);
141
- result.push(0);
142
- result.push(u10Ratio);
143
- }
144
- if (u12Ratio !== 1) {
145
- result.push(-1);
146
- result.push(1);
147
- result.push(2);
148
- result.push(u12Ratio);
149
- }
150
- } else if (u2Behind) {
151
- u20Ratio = (threshold - u2) / (u0 - u2);
152
- u21Ratio = (threshold - u2) / (u1 - u2);
153
- result.push(0);
154
- result.push(1);
155
- if (u21Ratio !== 1) {
156
- result.push(-1);
157
- result.push(2);
158
- result.push(1);
159
- result.push(u21Ratio);
160
- }
161
- if (u20Ratio !== 1) {
162
- result.push(-1);
163
- result.push(2);
164
- result.push(0);
165
- result.push(u20Ratio);
166
- }
167
- }
168
- } else if (numBehind === 2) {
169
- if (!u0Behind && u0 !== threshold) {
170
- u10Ratio = (threshold - u1) / (u0 - u1);
171
- u20Ratio = (threshold - u2) / (u0 - u2);
172
- result.push(0);
173
- result.push(-1);
174
- result.push(1);
175
- result.push(0);
176
- result.push(u10Ratio);
177
- result.push(-1);
178
- result.push(2);
179
- result.push(0);
180
- result.push(u20Ratio);
181
- } else if (!u1Behind && u1 !== threshold) {
182
- u21Ratio = (threshold - u2) / (u1 - u2);
183
- u01Ratio = (threshold - u0) / (u1 - u0);
184
- result.push(1);
185
- result.push(-1);
186
- result.push(2);
187
- result.push(1);
188
- result.push(u21Ratio);
189
- result.push(-1);
190
- result.push(0);
191
- result.push(1);
192
- result.push(u01Ratio);
193
- } else if (!u2Behind && u2 !== threshold) {
194
- u02Ratio = (threshold - u0) / (u2 - u0);
195
- u12Ratio = (threshold - u1) / (u2 - u1);
196
- result.push(2);
197
- result.push(-1);
198
- result.push(0);
199
- result.push(2);
200
- result.push(u02Ratio);
201
- result.push(-1);
202
- result.push(1);
203
- result.push(2);
204
- result.push(u12Ratio);
205
- }
206
- } else if (numBehind !== 3) {
207
- result.push(0);
208
- result.push(1);
209
- result.push(2);
210
- }
211
- return result;
212
- };
213
- Intersections2D.computeBarycentricCoordinates = function(x, y, x1, y1, x2, y2, x3, y3, result) {
214
- if (!defined_default(x)) {
215
- throw new DeveloperError_default("x is required.");
216
- }
217
- if (!defined_default(y)) {
218
- throw new DeveloperError_default("y is required.");
219
- }
220
- if (!defined_default(x1)) {
221
- throw new DeveloperError_default("x1 is required.");
222
- }
223
- if (!defined_default(y1)) {
224
- throw new DeveloperError_default("y1 is required.");
225
- }
226
- if (!defined_default(x2)) {
227
- throw new DeveloperError_default("x2 is required.");
228
- }
229
- if (!defined_default(y2)) {
230
- throw new DeveloperError_default("y2 is required.");
231
- }
232
- if (!defined_default(x3)) {
233
- throw new DeveloperError_default("x3 is required.");
234
- }
235
- if (!defined_default(y3)) {
236
- throw new DeveloperError_default("y3 is required.");
237
- }
238
- const x1mx3 = x1 - x3;
239
- const x3mx2 = x3 - x2;
240
- const y2my3 = y2 - y3;
241
- const y1my3 = y1 - y3;
242
- const inverseDeterminant = 1 / (y2my3 * x1mx3 + x3mx2 * y1my3);
243
- const ymy3 = y - y3;
244
- const xmx3 = x - x3;
245
- const l1 = (y2my3 * xmx3 + x3mx2 * ymy3) * inverseDeterminant;
246
- const l2 = (-y1my3 * xmx3 + x1mx3 * ymy3) * inverseDeterminant;
247
- const l3 = 1 - l1 - l2;
248
- if (defined_default(result)) {
249
- result.x = l1;
250
- result.y = l2;
251
- result.z = l3;
252
- return result;
253
- }
254
- return new Cartesian3_default(l1, l2, l3);
255
- };
256
- Intersections2D.computeLineSegmentLineSegmentIntersection = function(x00, y00, x01, y01, x10, y10, x11, y11, result) {
257
- Check_default.typeOf.number("x00", x00);
258
- Check_default.typeOf.number("y00", y00);
259
- Check_default.typeOf.number("x01", x01);
260
- Check_default.typeOf.number("y01", y01);
261
- Check_default.typeOf.number("x10", x10);
262
- Check_default.typeOf.number("y10", y10);
263
- Check_default.typeOf.number("x11", x11);
264
- Check_default.typeOf.number("y11", y11);
265
- const numerator1A = (x11 - x10) * (y00 - y10) - (y11 - y10) * (x00 - x10);
266
- const numerator1B = (x01 - x00) * (y00 - y10) - (y01 - y00) * (x00 - x10);
267
- const denominator1 = (y11 - y10) * (x01 - x00) - (x11 - x10) * (y01 - y00);
268
- if (denominator1 === 0) {
269
- return;
270
- }
271
- const ua1 = numerator1A / denominator1;
272
- const ub1 = numerator1B / denominator1;
273
- if (ua1 >= 0 && ua1 <= 1 && ub1 >= 0 && ub1 <= 1) {
274
- if (!defined_default(result)) {
275
- result = new Cartesian2_default();
276
- }
277
- result.x = x00 + ua1 * (x01 - x00);
278
- result.y = y00 + ua1 * (y01 - y00);
279
- return result;
280
- }
281
- };
282
- var Intersections2D_default = Intersections2D;
283
-
284
- // packages/engine/Source/Workers/upsampleQuantizedTerrainMesh.js
285
- var maxShort = 32767;
286
- var halfMaxShort = maxShort / 2 | 0;
287
- var clipScratch = [];
288
- var clipScratch2 = [];
289
- var verticesScratch = [];
290
- var cartographicScratch = new Cartographic_default();
291
- var cartesian3Scratch = new Cartesian3_default();
292
- var uScratch = [];
293
- var vScratch = [];
294
- var heightScratch = [];
295
- var indicesScratch = [];
296
- var normalsScratch = [];
297
- var horizonOcclusionPointScratch = new Cartesian3_default();
298
- var boundingSphereScratch = new BoundingSphere_default();
299
- var orientedBoundingBoxScratch = new OrientedBoundingBox_default();
300
- var decodeTexCoordsScratch = new Cartesian2_default();
301
- var octEncodedNormalScratch = new Cartesian3_default();
302
- function upsampleQuantizedTerrainMesh(parameters, transferableObjects) {
303
- const isEastChild = parameters.isEastChild;
304
- const isNorthChild = parameters.isNorthChild;
305
- const minU = isEastChild ? halfMaxShort : 0;
306
- const maxU = isEastChild ? maxShort : halfMaxShort;
307
- const minV = isNorthChild ? halfMaxShort : 0;
308
- const maxV = isNorthChild ? maxShort : halfMaxShort;
309
- const uBuffer = uScratch;
310
- const vBuffer = vScratch;
311
- const heightBuffer = heightScratch;
312
- const normalBuffer = normalsScratch;
313
- uBuffer.length = 0;
314
- vBuffer.length = 0;
315
- heightBuffer.length = 0;
316
- normalBuffer.length = 0;
317
- const indices = indicesScratch;
318
- indices.length = 0;
319
- const vertexMap = {};
320
- const parentVertices = parameters.vertices;
321
- let parentIndices = parameters.indices;
322
- parentIndices = parentIndices.subarray(0, parameters.indexCountWithoutSkirts);
323
- const encoding = TerrainEncoding_default.clone(parameters.encoding);
324
- const hasVertexNormals = encoding.hasVertexNormals;
325
- let vertexCount = 0;
326
- const quantizedVertexCount = parameters.vertexCountWithoutSkirts;
327
- const parentMinimumHeight = parameters.minimumHeight;
328
- const parentMaximumHeight = parameters.maximumHeight;
329
- const parentUBuffer = new Array(quantizedVertexCount);
330
- const parentVBuffer = new Array(quantizedVertexCount);
331
- const parentHeightBuffer = new Array(quantizedVertexCount);
332
- const parentNormalBuffer = hasVertexNormals ? new Array(quantizedVertexCount * 2) : void 0;
333
- const threshold = 20;
334
- let height;
335
- let i, n;
336
- let u, v;
337
- for (i = 0, n = 0; i < quantizedVertexCount; ++i, n += 2) {
338
- const texCoords = encoding.decodeTextureCoordinates(
339
- parentVertices,
340
- i,
341
- decodeTexCoordsScratch
342
- );
343
- height = encoding.decodeHeight(parentVertices, i);
344
- u = Math_default.clamp(texCoords.x * maxShort | 0, 0, maxShort);
345
- v = Math_default.clamp(texCoords.y * maxShort | 0, 0, maxShort);
346
- parentHeightBuffer[i] = Math_default.clamp(
347
- (height - parentMinimumHeight) / (parentMaximumHeight - parentMinimumHeight) * maxShort | 0,
348
- 0,
349
- maxShort
350
- );
351
- if (u < threshold) {
352
- u = 0;
353
- }
354
- if (v < threshold) {
355
- v = 0;
356
- }
357
- if (maxShort - u < threshold) {
358
- u = maxShort;
359
- }
360
- if (maxShort - v < threshold) {
361
- v = maxShort;
362
- }
363
- parentUBuffer[i] = u;
364
- parentVBuffer[i] = v;
365
- if (hasVertexNormals) {
366
- const encodedNormal = encoding.getOctEncodedNormal(
367
- parentVertices,
368
- i,
369
- octEncodedNormalScratch
370
- );
371
- parentNormalBuffer[n] = encodedNormal.x;
372
- parentNormalBuffer[n + 1] = encodedNormal.y;
373
- }
374
- if ((isEastChild && u >= halfMaxShort || !isEastChild && u <= halfMaxShort) && (isNorthChild && v >= halfMaxShort || !isNorthChild && v <= halfMaxShort)) {
375
- vertexMap[i] = vertexCount;
376
- uBuffer.push(u);
377
- vBuffer.push(v);
378
- heightBuffer.push(parentHeightBuffer[i]);
379
- if (hasVertexNormals) {
380
- normalBuffer.push(parentNormalBuffer[n]);
381
- normalBuffer.push(parentNormalBuffer[n + 1]);
382
- }
383
- ++vertexCount;
384
- }
385
- }
386
- const triangleVertices = [];
387
- triangleVertices.push(new Vertex());
388
- triangleVertices.push(new Vertex());
389
- triangleVertices.push(new Vertex());
390
- const clippedTriangleVertices = [];
391
- clippedTriangleVertices.push(new Vertex());
392
- clippedTriangleVertices.push(new Vertex());
393
- clippedTriangleVertices.push(new Vertex());
394
- let clippedIndex;
395
- let clipped2;
396
- for (i = 0; i < parentIndices.length; i += 3) {
397
- const i0 = parentIndices[i];
398
- const i1 = parentIndices[i + 1];
399
- const i2 = parentIndices[i + 2];
400
- const u0 = parentUBuffer[i0];
401
- const u1 = parentUBuffer[i1];
402
- const u2 = parentUBuffer[i2];
403
- triangleVertices[0].initializeIndexed(
404
- parentUBuffer,
405
- parentVBuffer,
406
- parentHeightBuffer,
407
- parentNormalBuffer,
408
- i0
409
- );
410
- triangleVertices[1].initializeIndexed(
411
- parentUBuffer,
412
- parentVBuffer,
413
- parentHeightBuffer,
414
- parentNormalBuffer,
415
- i1
416
- );
417
- triangleVertices[2].initializeIndexed(
418
- parentUBuffer,
419
- parentVBuffer,
420
- parentHeightBuffer,
421
- parentNormalBuffer,
422
- i2
423
- );
424
- const clipped = Intersections2D_default.clipTriangleAtAxisAlignedThreshold(
425
- halfMaxShort,
426
- isEastChild,
427
- u0,
428
- u1,
429
- u2,
430
- clipScratch
431
- );
432
- clippedIndex = 0;
433
- if (clippedIndex >= clipped.length) {
434
- continue;
435
- }
436
- clippedIndex = clippedTriangleVertices[0].initializeFromClipResult(
437
- clipped,
438
- clippedIndex,
439
- triangleVertices
440
- );
441
- if (clippedIndex >= clipped.length) {
442
- continue;
443
- }
444
- clippedIndex = clippedTriangleVertices[1].initializeFromClipResult(
445
- clipped,
446
- clippedIndex,
447
- triangleVertices
448
- );
449
- if (clippedIndex >= clipped.length) {
450
- continue;
451
- }
452
- clippedIndex = clippedTriangleVertices[2].initializeFromClipResult(
453
- clipped,
454
- clippedIndex,
455
- triangleVertices
456
- );
457
- clipped2 = Intersections2D_default.clipTriangleAtAxisAlignedThreshold(
458
- halfMaxShort,
459
- isNorthChild,
460
- clippedTriangleVertices[0].getV(),
461
- clippedTriangleVertices[1].getV(),
462
- clippedTriangleVertices[2].getV(),
463
- clipScratch2
464
- );
465
- addClippedPolygon(
466
- uBuffer,
467
- vBuffer,
468
- heightBuffer,
469
- normalBuffer,
470
- indices,
471
- vertexMap,
472
- clipped2,
473
- clippedTriangleVertices,
474
- hasVertexNormals
475
- );
476
- if (clippedIndex < clipped.length) {
477
- clippedTriangleVertices[2].clone(clippedTriangleVertices[1]);
478
- clippedTriangleVertices[2].initializeFromClipResult(
479
- clipped,
480
- clippedIndex,
481
- triangleVertices
482
- );
483
- clipped2 = Intersections2D_default.clipTriangleAtAxisAlignedThreshold(
484
- halfMaxShort,
485
- isNorthChild,
486
- clippedTriangleVertices[0].getV(),
487
- clippedTriangleVertices[1].getV(),
488
- clippedTriangleVertices[2].getV(),
489
- clipScratch2
490
- );
491
- addClippedPolygon(
492
- uBuffer,
493
- vBuffer,
494
- heightBuffer,
495
- normalBuffer,
496
- indices,
497
- vertexMap,
498
- clipped2,
499
- clippedTriangleVertices,
500
- hasVertexNormals
501
- );
502
- }
503
- }
504
- const uOffset = isEastChild ? -maxShort : 0;
505
- const vOffset = isNorthChild ? -maxShort : 0;
506
- const westIndices = [];
507
- const southIndices = [];
508
- const eastIndices = [];
509
- const northIndices = [];
510
- let minimumHeight = Number.MAX_VALUE;
511
- let maximumHeight = -minimumHeight;
512
- const cartesianVertices = verticesScratch;
513
- cartesianVertices.length = 0;
514
- const ellipsoid = Ellipsoid_default.clone(parameters.ellipsoid);
515
- const rectangle = Rectangle_default.clone(parameters.childRectangle);
516
- const north = rectangle.north;
517
- const south = rectangle.south;
518
- let east = rectangle.east;
519
- const west = rectangle.west;
520
- if (east < west) {
521
- east += Math_default.TWO_PI;
522
- }
523
- for (i = 0; i < uBuffer.length; ++i) {
524
- u = Math.round(uBuffer[i]);
525
- if (u <= minU) {
526
- westIndices.push(i);
527
- u = 0;
528
- } else if (u >= maxU) {
529
- eastIndices.push(i);
530
- u = maxShort;
531
- } else {
532
- u = u * 2 + uOffset;
533
- }
534
- uBuffer[i] = u;
535
- v = Math.round(vBuffer[i]);
536
- if (v <= minV) {
537
- southIndices.push(i);
538
- v = 0;
539
- } else if (v >= maxV) {
540
- northIndices.push(i);
541
- v = maxShort;
542
- } else {
543
- v = v * 2 + vOffset;
544
- }
545
- vBuffer[i] = v;
546
- height = Math_default.lerp(
547
- parentMinimumHeight,
548
- parentMaximumHeight,
549
- heightBuffer[i] / maxShort
550
- );
551
- if (height < minimumHeight) {
552
- minimumHeight = height;
553
- }
554
- if (height > maximumHeight) {
555
- maximumHeight = height;
556
- }
557
- heightBuffer[i] = height;
558
- cartographicScratch.longitude = Math_default.lerp(west, east, u / maxShort);
559
- cartographicScratch.latitude = Math_default.lerp(south, north, v / maxShort);
560
- cartographicScratch.height = height;
561
- ellipsoid.cartographicToCartesian(cartographicScratch, cartesian3Scratch);
562
- cartesianVertices.push(cartesian3Scratch.x);
563
- cartesianVertices.push(cartesian3Scratch.y);
564
- cartesianVertices.push(cartesian3Scratch.z);
565
- }
566
- const boundingSphere = BoundingSphere_default.fromVertices(
567
- cartesianVertices,
568
- Cartesian3_default.ZERO,
569
- 3,
570
- boundingSphereScratch
571
- );
572
- const orientedBoundingBox = OrientedBoundingBox_default.fromRectangle(
573
- rectangle,
574
- minimumHeight,
575
- maximumHeight,
576
- ellipsoid,
577
- orientedBoundingBoxScratch
578
- );
579
- const occluder = new EllipsoidalOccluder_default(ellipsoid);
580
- const horizonOcclusionPoint = occluder.computeHorizonCullingPointFromVerticesPossiblyUnderEllipsoid(
581
- boundingSphere.center,
582
- cartesianVertices,
583
- 3,
584
- boundingSphere.center,
585
- minimumHeight,
586
- horizonOcclusionPointScratch
587
- );
588
- const heightRange = maximumHeight - minimumHeight;
589
- const vertices = new Uint16Array(
590
- uBuffer.length + vBuffer.length + heightBuffer.length
591
- );
592
- for (i = 0; i < uBuffer.length; ++i) {
593
- vertices[i] = uBuffer[i];
594
- }
595
- let start = uBuffer.length;
596
- for (i = 0; i < vBuffer.length; ++i) {
597
- vertices[start + i] = vBuffer[i];
598
- }
599
- start += vBuffer.length;
600
- for (i = 0; i < heightBuffer.length; ++i) {
601
- vertices[start + i] = maxShort * (heightBuffer[i] - minimumHeight) / heightRange;
602
- }
603
- const indicesTypedArray = IndexDatatype_default.createTypedArray(
604
- uBuffer.length,
605
- indices
606
- );
607
- let encodedNormals;
608
- if (hasVertexNormals) {
609
- const normalArray = new Uint8Array(normalBuffer);
610
- transferableObjects.push(
611
- vertices.buffer,
612
- indicesTypedArray.buffer,
613
- normalArray.buffer
614
- );
615
- encodedNormals = normalArray.buffer;
616
- } else {
617
- transferableObjects.push(vertices.buffer, indicesTypedArray.buffer);
618
- }
619
- return {
620
- vertices: vertices.buffer,
621
- encodedNormals,
622
- indices: indicesTypedArray.buffer,
623
- minimumHeight,
624
- maximumHeight,
625
- westIndices,
626
- southIndices,
627
- eastIndices,
628
- northIndices,
629
- boundingSphere,
630
- orientedBoundingBox,
631
- horizonOcclusionPoint
632
- };
633
- }
634
- function Vertex() {
635
- this.vertexBuffer = void 0;
636
- this.index = void 0;
637
- this.first = void 0;
638
- this.second = void 0;
639
- this.ratio = void 0;
640
- }
641
- Vertex.prototype.clone = function(result) {
642
- if (!defined_default(result)) {
643
- result = new Vertex();
644
- }
645
- result.uBuffer = this.uBuffer;
646
- result.vBuffer = this.vBuffer;
647
- result.heightBuffer = this.heightBuffer;
648
- result.normalBuffer = this.normalBuffer;
649
- result.index = this.index;
650
- result.first = this.first;
651
- result.second = this.second;
652
- result.ratio = this.ratio;
653
- return result;
654
- };
655
- Vertex.prototype.initializeIndexed = function(uBuffer, vBuffer, heightBuffer, normalBuffer, index) {
656
- this.uBuffer = uBuffer;
657
- this.vBuffer = vBuffer;
658
- this.heightBuffer = heightBuffer;
659
- this.normalBuffer = normalBuffer;
660
- this.index = index;
661
- this.first = void 0;
662
- this.second = void 0;
663
- this.ratio = void 0;
664
- };
665
- Vertex.prototype.initializeFromClipResult = function(clipResult, index, vertices) {
666
- let nextIndex = index + 1;
667
- if (clipResult[index] !== -1) {
668
- vertices[clipResult[index]].clone(this);
669
- } else {
670
- this.vertexBuffer = void 0;
671
- this.index = void 0;
672
- this.first = vertices[clipResult[nextIndex]];
673
- ++nextIndex;
674
- this.second = vertices[clipResult[nextIndex]];
675
- ++nextIndex;
676
- this.ratio = clipResult[nextIndex];
677
- ++nextIndex;
678
- }
679
- return nextIndex;
680
- };
681
- Vertex.prototype.getKey = function() {
682
- if (this.isIndexed()) {
683
- return this.index;
684
- }
685
- return JSON.stringify({
686
- first: this.first.getKey(),
687
- second: this.second.getKey(),
688
- ratio: this.ratio
689
- });
690
- };
691
- Vertex.prototype.isIndexed = function() {
692
- return defined_default(this.index);
693
- };
694
- Vertex.prototype.getH = function() {
695
- if (defined_default(this.index)) {
696
- return this.heightBuffer[this.index];
697
- }
698
- return Math_default.lerp(this.first.getH(), this.second.getH(), this.ratio);
699
- };
700
- Vertex.prototype.getU = function() {
701
- if (defined_default(this.index)) {
702
- return this.uBuffer[this.index];
703
- }
704
- return Math_default.lerp(this.first.getU(), this.second.getU(), this.ratio);
705
- };
706
- Vertex.prototype.getV = function() {
707
- if (defined_default(this.index)) {
708
- return this.vBuffer[this.index];
709
- }
710
- return Math_default.lerp(this.first.getV(), this.second.getV(), this.ratio);
711
- };
712
- var encodedScratch = new Cartesian2_default();
713
- var depth = -1;
714
- var cartesianScratch1 = [new Cartesian3_default(), new Cartesian3_default()];
715
- var cartesianScratch2 = [new Cartesian3_default(), new Cartesian3_default()];
716
- function lerpOctEncodedNormal(vertex, result) {
717
- ++depth;
718
- let first = cartesianScratch1[depth];
719
- let second = cartesianScratch2[depth];
720
- first = AttributeCompression_default.octDecode(
721
- vertex.first.getNormalX(),
722
- vertex.first.getNormalY(),
723
- first
724
- );
725
- second = AttributeCompression_default.octDecode(
726
- vertex.second.getNormalX(),
727
- vertex.second.getNormalY(),
728
- second
729
- );
730
- cartesian3Scratch = Cartesian3_default.lerp(
731
- first,
732
- second,
733
- vertex.ratio,
734
- cartesian3Scratch
735
- );
736
- Cartesian3_default.normalize(cartesian3Scratch, cartesian3Scratch);
737
- AttributeCompression_default.octEncode(cartesian3Scratch, result);
738
- --depth;
739
- return result;
740
- }
741
- Vertex.prototype.getNormalX = function() {
742
- if (defined_default(this.index)) {
743
- return this.normalBuffer[this.index * 2];
744
- }
745
- encodedScratch = lerpOctEncodedNormal(this, encodedScratch);
746
- return encodedScratch.x;
747
- };
748
- Vertex.prototype.getNormalY = function() {
749
- if (defined_default(this.index)) {
750
- return this.normalBuffer[this.index * 2 + 1];
751
- }
752
- encodedScratch = lerpOctEncodedNormal(this, encodedScratch);
753
- return encodedScratch.y;
754
- };
755
- var polygonVertices = [];
756
- polygonVertices.push(new Vertex());
757
- polygonVertices.push(new Vertex());
758
- polygonVertices.push(new Vertex());
759
- polygonVertices.push(new Vertex());
760
- function addClippedPolygon(uBuffer, vBuffer, heightBuffer, normalBuffer, indices, vertexMap, clipped, triangleVertices, hasVertexNormals) {
761
- if (clipped.length === 0) {
762
- return;
763
- }
764
- let numVertices = 0;
765
- let clippedIndex = 0;
766
- while (clippedIndex < clipped.length) {
767
- clippedIndex = polygonVertices[numVertices++].initializeFromClipResult(
768
- clipped,
769
- clippedIndex,
770
- triangleVertices
771
- );
772
- }
773
- for (let i = 0; i < numVertices; ++i) {
774
- const polygonVertex = polygonVertices[i];
775
- if (!polygonVertex.isIndexed()) {
776
- const key = polygonVertex.getKey();
777
- if (defined_default(vertexMap[key])) {
778
- polygonVertex.newIndex = vertexMap[key];
779
- } else {
780
- const newIndex = uBuffer.length;
781
- uBuffer.push(polygonVertex.getU());
782
- vBuffer.push(polygonVertex.getV());
783
- heightBuffer.push(polygonVertex.getH());
784
- if (hasVertexNormals) {
785
- normalBuffer.push(polygonVertex.getNormalX());
786
- normalBuffer.push(polygonVertex.getNormalY());
787
- }
788
- polygonVertex.newIndex = newIndex;
789
- vertexMap[key] = newIndex;
790
- }
791
- } else {
792
- polygonVertex.newIndex = vertexMap[polygonVertex.index];
793
- polygonVertex.uBuffer = uBuffer;
794
- polygonVertex.vBuffer = vBuffer;
795
- polygonVertex.heightBuffer = heightBuffer;
796
- if (hasVertexNormals) {
797
- polygonVertex.normalBuffer = normalBuffer;
798
- }
799
- }
800
- }
801
- if (numVertices === 3) {
802
- indices.push(polygonVertices[0].newIndex);
803
- indices.push(polygonVertices[1].newIndex);
804
- indices.push(polygonVertices[2].newIndex);
805
- } else if (numVertices === 4) {
806
- indices.push(polygonVertices[0].newIndex);
807
- indices.push(polygonVertices[1].newIndex);
808
- indices.push(polygonVertices[2].newIndex);
809
- indices.push(polygonVertices[0].newIndex);
810
- indices.push(polygonVertices[2].newIndex);
811
- indices.push(polygonVertices[3].newIndex);
812
- }
813
- }
814
- var upsampleQuantizedTerrainMesh_default = createTaskProcessorWorker_default(upsampleQuantizedTerrainMesh);
815
- export {
816
- upsampleQuantizedTerrainMesh_default as default
817
- };
26
+ import{a as be,b as Ne}from"./chunk-7HTKERZY.js";import{a as Ae}from"./chunk-WZDE3RYP.js";import{a as ue}from"./chunk-CNCV5UL7.js";import{a as ee}from"./chunk-DEPHB2WM.js";import"./chunk-TCGIRNHN.js";import"./chunk-N4VJKXZS.js";import"./chunk-DMEY62ID.js";import"./chunk-HTFSEEMT.js";import{a as Ve}from"./chunk-OFUUQVMR.js";import{d as de}from"./chunk-4IW2T6GF.js";import{h as Se}from"./chunk-PSPPBZWI.js";import"./chunk-AU7IKHOH.js";import{a as A,b as Ie,c as Z,d as Ce}from"./chunk-64RSHJUE.js";import{a as N}from"./chunk-3SSKC3VN.js";import"./chunk-OSW76XDF.js";import"./chunk-ED5JPB3S.js";import{a as V,b as q}from"./chunk-LEYMRMBK.js";import{e as f}from"./chunk-VTAIKJXX.js";var ne={};ne.clipTriangleAtAxisAlignedThreshold=function(n,h,o,i,s,e){if(!f(n))throw new V("threshold is required.");if(!f(h))throw new V("keepAbove is required.");if(!f(o))throw new V("u0 is required.");if(!f(i))throw new V("u1 is required.");if(!f(s))throw new V("u2 is required.");f(e)?e.length=0:e=[];let g,w,c;h?(g=o<n,w=i<n,c=s<n):(g=o>n,w=i>n,c=s>n);let p=g+w+c,d,u,r,l,I,C;return p===1?g?(d=(n-o)/(i-o),u=(n-o)/(s-o),e.push(1),e.push(2),u!==1&&(e.push(-1),e.push(0),e.push(2),e.push(u)),d!==1&&(e.push(-1),e.push(0),e.push(1),e.push(d))):w?(r=(n-i)/(s-i),l=(n-i)/(o-i),e.push(2),e.push(0),l!==1&&(e.push(-1),e.push(1),e.push(0),e.push(l)),r!==1&&(e.push(-1),e.push(1),e.push(2),e.push(r))):c&&(I=(n-s)/(o-s),C=(n-s)/(i-s),e.push(0),e.push(1),C!==1&&(e.push(-1),e.push(2),e.push(1),e.push(C)),I!==1&&(e.push(-1),e.push(2),e.push(0),e.push(I))):p===2?!g&&o!==n?(l=(n-i)/(o-i),I=(n-s)/(o-s),e.push(0),e.push(-1),e.push(1),e.push(0),e.push(l),e.push(-1),e.push(2),e.push(0),e.push(I)):!w&&i!==n?(C=(n-s)/(i-s),d=(n-o)/(i-o),e.push(1),e.push(-1),e.push(2),e.push(1),e.push(C),e.push(-1),e.push(0),e.push(1),e.push(d)):!c&&s!==n&&(u=(n-o)/(s-o),r=(n-i)/(s-i),e.push(2),e.push(-1),e.push(0),e.push(2),e.push(u),e.push(-1),e.push(1),e.push(2),e.push(r)):p!==3&&(e.push(0),e.push(1),e.push(2)),e};ne.computeBarycentricCoordinates=function(n,h,o,i,s,e,g,w,c){if(!f(n))throw new V("x is required.");if(!f(h))throw new V("y is required.");if(!f(o))throw new V("x1 is required.");if(!f(i))throw new V("y1 is required.");if(!f(s))throw new V("x2 is required.");if(!f(e))throw new V("y2 is required.");if(!f(g))throw new V("x3 is required.");if(!f(w))throw new V("y3 is required.");let p=o-g,d=g-s,u=e-w,r=i-w,l=1/(u*p+d*r),I=h-w,C=n-g,R=(u*C+d*I)*l,O=(-r*C+p*I)*l,W=1-R-O;return f(c)?(c.x=R,c.y=O,c.z=W,c):new A(R,O,W)};ne.computeLineSegmentLineSegmentIntersection=function(n,h,o,i,s,e,g,w,c){q.typeOf.number("x00",n),q.typeOf.number("y00",h),q.typeOf.number("x01",o),q.typeOf.number("y01",i),q.typeOf.number("x10",s),q.typeOf.number("y10",e),q.typeOf.number("x11",g),q.typeOf.number("y11",w);let p=(g-s)*(h-e)-(w-e)*(n-s),d=(o-n)*(h-e)-(i-h)*(n-s),u=(w-e)*(o-n)-(g-s)*(i-h);if(u===0)return;let r=p/u,l=d/u;if(r>=0&&r<=1&&l>=0&&l<=1)return f(c)||(c=new Z),c.x=n+r*(o-n),c.y=h+r*(i-h),c};var ie=ne;var a=32767,z=a/2|0,Me=[],ze=[],Xe=[],te=new Ie,E=new A,Ke=[],We=[],Ye=[],Le=[],_e=[],Je=new A,Qe=new de,Ze=new ue,Ge=new Z,$e=new A;function je(n,h){let o=n.isEastChild,i=n.isNorthChild,s=o?z:0,e=o?a:z,g=i?z:0,w=i?a:z,c=Ke,p=We,d=Ye,u=_e;c.length=0,p.length=0,d.length=0,u.length=0;let r=Le;r.length=0;let l={},I=n.vertices,C=n.indices;C=C.subarray(0,n.indexCountWithoutSkirts);let R=Ne.clone(n.encoding),O=R.hasVertexNormals,W=0,Y=n.vertexCountWithoutSkirts,se=n.minimumHeight,ae=n.maximumHeight,D=new Array(Y),G=new Array(Y),L=new Array(Y),F=O?new Array(Y*2):void 0,$=20,H,t,k,x,y;for(t=0,k=0;t<Y;++t,k+=2){let v=R.decodeTextureCoordinates(I,t,Ge);if(H=R.decodeHeight(I,t),x=N.clamp(v.x*a|0,0,a),y=N.clamp(v.y*a|0,0,a),L[t]=N.clamp((H-se)/(ae-se)*a|0,0,a),x<$&&(x=0),y<$&&(y=0),a-x<$&&(x=a),a-y<$&&(y=a),D[t]=x,G[t]=y,O){let Q=R.getOctEncodedNormal(I,t,$e);F[k]=Q.x,F[k+1]=Q.y}(o&&x>=z||!o&&x<=z)&&(i&&y>=z||!i&&y<=z)&&(l[t]=W,c.push(x),p.push(y),d.push(L[t]),O&&(u.push(F[k]),u.push(F[k+1])),++W)}let T=[];T.push(new m),T.push(new m),T.push(new m);let B=[];B.push(new m),B.push(new m),B.push(new m);let b,j;for(t=0;t<C.length;t+=3){let v=C[t],Q=C[t+1],Be=C[t+2],De=D[v],Fe=D[Q],ke=D[Be];T[0].initializeIndexed(D,G,L,F,v),T[1].initializeIndexed(D,G,L,F,Q),T[2].initializeIndexed(D,G,L,F,Be);let P=ie.clipTriangleAtAxisAlignedThreshold(z,o,De,Fe,ke,Me);b=0,!(b>=P.length)&&(b=B[0].initializeFromClipResult(P,b,T),!(b>=P.length)&&(b=B[1].initializeFromClipResult(P,b,T),!(b>=P.length)&&(b=B[2].initializeFromClipResult(P,b,T),j=ie.clipTriangleAtAxisAlignedThreshold(z,i,B[0].getV(),B[1].getV(),B[2].getV(),ze),Oe(c,p,d,u,r,l,j,B,O),b<P.length&&(B[2].clone(B[1]),B[2].initializeFromClipResult(P,b,T),j=ie.clipTriangleAtAxisAlignedThreshold(z,i,B[0].getV(),B[1].getV(),B[2].getV(),ze),Oe(c,p,d,u,r,l,j,B,O)))))}let He=o?-a:0,qe=i?-a:0,me=[],ge=[],le=[],we=[],U=Number.MAX_VALUE,_=-U,M=Xe;M.length=0;let re=Ce.clone(n.ellipsoid),J=Se.clone(n.childRectangle),Ee=J.north,Re=J.south,ce=J.east,xe=J.west;for(ce<xe&&(ce+=N.TWO_PI),t=0;t<c.length;++t)x=Math.round(c[t]),x<=s?(me.push(t),x=0):x>=e?(le.push(t),x=a):x=x*2+He,c[t]=x,y=Math.round(p[t]),y<=g?(ge.push(t),y=0):y>=w?(we.push(t),y=a):y=y*2+qe,p[t]=y,H=N.lerp(se,ae,d[t]/a),H<U&&(U=H),H>_&&(_=H),d[t]=H,te.longitude=N.lerp(xe,ce,x/a),te.latitude=N.lerp(Re,Ee,y/a),te.height=H,re.cartographicToCartesian(te,E),M.push(E.x),M.push(E.y),M.push(E.z);let he=de.fromVertices(M,A.ZERO,3,Qe),Ue=ue.fromRectangle(J,U,_,re,Ze),ve=new be(re).computeHorizonCullingPointFromVerticesPossiblyUnderEllipsoid(he.center,M,3,he.center,U,Je),Pe=_-U,X=new Uint16Array(c.length+p.length+d.length);for(t=0;t<c.length;++t)X[t]=c[t];let fe=c.length;for(t=0;t<p.length;++t)X[fe+t]=p[t];for(fe+=p.length,t=0;t<d.length;++t)X[fe+t]=a*(d[t]-U)/Pe;let pe=Ve.createTypedArray(c.length,r),ye;if(O){let v=new Uint8Array(u);h.push(X.buffer,pe.buffer,v.buffer),ye=v.buffer}else h.push(X.buffer,pe.buffer);return{vertices:X.buffer,encodedNormals:ye,indices:pe.buffer,minimumHeight:U,maximumHeight:_,westIndices:me,southIndices:ge,eastIndices:le,northIndices:we,boundingSphere:he,orientedBoundingBox:Ue,horizonOcclusionPoint:ve}}function m(){this.vertexBuffer=void 0,this.index=void 0,this.first=void 0,this.second=void 0,this.ratio=void 0}m.prototype.clone=function(n){return f(n)||(n=new m),n.uBuffer=this.uBuffer,n.vBuffer=this.vBuffer,n.heightBuffer=this.heightBuffer,n.normalBuffer=this.normalBuffer,n.index=this.index,n.first=this.first,n.second=this.second,n.ratio=this.ratio,n};m.prototype.initializeIndexed=function(n,h,o,i,s){this.uBuffer=n,this.vBuffer=h,this.heightBuffer=o,this.normalBuffer=i,this.index=s,this.first=void 0,this.second=void 0,this.ratio=void 0};m.prototype.initializeFromClipResult=function(n,h,o){let i=h+1;return n[h]!==-1?o[n[h]].clone(this):(this.vertexBuffer=void 0,this.index=void 0,this.first=o[n[i]],++i,this.second=o[n[i]],++i,this.ratio=n[i],++i),i};m.prototype.getKey=function(){return this.isIndexed()?this.index:JSON.stringify({first:this.first.getKey(),second:this.second.getKey(),ratio:this.ratio})};m.prototype.isIndexed=function(){return f(this.index)};m.prototype.getH=function(){return f(this.index)?this.heightBuffer[this.index]:N.lerp(this.first.getH(),this.second.getH(),this.ratio)};m.prototype.getU=function(){return f(this.index)?this.uBuffer[this.index]:N.lerp(this.first.getU(),this.second.getU(),this.ratio)};m.prototype.getV=function(){return f(this.index)?this.vBuffer[this.index]:N.lerp(this.first.getV(),this.second.getV(),this.ratio)};var K=new Z,oe=-1,en=[new A,new A],nn=[new A,new A];function Te(n,h){++oe;let o=en[oe],i=nn[oe];return o=ee.octDecode(n.first.getNormalX(),n.first.getNormalY(),o),i=ee.octDecode(n.second.getNormalX(),n.second.getNormalY(),i),E=A.lerp(o,i,n.ratio,E),A.normalize(E,E),ee.octEncode(E,h),--oe,h}m.prototype.getNormalX=function(){return f(this.index)?this.normalBuffer[this.index*2]:(K=Te(this,K),K.x)};m.prototype.getNormalY=function(){return f(this.index)?this.normalBuffer[this.index*2+1]:(K=Te(this,K),K.y)};var S=[];S.push(new m);S.push(new m);S.push(new m);S.push(new m);function Oe(n,h,o,i,s,e,g,w,c){if(g.length===0)return;let p=0,d=0;for(;d<g.length;)d=S[p++].initializeFromClipResult(g,d,w);for(let u=0;u<p;++u){let r=S[u];if(r.isIndexed())r.newIndex=e[r.index],r.uBuffer=n,r.vBuffer=h,r.heightBuffer=o,c&&(r.normalBuffer=i);else{let l=r.getKey();if(f(e[l]))r.newIndex=e[l];else{let I=n.length;n.push(r.getU()),h.push(r.getV()),o.push(r.getH()),c&&(i.push(r.getNormalX()),i.push(r.getNormalY())),r.newIndex=I,e[l]=I}}}p===3?(s.push(S[0].newIndex),s.push(S[1].newIndex),s.push(S[2].newIndex)):p===4&&(s.push(S[0].newIndex),s.push(S[1].newIndex),s.push(S[2].newIndex),s.push(S[0].newIndex),s.push(S[2].newIndex),s.push(S[3].newIndex))}var An=Ae(je);export{An as default};