@pggis/pg-sdk 3.3.9 → 3.5.0

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