@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,820 +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
- EllipsoidalOccluder_default,
28
- TerrainEncoding_default
29
- } from "./chunk-OFJRMGNX.js";
30
- import {
31
- createTaskProcessorWorker_default
32
- } from "./chunk-TSAJNE4K.js";
33
- import {
34
- OrientedBoundingBox_default
35
- } from "./chunk-25BA4527.js";
36
- import {
37
- AttributeCompression_default
38
- } from "./chunk-6LZBBEA7.js";
39
- import "./chunk-WAS3IHIQ.js";
40
- import "./chunk-K4IMD7KH.js";
41
- import "./chunk-66YGZWBI.js";
42
- import "./chunk-J4MIJCN5.js";
43
- import {
44
- IndexDatatype_default
45
- } from "./chunk-55IROWAX.js";
46
- import {
47
- BoundingSphere_default
48
- } from "./chunk-OAOREOSO.js";
49
- import "./chunk-EKMWNF4U.js";
50
- import {
51
- Rectangle_default
52
- } from "./chunk-KQIZ7AFF.js";
53
- import "./chunk-POY6ZE32.js";
54
- import "./chunk-AL22JVIA.js";
55
- import "./chunk-5VZISKJF.js";
56
- import "./chunk-UYT2PBMV.js";
57
- import {
58
- Cartesian2_default,
59
- Cartographic_default,
60
- Ellipsoid_default
61
- } from "./chunk-YPGJSFOO.js";
62
- import {
63
- Cartesian3_default
64
- } from "./chunk-QWV2DM66.js";
65
- import {
66
- Math_default
67
- } from "./chunk-6XJO625E.js";
68
- import {
69
- Check_default,
70
- DeveloperError_default
71
- } from "./chunk-KH2OWUUA.js";
72
- import {
73
- defined_default
74
- } from "./chunk-AVSQILVI.js";
75
-
76
- // packages/engine/Source/Core/Intersections2D.js
77
- var Intersections2D = {};
78
- Intersections2D.clipTriangleAtAxisAlignedThreshold = function(threshold, keepAbove, u0, u1, u2, result) {
79
- if (!defined_default(threshold)) {
80
- throw new DeveloperError_default("threshold is required.");
81
- }
82
- if (!defined_default(keepAbove)) {
83
- throw new DeveloperError_default("keepAbove is required.");
84
- }
85
- if (!defined_default(u0)) {
86
- throw new DeveloperError_default("u0 is required.");
87
- }
88
- if (!defined_default(u1)) {
89
- throw new DeveloperError_default("u1 is required.");
90
- }
91
- if (!defined_default(u2)) {
92
- throw new DeveloperError_default("u2 is required.");
93
- }
94
- if (!defined_default(result)) {
95
- result = [];
96
- } else {
97
- result.length = 0;
98
- }
99
- let u0Behind;
100
- let u1Behind;
101
- let u2Behind;
102
- if (keepAbove) {
103
- u0Behind = u0 < threshold;
104
- u1Behind = u1 < threshold;
105
- u2Behind = u2 < threshold;
106
- } else {
107
- u0Behind = u0 > threshold;
108
- u1Behind = u1 > threshold;
109
- u2Behind = u2 > threshold;
110
- }
111
- const numBehind = u0Behind + u1Behind + u2Behind;
112
- let u01Ratio;
113
- let u02Ratio;
114
- let u12Ratio;
115
- let u10Ratio;
116
- let u20Ratio;
117
- let u21Ratio;
118
- if (numBehind === 1) {
119
- if (u0Behind) {
120
- u01Ratio = (threshold - u0) / (u1 - u0);
121
- u02Ratio = (threshold - u0) / (u2 - u0);
122
- result.push(1);
123
- result.push(2);
124
- if (u02Ratio !== 1) {
125
- result.push(-1);
126
- result.push(0);
127
- result.push(2);
128
- result.push(u02Ratio);
129
- }
130
- if (u01Ratio !== 1) {
131
- result.push(-1);
132
- result.push(0);
133
- result.push(1);
134
- result.push(u01Ratio);
135
- }
136
- } else if (u1Behind) {
137
- u12Ratio = (threshold - u1) / (u2 - u1);
138
- u10Ratio = (threshold - u1) / (u0 - u1);
139
- result.push(2);
140
- result.push(0);
141
- if (u10Ratio !== 1) {
142
- result.push(-1);
143
- result.push(1);
144
- result.push(0);
145
- result.push(u10Ratio);
146
- }
147
- if (u12Ratio !== 1) {
148
- result.push(-1);
149
- result.push(1);
150
- result.push(2);
151
- result.push(u12Ratio);
152
- }
153
- } else if (u2Behind) {
154
- u20Ratio = (threshold - u2) / (u0 - u2);
155
- u21Ratio = (threshold - u2) / (u1 - u2);
156
- result.push(0);
157
- result.push(1);
158
- if (u21Ratio !== 1) {
159
- result.push(-1);
160
- result.push(2);
161
- result.push(1);
162
- result.push(u21Ratio);
163
- }
164
- if (u20Ratio !== 1) {
165
- result.push(-1);
166
- result.push(2);
167
- result.push(0);
168
- result.push(u20Ratio);
169
- }
170
- }
171
- } else if (numBehind === 2) {
172
- if (!u0Behind && u0 !== threshold) {
173
- u10Ratio = (threshold - u1) / (u0 - u1);
174
- u20Ratio = (threshold - u2) / (u0 - u2);
175
- result.push(0);
176
- result.push(-1);
177
- result.push(1);
178
- result.push(0);
179
- result.push(u10Ratio);
180
- result.push(-1);
181
- result.push(2);
182
- result.push(0);
183
- result.push(u20Ratio);
184
- } else if (!u1Behind && u1 !== threshold) {
185
- u21Ratio = (threshold - u2) / (u1 - u2);
186
- u01Ratio = (threshold - u0) / (u1 - u0);
187
- result.push(1);
188
- result.push(-1);
189
- result.push(2);
190
- result.push(1);
191
- result.push(u21Ratio);
192
- result.push(-1);
193
- result.push(0);
194
- result.push(1);
195
- result.push(u01Ratio);
196
- } else if (!u2Behind && u2 !== threshold) {
197
- u02Ratio = (threshold - u0) / (u2 - u0);
198
- u12Ratio = (threshold - u1) / (u2 - u1);
199
- result.push(2);
200
- result.push(-1);
201
- result.push(0);
202
- result.push(2);
203
- result.push(u02Ratio);
204
- result.push(-1);
205
- result.push(1);
206
- result.push(2);
207
- result.push(u12Ratio);
208
- }
209
- } else if (numBehind !== 3) {
210
- result.push(0);
211
- result.push(1);
212
- result.push(2);
213
- }
214
- return result;
215
- };
216
- Intersections2D.computeBarycentricCoordinates = function(x, y, x1, y1, x2, y2, x3, y3, result) {
217
- if (!defined_default(x)) {
218
- throw new DeveloperError_default("x is required.");
219
- }
220
- if (!defined_default(y)) {
221
- throw new DeveloperError_default("y is required.");
222
- }
223
- if (!defined_default(x1)) {
224
- throw new DeveloperError_default("x1 is required.");
225
- }
226
- if (!defined_default(y1)) {
227
- throw new DeveloperError_default("y1 is required.");
228
- }
229
- if (!defined_default(x2)) {
230
- throw new DeveloperError_default("x2 is required.");
231
- }
232
- if (!defined_default(y2)) {
233
- throw new DeveloperError_default("y2 is required.");
234
- }
235
- if (!defined_default(x3)) {
236
- throw new DeveloperError_default("x3 is required.");
237
- }
238
- if (!defined_default(y3)) {
239
- throw new DeveloperError_default("y3 is required.");
240
- }
241
- const x1mx3 = x1 - x3;
242
- const x3mx2 = x3 - x2;
243
- const y2my3 = y2 - y3;
244
- const y1my3 = y1 - y3;
245
- const inverseDeterminant = 1 / (y2my3 * x1mx3 + x3mx2 * y1my3);
246
- const ymy3 = y - y3;
247
- const xmx3 = x - x3;
248
- const l1 = (y2my3 * xmx3 + x3mx2 * ymy3) * inverseDeterminant;
249
- const l2 = (-y1my3 * xmx3 + x1mx3 * ymy3) * inverseDeterminant;
250
- const l3 = 1 - l1 - l2;
251
- if (defined_default(result)) {
252
- result.x = l1;
253
- result.y = l2;
254
- result.z = l3;
255
- return result;
256
- }
257
- return new Cartesian3_default(l1, l2, l3);
258
- };
259
- Intersections2D.computeLineSegmentLineSegmentIntersection = function(x00, y00, x01, y01, x10, y10, x11, y11, result) {
260
- Check_default.typeOf.number("x00", x00);
261
- Check_default.typeOf.number("y00", y00);
262
- Check_default.typeOf.number("x01", x01);
263
- Check_default.typeOf.number("y01", y01);
264
- Check_default.typeOf.number("x10", x10);
265
- Check_default.typeOf.number("y10", y10);
266
- Check_default.typeOf.number("x11", x11);
267
- Check_default.typeOf.number("y11", y11);
268
- const numerator1A = (x11 - x10) * (y00 - y10) - (y11 - y10) * (x00 - x10);
269
- const numerator1B = (x01 - x00) * (y00 - y10) - (y01 - y00) * (x00 - x10);
270
- const denominator1 = (y11 - y10) * (x01 - x00) - (x11 - x10) * (y01 - y00);
271
- if (denominator1 === 0) {
272
- return;
273
- }
274
- const ua1 = numerator1A / denominator1;
275
- const ub1 = numerator1B / denominator1;
276
- if (ua1 >= 0 && ua1 <= 1 && ub1 >= 0 && ub1 <= 1) {
277
- if (!defined_default(result)) {
278
- result = new Cartesian2_default();
279
- }
280
- result.x = x00 + ua1 * (x01 - x00);
281
- result.y = y00 + ua1 * (y01 - y00);
282
- return result;
283
- }
284
- };
285
- var Intersections2D_default = Intersections2D;
286
-
287
- // packages/engine/Source/Workers/upsampleQuantizedTerrainMesh.js
288
- var maxShort = 32767;
289
- var halfMaxShort = maxShort / 2 | 0;
290
- var clipScratch = [];
291
- var clipScratch2 = [];
292
- var verticesScratch = [];
293
- var cartographicScratch = new Cartographic_default();
294
- var cartesian3Scratch = new Cartesian3_default();
295
- var uScratch = [];
296
- var vScratch = [];
297
- var heightScratch = [];
298
- var indicesScratch = [];
299
- var normalsScratch = [];
300
- var horizonOcclusionPointScratch = new Cartesian3_default();
301
- var boundingSphereScratch = new BoundingSphere_default();
302
- var orientedBoundingBoxScratch = new OrientedBoundingBox_default();
303
- var decodeTexCoordsScratch = new Cartesian2_default();
304
- var octEncodedNormalScratch = new Cartesian3_default();
305
- function upsampleQuantizedTerrainMesh(parameters, transferableObjects) {
306
- const isEastChild = parameters.isEastChild;
307
- const isNorthChild = parameters.isNorthChild;
308
- const minU = isEastChild ? halfMaxShort : 0;
309
- const maxU = isEastChild ? maxShort : halfMaxShort;
310
- const minV = isNorthChild ? halfMaxShort : 0;
311
- const maxV = isNorthChild ? maxShort : halfMaxShort;
312
- const uBuffer = uScratch;
313
- const vBuffer = vScratch;
314
- const heightBuffer = heightScratch;
315
- const normalBuffer = normalsScratch;
316
- uBuffer.length = 0;
317
- vBuffer.length = 0;
318
- heightBuffer.length = 0;
319
- normalBuffer.length = 0;
320
- const indices = indicesScratch;
321
- indices.length = 0;
322
- const vertexMap = {};
323
- const parentVertices = parameters.vertices;
324
- let parentIndices = parameters.indices;
325
- parentIndices = parentIndices.subarray(0, parameters.indexCountWithoutSkirts);
326
- const encoding = TerrainEncoding_default.clone(parameters.encoding);
327
- const hasVertexNormals = encoding.hasVertexNormals;
328
- let vertexCount = 0;
329
- const quantizedVertexCount = parameters.vertexCountWithoutSkirts;
330
- const parentMinimumHeight = parameters.minimumHeight;
331
- const parentMaximumHeight = parameters.maximumHeight;
332
- const parentUBuffer = new Array(quantizedVertexCount);
333
- const parentVBuffer = new Array(quantizedVertexCount);
334
- const parentHeightBuffer = new Array(quantizedVertexCount);
335
- const parentNormalBuffer = hasVertexNormals ? new Array(quantizedVertexCount * 2) : void 0;
336
- const threshold = 20;
337
- let height;
338
- let i, n;
339
- let u, v;
340
- for (i = 0, n = 0; i < quantizedVertexCount; ++i, n += 2) {
341
- const texCoords = encoding.decodeTextureCoordinates(
342
- parentVertices,
343
- i,
344
- decodeTexCoordsScratch
345
- );
346
- height = encoding.decodeHeight(parentVertices, i);
347
- u = Math_default.clamp(texCoords.x * maxShort | 0, 0, maxShort);
348
- v = Math_default.clamp(texCoords.y * maxShort | 0, 0, maxShort);
349
- parentHeightBuffer[i] = Math_default.clamp(
350
- (height - parentMinimumHeight) / (parentMaximumHeight - parentMinimumHeight) * maxShort | 0,
351
- 0,
352
- maxShort
353
- );
354
- if (u < threshold) {
355
- u = 0;
356
- }
357
- if (v < threshold) {
358
- v = 0;
359
- }
360
- if (maxShort - u < threshold) {
361
- u = maxShort;
362
- }
363
- if (maxShort - v < threshold) {
364
- v = maxShort;
365
- }
366
- parentUBuffer[i] = u;
367
- parentVBuffer[i] = v;
368
- if (hasVertexNormals) {
369
- const encodedNormal = encoding.getOctEncodedNormal(
370
- parentVertices,
371
- i,
372
- octEncodedNormalScratch
373
- );
374
- parentNormalBuffer[n] = encodedNormal.x;
375
- parentNormalBuffer[n + 1] = encodedNormal.y;
376
- }
377
- if ((isEastChild && u >= halfMaxShort || !isEastChild && u <= halfMaxShort) && (isNorthChild && v >= halfMaxShort || !isNorthChild && v <= halfMaxShort)) {
378
- vertexMap[i] = vertexCount;
379
- uBuffer.push(u);
380
- vBuffer.push(v);
381
- heightBuffer.push(parentHeightBuffer[i]);
382
- if (hasVertexNormals) {
383
- normalBuffer.push(parentNormalBuffer[n]);
384
- normalBuffer.push(parentNormalBuffer[n + 1]);
385
- }
386
- ++vertexCount;
387
- }
388
- }
389
- const triangleVertices = [];
390
- triangleVertices.push(new Vertex());
391
- triangleVertices.push(new Vertex());
392
- triangleVertices.push(new Vertex());
393
- const clippedTriangleVertices = [];
394
- clippedTriangleVertices.push(new Vertex());
395
- clippedTriangleVertices.push(new Vertex());
396
- clippedTriangleVertices.push(new Vertex());
397
- let clippedIndex;
398
- let clipped2;
399
- for (i = 0; i < parentIndices.length; i += 3) {
400
- const i0 = parentIndices[i];
401
- const i1 = parentIndices[i + 1];
402
- const i2 = parentIndices[i + 2];
403
- const u0 = parentUBuffer[i0];
404
- const u1 = parentUBuffer[i1];
405
- const u2 = parentUBuffer[i2];
406
- triangleVertices[0].initializeIndexed(
407
- parentUBuffer,
408
- parentVBuffer,
409
- parentHeightBuffer,
410
- parentNormalBuffer,
411
- i0
412
- );
413
- triangleVertices[1].initializeIndexed(
414
- parentUBuffer,
415
- parentVBuffer,
416
- parentHeightBuffer,
417
- parentNormalBuffer,
418
- i1
419
- );
420
- triangleVertices[2].initializeIndexed(
421
- parentUBuffer,
422
- parentVBuffer,
423
- parentHeightBuffer,
424
- parentNormalBuffer,
425
- i2
426
- );
427
- const clipped = Intersections2D_default.clipTriangleAtAxisAlignedThreshold(
428
- halfMaxShort,
429
- isEastChild,
430
- u0,
431
- u1,
432
- u2,
433
- clipScratch
434
- );
435
- clippedIndex = 0;
436
- if (clippedIndex >= clipped.length) {
437
- continue;
438
- }
439
- clippedIndex = clippedTriangleVertices[0].initializeFromClipResult(
440
- clipped,
441
- clippedIndex,
442
- triangleVertices
443
- );
444
- if (clippedIndex >= clipped.length) {
445
- continue;
446
- }
447
- clippedIndex = clippedTriangleVertices[1].initializeFromClipResult(
448
- clipped,
449
- clippedIndex,
450
- triangleVertices
451
- );
452
- if (clippedIndex >= clipped.length) {
453
- continue;
454
- }
455
- clippedIndex = clippedTriangleVertices[2].initializeFromClipResult(
456
- clipped,
457
- clippedIndex,
458
- triangleVertices
459
- );
460
- clipped2 = Intersections2D_default.clipTriangleAtAxisAlignedThreshold(
461
- halfMaxShort,
462
- isNorthChild,
463
- clippedTriangleVertices[0].getV(),
464
- clippedTriangleVertices[1].getV(),
465
- clippedTriangleVertices[2].getV(),
466
- clipScratch2
467
- );
468
- addClippedPolygon(
469
- uBuffer,
470
- vBuffer,
471
- heightBuffer,
472
- normalBuffer,
473
- indices,
474
- vertexMap,
475
- clipped2,
476
- clippedTriangleVertices,
477
- hasVertexNormals
478
- );
479
- if (clippedIndex < clipped.length) {
480
- clippedTriangleVertices[2].clone(clippedTriangleVertices[1]);
481
- clippedTriangleVertices[2].initializeFromClipResult(
482
- clipped,
483
- clippedIndex,
484
- triangleVertices
485
- );
486
- clipped2 = Intersections2D_default.clipTriangleAtAxisAlignedThreshold(
487
- halfMaxShort,
488
- isNorthChild,
489
- clippedTriangleVertices[0].getV(),
490
- clippedTriangleVertices[1].getV(),
491
- clippedTriangleVertices[2].getV(),
492
- clipScratch2
493
- );
494
- addClippedPolygon(
495
- uBuffer,
496
- vBuffer,
497
- heightBuffer,
498
- normalBuffer,
499
- indices,
500
- vertexMap,
501
- clipped2,
502
- clippedTriangleVertices,
503
- hasVertexNormals
504
- );
505
- }
506
- }
507
- const uOffset = isEastChild ? -maxShort : 0;
508
- const vOffset = isNorthChild ? -maxShort : 0;
509
- const westIndices = [];
510
- const southIndices = [];
511
- const eastIndices = [];
512
- const northIndices = [];
513
- let minimumHeight = Number.MAX_VALUE;
514
- let maximumHeight = -minimumHeight;
515
- const cartesianVertices = verticesScratch;
516
- cartesianVertices.length = 0;
517
- const ellipsoid = Ellipsoid_default.clone(parameters.ellipsoid);
518
- const rectangle = Rectangle_default.clone(parameters.childRectangle);
519
- const north = rectangle.north;
520
- const south = rectangle.south;
521
- let east = rectangle.east;
522
- const west = rectangle.west;
523
- if (east < west) {
524
- east += Math_default.TWO_PI;
525
- }
526
- for (i = 0; i < uBuffer.length; ++i) {
527
- u = Math.round(uBuffer[i]);
528
- if (u <= minU) {
529
- westIndices.push(i);
530
- u = 0;
531
- } else if (u >= maxU) {
532
- eastIndices.push(i);
533
- u = maxShort;
534
- } else {
535
- u = u * 2 + uOffset;
536
- }
537
- uBuffer[i] = u;
538
- v = Math.round(vBuffer[i]);
539
- if (v <= minV) {
540
- southIndices.push(i);
541
- v = 0;
542
- } else if (v >= maxV) {
543
- northIndices.push(i);
544
- v = maxShort;
545
- } else {
546
- v = v * 2 + vOffset;
547
- }
548
- vBuffer[i] = v;
549
- height = Math_default.lerp(
550
- parentMinimumHeight,
551
- parentMaximumHeight,
552
- heightBuffer[i] / maxShort
553
- );
554
- if (height < minimumHeight) {
555
- minimumHeight = height;
556
- }
557
- if (height > maximumHeight) {
558
- maximumHeight = height;
559
- }
560
- heightBuffer[i] = height;
561
- cartographicScratch.longitude = Math_default.lerp(west, east, u / maxShort);
562
- cartographicScratch.latitude = Math_default.lerp(south, north, v / maxShort);
563
- cartographicScratch.height = height;
564
- ellipsoid.cartographicToCartesian(cartographicScratch, cartesian3Scratch);
565
- cartesianVertices.push(cartesian3Scratch.x);
566
- cartesianVertices.push(cartesian3Scratch.y);
567
- cartesianVertices.push(cartesian3Scratch.z);
568
- }
569
- const boundingSphere = BoundingSphere_default.fromVertices(
570
- cartesianVertices,
571
- Cartesian3_default.ZERO,
572
- 3,
573
- boundingSphereScratch
574
- );
575
- const orientedBoundingBox = OrientedBoundingBox_default.fromRectangle(
576
- rectangle,
577
- minimumHeight,
578
- maximumHeight,
579
- ellipsoid,
580
- orientedBoundingBoxScratch
581
- );
582
- const occluder = new EllipsoidalOccluder_default(ellipsoid);
583
- const horizonOcclusionPoint = occluder.computeHorizonCullingPointFromVerticesPossiblyUnderEllipsoid(
584
- boundingSphere.center,
585
- cartesianVertices,
586
- 3,
587
- boundingSphere.center,
588
- minimumHeight,
589
- horizonOcclusionPointScratch
590
- );
591
- const heightRange = maximumHeight - minimumHeight;
592
- const vertices = new Uint16Array(
593
- uBuffer.length + vBuffer.length + heightBuffer.length
594
- );
595
- for (i = 0; i < uBuffer.length; ++i) {
596
- vertices[i] = uBuffer[i];
597
- }
598
- let start = uBuffer.length;
599
- for (i = 0; i < vBuffer.length; ++i) {
600
- vertices[start + i] = vBuffer[i];
601
- }
602
- start += vBuffer.length;
603
- for (i = 0; i < heightBuffer.length; ++i) {
604
- vertices[start + i] = maxShort * (heightBuffer[i] - minimumHeight) / heightRange;
605
- }
606
- const indicesTypedArray = IndexDatatype_default.createTypedArray(
607
- uBuffer.length,
608
- indices
609
- );
610
- let encodedNormals;
611
- if (hasVertexNormals) {
612
- const normalArray = new Uint8Array(normalBuffer);
613
- transferableObjects.push(
614
- vertices.buffer,
615
- indicesTypedArray.buffer,
616
- normalArray.buffer
617
- );
618
- encodedNormals = normalArray.buffer;
619
- } else {
620
- transferableObjects.push(vertices.buffer, indicesTypedArray.buffer);
621
- }
622
- return {
623
- vertices: vertices.buffer,
624
- encodedNormals,
625
- indices: indicesTypedArray.buffer,
626
- minimumHeight,
627
- maximumHeight,
628
- westIndices,
629
- southIndices,
630
- eastIndices,
631
- northIndices,
632
- boundingSphere,
633
- orientedBoundingBox,
634
- horizonOcclusionPoint
635
- };
636
- }
637
- function Vertex() {
638
- this.vertexBuffer = void 0;
639
- this.index = void 0;
640
- this.first = void 0;
641
- this.second = void 0;
642
- this.ratio = void 0;
643
- }
644
- Vertex.prototype.clone = function(result) {
645
- if (!defined_default(result)) {
646
- result = new Vertex();
647
- }
648
- result.uBuffer = this.uBuffer;
649
- result.vBuffer = this.vBuffer;
650
- result.heightBuffer = this.heightBuffer;
651
- result.normalBuffer = this.normalBuffer;
652
- result.index = this.index;
653
- result.first = this.first;
654
- result.second = this.second;
655
- result.ratio = this.ratio;
656
- return result;
657
- };
658
- Vertex.prototype.initializeIndexed = function(uBuffer, vBuffer, heightBuffer, normalBuffer, index) {
659
- this.uBuffer = uBuffer;
660
- this.vBuffer = vBuffer;
661
- this.heightBuffer = heightBuffer;
662
- this.normalBuffer = normalBuffer;
663
- this.index = index;
664
- this.first = void 0;
665
- this.second = void 0;
666
- this.ratio = void 0;
667
- };
668
- Vertex.prototype.initializeFromClipResult = function(clipResult, index, vertices) {
669
- let nextIndex = index + 1;
670
- if (clipResult[index] !== -1) {
671
- vertices[clipResult[index]].clone(this);
672
- } else {
673
- this.vertexBuffer = void 0;
674
- this.index = void 0;
675
- this.first = vertices[clipResult[nextIndex]];
676
- ++nextIndex;
677
- this.second = vertices[clipResult[nextIndex]];
678
- ++nextIndex;
679
- this.ratio = clipResult[nextIndex];
680
- ++nextIndex;
681
- }
682
- return nextIndex;
683
- };
684
- Vertex.prototype.getKey = function() {
685
- if (this.isIndexed()) {
686
- return this.index;
687
- }
688
- return JSON.stringify({
689
- first: this.first.getKey(),
690
- second: this.second.getKey(),
691
- ratio: this.ratio
692
- });
693
- };
694
- Vertex.prototype.isIndexed = function() {
695
- return defined_default(this.index);
696
- };
697
- Vertex.prototype.getH = function() {
698
- if (defined_default(this.index)) {
699
- return this.heightBuffer[this.index];
700
- }
701
- return Math_default.lerp(this.first.getH(), this.second.getH(), this.ratio);
702
- };
703
- Vertex.prototype.getU = function() {
704
- if (defined_default(this.index)) {
705
- return this.uBuffer[this.index];
706
- }
707
- return Math_default.lerp(this.first.getU(), this.second.getU(), this.ratio);
708
- };
709
- Vertex.prototype.getV = function() {
710
- if (defined_default(this.index)) {
711
- return this.vBuffer[this.index];
712
- }
713
- return Math_default.lerp(this.first.getV(), this.second.getV(), this.ratio);
714
- };
715
- var encodedScratch = new Cartesian2_default();
716
- var depth = -1;
717
- var cartesianScratch1 = [new Cartesian3_default(), new Cartesian3_default()];
718
- var cartesianScratch2 = [new Cartesian3_default(), new Cartesian3_default()];
719
- function lerpOctEncodedNormal(vertex, result) {
720
- ++depth;
721
- let first = cartesianScratch1[depth];
722
- let second = cartesianScratch2[depth];
723
- first = AttributeCompression_default.octDecode(
724
- vertex.first.getNormalX(),
725
- vertex.first.getNormalY(),
726
- first
727
- );
728
- second = AttributeCompression_default.octDecode(
729
- vertex.second.getNormalX(),
730
- vertex.second.getNormalY(),
731
- second
732
- );
733
- cartesian3Scratch = Cartesian3_default.lerp(
734
- first,
735
- second,
736
- vertex.ratio,
737
- cartesian3Scratch
738
- );
739
- Cartesian3_default.normalize(cartesian3Scratch, cartesian3Scratch);
740
- AttributeCompression_default.octEncode(cartesian3Scratch, result);
741
- --depth;
742
- return result;
743
- }
744
- Vertex.prototype.getNormalX = function() {
745
- if (defined_default(this.index)) {
746
- return this.normalBuffer[this.index * 2];
747
- }
748
- encodedScratch = lerpOctEncodedNormal(this, encodedScratch);
749
- return encodedScratch.x;
750
- };
751
- Vertex.prototype.getNormalY = function() {
752
- if (defined_default(this.index)) {
753
- return this.normalBuffer[this.index * 2 + 1];
754
- }
755
- encodedScratch = lerpOctEncodedNormal(this, encodedScratch);
756
- return encodedScratch.y;
757
- };
758
- var polygonVertices = [];
759
- polygonVertices.push(new Vertex());
760
- polygonVertices.push(new Vertex());
761
- polygonVertices.push(new Vertex());
762
- polygonVertices.push(new Vertex());
763
- function addClippedPolygon(uBuffer, vBuffer, heightBuffer, normalBuffer, indices, vertexMap, clipped, triangleVertices, hasVertexNormals) {
764
- if (clipped.length === 0) {
765
- return;
766
- }
767
- let numVertices = 0;
768
- let clippedIndex = 0;
769
- while (clippedIndex < clipped.length) {
770
- clippedIndex = polygonVertices[numVertices++].initializeFromClipResult(
771
- clipped,
772
- clippedIndex,
773
- triangleVertices
774
- );
775
- }
776
- for (let i = 0; i < numVertices; ++i) {
777
- const polygonVertex = polygonVertices[i];
778
- if (!polygonVertex.isIndexed()) {
779
- const key = polygonVertex.getKey();
780
- if (defined_default(vertexMap[key])) {
781
- polygonVertex.newIndex = vertexMap[key];
782
- } else {
783
- const newIndex = uBuffer.length;
784
- uBuffer.push(polygonVertex.getU());
785
- vBuffer.push(polygonVertex.getV());
786
- heightBuffer.push(polygonVertex.getH());
787
- if (hasVertexNormals) {
788
- normalBuffer.push(polygonVertex.getNormalX());
789
- normalBuffer.push(polygonVertex.getNormalY());
790
- }
791
- polygonVertex.newIndex = newIndex;
792
- vertexMap[key] = newIndex;
793
- }
794
- } else {
795
- polygonVertex.newIndex = vertexMap[polygonVertex.index];
796
- polygonVertex.uBuffer = uBuffer;
797
- polygonVertex.vBuffer = vBuffer;
798
- polygonVertex.heightBuffer = heightBuffer;
799
- if (hasVertexNormals) {
800
- polygonVertex.normalBuffer = normalBuffer;
801
- }
802
- }
803
- }
804
- if (numVertices === 3) {
805
- indices.push(polygonVertices[0].newIndex);
806
- indices.push(polygonVertices[1].newIndex);
807
- indices.push(polygonVertices[2].newIndex);
808
- } else if (numVertices === 4) {
809
- indices.push(polygonVertices[0].newIndex);
810
- indices.push(polygonVertices[1].newIndex);
811
- indices.push(polygonVertices[2].newIndex);
812
- indices.push(polygonVertices[0].newIndex);
813
- indices.push(polygonVertices[2].newIndex);
814
- indices.push(polygonVertices[3].newIndex);
815
- }
816
- }
817
- var upsampleQuantizedTerrainMesh_default = createTaskProcessorWorker_default(upsampleQuantizedTerrainMesh);
818
- export {
819
- upsampleQuantizedTerrainMesh_default as default
820
- };