@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,1321 +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
- require_draco_decoder_nodejs
28
- } from "./chunk-GESF4OXQ.js";
29
- import {
30
- Color_default
31
- } from "./chunk-5OOFQLKF.js";
32
- import {
33
- createTaskProcessorWorker_default
34
- } from "./chunk-5ODQSF26.js";
35
- import {
36
- WebMercatorProjection_default
37
- } from "./chunk-E27BLMDD.js";
38
- import {
39
- Cartesian3_default,
40
- Cartographic_default,
41
- Ellipsoid_default,
42
- Matrix3_default
43
- } from "./chunk-YFXQECWV.js";
44
- import {
45
- Math_default
46
- } from "./chunk-XY4BATBS.js";
47
- import {
48
- defaultValue_default
49
- } from "./chunk-7JO7GPJN.js";
50
- import {
51
- Check_default
52
- } from "./chunk-AD63PIY6.js";
53
- import {
54
- __toESM,
55
- defined_default
56
- } from "./chunk-E63IIM5T.js";
57
-
58
- // packages/engine/Source/Workers/decodeI3S.js
59
- var import_draco_decoder_nodejs = __toESM(require_draco_decoder_nodejs(), 1);
60
-
61
- // packages/engine/Source/Core/srgbToLinear.js
62
- function srgbToLinear(value) {
63
- Check_default.defined("value", value);
64
- if (value <= 0.04045) {
65
- return value * 0.07739938080495357;
66
- }
67
- return Math.pow(
68
- // eslint-disable-next-line no-loss-of-precision
69
- (value + 0.055) * 0.9478672985781991,
70
- 2.4
71
- );
72
- }
73
- var srgbToLinear_default = srgbToLinear;
74
-
75
- // packages/engine/Source/Workers/decodeI3S.js
76
- var draco;
77
- function bilinearInterpolate(tx, ty, h00, h10, h01, h11) {
78
- const a = h00 * (1 - tx) + h10 * tx;
79
- const b = h01 * (1 - tx) + h11 * tx;
80
- return a * (1 - ty) + b * ty;
81
- }
82
- function sampleMap(u, v, width, data) {
83
- const address = u + v * width;
84
- return data[address];
85
- }
86
- function sampleGeoid(sampleX, sampleY, geoidData) {
87
- const extent = geoidData.nativeExtent;
88
- let x = (sampleX - extent.west) / (extent.east - extent.west) * (geoidData.width - 1);
89
- let y = (sampleY - extent.south) / (extent.north - extent.south) * (geoidData.height - 1);
90
- const xi = Math.floor(x);
91
- let yi = Math.floor(y);
92
- x -= xi;
93
- y -= yi;
94
- const xNext = xi < geoidData.width ? xi + 1 : xi;
95
- let yNext = yi < geoidData.height ? yi + 1 : yi;
96
- yi = geoidData.height - 1 - yi;
97
- yNext = geoidData.height - 1 - yNext;
98
- const h00 = sampleMap(xi, yi, geoidData.width, geoidData.buffer);
99
- const h10 = sampleMap(xNext, yi, geoidData.width, geoidData.buffer);
100
- const h01 = sampleMap(xi, yNext, geoidData.width, geoidData.buffer);
101
- const h11 = sampleMap(xNext, yNext, geoidData.width, geoidData.buffer);
102
- let finalHeight = bilinearInterpolate(x, y, h00, h10, h01, h11);
103
- finalHeight = finalHeight * geoidData.scale + geoidData.offset;
104
- return finalHeight;
105
- }
106
- function sampleGeoidFromList(lon, lat, geoidDataList) {
107
- for (let i = 0; i < geoidDataList.length; i++) {
108
- const localExtent = geoidDataList[i].nativeExtent;
109
- let localPt = new Cartesian3_default();
110
- if (geoidDataList[i].projectionType === "WebMercator") {
111
- const radii = geoidDataList[i].projection._ellipsoid._radii;
112
- const webMercatorProj = new WebMercatorProjection_default(
113
- new Ellipsoid_default(radii.x, radii.y, radii.z)
114
- );
115
- localPt = webMercatorProj.project(new Cartographic_default(lon, lat, 0));
116
- } else {
117
- localPt.x = lon;
118
- localPt.y = lat;
119
- }
120
- if (localPt.x > localExtent.west && localPt.x < localExtent.east && localPt.y > localExtent.south && localPt.y < localExtent.north) {
121
- return sampleGeoid(localPt.x, localPt.y, geoidDataList[i]);
122
- }
123
- }
124
- return 0;
125
- }
126
- function orthometricToEllipsoidal(vertexCount, position, scale_x, scale_y, center, geoidDataList, fast) {
127
- if (fast) {
128
- return;
129
- }
130
- const centerHeight = sampleGeoidFromList(
131
- center.longitude,
132
- center.latitude,
133
- geoidDataList
134
- );
135
- for (let i = 0; i < vertexCount; ++i) {
136
- const height = sampleGeoidFromList(
137
- center.longitude + Math_default.toRadians(scale_x * position[i * 3]),
138
- center.latitude + Math_default.toRadians(scale_y * position[i * 3 + 1]),
139
- geoidDataList
140
- );
141
- position[i * 3 + 2] += height - centerHeight;
142
- }
143
- }
144
- function transformToLocal(vertexCount, positions, normals, cartographicCenter, cartesianCenter, parentRotation, ellipsoidRadiiSquare, scale_x, scale_y) {
145
- if (vertexCount === 0 || !defined_default(positions) || positions.length === 0) {
146
- return;
147
- }
148
- const ellipsoid = new Ellipsoid_default(
149
- Math.sqrt(ellipsoidRadiiSquare.x),
150
- Math.sqrt(ellipsoidRadiiSquare.y),
151
- Math.sqrt(ellipsoidRadiiSquare.z)
152
- );
153
- for (let i = 0; i < vertexCount; ++i) {
154
- const indexOffset = i * 3;
155
- const indexOffset1 = indexOffset + 1;
156
- const indexOffset2 = indexOffset + 2;
157
- const cartographic = new Cartographic_default();
158
- cartographic.longitude = cartographicCenter.longitude + Math_default.toRadians(scale_x * positions[indexOffset]);
159
- cartographic.latitude = cartographicCenter.latitude + Math_default.toRadians(scale_y * positions[indexOffset1]);
160
- cartographic.height = cartographicCenter.height + positions[indexOffset2];
161
- const position = {};
162
- ellipsoid.cartographicToCartesian(cartographic, position);
163
- position.x -= cartesianCenter.x;
164
- position.y -= cartesianCenter.y;
165
- position.z -= cartesianCenter.z;
166
- const rotatedPosition = {};
167
- Matrix3_default.multiplyByVector(parentRotation, position, rotatedPosition);
168
- positions[indexOffset] = rotatedPosition.x;
169
- positions[indexOffset1] = rotatedPosition.y;
170
- positions[indexOffset2] = rotatedPosition.z;
171
- if (defined_default(normals)) {
172
- const normal = new Cartesian3_default(
173
- normals[indexOffset],
174
- normals[indexOffset1],
175
- normals[indexOffset2]
176
- );
177
- const rotatedNormal = {};
178
- Matrix3_default.multiplyByVector(parentRotation, normal, rotatedNormal);
179
- normals[indexOffset] = rotatedNormal.x;
180
- normals[indexOffset1] = rotatedNormal.y;
181
- normals[indexOffset2] = rotatedNormal.z;
182
- }
183
- }
184
- }
185
- function cropUVs(vertexCount, uv0s, uvRegions) {
186
- for (let vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex) {
187
- const minU = uvRegions[vertexIndex * 4] / 65535;
188
- const minV = uvRegions[vertexIndex * 4 + 1] / 65535;
189
- const scaleU = (uvRegions[vertexIndex * 4 + 2] - uvRegions[vertexIndex * 4]) / 65535;
190
- const scaleV = (uvRegions[vertexIndex * 4 + 3] - uvRegions[vertexIndex * 4 + 1]) / 65535;
191
- uv0s[vertexIndex * 2] *= scaleU;
192
- uv0s[vertexIndex * 2] += minU;
193
- uv0s[vertexIndex * 2 + 1] *= scaleV;
194
- uv0s[vertexIndex * 2 + 1] += minV;
195
- }
196
- }
197
- function generateIndexArray(vertexCount, indices, colors, splitGeometryByColorTransparency) {
198
- const indexArray = new Uint32Array(vertexCount);
199
- const vertexIndexFn = defined_default(indices) ? (vertexIndex) => indices[vertexIndex] : (vertexIndex) => vertexIndex;
200
- let transparentVertexOffset = 0;
201
- if (splitGeometryByColorTransparency && defined_default(colors)) {
202
- const isVertexTransparentFn = (vertexIndex) => colors[vertexIndexFn(vertexIndex) * 4 + 3] < 255;
203
- for (let vertexIndex = 0; vertexIndex < vertexCount; vertexIndex += 3) {
204
- if (!isVertexTransparentFn(vertexIndex) && !isVertexTransparentFn(vertexIndex + 1) && !isVertexTransparentFn(vertexIndex + 2)) {
205
- indexArray[transparentVertexOffset++] = vertexIndexFn(vertexIndex);
206
- indexArray[transparentVertexOffset++] = vertexIndexFn(vertexIndex + 1);
207
- indexArray[transparentVertexOffset++] = vertexIndexFn(vertexIndex + 2);
208
- }
209
- }
210
- if (transparentVertexOffset > 0) {
211
- let offset = transparentVertexOffset;
212
- for (let vertexIndex = 0; vertexIndex < vertexCount; vertexIndex += 3) {
213
- if (isVertexTransparentFn(vertexIndex) || isVertexTransparentFn(vertexIndex + 1) || isVertexTransparentFn(vertexIndex + 2)) {
214
- indexArray[offset++] = vertexIndexFn(vertexIndex);
215
- indexArray[offset++] = vertexIndexFn(vertexIndex + 1);
216
- indexArray[offset++] = vertexIndexFn(vertexIndex + 2);
217
- }
218
- }
219
- } else {
220
- for (let vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex) {
221
- indexArray[vertexIndex] = vertexIndexFn(vertexIndex);
222
- }
223
- }
224
- } else {
225
- transparentVertexOffset = vertexCount;
226
- for (let vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex) {
227
- indexArray[vertexIndex] = vertexIndexFn(vertexIndex);
228
- }
229
- }
230
- return {
231
- indexArray,
232
- transparentVertexOffset
233
- };
234
- }
235
- function getFeatureHash(symbologyData, outlinesHash, featureIndex) {
236
- const featureHash = outlinesHash[featureIndex];
237
- if (defined_default(featureHash)) {
238
- return featureHash;
239
- }
240
- const newFeatureHash = outlinesHash[featureIndex] = {
241
- positions: {},
242
- indices: {},
243
- edges: {}
244
- };
245
- const featureSymbology = defaultValue_default(
246
- symbologyData[featureIndex],
247
- symbologyData.default
248
- );
249
- newFeatureHash.hasOutline = defined_default(featureSymbology?.edges);
250
- return newFeatureHash;
251
- }
252
- function addVertexToHash(indexHash, positionHash, vertexIndex, positions) {
253
- if (!defined_default(indexHash[vertexIndex])) {
254
- const startPositionIndex = vertexIndex * 3;
255
- let coordinateHash = positionHash;
256
- for (let index = 0; index < 3; index++) {
257
- const coordinate = positions[startPositionIndex + index];
258
- if (!defined_default(coordinateHash[coordinate])) {
259
- coordinateHash[coordinate] = {};
260
- }
261
- coordinateHash = coordinateHash[coordinate];
262
- }
263
- if (!defined_default(coordinateHash.index)) {
264
- coordinateHash.index = vertexIndex;
265
- }
266
- indexHash[vertexIndex] = coordinateHash.index;
267
- }
268
- }
269
- function addEdgeToHash(edgeHash, vertexAIndex, vertexBIndex, vertexAIndexUnique, vertexBIndexUnique, normalIndex) {
270
- let startVertexIndex;
271
- let endVertexIndex;
272
- if (vertexAIndexUnique < vertexBIndexUnique) {
273
- startVertexIndex = vertexAIndexUnique;
274
- endVertexIndex = vertexBIndexUnique;
275
- } else {
276
- startVertexIndex = vertexBIndexUnique;
277
- endVertexIndex = vertexAIndexUnique;
278
- }
279
- let edgeStart = edgeHash[startVertexIndex];
280
- if (!defined_default(edgeStart)) {
281
- edgeStart = edgeHash[startVertexIndex] = {};
282
- }
283
- let edgeEnd = edgeStart[endVertexIndex];
284
- if (!defined_default(edgeEnd)) {
285
- edgeEnd = edgeStart[endVertexIndex] = {
286
- normalsIndex: [],
287
- outlines: []
288
- };
289
- }
290
- edgeEnd.normalsIndex.push(normalIndex);
291
- if (edgeEnd.outlines.length === 0 || vertexAIndex !== vertexAIndexUnique || vertexBIndex !== vertexBIndexUnique) {
292
- edgeEnd.outlines.push(vertexAIndex, vertexBIndex);
293
- }
294
- }
295
- function generateOutlinesHash(symbologyData, featureIndexArray, indexArray, positions) {
296
- const outlinesHash = [];
297
- for (let i = 0; i < indexArray.length; i += 3) {
298
- const featureIndex = defined_default(featureIndexArray) ? featureIndexArray[indexArray[i]] : "default";
299
- const featureHash = getFeatureHash(
300
- symbologyData,
301
- outlinesHash,
302
- featureIndex
303
- );
304
- if (!featureHash.hasOutline) {
305
- continue;
306
- }
307
- const indexHash = featureHash.indices;
308
- const positionHash = featureHash.positions;
309
- for (let vertex = 0; vertex < 3; vertex++) {
310
- const vertexIndex = indexArray[i + vertex];
311
- addVertexToHash(indexHash, positionHash, vertexIndex, positions);
312
- }
313
- const edgeHash = featureHash.edges;
314
- for (let vertex = 0; vertex < 3; vertex++) {
315
- const vertexIndex = indexArray[i + vertex];
316
- const nextVertexIndex = indexArray[i + (vertex + 1) % 3];
317
- const uniqueVertexIndex = indexHash[vertexIndex];
318
- const uniqueNextVertexIndex = indexHash[nextVertexIndex];
319
- addEdgeToHash(
320
- edgeHash,
321
- vertexIndex,
322
- nextVertexIndex,
323
- uniqueVertexIndex,
324
- uniqueNextVertexIndex,
325
- i
326
- );
327
- }
328
- }
329
- return outlinesHash;
330
- }
331
- var calculateFaceNormalA = new Cartesian3_default();
332
- var calculateFaceNormalB = new Cartesian3_default();
333
- var calculateFaceNormalC = new Cartesian3_default();
334
- function calculateFaceNormal(normals, vertexAIndex, indexArray, positions) {
335
- const positionAIndex = indexArray[vertexAIndex] * 3;
336
- const positionBIndex = indexArray[vertexAIndex + 1] * 3;
337
- const positionCIndex = indexArray[vertexAIndex + 2] * 3;
338
- Cartesian3_default.fromArray(positions, positionAIndex, calculateFaceNormalA);
339
- Cartesian3_default.fromArray(positions, positionBIndex, calculateFaceNormalB);
340
- Cartesian3_default.fromArray(positions, positionCIndex, calculateFaceNormalC);
341
- Cartesian3_default.subtract(
342
- calculateFaceNormalB,
343
- calculateFaceNormalA,
344
- calculateFaceNormalB
345
- );
346
- Cartesian3_default.subtract(
347
- calculateFaceNormalC,
348
- calculateFaceNormalA,
349
- calculateFaceNormalC
350
- );
351
- Cartesian3_default.cross(
352
- calculateFaceNormalB,
353
- calculateFaceNormalC,
354
- calculateFaceNormalA
355
- );
356
- const magnitude = Cartesian3_default.magnitude(calculateFaceNormalA);
357
- if (magnitude !== 0) {
358
- Cartesian3_default.divideByScalar(
359
- calculateFaceNormalA,
360
- magnitude,
361
- calculateFaceNormalA
362
- );
363
- }
364
- const normalAIndex = vertexAIndex * 3;
365
- const normalBIndex = (vertexAIndex + 1) * 3;
366
- const normalCIndex = (vertexAIndex + 2) * 3;
367
- Cartesian3_default.pack(calculateFaceNormalA, normals, normalAIndex);
368
- Cartesian3_default.pack(calculateFaceNormalA, normals, normalBIndex);
369
- Cartesian3_default.pack(calculateFaceNormalA, normals, normalCIndex);
370
- }
371
- var isEdgeSmoothA = new Cartesian3_default();
372
- var isEdgeSmoothB = new Cartesian3_default();
373
- function isEdgeSmooth(normals, normalAIndex, normalBIndex) {
374
- Cartesian3_default.fromArray(normals, normalAIndex, isEdgeSmoothA);
375
- Cartesian3_default.fromArray(normals, normalBIndex, isEdgeSmoothB);
376
- const cosine = Cartesian3_default.dot(isEdgeSmoothA, isEdgeSmoothB);
377
- const sine = Cartesian3_default.magnitude(
378
- Cartesian3_default.cross(isEdgeSmoothA, isEdgeSmoothB, isEdgeSmoothA)
379
- );
380
- return Math.atan2(sine, cosine) < 0.25;
381
- }
382
- function addOutlinesForEdge(outlines, edgeData, indexArray, positions, normals) {
383
- if (edgeData.normalsIndex.length > 1) {
384
- const normalsByIndex = positions.length === normals.length;
385
- for (let indexA = 0; indexA < edgeData.normalsIndex.length; indexA++) {
386
- const vertexAIndex = edgeData.normalsIndex[indexA];
387
- if (!defined_default(normals[vertexAIndex * 3])) {
388
- calculateFaceNormal(normals, vertexAIndex, indexArray, positions);
389
- }
390
- if (indexA === 0) {
391
- continue;
392
- }
393
- for (let indexB = 0; indexB < indexA; indexB++) {
394
- const vertexBIndex = edgeData.normalsIndex[indexB];
395
- const normalAIndex = normalsByIndex ? indexArray[vertexAIndex] * 3 : vertexAIndex * 3;
396
- const normalBIndex = normalsByIndex ? indexArray[vertexBIndex] * 3 : vertexBIndex * 3;
397
- if (isEdgeSmooth(normals, normalAIndex, normalBIndex)) {
398
- return;
399
- }
400
- }
401
- }
402
- }
403
- outlines.push(...edgeData.outlines);
404
- }
405
- function addOutlinesForFeature(outlines, edgeHash, indexArray, positions, normals) {
406
- const edgeStartKeys = Object.keys(edgeHash);
407
- for (let startIndex = 0; startIndex < edgeStartKeys.length; startIndex++) {
408
- const edgeEnds = edgeHash[edgeStartKeys[startIndex]];
409
- const edgeEndKeys = Object.keys(edgeEnds);
410
- for (let endIndex = 0; endIndex < edgeEndKeys.length; endIndex++) {
411
- const edgeData = edgeEnds[edgeEndKeys[endIndex]];
412
- addOutlinesForEdge(outlines, edgeData, indexArray, positions, normals);
413
- }
414
- }
415
- }
416
- function generateOutlinesFromHash(outlinesHash, indexArray, positions, normals) {
417
- const outlines = [];
418
- const features = Object.keys(outlinesHash);
419
- for (let featureIndex = 0; featureIndex < features.length; featureIndex++) {
420
- const edgeHash = outlinesHash[features[featureIndex]].edges;
421
- addOutlinesForFeature(outlines, edgeHash, indexArray, positions, normals);
422
- }
423
- return outlines;
424
- }
425
- function generateOutlinesIndexArray(symbologyData, featureIndexArray, indexArray, positions, normals) {
426
- if (!defined_default(symbologyData) || Object.keys(symbologyData).length === 0) {
427
- return void 0;
428
- }
429
- const outlinesHash = generateOutlinesHash(
430
- symbologyData,
431
- featureIndexArray,
432
- indexArray,
433
- positions
434
- );
435
- if (!defined_default(normals) || indexArray.length * 3 !== normals.length) {
436
- normals = [];
437
- }
438
- const outlines = generateOutlinesFromHash(
439
- outlinesHash,
440
- indexArray,
441
- positions,
442
- normals
443
- );
444
- const outlinesIndexArray = outlines.length > 0 ? new Uint32Array(outlines) : void 0;
445
- return outlinesIndexArray;
446
- }
447
- function convertColorsArray(colors) {
448
- const colorsArray = new Float32Array(colors.length);
449
- for (let index = 0; index < colors.length; index += 4) {
450
- colorsArray[index] = srgbToLinear_default(Color_default.byteToFloat(colors[index]));
451
- colorsArray[index + 1] = srgbToLinear_default(Color_default.byteToFloat(colors[index + 1]));
452
- colorsArray[index + 2] = srgbToLinear_default(Color_default.byteToFloat(colors[index + 2]));
453
- colorsArray[index + 3] = Color_default.byteToFloat(colors[index + 3]);
454
- }
455
- return colorsArray;
456
- }
457
- function generateNormals(vertexCount, indices, positions, normals, uv0s, colors, featureIndex) {
458
- const result = {
459
- normals: void 0,
460
- positions: void 0,
461
- uv0s: void 0,
462
- colors: void 0,
463
- featureIndex: void 0,
464
- vertexCount: void 0
465
- };
466
- if (vertexCount === 0 || !defined_default(positions) || positions.length === 0 || defined_default(normals)) {
467
- return result;
468
- }
469
- if (defined_default(indices)) {
470
- result.vertexCount = indices.length;
471
- result.positions = new Float32Array(indices.length * 3);
472
- result.uv0s = defined_default(uv0s) ? new Float32Array(indices.length * 2) : void 0;
473
- result.colors = defined_default(colors) ? new Uint8Array(indices.length * 4) : void 0;
474
- result.featureIndex = defined_default(featureIndex) ? new Array(indices.length) : void 0;
475
- for (let i = 0; i < indices.length; i++) {
476
- const index = indices[i];
477
- result.positions[i * 3] = positions[index * 3];
478
- result.positions[i * 3 + 1] = positions[index * 3 + 1];
479
- result.positions[i * 3 + 2] = positions[index * 3 + 2];
480
- if (defined_default(result.uv0s)) {
481
- result.uv0s[i * 2] = uv0s[index * 2];
482
- result.uv0s[i * 2 + 1] = uv0s[index * 2 + 1];
483
- }
484
- if (defined_default(result.colors)) {
485
- result.colors[i * 4] = colors[index * 4];
486
- result.colors[i * 4 + 1] = colors[index * 4 + 1];
487
- result.colors[i * 4 + 2] = colors[index * 4 + 2];
488
- result.colors[i * 4 + 3] = colors[index * 4 + 3];
489
- }
490
- if (defined_default(result.featureIndex)) {
491
- result.featureIndex[i] = featureIndex[index];
492
- }
493
- }
494
- vertexCount = indices.length;
495
- positions = result.positions;
496
- }
497
- indices = new Array(vertexCount);
498
- for (let i = 0; i < vertexCount; i++) {
499
- indices[i] = i;
500
- }
501
- result.normals = new Float32Array(indices.length * 3);
502
- for (let i = 0; i < indices.length; i += 3) {
503
- calculateFaceNormal(result.normals, i, indices, positions);
504
- }
505
- return result;
506
- }
507
- function generateGltfBuffer(vertexCount, indices, positions, normals, uv0s, colors, featureIndex, parameters) {
508
- if (vertexCount === 0 || !defined_default(positions) || positions.length === 0) {
509
- return {
510
- buffers: [],
511
- bufferViews: [],
512
- accessors: [],
513
- meshes: [],
514
- nodes: [],
515
- nodesInScene: []
516
- };
517
- }
518
- const buffers = [];
519
- const bufferViews = [];
520
- const accessors = [];
521
- const meshes = [];
522
- const nodes = [];
523
- const nodesInScene = [];
524
- const rootExtensions = {};
525
- const extensionsUsed = [];
526
- if (defined_default(indices)) {
527
- vertexCount = indices.length;
528
- }
529
- const { indexArray, transparentVertexOffset } = generateIndexArray(
530
- vertexCount,
531
- indices,
532
- colors,
533
- parameters.splitGeometryByColorTransparency
534
- );
535
- const indicesBlob = new Blob([indexArray], { type: "application/binary" });
536
- const indicesURL = URL.createObjectURL(indicesBlob);
537
- const endIndex = vertexCount;
538
- const featureIndexArray = parameters.enableFeatures && defined_default(featureIndex) ? new Float32Array(featureIndex.length) : void 0;
539
- let featureCount = 0;
540
- if (defined_default(featureIndexArray)) {
541
- for (let index = 0; index < featureIndex.length; ++index) {
542
- featureIndexArray[index] = featureIndex[index];
543
- const countByIndex = featureIndex[index] + 1;
544
- if (featureCount < countByIndex) {
545
- featureCount = countByIndex;
546
- }
547
- }
548
- }
549
- let outlinesIndicesURL;
550
- const outlinesIndexArray = generateOutlinesIndexArray(
551
- parameters.symbologyData,
552
- featureIndex,
553
- indexArray,
554
- positions,
555
- normals
556
- );
557
- if (defined_default(outlinesIndexArray)) {
558
- const outlinesIndicesBlob = new Blob([outlinesIndexArray], {
559
- type: "application/binary"
560
- });
561
- outlinesIndicesURL = URL.createObjectURL(outlinesIndicesBlob);
562
- }
563
- const meshPositions = positions.subarray(0, endIndex * 3);
564
- const positionsBlob = new Blob([meshPositions], {
565
- type: "application/binary"
566
- });
567
- const positionsURL = URL.createObjectURL(positionsBlob);
568
- let minX = Number.POSITIVE_INFINITY;
569
- let maxX = Number.NEGATIVE_INFINITY;
570
- let minY = Number.POSITIVE_INFINITY;
571
- let maxY = Number.NEGATIVE_INFINITY;
572
- let minZ = Number.POSITIVE_INFINITY;
573
- let maxZ = Number.NEGATIVE_INFINITY;
574
- for (let i = 0; i < meshPositions.length / 3; i++) {
575
- minX = Math.min(minX, meshPositions[i * 3 + 0]);
576
- maxX = Math.max(maxX, meshPositions[i * 3 + 0]);
577
- minY = Math.min(minY, meshPositions[i * 3 + 1]);
578
- maxY = Math.max(maxY, meshPositions[i * 3 + 1]);
579
- minZ = Math.min(minZ, meshPositions[i * 3 + 2]);
580
- maxZ = Math.max(maxZ, meshPositions[i * 3 + 2]);
581
- }
582
- const meshNormals = normals ? normals.subarray(0, endIndex * 3) : void 0;
583
- let normalsURL;
584
- if (defined_default(meshNormals)) {
585
- const normalsBlob = new Blob([meshNormals], {
586
- type: "application/binary"
587
- });
588
- normalsURL = URL.createObjectURL(normalsBlob);
589
- }
590
- const meshUv0s = uv0s ? uv0s.subarray(0, endIndex * 2) : void 0;
591
- let uv0URL;
592
- if (defined_default(meshUv0s)) {
593
- const uv0Blob = new Blob([meshUv0s], { type: "application/binary" });
594
- uv0URL = URL.createObjectURL(uv0Blob);
595
- }
596
- const meshColorsInBytes = defined_default(colors) ? convertColorsArray(colors.subarray(0, endIndex * 4)) : void 0;
597
- let colorsURL;
598
- if (defined_default(meshColorsInBytes)) {
599
- const colorsBlob = new Blob([meshColorsInBytes], {
600
- type: "application/binary"
601
- });
602
- colorsURL = URL.createObjectURL(colorsBlob);
603
- }
604
- const meshFeatureId0 = defined_default(featureIndexArray) ? featureIndexArray.subarray(0, endIndex) : void 0;
605
- let featureId0URL;
606
- if (defined_default(meshFeatureId0)) {
607
- const featureId0Blob = new Blob([meshFeatureId0], {
608
- type: "application/binary"
609
- });
610
- featureId0URL = URL.createObjectURL(featureId0Blob);
611
- }
612
- const meshPropertyTable0 = defined_default(featureIndexArray) ? new Float32Array(featureCount) : void 0;
613
- let propertyTable0URL;
614
- if (defined_default(meshPropertyTable0)) {
615
- for (let index = 0; index < meshPropertyTable0.length; ++index) {
616
- meshPropertyTable0[index] = index;
617
- }
618
- const propertyTable0Blob = new Blob([meshPropertyTable0], {
619
- type: "application/binary"
620
- });
621
- propertyTable0URL = URL.createObjectURL(propertyTable0Blob);
622
- }
623
- const attributes = {};
624
- const extensions = {};
625
- attributes.POSITION = accessors.length;
626
- buffers.push({
627
- uri: positionsURL,
628
- byteLength: meshPositions.byteLength
629
- });
630
- bufferViews.push({
631
- buffer: buffers.length - 1,
632
- byteOffset: 0,
633
- byteLength: meshPositions.byteLength,
634
- target: 34962
635
- });
636
- accessors.push({
637
- bufferView: bufferViews.length - 1,
638
- byteOffset: 0,
639
- componentType: 5126,
640
- count: meshPositions.length / 3,
641
- type: "VEC3",
642
- max: [minX, minY, minZ],
643
- min: [maxX, maxY, maxZ]
644
- });
645
- if (defined_default(normalsURL)) {
646
- attributes.NORMAL = accessors.length;
647
- buffers.push({
648
- uri: normalsURL,
649
- byteLength: meshNormals.byteLength
650
- });
651
- bufferViews.push({
652
- buffer: buffers.length - 1,
653
- byteOffset: 0,
654
- byteLength: meshNormals.byteLength,
655
- target: 34962
656
- });
657
- accessors.push({
658
- bufferView: bufferViews.length - 1,
659
- byteOffset: 0,
660
- componentType: 5126,
661
- count: meshNormals.length / 3,
662
- type: "VEC3"
663
- });
664
- }
665
- if (defined_default(uv0URL)) {
666
- attributes.TEXCOORD_0 = accessors.length;
667
- buffers.push({
668
- uri: uv0URL,
669
- byteLength: meshUv0s.byteLength
670
- });
671
- bufferViews.push({
672
- buffer: buffers.length - 1,
673
- byteOffset: 0,
674
- byteLength: meshUv0s.byteLength,
675
- target: 34962
676
- });
677
- accessors.push({
678
- bufferView: bufferViews.length - 1,
679
- byteOffset: 0,
680
- componentType: 5126,
681
- count: meshUv0s.length / 2,
682
- type: "VEC2"
683
- });
684
- }
685
- if (defined_default(colorsURL)) {
686
- attributes.COLOR_0 = accessors.length;
687
- buffers.push({
688
- uri: colorsURL,
689
- byteLength: meshColorsInBytes.byteLength
690
- });
691
- bufferViews.push({
692
- buffer: buffers.length - 1,
693
- byteOffset: 0,
694
- byteLength: meshColorsInBytes.byteLength,
695
- target: 34962
696
- });
697
- accessors.push({
698
- bufferView: bufferViews.length - 1,
699
- byteOffset: 0,
700
- componentType: 5126,
701
- count: meshColorsInBytes.length / 4,
702
- type: "VEC4"
703
- });
704
- }
705
- if (defined_default(featureId0URL)) {
706
- attributes._FEATURE_ID_0 = accessors.length;
707
- buffers.push({
708
- uri: featureId0URL,
709
- byteLength: meshFeatureId0.byteLength
710
- });
711
- bufferViews.push({
712
- buffer: buffers.length - 1,
713
- byteOffset: 0,
714
- byteLength: meshFeatureId0.byteLength,
715
- target: 34963
716
- });
717
- accessors.push({
718
- bufferView: bufferViews.length - 1,
719
- byteOffset: 0,
720
- componentType: 5126,
721
- count: meshFeatureId0.length,
722
- type: "SCALAR"
723
- });
724
- extensions.EXT_mesh_features = {
725
- featureIds: [
726
- {
727
- attribute: 0,
728
- propertyTable: 0,
729
- featureCount
730
- }
731
- ]
732
- };
733
- extensionsUsed.push("EXT_mesh_features");
734
- }
735
- if (defined_default(propertyTable0URL)) {
736
- buffers.push({
737
- uri: propertyTable0URL,
738
- byteLength: meshPropertyTable0.byteLength
739
- });
740
- bufferViews.push({
741
- buffer: buffers.length - 1,
742
- byteOffset: 0,
743
- byteLength: meshPropertyTable0.byteLength,
744
- target: 34963
745
- });
746
- rootExtensions.EXT_structural_metadata = {
747
- schema: {
748
- id: "i3s-metadata-schema-001",
749
- name: "I3S metadata schema 001",
750
- description: "The schema for I3S metadata",
751
- version: "1.0",
752
- classes: {
753
- feature: {
754
- name: "feature",
755
- description: "Feature metadata",
756
- properties: {
757
- index: {
758
- description: "The feature index",
759
- type: "SCALAR",
760
- componentType: "FLOAT32",
761
- required: true
762
- }
763
- }
764
- }
765
- }
766
- },
767
- propertyTables: [
768
- {
769
- name: "feature-indices-mapping",
770
- class: "feature",
771
- count: featureCount,
772
- properties: {
773
- index: {
774
- values: bufferViews.length - 1
775
- }
776
- }
777
- }
778
- ]
779
- };
780
- extensionsUsed.push("EXT_structural_metadata");
781
- }
782
- if (defined_default(outlinesIndicesURL)) {
783
- buffers.push({
784
- uri: outlinesIndicesURL,
785
- byteLength: outlinesIndexArray.byteLength
786
- });
787
- bufferViews.push({
788
- buffer: buffers.length - 1,
789
- byteOffset: 0,
790
- byteLength: outlinesIndexArray.byteLength,
791
- target: 34963
792
- });
793
- accessors.push({
794
- bufferView: bufferViews.length - 1,
795
- byteOffset: 0,
796
- componentType: 5125,
797
- count: outlinesIndexArray.length,
798
- type: "SCALAR"
799
- });
800
- extensions.CESIUM_primitive_outline = {
801
- indices: accessors.length - 1
802
- };
803
- extensionsUsed.push("CESIUM_primitive_outline");
804
- }
805
- buffers.push({
806
- uri: indicesURL,
807
- byteLength: indexArray.byteLength
808
- });
809
- bufferViews.push({
810
- buffer: buffers.length - 1,
811
- byteOffset: 0,
812
- byteLength: indexArray.byteLength,
813
- target: 34963
814
- });
815
- const meshPrimitives = [];
816
- if (transparentVertexOffset > 0) {
817
- accessors.push({
818
- bufferView: bufferViews.length - 1,
819
- byteOffset: 0,
820
- componentType: 5125,
821
- count: transparentVertexOffset,
822
- type: "SCALAR"
823
- });
824
- meshPrimitives.push({
825
- attributes,
826
- indices: accessors.length - 1,
827
- material: meshPrimitives.length,
828
- extensions
829
- });
830
- }
831
- if (transparentVertexOffset < vertexCount) {
832
- accessors.push({
833
- bufferView: bufferViews.length - 1,
834
- byteOffset: 4 * transparentVertexOffset,
835
- // skip 4 bytes for each opaque vertex
836
- componentType: 5125,
837
- count: vertexCount - transparentVertexOffset,
838
- type: "SCALAR"
839
- });
840
- meshPrimitives.push({
841
- attributes,
842
- indices: accessors.length - 1,
843
- material: meshPrimitives.length,
844
- extensions,
845
- extra: {
846
- isTransparent: true
847
- }
848
- });
849
- }
850
- meshes.push({
851
- primitives: meshPrimitives
852
- });
853
- nodesInScene.push(0);
854
- nodes.push({ mesh: 0 });
855
- return {
856
- buffers,
857
- bufferViews,
858
- accessors,
859
- meshes,
860
- nodes,
861
- nodesInScene,
862
- rootExtensions,
863
- extensionsUsed
864
- };
865
- }
866
- function decode(data, schema, bufferInfo, featureData) {
867
- const magicNumber = new Uint8Array(data, 0, 5);
868
- if (magicNumber[0] === "D".charCodeAt() && magicNumber[1] === "R".charCodeAt() && magicNumber[2] === "A".charCodeAt() && magicNumber[3] === "C".charCodeAt() && magicNumber[4] === "O".charCodeAt()) {
869
- return decodeDracoEncodedGeometry(data, bufferInfo);
870
- }
871
- return decodeBinaryGeometry(data, schema, bufferInfo, featureData);
872
- }
873
- function decodeDracoEncodedGeometry(data) {
874
- const dracoDecoderModule = draco;
875
- const buffer = new dracoDecoderModule.DecoderBuffer();
876
- const byteArray = new Uint8Array(data);
877
- buffer.Init(byteArray, byteArray.length);
878
- const dracoDecoder = new dracoDecoderModule.Decoder();
879
- const geometryType = dracoDecoder.GetEncodedGeometryType(buffer);
880
- const metadataQuerier = new dracoDecoderModule.MetadataQuerier();
881
- let dracoGeometry;
882
- let status;
883
- if (geometryType === dracoDecoderModule.TRIANGULAR_MESH) {
884
- dracoGeometry = new dracoDecoderModule.Mesh();
885
- status = dracoDecoder.DecodeBufferToMesh(buffer, dracoGeometry);
886
- }
887
- const decodedGeometry = {
888
- vertexCount: [0],
889
- featureCount: 0
890
- };
891
- if (defined_default(status) && status.ok() && dracoGeometry.ptr !== 0) {
892
- const faceCount = dracoGeometry.num_faces();
893
- const attributesCount = dracoGeometry.num_attributes();
894
- const vertexCount = dracoGeometry.num_points();
895
- decodedGeometry.indices = new Uint32Array(faceCount * 3);
896
- const faces = decodedGeometry.indices;
897
- decodedGeometry.vertexCount[0] = vertexCount;
898
- decodedGeometry.scale_x = 1;
899
- decodedGeometry.scale_y = 1;
900
- const face = new dracoDecoderModule.DracoInt32Array(3);
901
- for (let faceIndex = 0; faceIndex < faceCount; ++faceIndex) {
902
- dracoDecoder.GetFaceFromMesh(dracoGeometry, faceIndex, face);
903
- faces[faceIndex * 3] = face.GetValue(0);
904
- faces[faceIndex * 3 + 1] = face.GetValue(1);
905
- faces[faceIndex * 3 + 2] = face.GetValue(2);
906
- }
907
- dracoDecoderModule.destroy(face);
908
- for (let attrIndex = 0; attrIndex < attributesCount; ++attrIndex) {
909
- const dracoAttribute = dracoDecoder.GetAttribute(
910
- dracoGeometry,
911
- attrIndex
912
- );
913
- const attributeData = decodeDracoAttribute(
914
- dracoDecoderModule,
915
- dracoDecoder,
916
- dracoGeometry,
917
- dracoAttribute,
918
- vertexCount
919
- );
920
- const dracoAttributeType = dracoAttribute.attribute_type();
921
- let attributei3sName = "unknown";
922
- if (dracoAttributeType === dracoDecoderModule.POSITION) {
923
- attributei3sName = "positions";
924
- } else if (dracoAttributeType === dracoDecoderModule.NORMAL) {
925
- attributei3sName = "normals";
926
- } else if (dracoAttributeType === dracoDecoderModule.COLOR) {
927
- attributei3sName = "colors";
928
- } else if (dracoAttributeType === dracoDecoderModule.TEX_COORD) {
929
- attributei3sName = "uv0s";
930
- }
931
- const metadata = dracoDecoder.GetAttributeMetadata(
932
- dracoGeometry,
933
- attrIndex
934
- );
935
- if (metadata.ptr !== 0) {
936
- const numEntries = metadataQuerier.NumEntries(metadata);
937
- for (let entry = 0; entry < numEntries; ++entry) {
938
- const entryName = metadataQuerier.GetEntryName(metadata, entry);
939
- if (entryName === "i3s-scale_x") {
940
- decodedGeometry.scale_x = metadataQuerier.GetDoubleEntry(
941
- metadata,
942
- "i3s-scale_x"
943
- );
944
- } else if (entryName === "i3s-scale_y") {
945
- decodedGeometry.scale_y = metadataQuerier.GetDoubleEntry(
946
- metadata,
947
- "i3s-scale_y"
948
- );
949
- } else if (entryName === "i3s-attribute-type") {
950
- attributei3sName = metadataQuerier.GetStringEntry(
951
- metadata,
952
- "i3s-attribute-type"
953
- );
954
- }
955
- }
956
- }
957
- if (defined_default(decodedGeometry[attributei3sName])) {
958
- console.log("Attribute already exists", attributei3sName);
959
- }
960
- decodedGeometry[attributei3sName] = attributeData;
961
- if (attributei3sName === "feature-index") {
962
- decodedGeometry.featureCount++;
963
- }
964
- }
965
- dracoDecoderModule.destroy(dracoGeometry);
966
- }
967
- dracoDecoderModule.destroy(metadataQuerier);
968
- dracoDecoderModule.destroy(dracoDecoder);
969
- return decodedGeometry;
970
- }
971
- function decodeDracoAttribute(dracoDecoderModule, dracoDecoder, dracoGeometry, dracoAttribute, vertexCount) {
972
- const bufferSize = dracoAttribute.num_components() * vertexCount;
973
- let dracoAttributeData;
974
- const handlers = [
975
- function() {
976
- },
977
- // DT_INVALID - 0
978
- function() {
979
- dracoAttributeData = new dracoDecoderModule.DracoInt8Array(bufferSize);
980
- const success = dracoDecoder.GetAttributeInt8ForAllPoints(
981
- dracoGeometry,
982
- dracoAttribute,
983
- dracoAttributeData
984
- );
985
- if (!success) {
986
- console.error("Bad stream");
987
- }
988
- const attributeData2 = new Int8Array(bufferSize);
989
- for (let i = 0; i < bufferSize; ++i) {
990
- attributeData2[i] = dracoAttributeData.GetValue(i);
991
- }
992
- return attributeData2;
993
- },
994
- function() {
995
- dracoAttributeData = new dracoDecoderModule.DracoInt8Array(bufferSize);
996
- const success = dracoDecoder.GetAttributeUInt8ForAllPoints(
997
- dracoGeometry,
998
- dracoAttribute,
999
- dracoAttributeData
1000
- );
1001
- if (!success) {
1002
- console.error("Bad stream");
1003
- }
1004
- const attributeData2 = new Uint8Array(bufferSize);
1005
- for (let i = 0; i < bufferSize; ++i) {
1006
- attributeData2[i] = dracoAttributeData.GetValue(i);
1007
- }
1008
- return attributeData2;
1009
- },
1010
- function() {
1011
- dracoAttributeData = new dracoDecoderModule.DracoInt16Array(bufferSize);
1012
- const success = dracoDecoder.GetAttributeInt16ForAllPoints(
1013
- dracoGeometry,
1014
- dracoAttribute,
1015
- dracoAttributeData
1016
- );
1017
- if (!success) {
1018
- console.error("Bad stream");
1019
- }
1020
- const attributeData2 = new Int16Array(bufferSize);
1021
- for (let i = 0; i < bufferSize; ++i) {
1022
- attributeData2[i] = dracoAttributeData.GetValue(i);
1023
- }
1024
- return attributeData2;
1025
- },
1026
- function() {
1027
- dracoAttributeData = new dracoDecoderModule.DracoInt16Array(bufferSize);
1028
- const success = dracoDecoder.GetAttributeUInt16ForAllPoints(
1029
- dracoGeometry,
1030
- dracoAttribute,
1031
- dracoAttributeData
1032
- );
1033
- if (!success) {
1034
- console.error("Bad stream");
1035
- }
1036
- const attributeData2 = new Uint16Array(bufferSize);
1037
- for (let i = 0; i < bufferSize; ++i) {
1038
- attributeData2[i] = dracoAttributeData.GetValue(i);
1039
- }
1040
- return attributeData2;
1041
- },
1042
- function() {
1043
- dracoAttributeData = new dracoDecoderModule.DracoInt32Array(bufferSize);
1044
- const success = dracoDecoder.GetAttributeInt32ForAllPoints(
1045
- dracoGeometry,
1046
- dracoAttribute,
1047
- dracoAttributeData
1048
- );
1049
- if (!success) {
1050
- console.error("Bad stream");
1051
- }
1052
- const attributeData2 = new Int32Array(bufferSize);
1053
- for (let i = 0; i < bufferSize; ++i) {
1054
- attributeData2[i] = dracoAttributeData.GetValue(i);
1055
- }
1056
- return attributeData2;
1057
- },
1058
- function() {
1059
- dracoAttributeData = new dracoDecoderModule.DracoInt32Array(bufferSize);
1060
- const success = dracoDecoder.GetAttributeUInt32ForAllPoints(
1061
- dracoGeometry,
1062
- dracoAttribute,
1063
- dracoAttributeData
1064
- );
1065
- if (!success) {
1066
- console.error("Bad stream");
1067
- }
1068
- const attributeData2 = new Uint32Array(bufferSize);
1069
- for (let i = 0; i < bufferSize; ++i) {
1070
- attributeData2[i] = dracoAttributeData.GetValue(i);
1071
- }
1072
- return attributeData2;
1073
- },
1074
- function() {
1075
- },
1076
- function() {
1077
- },
1078
- function() {
1079
- dracoAttributeData = new dracoDecoderModule.DracoFloat32Array(bufferSize);
1080
- const success = dracoDecoder.GetAttributeFloatForAllPoints(
1081
- dracoGeometry,
1082
- dracoAttribute,
1083
- dracoAttributeData
1084
- );
1085
- if (!success) {
1086
- console.error("Bad stream");
1087
- }
1088
- const attributeData2 = new Float32Array(bufferSize);
1089
- for (let i = 0; i < bufferSize; ++i) {
1090
- attributeData2[i] = dracoAttributeData.GetValue(i);
1091
- }
1092
- return attributeData2;
1093
- },
1094
- function() {
1095
- },
1096
- function() {
1097
- dracoAttributeData = new dracoDecoderModule.DracoUInt8Array(bufferSize);
1098
- const success = dracoDecoder.GetAttributeUInt8ForAllPoints(
1099
- dracoGeometry,
1100
- dracoAttribute,
1101
- dracoAttributeData
1102
- );
1103
- if (!success) {
1104
- console.error("Bad stream");
1105
- }
1106
- const attributeData2 = new Uint8Array(bufferSize);
1107
- for (let i = 0; i < bufferSize; ++i) {
1108
- attributeData2[i] = dracoAttributeData.GetValue(i);
1109
- }
1110
- return attributeData2;
1111
- }
1112
- ];
1113
- const attributeData = handlers[dracoAttribute.data_type()]();
1114
- if (defined_default(dracoAttributeData)) {
1115
- dracoDecoderModule.destroy(dracoAttributeData);
1116
- }
1117
- return attributeData;
1118
- }
1119
- var binaryAttributeDecoders = {
1120
- position: function(decodedGeometry, data, offset) {
1121
- const count = decodedGeometry.vertexCount * 3;
1122
- decodedGeometry.positions = new Float32Array(data, offset, count);
1123
- offset += count * 4;
1124
- return offset;
1125
- },
1126
- normal: function(decodedGeometry, data, offset) {
1127
- const count = decodedGeometry.vertexCount * 3;
1128
- decodedGeometry.normals = new Float32Array(data, offset, count);
1129
- offset += count * 4;
1130
- return offset;
1131
- },
1132
- uv0: function(decodedGeometry, data, offset) {
1133
- const count = decodedGeometry.vertexCount * 2;
1134
- decodedGeometry.uv0s = new Float32Array(data, offset, count);
1135
- offset += count * 4;
1136
- return offset;
1137
- },
1138
- color: function(decodedGeometry, data, offset) {
1139
- const count = decodedGeometry.vertexCount * 4;
1140
- decodedGeometry.colors = new Uint8Array(data, offset, count);
1141
- offset += count;
1142
- return offset;
1143
- },
1144
- featureId: function(decodedGeometry, data, offset) {
1145
- const count = decodedGeometry.featureCount;
1146
- offset += count * 8;
1147
- return offset;
1148
- },
1149
- id: function(decodedGeometry, data, offset) {
1150
- const count = decodedGeometry.featureCount;
1151
- offset += count * 8;
1152
- return offset;
1153
- },
1154
- faceRange: function(decodedGeometry, data, offset) {
1155
- const count = decodedGeometry.featureCount * 2;
1156
- decodedGeometry.faceRange = new Uint32Array(data, offset, count);
1157
- offset += count * 4;
1158
- return offset;
1159
- },
1160
- uvRegion: function(decodedGeometry, data, offset) {
1161
- const count = decodedGeometry.vertexCount * 4;
1162
- decodedGeometry["uv-region"] = new Uint16Array(data, offset, count);
1163
- offset += count * 2;
1164
- return offset;
1165
- },
1166
- region: function(decodedGeometry, data, offset) {
1167
- const count = decodedGeometry.vertexCount * 4;
1168
- decodedGeometry["uv-region"] = new Uint16Array(data, offset, count);
1169
- offset += count * 2;
1170
- return offset;
1171
- }
1172
- };
1173
- function decodeBinaryGeometry(data, schema, bufferInfo, featureData) {
1174
- const decodedGeometry = {
1175
- vertexCount: 0
1176
- };
1177
- const dataView = new DataView(data);
1178
- try {
1179
- let offset = 0;
1180
- decodedGeometry.vertexCount = dataView.getUint32(offset, 1);
1181
- offset += 4;
1182
- decodedGeometry.featureCount = dataView.getUint32(offset, 1);
1183
- offset += 4;
1184
- if (defined_default(bufferInfo)) {
1185
- for (let attrIndex = 0; attrIndex < bufferInfo.attributes.length; attrIndex++) {
1186
- if (defined_default(binaryAttributeDecoders[bufferInfo.attributes[attrIndex]])) {
1187
- offset = binaryAttributeDecoders[bufferInfo.attributes[attrIndex]](
1188
- decodedGeometry,
1189
- data,
1190
- offset
1191
- );
1192
- } else {
1193
- console.error(
1194
- "Unknown decoder for",
1195
- bufferInfo.attributes[attrIndex]
1196
- );
1197
- }
1198
- }
1199
- } else {
1200
- let ordering = schema.ordering;
1201
- let featureAttributeOrder = schema.featureAttributeOrder;
1202
- if (defined_default(featureData) && defined_default(featureData.geometryData) && defined_default(featureData.geometryData[0]) && defined_default(featureData.geometryData[0].params)) {
1203
- ordering = Object.keys(
1204
- featureData.geometryData[0].params.vertexAttributes
1205
- );
1206
- featureAttributeOrder = Object.keys(
1207
- featureData.geometryData[0].params.featureAttributes
1208
- );
1209
- }
1210
- for (let i = 0; i < ordering.length; i++) {
1211
- const decoder = binaryAttributeDecoders[ordering[i]];
1212
- offset = decoder(decodedGeometry, data, offset);
1213
- }
1214
- for (let j = 0; j < featureAttributeOrder.length; j++) {
1215
- const curDecoder = binaryAttributeDecoders[featureAttributeOrder[j]];
1216
- offset = curDecoder(decodedGeometry, data, offset);
1217
- }
1218
- }
1219
- } catch (e) {
1220
- console.error(e);
1221
- }
1222
- decodedGeometry.scale_x = 1;
1223
- decodedGeometry.scale_y = 1;
1224
- return decodedGeometry;
1225
- }
1226
- function decodeAndCreateGltf(parameters) {
1227
- const geometryData = decode(
1228
- parameters.binaryData,
1229
- parameters.schema,
1230
- parameters.bufferInfo,
1231
- parameters.featureData
1232
- );
1233
- if (defined_default(parameters.geoidDataList) && parameters.geoidDataList.length > 0) {
1234
- orthometricToEllipsoidal(
1235
- geometryData.vertexCount,
1236
- geometryData.positions,
1237
- geometryData.scale_x,
1238
- geometryData.scale_y,
1239
- parameters.cartographicCenter,
1240
- parameters.geoidDataList,
1241
- false
1242
- );
1243
- }
1244
- transformToLocal(
1245
- geometryData.vertexCount,
1246
- geometryData.positions,
1247
- geometryData.normals,
1248
- parameters.cartographicCenter,
1249
- parameters.cartesianCenter,
1250
- parameters.parentRotation,
1251
- parameters.ellipsoidRadiiSquare,
1252
- geometryData.scale_x,
1253
- geometryData.scale_y
1254
- );
1255
- if (defined_default(geometryData.uv0s) && defined_default(geometryData["uv-region"])) {
1256
- cropUVs(
1257
- geometryData.vertexCount,
1258
- geometryData.uv0s,
1259
- geometryData["uv-region"]
1260
- );
1261
- }
1262
- let featureIndex;
1263
- if (defined_default(geometryData["feature-index"])) {
1264
- featureIndex = geometryData["feature-index"];
1265
- } else if (defined_default(geometryData["faceRange"])) {
1266
- featureIndex = new Array(geometryData.vertexCount);
1267
- for (let range = 0; range < geometryData["faceRange"].length - 1; range += 2) {
1268
- const curIndex = range / 2;
1269
- const rangeStart = geometryData["faceRange"][range];
1270
- const rangeEnd = geometryData["faceRange"][range + 1];
1271
- for (let i = rangeStart; i <= rangeEnd; i++) {
1272
- featureIndex[i * 3] = curIndex;
1273
- featureIndex[i * 3 + 1] = curIndex;
1274
- featureIndex[i * 3 + 2] = curIndex;
1275
- }
1276
- }
1277
- }
1278
- if (parameters.calculateNormals) {
1279
- const data = generateNormals(
1280
- geometryData.vertexCount,
1281
- geometryData.indices,
1282
- geometryData.positions,
1283
- geometryData.normals,
1284
- geometryData.uv0s,
1285
- geometryData.colors,
1286
- featureIndex
1287
- );
1288
- if (defined_default(data.normals)) {
1289
- geometryData.normals = data.normals;
1290
- if (defined_default(data.vertexCount)) {
1291
- geometryData.vertexCount = data.vertexCount;
1292
- geometryData.indices = data.indices;
1293
- geometryData.positions = data.positions;
1294
- geometryData.uv0s = data.uv0s;
1295
- geometryData.colors = data.colors;
1296
- featureIndex = data.featureIndex;
1297
- }
1298
- }
1299
- }
1300
- const meshData = generateGltfBuffer(
1301
- geometryData.vertexCount,
1302
- geometryData.indices,
1303
- geometryData.positions,
1304
- geometryData.normals,
1305
- geometryData.uv0s,
1306
- geometryData.colors,
1307
- featureIndex,
1308
- parameters
1309
- );
1310
- const customAttributes = {
1311
- positions: geometryData.positions,
1312
- indices: geometryData.indices,
1313
- featureIndex,
1314
- sourceURL: parameters.url,
1315
- cartesianCenter: parameters.cartesianCenter,
1316
- parentRotation: parameters.parentRotation
1317
- };
1318
- meshData._customAttributes = customAttributes;
1319
- const results = {
1320
- meshData
1321
- };
1322
- return results;
1323
- }
1324
- async function initWorker(parameters, transferableObjects) {
1325
- const wasmConfig = parameters.webAssemblyConfig;
1326
- if (defined_default(wasmConfig) && defined_default(wasmConfig.wasmBinaryFile)) {
1327
- draco = await (0, import_draco_decoder_nodejs.default)(wasmConfig);
1328
- } else {
1329
- draco = await (0, import_draco_decoder_nodejs.default)();
1330
- }
1331
- return true;
1332
- }
1333
- function decodeI3S(parameters, transferableObjects) {
1334
- const wasmConfig = parameters.webAssemblyConfig;
1335
- if (defined_default(wasmConfig)) {
1336
- return initWorker(parameters, transferableObjects);
1337
- }
1338
- return decodeAndCreateGltf(parameters, transferableObjects);
1339
- }
1340
- var decodeI3S_default = createTaskProcessorWorker_default(decodeI3S);
1341
- export {
1342
- decodeI3S_default as default
1343
- };
26
+ import{a as mt}from"./chunk-35SHYARM.js";import{a as P}from"./chunk-HMIYSTF6.js";import{a as ht}from"./chunk-WZDE3RYP.js";import{a as ft}from"./chunk-DQQ63PYM.js";import{a as g,b as ot,d as st,e as it}from"./chunk-64RSHJUE.js";import{a as M}from"./chunk-3SSKC3VN.js";import{b as lt}from"./chunk-LEYMRMBK.js";import{d as pt,e as h}from"./chunk-VTAIKJXX.js";var at=pt(mt(),1);function xt(n){return lt.defined("value",n),n<=.04045?n*.07739938080495357:Math.pow((n+.055)*.9478672985781991,2.4)}var k=xt;var ut;function wt(n,t,e,o,a,i){let r=e*(1-n)+o*n,s=a*(1-n)+i*n;return r*(1-t)+s*t}function H(n,t,e,o){let a=n+t*e;return o[a]}function It(n,t,e){let o=e.nativeExtent,a=(n-o.west)/(o.east-o.west)*(e.width-1),i=(t-o.south)/(o.north-o.south)*(e.height-1),r=Math.floor(a),s=Math.floor(i);a-=r,i-=s;let c=r<e.width?r+1:r,u=s<e.height?s+1:s;s=e.height-1-s,u=e.height-1-u;let l=H(r,s,e.width,e.buffer),f=H(c,s,e.width,e.buffer),p=H(r,u,e.width,e.buffer),m=H(c,u,e.width,e.buffer),d=wt(a,i,l,f,p,m);return d=d*e.scale+e.offset,d}function yt(n,t,e){for(let o=0;o<e.length;o++){let a=e[o].nativeExtent,i=new g;if(e[o].projectionType==="WebMercator"){let r=e[o].projection._ellipsoid._radii;i=new ft(new st(r.x,r.y,r.z)).project(new ot(n,t,0))}else i.x=n,i.y=t;if(i.x>a.west&&i.x<a.east&&i.y>a.south&&i.y<a.north)return It(i.x,i.y,e[o])}return 0}function At(n,t,e,o,a,i,r){if(r)return;let s=yt(a.longitude,a.latitude,i);for(let c=0;c<n;++c){let u=yt(a.longitude+M.toRadians(e*t[c*3]),a.latitude+M.toRadians(o*t[c*3+1]),i);t[c*3+2]+=u-s}}function Lt(n,t,e,o,a,i,r,s,c){if(n===0||!h(t)||t.length===0)return;let u=new st(Math.sqrt(r.x),Math.sqrt(r.y),Math.sqrt(r.z));for(let l=0;l<n;++l){let f=l*3,p=f+1,m=f+2,d=new ot;d.longitude=o.longitude+M.toRadians(s*t[f]),d.latitude=o.latitude+M.toRadians(c*t[p]),d.height=o.height+t[m];let b={};u.cartographicToCartesian(d,b),b.x-=a.x,b.y-=a.y,b.z-=a.z;let x={};if(it.multiplyByVector(i,b,x),t[f]=x.x,t[p]=x.y,t[m]=x.z,h(e)){let T=new g(e[f],e[p],e[m]),I={};it.multiplyByVector(i,T,I),e[f]=I.x,e[p]=I.y,e[m]=I.z}}}function Ot(n,t,e){for(let o=0;o<n;++o){let a=e[o*4]/65535,i=e[o*4+1]/65535,r=(e[o*4+2]-e[o*4])/65535,s=(e[o*4+3]-e[o*4+1])/65535;t[o*2]*=r,t[o*2]+=a,t[o*2+1]*=s,t[o*2+1]+=i}}function Tt(n,t,e,o){let a=new Uint32Array(n),i=h(t)?s=>t[s]:s=>s,r=0;if(o&&h(e)){let s=c=>e[i(c)*4+3]<255;for(let c=0;c<n;c+=3)!s(c)&&!s(c+1)&&!s(c+2)&&(a[r++]=i(c),a[r++]=i(c+1),a[r++]=i(c+2));if(r>0){let c=r;for(let u=0;u<n;u+=3)(s(u)||s(u+1)||s(u+2))&&(a[c++]=i(u),a[c++]=i(u+1),a[c++]=i(u+2))}else for(let c=0;c<n;++c)a[c]=i(c)}else{r=n;for(let s=0;s<n;++s)a[s]=i(s)}return{indexArray:a,transparentVertexOffset:r}}function Ct(n,t,e){let o=t[e];if(h(o))return o;let a=t[e]={positions:{},indices:{},edges:{}},i=n[e]??n.default;return a.hasOutline=h(i?.edges),a}function Ft(n,t,e,o){if(!h(n[e])){let a=e*3,i=t;for(let r=0;r<3;r++){let s=o[a+r];h(i[s])||(i[s]={}),i=i[s]}h(i.index)||(i.index=e),n[e]=i.index}}function Ut(n,t,e,o,a,i){let r,s;o<a?(r=o,s=a):(r=a,s=o);let c=n[r];h(c)||(c=n[r]={});let u=c[s];h(u)||(u=c[s]={normalsIndex:[],outlines:[]}),u.normalsIndex.push(i),(u.outlines.length===0||t!==o||e!==a)&&u.outlines.push(t,e)}function Vt(n,t,e,o){let a=[];for(let i=0;i<e.length;i+=3){let r=h(t)?t[e[i]]:"default",s=Ct(n,a,r);if(!s.hasOutline)continue;let c=s.indices,u=s.positions;for(let f=0;f<3;f++){let p=e[i+f];Ft(c,u,p,o)}let l=s.edges;for(let f=0;f<3;f++){let p=e[i+f],m=e[i+(f+1)%3],d=c[p],b=c[m];Ut(l,p,m,d,b,i)}}return a}var O=new g,X=new g,Y=new g;function bt(n,t,e,o){let a=e[t]*3,i=e[t+1]*3,r=e[t+2]*3;g.fromArray(o,a,O),g.fromArray(o,i,X),g.fromArray(o,r,Y),g.subtract(X,O,X),g.subtract(Y,O,Y),g.cross(X,Y,O);let s=g.magnitude(O);s!==0&&g.divideByScalar(O,s,O);let c=t*3,u=(t+1)*3,l=(t+2)*3;g.pack(O,n,c),g.pack(O,n,u),g.pack(O,n,l)}var z=new g,ct=new g;function Et(n,t,e){g.fromArray(n,t,z),g.fromArray(n,e,ct);let o=g.dot(z,ct),a=g.magnitude(g.cross(z,ct,z));return Math.atan2(a,o)<.25}function _t(n,t,e,o,a){if(t.normalsIndex.length>1){let i=o.length===a.length;for(let r=0;r<t.normalsIndex.length;r++){let s=t.normalsIndex[r];if(h(a[s*3])||bt(a,s,e,o),r!==0)for(let c=0;c<r;c++){let u=t.normalsIndex[c],l=i?e[s]*3:s*3,f=i?e[u]*3:u*3;if(Et(a,l,f))return}}}n.push(...t.outlines)}function Rt(n,t,e,o,a){let i=Object.keys(t);for(let r=0;r<i.length;r++){let s=t[i[r]],c=Object.keys(s);for(let u=0;u<c.length;u++){let l=s[c[u]];_t(n,l,e,o,a)}}}function Nt(n,t,e,o){let a=[],i=Object.keys(n);for(let r=0;r<i.length;r++){let s=n[i[r]].edges;Rt(a,s,t,e,o)}return a}function Bt(n,t,e,o,a){if(!h(n)||Object.keys(n).length===0)return;let i=Vt(n,t,e,o);(!h(a)||e.length*3!==a.length)&&(a=[]);let r=Nt(i,e,o,a);return r.length>0?new Uint32Array(r):void 0}function Gt(n){let t=new Float32Array(n.length);for(let e=0;e<n.length;e+=4)t[e]=k(P.byteToFloat(n[e])),t[e+1]=k(P.byteToFloat(n[e+1])),t[e+2]=k(P.byteToFloat(n[e+2])),t[e+3]=P.byteToFloat(n[e+3]);return t}function St(n,t,e,o,a,i,r){let s={normals:void 0,positions:void 0,uv0s:void 0,colors:void 0,featureIndex:void 0,vertexCount:void 0};if(n===0||!h(e)||e.length===0||h(o))return s;if(h(t)){s.vertexCount=t.length,s.positions=new Float32Array(t.length*3),s.uv0s=h(a)?new Float32Array(t.length*2):void 0,s.colors=h(i)?new Uint8Array(t.length*4):void 0,s.featureIndex=h(r)?new Array(t.length):void 0;for(let c=0;c<t.length;c++){let u=t[c];s.positions[c*3]=e[u*3],s.positions[c*3+1]=e[u*3+1],s.positions[c*3+2]=e[u*3+2],h(s.uv0s)&&(s.uv0s[c*2]=a[u*2],s.uv0s[c*2+1]=a[u*2+1]),h(s.colors)&&(s.colors[c*4]=i[u*4],s.colors[c*4+1]=i[u*4+1],s.colors[c*4+2]=i[u*4+2],s.colors[c*4+3]=i[u*4+3]),h(s.featureIndex)&&(s.featureIndex[c]=r[u])}n=t.length,e=s.positions}t=new Array(n);for(let c=0;c<n;c++)t[c]=c;s.normals=new Float32Array(t.length*3);for(let c=0;c<t.length;c+=3)bt(s.normals,c,t,e);return s}function vt(n,t,e,o,a,i,r,s){if(n===0||!h(e)||e.length===0)return{buffers:[],bufferViews:[],accessors:[],meshes:[],nodes:[],nodesInScene:[]};let c=[],u=[],l=[],f=[],p=[],m=[],d={},b=[];h(t)&&(n=t.length);let{indexArray:x,transparentVertexOffset:T}=Tt(n,t,i,s.splitGeometryByColorTransparency),I=new Blob([x],{type:"application/binary"}),A=URL.createObjectURL(I),w=n,F=s.enableFeatures&&h(r)?new Float32Array(r.length):void 0,C=0;if(h(F))for(let y=0;y<r.length;++y){F[y]=r[y];let E=r[y]+1;C<E&&(C=E)}let U,R=Bt(s.symbologyData,r,x,e,o);if(h(R)){let y=new Blob([R],{type:"application/binary"});U=URL.createObjectURL(y)}let L=e.subarray(0,w*3),gt=new Blob([L],{type:"application/binary"}),dt=URL.createObjectURL(gt),D=Number.POSITIVE_INFINITY,K=Number.NEGATIVE_INFINITY,Q=Number.POSITIVE_INFINITY,Z=Number.NEGATIVE_INFINITY,J=Number.POSITIVE_INFINITY,$=Number.NEGATIVE_INFINITY;for(let y=0;y<L.length/3;y++)D=Math.min(D,L[y*3+0]),K=Math.max(K,L[y*3+0]),Q=Math.min(Q,L[y*3+1]),Z=Math.max(Z,L[y*3+1]),J=Math.min(J,L[y*3+2]),$=Math.max($,L[y*3+2]);let N=o?o.subarray(0,w*3):void 0,q;if(h(N)){let y=new Blob([N],{type:"application/binary"});q=URL.createObjectURL(y)}let B=a?a.subarray(0,w*2):void 0,tt;if(h(B)){let y=new Blob([B],{type:"application/binary"});tt=URL.createObjectURL(y)}let G=h(i)?Gt(i.subarray(0,w*4)):void 0,et;if(h(G)){let y=new Blob([G],{type:"application/binary"});et=URL.createObjectURL(y)}let S=h(F)?F.subarray(0,w):void 0,nt;if(h(S)){let y=new Blob([S],{type:"application/binary"});nt=URL.createObjectURL(y)}let _=h(F)?new Float32Array(C):void 0,rt;if(h(_)){for(let E=0;E<_.length;++E)_[E]=E;let y=new Blob([_],{type:"application/binary"});rt=URL.createObjectURL(y)}let V={},j={};V.POSITION=l.length,c.push({uri:dt,byteLength:L.byteLength}),u.push({buffer:c.length-1,byteOffset:0,byteLength:L.byteLength,target:34962}),l.push({bufferView:u.length-1,byteOffset:0,componentType:5126,count:L.length/3,type:"VEC3",max:[D,Q,J],min:[K,Z,$]}),h(q)&&(V.NORMAL=l.length,c.push({uri:q,byteLength:N.byteLength}),u.push({buffer:c.length-1,byteOffset:0,byteLength:N.byteLength,target:34962}),l.push({bufferView:u.length-1,byteOffset:0,componentType:5126,count:N.length/3,type:"VEC3"})),h(tt)&&(V.TEXCOORD_0=l.length,c.push({uri:tt,byteLength:B.byteLength}),u.push({buffer:c.length-1,byteOffset:0,byteLength:B.byteLength,target:34962}),l.push({bufferView:u.length-1,byteOffset:0,componentType:5126,count:B.length/2,type:"VEC2"})),h(et)&&(V.COLOR_0=l.length,c.push({uri:et,byteLength:G.byteLength}),u.push({buffer:c.length-1,byteOffset:0,byteLength:G.byteLength,target:34962}),l.push({bufferView:u.length-1,byteOffset:0,componentType:5126,count:G.length/4,type:"VEC4"})),h(nt)&&(V._FEATURE_ID_0=l.length,c.push({uri:nt,byteLength:S.byteLength}),u.push({buffer:c.length-1,byteOffset:0,byteLength:S.byteLength,target:34963}),l.push({bufferView:u.length-1,byteOffset:0,componentType:5126,count:S.length,type:"SCALAR"}),j.EXT_mesh_features={featureIds:[{attribute:0,propertyTable:0,featureCount:C}]},b.push("EXT_mesh_features")),h(rt)&&(c.push({uri:rt,byteLength:_.byteLength}),u.push({buffer:c.length-1,byteOffset:0,byteLength:_.byteLength,target:34963}),d.EXT_structural_metadata={schema:{id:"i3s-metadata-schema-001",name:"I3S metadata schema 001",description:"The schema for I3S metadata",version:"1.0",classes:{feature:{name:"feature",description:"Feature metadata",properties:{index:{description:"The feature index",type:"SCALAR",componentType:"FLOAT32",required:!0}}}}},propertyTables:[{name:"feature-indices-mapping",class:"feature",count:C,properties:{index:{values:u.length-1}}}]},b.push("EXT_structural_metadata")),h(U)&&(c.push({uri:U,byteLength:R.byteLength}),u.push({buffer:c.length-1,byteOffset:0,byteLength:R.byteLength,target:34963}),l.push({bufferView:u.length-1,byteOffset:0,componentType:5125,count:R.length,type:"SCALAR"}),j.CESIUM_primitive_outline={indices:l.length-1},b.push("CESIUM_primitive_outline")),c.push({uri:A,byteLength:x.byteLength}),u.push({buffer:c.length-1,byteOffset:0,byteLength:x.byteLength,target:34963});let v=[];return T>0&&(l.push({bufferView:u.length-1,byteOffset:0,componentType:5125,count:T,type:"SCALAR"}),v.push({attributes:V,indices:l.length-1,material:v.length,extensions:j})),T<n&&(l.push({bufferView:u.length-1,byteOffset:4*T,componentType:5125,count:n-T,type:"SCALAR"}),v.push({attributes:V,indices:l.length-1,material:v.length,extensions:j,extra:{isTransparent:!0}})),f.push({primitives:v}),m.push(0),p.push({mesh:0}),{buffers:c,bufferViews:u,accessors:l,meshes:f,nodes:p,nodesInScene:m,rootExtensions:d,extensionsUsed:b}}function Mt(n,t,e,o){let a=new Uint8Array(n,0,5);return a[0]===68&&a[1]===82&&a[2]===65&&a[3]===67&&a[4]===79?Pt(n,e):kt(n,t,e,o)}function Pt(n){let t=ut,e=new t.DecoderBuffer,o=new Uint8Array(n);e.Init(o,o.length);let a=new t.Decoder,i=a.GetEncodedGeometryType(e),r=new t.MetadataQuerier,s,c;i===t.TRIANGULAR_MESH&&(s=new t.Mesh,c=a.DecodeBufferToMesh(e,s));let u={vertexCount:[0],featureCount:0};if(h(c)&&c.ok()&&s.ptr!==0){let l=s.num_faces(),f=s.num_attributes(),p=s.num_points();u.indices=new Uint32Array(l*3);let m=u.indices;u.vertexCount[0]=p,u.scale_x=1,u.scale_y=1;let d=new t.DracoInt32Array(3);for(let b=0;b<l;++b)a.GetFaceFromMesh(s,b,d),m[b*3]=d.GetValue(0),m[b*3+1]=d.GetValue(1),m[b*3+2]=d.GetValue(2);t.destroy(d);for(let b=0;b<f;++b){let x=a.GetAttribute(s,b),T=jt(t,a,s,x,p),I=x.attribute_type(),A="unknown";I===t.POSITION?A="positions":I===t.NORMAL?A="normals":I===t.COLOR?A="colors":I===t.TEX_COORD&&(A="uv0s");let w=a.GetAttributeMetadata(s,b);if(w.ptr!==0){let F=r.NumEntries(w);for(let C=0;C<F;++C){let U=r.GetEntryName(w,C);U==="i3s-scale_x"?u.scale_x=r.GetDoubleEntry(w,"i3s-scale_x"):U==="i3s-scale_y"?u.scale_y=r.GetDoubleEntry(w,"i3s-scale_y"):U==="i3s-attribute-type"&&(A=r.GetStringEntry(w,"i3s-attribute-type"))}}h(u[A])&&console.log("Attribute already exists",A),u[A]=T,A==="feature-index"&&u.featureCount++}t.destroy(s)}return t.destroy(r),t.destroy(a),u}function jt(n,t,e,o,a){let i=o.num_components()*a,r,c=[function(){},function(){r=new n.DracoInt8Array(i),t.GetAttributeInt8ForAllPoints(e,o,r)||console.error("Bad stream");let l=new Int8Array(i);for(let f=0;f<i;++f)l[f]=r.GetValue(f);return l},function(){r=new n.DracoInt8Array(i),t.GetAttributeUInt8ForAllPoints(e,o,r)||console.error("Bad stream");let l=new Uint8Array(i);for(let f=0;f<i;++f)l[f]=r.GetValue(f);return l},function(){r=new n.DracoInt16Array(i),t.GetAttributeInt16ForAllPoints(e,o,r)||console.error("Bad stream");let l=new Int16Array(i);for(let f=0;f<i;++f)l[f]=r.GetValue(f);return l},function(){r=new n.DracoInt16Array(i),t.GetAttributeUInt16ForAllPoints(e,o,r)||console.error("Bad stream");let l=new Uint16Array(i);for(let f=0;f<i;++f)l[f]=r.GetValue(f);return l},function(){r=new n.DracoInt32Array(i),t.GetAttributeInt32ForAllPoints(e,o,r)||console.error("Bad stream");let l=new Int32Array(i);for(let f=0;f<i;++f)l[f]=r.GetValue(f);return l},function(){r=new n.DracoInt32Array(i),t.GetAttributeUInt32ForAllPoints(e,o,r)||console.error("Bad stream");let l=new Uint32Array(i);for(let f=0;f<i;++f)l[f]=r.GetValue(f);return l},function(){},function(){},function(){r=new n.DracoFloat32Array(i),t.GetAttributeFloatForAllPoints(e,o,r)||console.error("Bad stream");let l=new Float32Array(i);for(let f=0;f<i;++f)l[f]=r.GetValue(f);return l},function(){},function(){r=new n.DracoUInt8Array(i),t.GetAttributeUInt8ForAllPoints(e,o,r)||console.error("Bad stream");let l=new Uint8Array(i);for(let f=0;f<i;++f)l[f]=r.GetValue(f);return l}][o.data_type()]();return h(r)&&n.destroy(r),c}var W={position:function(n,t,e){let o=n.vertexCount*3;return n.positions=new Float32Array(t,e,o),e+=o*4,e},normal:function(n,t,e){let o=n.vertexCount*3;return n.normals=new Float32Array(t,e,o),e+=o*4,e},uv0:function(n,t,e){let o=n.vertexCount*2;return n.uv0s=new Float32Array(t,e,o),e+=o*4,e},color:function(n,t,e){let o=n.vertexCount*4;return n.colors=new Uint8Array(t,e,o),e+=o,e},featureId:function(n,t,e){let o=n.featureCount;return e+=o*8,e},id:function(n,t,e){let o=n.featureCount;return e+=o*8,e},faceRange:function(n,t,e){let o=n.featureCount*2;return n.faceRange=new Uint32Array(t,e,o),e+=o*4,e},uvRegion:function(n,t,e){let o=n.vertexCount*4;return n["uv-region"]=new Uint16Array(t,e,o),e+=o*2,e},region:function(n,t,e){let o=n.vertexCount*4;return n["uv-region"]=new Uint16Array(t,e,o),e+=o*2,e}};function kt(n,t,e,o){let a={vertexCount:0},i=new DataView(n);try{let r=0;if(a.vertexCount=i.getUint32(r,1),r+=4,a.featureCount=i.getUint32(r,1),r+=4,h(e))for(let s=0;s<e.attributes.length;s++)h(W[e.attributes[s]])?r=W[e.attributes[s]](a,n,r):console.error("Unknown decoder for",e.attributes[s]);else{let s=t.ordering,c=t.featureAttributeOrder;h(o)&&h(o.geometryData)&&h(o.geometryData[0])&&h(o.geometryData[0].params)&&(s=Object.keys(o.geometryData[0].params.vertexAttributes),c=Object.keys(o.geometryData[0].params.featureAttributes));for(let u=0;u<s.length;u++){let l=W[s[u]];r=l(a,n,r)}for(let u=0;u<c.length;u++){let l=W[c[u]];r=l(a,n,r)}}}catch(r){console.error(r)}return a.scale_x=1,a.scale_y=1,a}function Ht(n){let t=Mt(n.binaryData,n.schema,n.bufferInfo,n.featureData);h(n.geoidDataList)&&n.geoidDataList.length>0&&At(t.vertexCount,t.positions,t.scale_x,t.scale_y,n.cartographicCenter,n.geoidDataList,!1),Lt(t.vertexCount,t.positions,t.normals,n.cartographicCenter,n.cartesianCenter,n.parentRotation,n.ellipsoidRadiiSquare,t.scale_x,t.scale_y),h(t.uv0s)&&h(t["uv-region"])&&Ot(t.vertexCount,t.uv0s,t["uv-region"]);let e;if(h(t["feature-index"]))e=t["feature-index"];else if(h(t.faceRange)){e=new Array(t.vertexCount);for(let r=0;r<t.faceRange.length-1;r+=2){let s=r/2,c=t.faceRange[r],u=t.faceRange[r+1];for(let l=c;l<=u;l++)e[l*3]=s,e[l*3+1]=s,e[l*3+2]=s}}if(n.calculateNormals){let r=St(t.vertexCount,t.indices,t.positions,t.normals,t.uv0s,t.colors,e);h(r.normals)&&(t.normals=r.normals,h(r.vertexCount)&&(t.vertexCount=r.vertexCount,t.indices=r.indices,t.positions=r.positions,t.uv0s=r.uv0s,t.colors=r.colors,e=r.featureIndex))}let o=vt(t.vertexCount,t.indices,t.positions,t.normals,t.uv0s,t.colors,e,n),a={positions:t.positions,indices:t.indices,featureIndex:e,sourceURL:n.url,cartesianCenter:n.cartesianCenter,parentRotation:n.parentRotation};return o._customAttributes=a,{meshData:o}}async function Xt(n,t){let e=n.webAssemblyConfig;return h(e)&&h(e.wasmBinaryFile)?ut=await(0,at.default)(e):ut=await(0,at.default)(),!0}function Yt(n,t){let e=n.webAssemblyConfig;return h(e)?Xt(n,t):Ht(n,t)}var re=ht(Yt);export{re as default};