@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,335 +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
- WallGeometryLibrary_default
28
- } from "./chunk-PLLZB3R4.js";
29
- import "./chunk-Q2DXNFYW.js";
30
- import "./chunk-AIW5F22O.js";
31
- import "./chunk-HAY6YE7M.js";
32
- import "./chunk-FVYRV2T6.js";
33
- import "./chunk-66YGZWBI.js";
34
- import "./chunk-J4MIJCN5.js";
35
- import {
36
- IndexDatatype_default
37
- } from "./chunk-55IROWAX.js";
38
- import {
39
- GeometryAttributes_default
40
- } from "./chunk-BOV6T7FO.js";
41
- import {
42
- GeometryAttribute_default,
43
- Geometry_default,
44
- PrimitiveType_default
45
- } from "./chunk-XOVHLPKW.js";
46
- import {
47
- BoundingSphere_default
48
- } from "./chunk-OAOREOSO.js";
49
- import "./chunk-EKMWNF4U.js";
50
- import "./chunk-KQIZ7AFF.js";
51
- import "./chunk-POY6ZE32.js";
52
- import {
53
- ComponentDatatype_default
54
- } from "./chunk-AL22JVIA.js";
55
- import "./chunk-5VZISKJF.js";
56
- import "./chunk-UYT2PBMV.js";
57
- import {
58
- Ellipsoid_default
59
- } from "./chunk-YPGJSFOO.js";
60
- import {
61
- Cartesian3_default,
62
- Frozen_default
63
- } from "./chunk-QWV2DM66.js";
64
- import {
65
- Math_default
66
- } from "./chunk-6XJO625E.js";
67
- import {
68
- DeveloperError_default
69
- } from "./chunk-KH2OWUUA.js";
70
- import {
71
- defined_default
72
- } from "./chunk-AVSQILVI.js";
73
-
74
- // packages/engine/Source/Core/WallOutlineGeometry.js
75
- var scratchCartesian3Position1 = new Cartesian3_default();
76
- var scratchCartesian3Position2 = new Cartesian3_default();
77
- function WallOutlineGeometry(options) {
78
- options = options ?? Frozen_default.EMPTY_OBJECT;
79
- const wallPositions = options.positions;
80
- const maximumHeights = options.maximumHeights;
81
- const minimumHeights = options.minimumHeights;
82
- if (!defined_default(wallPositions)) {
83
- throw new DeveloperError_default("options.positions is required.");
84
- }
85
- if (defined_default(maximumHeights) && maximumHeights.length !== wallPositions.length) {
86
- throw new DeveloperError_default(
87
- "options.positions and options.maximumHeights must have the same length."
88
- );
89
- }
90
- if (defined_default(minimumHeights) && minimumHeights.length !== wallPositions.length) {
91
- throw new DeveloperError_default(
92
- "options.positions and options.minimumHeights must have the same length."
93
- );
94
- }
95
- const granularity = options.granularity ?? Math_default.RADIANS_PER_DEGREE;
96
- const ellipsoid = options.ellipsoid ?? Ellipsoid_default.default;
97
- this._positions = wallPositions;
98
- this._minimumHeights = minimumHeights;
99
- this._maximumHeights = maximumHeights;
100
- this._granularity = granularity;
101
- this._ellipsoid = Ellipsoid_default.clone(ellipsoid);
102
- this._workerName = "createWallOutlineGeometry";
103
- let numComponents = 1 + wallPositions.length * Cartesian3_default.packedLength + 2;
104
- if (defined_default(minimumHeights)) {
105
- numComponents += minimumHeights.length;
106
- }
107
- if (defined_default(maximumHeights)) {
108
- numComponents += maximumHeights.length;
109
- }
110
- this.packedLength = numComponents + Ellipsoid_default.packedLength + 1;
111
- }
112
- WallOutlineGeometry.pack = function(value, array, startingIndex) {
113
- if (!defined_default(value)) {
114
- throw new DeveloperError_default("value is required");
115
- }
116
- if (!defined_default(array)) {
117
- throw new DeveloperError_default("array is required");
118
- }
119
- startingIndex = startingIndex ?? 0;
120
- let i;
121
- const positions = value._positions;
122
- let length = positions.length;
123
- array[startingIndex++] = length;
124
- for (i = 0; i < length; ++i, startingIndex += Cartesian3_default.packedLength) {
125
- Cartesian3_default.pack(positions[i], array, startingIndex);
126
- }
127
- const minimumHeights = value._minimumHeights;
128
- length = defined_default(minimumHeights) ? minimumHeights.length : 0;
129
- array[startingIndex++] = length;
130
- if (defined_default(minimumHeights)) {
131
- for (i = 0; i < length; ++i) {
132
- array[startingIndex++] = minimumHeights[i];
133
- }
134
- }
135
- const maximumHeights = value._maximumHeights;
136
- length = defined_default(maximumHeights) ? maximumHeights.length : 0;
137
- array[startingIndex++] = length;
138
- if (defined_default(maximumHeights)) {
139
- for (i = 0; i < length; ++i) {
140
- array[startingIndex++] = maximumHeights[i];
141
- }
142
- }
143
- Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
144
- startingIndex += Ellipsoid_default.packedLength;
145
- array[startingIndex] = value._granularity;
146
- return array;
147
- };
148
- var scratchEllipsoid = Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE);
149
- var scratchOptions = {
150
- positions: void 0,
151
- minimumHeights: void 0,
152
- maximumHeights: void 0,
153
- ellipsoid: scratchEllipsoid,
154
- granularity: void 0
155
- };
156
- WallOutlineGeometry.unpack = function(array, startingIndex, result) {
157
- if (!defined_default(array)) {
158
- throw new DeveloperError_default("array is required");
159
- }
160
- startingIndex = startingIndex ?? 0;
161
- let i;
162
- let length = array[startingIndex++];
163
- const positions = new Array(length);
164
- for (i = 0; i < length; ++i, startingIndex += Cartesian3_default.packedLength) {
165
- positions[i] = Cartesian3_default.unpack(array, startingIndex);
166
- }
167
- length = array[startingIndex++];
168
- let minimumHeights;
169
- if (length > 0) {
170
- minimumHeights = new Array(length);
171
- for (i = 0; i < length; ++i) {
172
- minimumHeights[i] = array[startingIndex++];
173
- }
174
- }
175
- length = array[startingIndex++];
176
- let maximumHeights;
177
- if (length > 0) {
178
- maximumHeights = new Array(length);
179
- for (i = 0; i < length; ++i) {
180
- maximumHeights[i] = array[startingIndex++];
181
- }
182
- }
183
- const ellipsoid = Ellipsoid_default.unpack(array, startingIndex, scratchEllipsoid);
184
- startingIndex += Ellipsoid_default.packedLength;
185
- const granularity = array[startingIndex];
186
- if (!defined_default(result)) {
187
- scratchOptions.positions = positions;
188
- scratchOptions.minimumHeights = minimumHeights;
189
- scratchOptions.maximumHeights = maximumHeights;
190
- scratchOptions.granularity = granularity;
191
- return new WallOutlineGeometry(scratchOptions);
192
- }
193
- result._positions = positions;
194
- result._minimumHeights = minimumHeights;
195
- result._maximumHeights = maximumHeights;
196
- result._ellipsoid = Ellipsoid_default.clone(ellipsoid, result._ellipsoid);
197
- result._granularity = granularity;
198
- return result;
199
- };
200
- WallOutlineGeometry.fromConstantHeights = function(options) {
201
- options = options ?? Frozen_default.EMPTY_OBJECT;
202
- const positions = options.positions;
203
- if (!defined_default(positions)) {
204
- throw new DeveloperError_default("options.positions is required.");
205
- }
206
- let minHeights;
207
- let maxHeights;
208
- const min = options.minimumHeight;
209
- const max = options.maximumHeight;
210
- const doMin = defined_default(min);
211
- const doMax = defined_default(max);
212
- if (doMin || doMax) {
213
- const length = positions.length;
214
- minHeights = doMin ? new Array(length) : void 0;
215
- maxHeights = doMax ? new Array(length) : void 0;
216
- for (let i = 0; i < length; ++i) {
217
- if (doMin) {
218
- minHeights[i] = min;
219
- }
220
- if (doMax) {
221
- maxHeights[i] = max;
222
- }
223
- }
224
- }
225
- const newOptions = {
226
- positions,
227
- maximumHeights: maxHeights,
228
- minimumHeights: minHeights,
229
- ellipsoid: options.ellipsoid
230
- };
231
- return new WallOutlineGeometry(newOptions);
232
- };
233
- WallOutlineGeometry.createGeometry = function(wallGeometry) {
234
- const wallPositions = wallGeometry._positions;
235
- const minimumHeights = wallGeometry._minimumHeights;
236
- const maximumHeights = wallGeometry._maximumHeights;
237
- const granularity = wallGeometry._granularity;
238
- const ellipsoid = wallGeometry._ellipsoid;
239
- const pos = WallGeometryLibrary_default.computePositions(
240
- ellipsoid,
241
- wallPositions,
242
- maximumHeights,
243
- minimumHeights,
244
- granularity,
245
- false
246
- );
247
- if (!defined_default(pos)) {
248
- return;
249
- }
250
- const bottomPositions = pos.bottomPositions;
251
- const topPositions = pos.topPositions;
252
- let length = topPositions.length;
253
- let size = length * 2;
254
- const positions = new Float64Array(size);
255
- let positionIndex = 0;
256
- length /= 3;
257
- let i;
258
- for (i = 0; i < length; ++i) {
259
- const i3 = i * 3;
260
- const topPosition = Cartesian3_default.fromArray(
261
- topPositions,
262
- i3,
263
- scratchCartesian3Position1
264
- );
265
- const bottomPosition = Cartesian3_default.fromArray(
266
- bottomPositions,
267
- i3,
268
- scratchCartesian3Position2
269
- );
270
- positions[positionIndex++] = bottomPosition.x;
271
- positions[positionIndex++] = bottomPosition.y;
272
- positions[positionIndex++] = bottomPosition.z;
273
- positions[positionIndex++] = topPosition.x;
274
- positions[positionIndex++] = topPosition.y;
275
- positions[positionIndex++] = topPosition.z;
276
- }
277
- const attributes = new GeometryAttributes_default({
278
- position: new GeometryAttribute_default({
279
- componentDatatype: ComponentDatatype_default.DOUBLE,
280
- componentsPerAttribute: 3,
281
- values: positions
282
- })
283
- });
284
- const numVertices = size / 3;
285
- size = 2 * numVertices - 4 + numVertices;
286
- const indices = IndexDatatype_default.createTypedArray(numVertices, size);
287
- let edgeIndex = 0;
288
- for (i = 0; i < numVertices - 2; i += 2) {
289
- const LL = i;
290
- const LR = i + 2;
291
- const pl = Cartesian3_default.fromArray(
292
- positions,
293
- LL * 3,
294
- scratchCartesian3Position1
295
- );
296
- const pr = Cartesian3_default.fromArray(
297
- positions,
298
- LR * 3,
299
- scratchCartesian3Position2
300
- );
301
- if (Cartesian3_default.equalsEpsilon(pl, pr, Math_default.EPSILON10)) {
302
- continue;
303
- }
304
- const UL = i + 1;
305
- const UR = i + 3;
306
- indices[edgeIndex++] = UL;
307
- indices[edgeIndex++] = LL;
308
- indices[edgeIndex++] = UL;
309
- indices[edgeIndex++] = UR;
310
- indices[edgeIndex++] = LL;
311
- indices[edgeIndex++] = LR;
312
- }
313
- indices[edgeIndex++] = numVertices - 2;
314
- indices[edgeIndex++] = numVertices - 1;
315
- return new Geometry_default({
316
- attributes,
317
- indices,
318
- primitiveType: PrimitiveType_default.LINES,
319
- boundingSphere: new BoundingSphere_default.fromVertices(positions)
320
- });
321
- };
322
- var WallOutlineGeometry_default = WallOutlineGeometry;
323
-
324
- // packages/engine/Source/Workers/createWallOutlineGeometry.js
325
- function createWallOutlineGeometry(wallGeometry, offset) {
326
- if (defined_default(offset)) {
327
- wallGeometry = WallOutlineGeometry_default.unpack(wallGeometry, offset);
328
- }
329
- wallGeometry._ellipsoid = Ellipsoid_default.clone(wallGeometry._ellipsoid);
330
- return WallOutlineGeometry_default.createGeometry(wallGeometry);
331
- }
332
- var createWallOutlineGeometry_default = createWallOutlineGeometry;
333
- export {
334
- createWallOutlineGeometry_default as default
335
- };
@@ -1,369 +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
- require_draco_decoder_nodejs
28
- } from "./chunk-56XTN5NJ.js";
29
- import {
30
- createTaskProcessorWorker_default
31
- } from "./chunk-TSAJNE4K.js";
32
- import {
33
- IndexDatatype_default
34
- } from "./chunk-55IROWAX.js";
35
- import {
36
- ComponentDatatype_default
37
- } from "./chunk-AL22JVIA.js";
38
- import "./chunk-5VZISKJF.js";
39
- import {
40
- RuntimeError_default
41
- } from "./chunk-UYT2PBMV.js";
42
- import "./chunk-6XJO625E.js";
43
- import "./chunk-KH2OWUUA.js";
44
- import {
45
- __toESM,
46
- defined_default
47
- } from "./chunk-AVSQILVI.js";
48
-
49
- // packages/engine/Source/Workers/decodeDraco.js
50
- var import_draco_decoder_nodejs = __toESM(require_draco_decoder_nodejs(), 1);
51
- var draco;
52
- function decodeIndexArray(dracoGeometry, dracoDecoder) {
53
- const numPoints = dracoGeometry.num_points();
54
- const numFaces = dracoGeometry.num_faces();
55
- const faceIndices = new draco.DracoInt32Array();
56
- const numIndices = numFaces * 3;
57
- const indexArray = IndexDatatype_default.createTypedArray(numPoints, numIndices);
58
- let offset = 0;
59
- for (let i = 0; i < numFaces; ++i) {
60
- dracoDecoder.GetFaceFromMesh(dracoGeometry, i, faceIndices);
61
- indexArray[offset + 0] = faceIndices.GetValue(0);
62
- indexArray[offset + 1] = faceIndices.GetValue(1);
63
- indexArray[offset + 2] = faceIndices.GetValue(2);
64
- offset += 3;
65
- }
66
- draco.destroy(faceIndices);
67
- return {
68
- typedArray: indexArray,
69
- numberOfIndices: numIndices
70
- };
71
- }
72
- function decodeQuantizedDracoTypedArray(dracoGeometry, dracoDecoder, dracoAttribute, quantization, vertexArrayLength) {
73
- let vertexArray;
74
- let attributeData;
75
- if (quantization.quantizationBits <= 8) {
76
- attributeData = new draco.DracoUInt8Array();
77
- vertexArray = new Uint8Array(vertexArrayLength);
78
- dracoDecoder.GetAttributeUInt8ForAllPoints(
79
- dracoGeometry,
80
- dracoAttribute,
81
- attributeData
82
- );
83
- } else if (quantization.quantizationBits <= 16) {
84
- attributeData = new draco.DracoUInt16Array();
85
- vertexArray = new Uint16Array(vertexArrayLength);
86
- dracoDecoder.GetAttributeUInt16ForAllPoints(
87
- dracoGeometry,
88
- dracoAttribute,
89
- attributeData
90
- );
91
- } else {
92
- attributeData = new draco.DracoFloat32Array();
93
- vertexArray = new Float32Array(vertexArrayLength);
94
- dracoDecoder.GetAttributeFloatForAllPoints(
95
- dracoGeometry,
96
- dracoAttribute,
97
- attributeData
98
- );
99
- }
100
- for (let i = 0; i < vertexArrayLength; ++i) {
101
- vertexArray[i] = attributeData.GetValue(i);
102
- }
103
- draco.destroy(attributeData);
104
- return vertexArray;
105
- }
106
- function decodeDracoTypedArray(dracoGeometry, dracoDecoder, dracoAttribute, vertexArrayLength) {
107
- let vertexArray;
108
- let attributeData;
109
- switch (dracoAttribute.data_type()) {
110
- case 1:
111
- case 11:
112
- attributeData = new draco.DracoInt8Array();
113
- vertexArray = new Int8Array(vertexArrayLength);
114
- dracoDecoder.GetAttributeInt8ForAllPoints(
115
- dracoGeometry,
116
- dracoAttribute,
117
- attributeData
118
- );
119
- break;
120
- case 2:
121
- attributeData = new draco.DracoUInt8Array();
122
- vertexArray = new Uint8Array(vertexArrayLength);
123
- dracoDecoder.GetAttributeUInt8ForAllPoints(
124
- dracoGeometry,
125
- dracoAttribute,
126
- attributeData
127
- );
128
- break;
129
- case 3:
130
- attributeData = new draco.DracoInt16Array();
131
- vertexArray = new Int16Array(vertexArrayLength);
132
- dracoDecoder.GetAttributeInt16ForAllPoints(
133
- dracoGeometry,
134
- dracoAttribute,
135
- attributeData
136
- );
137
- break;
138
- case 4:
139
- attributeData = new draco.DracoUInt16Array();
140
- vertexArray = new Uint16Array(vertexArrayLength);
141
- dracoDecoder.GetAttributeUInt16ForAllPoints(
142
- dracoGeometry,
143
- dracoAttribute,
144
- attributeData
145
- );
146
- break;
147
- case 5:
148
- case 7:
149
- attributeData = new draco.DracoInt32Array();
150
- vertexArray = new Int32Array(vertexArrayLength);
151
- dracoDecoder.GetAttributeInt32ForAllPoints(
152
- dracoGeometry,
153
- dracoAttribute,
154
- attributeData
155
- );
156
- break;
157
- case 6:
158
- case 8:
159
- attributeData = new draco.DracoUInt32Array();
160
- vertexArray = new Uint32Array(vertexArrayLength);
161
- dracoDecoder.GetAttributeUInt32ForAllPoints(
162
- dracoGeometry,
163
- dracoAttribute,
164
- attributeData
165
- );
166
- break;
167
- case 9:
168
- case 10:
169
- attributeData = new draco.DracoFloat32Array();
170
- vertexArray = new Float32Array(vertexArrayLength);
171
- dracoDecoder.GetAttributeFloatForAllPoints(
172
- dracoGeometry,
173
- dracoAttribute,
174
- attributeData
175
- );
176
- break;
177
- }
178
- for (let i = 0; i < vertexArrayLength; ++i) {
179
- vertexArray[i] = attributeData.GetValue(i);
180
- }
181
- draco.destroy(attributeData);
182
- return vertexArray;
183
- }
184
- function decodeAttribute(dracoGeometry, dracoDecoder, dracoAttribute) {
185
- const numPoints = dracoGeometry.num_points();
186
- const numComponents = dracoAttribute.num_components();
187
- let quantization;
188
- let transform = new draco.AttributeQuantizationTransform();
189
- if (transform.InitFromAttribute(dracoAttribute)) {
190
- const minValues = new Array(numComponents);
191
- for (let i = 0; i < numComponents; ++i) {
192
- minValues[i] = transform.min_value(i);
193
- }
194
- quantization = {
195
- quantizationBits: transform.quantization_bits(),
196
- minValues,
197
- range: transform.range(),
198
- octEncoded: false
199
- };
200
- }
201
- draco.destroy(transform);
202
- transform = new draco.AttributeOctahedronTransform();
203
- if (transform.InitFromAttribute(dracoAttribute)) {
204
- quantization = {
205
- quantizationBits: transform.quantization_bits(),
206
- octEncoded: true
207
- };
208
- }
209
- draco.destroy(transform);
210
- const vertexArrayLength = numPoints * numComponents;
211
- let vertexArray;
212
- if (defined_default(quantization)) {
213
- vertexArray = decodeQuantizedDracoTypedArray(
214
- dracoGeometry,
215
- dracoDecoder,
216
- dracoAttribute,
217
- quantization,
218
- vertexArrayLength
219
- );
220
- } else {
221
- vertexArray = decodeDracoTypedArray(
222
- dracoGeometry,
223
- dracoDecoder,
224
- dracoAttribute,
225
- vertexArrayLength
226
- );
227
- }
228
- const componentDatatype = ComponentDatatype_default.fromTypedArray(vertexArray);
229
- return {
230
- array: vertexArray,
231
- data: {
232
- componentsPerAttribute: numComponents,
233
- componentDatatype,
234
- byteOffset: dracoAttribute.byte_offset(),
235
- byteStride: ComponentDatatype_default.getSizeInBytes(componentDatatype) * numComponents,
236
- normalized: dracoAttribute.normalized(),
237
- quantization
238
- }
239
- };
240
- }
241
- function decodePointCloud(parameters) {
242
- const dracoDecoder = new draco.Decoder();
243
- if (parameters.dequantizeInShader) {
244
- dracoDecoder.SkipAttributeTransform(draco.POSITION);
245
- dracoDecoder.SkipAttributeTransform(draco.NORMAL);
246
- }
247
- const buffer = new draco.DecoderBuffer();
248
- buffer.Init(parameters.buffer, parameters.buffer.length);
249
- const geometryType = dracoDecoder.GetEncodedGeometryType(buffer);
250
- if (geometryType !== draco.POINT_CLOUD) {
251
- throw new RuntimeError_default("Draco geometry type must be POINT_CLOUD.");
252
- }
253
- const dracoPointCloud = new draco.PointCloud();
254
- const decodingStatus = dracoDecoder.DecodeBufferToPointCloud(
255
- buffer,
256
- dracoPointCloud
257
- );
258
- if (!decodingStatus.ok() || dracoPointCloud.ptr === 0) {
259
- throw new RuntimeError_default(
260
- `Error decoding draco point cloud: ${decodingStatus.error_msg()}`
261
- );
262
- }
263
- draco.destroy(buffer);
264
- const result = {};
265
- const properties = parameters.properties;
266
- for (const propertyName in properties) {
267
- if (properties.hasOwnProperty(propertyName)) {
268
- let dracoAttribute;
269
- if (propertyName === "POSITION" || propertyName === "NORMAL") {
270
- const dracoAttributeId = dracoDecoder.GetAttributeId(
271
- dracoPointCloud,
272
- draco[propertyName]
273
- );
274
- dracoAttribute = dracoDecoder.GetAttribute(
275
- dracoPointCloud,
276
- dracoAttributeId
277
- );
278
- } else {
279
- const attributeId = properties[propertyName];
280
- dracoAttribute = dracoDecoder.GetAttributeByUniqueId(
281
- dracoPointCloud,
282
- attributeId
283
- );
284
- }
285
- result[propertyName] = decodeAttribute(
286
- dracoPointCloud,
287
- dracoDecoder,
288
- dracoAttribute
289
- );
290
- }
291
- }
292
- draco.destroy(dracoPointCloud);
293
- draco.destroy(dracoDecoder);
294
- return result;
295
- }
296
- function decodePrimitive(parameters) {
297
- const dracoDecoder = new draco.Decoder();
298
- if (parameters.dequantizeInShader) {
299
- for (let i = 0; i < parameters.attributesToSkipTransform.length; ++i) {
300
- dracoDecoder.SkipAttributeTransform(
301
- draco[parameters.attributesToSkipTransform[i]]
302
- );
303
- }
304
- }
305
- const bufferView = parameters.bufferView;
306
- const buffer = new draco.DecoderBuffer();
307
- buffer.Init(parameters.array, bufferView.byteLength);
308
- const geometryType = dracoDecoder.GetEncodedGeometryType(buffer);
309
- if (geometryType !== draco.TRIANGULAR_MESH) {
310
- throw new RuntimeError_default("Unsupported draco mesh geometry type.");
311
- }
312
- const dracoGeometry = new draco.Mesh();
313
- const decodingStatus = dracoDecoder.DecodeBufferToMesh(buffer, dracoGeometry);
314
- if (!decodingStatus.ok() || dracoGeometry.ptr === 0) {
315
- throw new RuntimeError_default(
316
- `Error decoding draco mesh geometry: ${decodingStatus.error_msg()}`
317
- );
318
- }
319
- draco.destroy(buffer);
320
- const attributeData = {};
321
- const compressedAttributes = parameters.compressedAttributes;
322
- for (const attributeName in compressedAttributes) {
323
- if (compressedAttributes.hasOwnProperty(attributeName)) {
324
- const compressedAttribute = compressedAttributes[attributeName];
325
- const dracoAttribute = dracoDecoder.GetAttributeByUniqueId(
326
- dracoGeometry,
327
- compressedAttribute
328
- );
329
- attributeData[attributeName] = decodeAttribute(
330
- dracoGeometry,
331
- dracoDecoder,
332
- dracoAttribute
333
- );
334
- }
335
- }
336
- const result = {
337
- indexArray: decodeIndexArray(dracoGeometry, dracoDecoder),
338
- attributeData
339
- };
340
- draco.destroy(dracoGeometry);
341
- draco.destroy(dracoDecoder);
342
- return result;
343
- }
344
- async function decode(parameters, transferableObjects) {
345
- if (defined_default(parameters.bufferView)) {
346
- return decodePrimitive(parameters);
347
- }
348
- return decodePointCloud(parameters);
349
- }
350
- async function initWorker(parameters, transferableObjects) {
351
- const wasmConfig = parameters.webAssemblyConfig;
352
- if (defined_default(wasmConfig) && defined_default(wasmConfig.wasmBinaryFile)) {
353
- draco = await (0, import_draco_decoder_nodejs.default)(wasmConfig);
354
- } else {
355
- draco = await (0, import_draco_decoder_nodejs.default)();
356
- }
357
- return true;
358
- }
359
- async function decodeDraco(parameters, transferableObjects) {
360
- const wasmConfig = parameters.webAssemblyConfig;
361
- if (defined_default(wasmConfig)) {
362
- return initWorker(parameters, transferableObjects);
363
- }
364
- return decode(parameters, transferableObjects);
365
- }
366
- var decodeDraco_default = createTaskProcessorWorker_default(decodeDraco);
367
- export {
368
- decodeDraco_default as default
369
- };