@pggis/pg-sdk 3.2.9 → 3.2.11

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 (110) hide show
  1. package/dist/index.cjs +14767 -13
  2. package/dist/pggis.min.css +1 -1
  3. package/dist/pggis.min.js +14789 -35
  4. package/dist/resources/Assets/approximateTerrainHeights.json +1 -1
  5. package/dist/resources/ThirdParty/Workers/z-worker-pako.js +1 -1
  6. package/dist/resources/ThirdParty/draco_decoder.wasm +0 -0
  7. package/dist/resources/Workers/{chunk-RH4N2ONY.js → chunk-23UFSGND.js} +7 -7
  8. package/dist/resources/Workers/{chunk-HPP4JLNH.js → chunk-2A75IWRS.js} +7 -7
  9. package/dist/resources/Workers/{chunk-5IRLXUTA.js → chunk-2FRVPMCS.js} +10 -10
  10. package/dist/resources/Workers/{chunk-ZQRZBHYI.js → chunk-2FWRMUTY.js} +4 -4
  11. package/dist/resources/Workers/{chunk-Z2SIPUKB.js → chunk-2UPKWTMJ.js} +6 -6
  12. package/dist/resources/Workers/{chunk-434ZTTFX.js → chunk-34FXV7D7.js} +2 -2
  13. package/dist/resources/Workers/{chunk-MW3CJYLX.js → chunk-3VAZEH7M.js} +2 -2
  14. package/dist/resources/Workers/{chunk-HUPNRBWW.js → chunk-4DO5W5XZ.js} +6 -6
  15. package/dist/resources/Workers/{chunk-PIXK6KHB.js → chunk-4H7PY4U5.js} +2 -2
  16. package/dist/resources/Workers/{chunk-BP467WX3.js → chunk-5QULIR53.js} +4 -4
  17. package/dist/resources/Workers/{chunk-R3HUGXBH.js → chunk-7TC63SJW.js} +8 -8
  18. package/dist/resources/Workers/{chunk-SQVTYRZY.js → chunk-7ZFGPDJA.js} +4 -4
  19. package/dist/resources/Workers/{chunk-TIXXVKUY.js → chunk-A5DWLWCY.js} +10 -10
  20. package/dist/resources/Workers/{chunk-CWJQGBWT.js → chunk-BBWDMCVU.js} +1 -1
  21. package/dist/resources/Workers/{chunk-4KP73B43.js → chunk-BG4UCVXN.js} +3 -3
  22. package/dist/resources/Workers/{chunk-Y4OJ4B23.js → chunk-BIKA3NRA.js} +5 -5
  23. package/dist/resources/Workers/{chunk-DR5XZ6K5.js → chunk-BROJAZRZ.js} +13 -13
  24. package/dist/resources/Workers/{chunk-FWGNCYP6.js → chunk-DDUQAJ4P.js} +7 -7
  25. package/dist/resources/Workers/{chunk-QRBRVGZC.js → chunk-EERJKOAF.js} +4 -4
  26. package/dist/resources/Workers/{chunk-52VSIKEA.js → chunk-EG6PTBY2.js} +15 -15
  27. package/dist/resources/Workers/{chunk-O43GWBSF.js → chunk-EHWHNOEX.js} +1 -1
  28. package/dist/resources/Workers/{chunk-MN34FIF5.js → chunk-F3YA3Y2Z.js} +1 -1
  29. package/dist/resources/Workers/{chunk-GF5TNNKP.js → chunk-F4HFJMGM.js} +6 -6
  30. package/dist/resources/Workers/{chunk-HOT2SNXP.js → chunk-FJKNFAKQ.js} +133 -553
  31. package/dist/resources/Workers/{chunk-TMPVBFJQ.js → chunk-FNIRWHJB.js} +10 -10
  32. package/dist/resources/Workers/{chunk-DMCSY5BU.js → chunk-FZRIVR7Y.js} +5 -5
  33. package/dist/resources/Workers/{chunk-Z4JUBRHP.js → chunk-G43QFN4Q.js} +6 -6
  34. package/dist/resources/Workers/{chunk-HPH5HSFE.js → chunk-GATZHF3K.js} +2 -2
  35. package/dist/resources/Workers/{chunk-CSIZ3BGT.js → chunk-GRC2ZTAF.js} +14 -14
  36. package/dist/resources/Workers/{chunk-NE4JNU6H.js → chunk-HU6N6EXB.js} +10 -10
  37. package/dist/resources/Workers/{chunk-GVL5I7TC.js → chunk-I46ZRR5W.js} +17 -17
  38. package/dist/resources/Workers/{chunk-5GDBZTHX.js → chunk-JURN7NPV.js} +17 -17
  39. package/dist/resources/Workers/{chunk-H5DUXHCV.js → chunk-KKCR2YOP.js} +11 -11
  40. package/dist/resources/Workers/{chunk-LX6XV4DK.js → chunk-LPR3YNP2.js} +5 -5
  41. package/dist/resources/Workers/{chunk-HFKSAB5K.js → chunk-M7ERACJJ.js} +13 -13
  42. package/dist/resources/Workers/{chunk-BUZDZBUH.js → chunk-MDWEGWPA.js} +10 -10
  43. package/dist/resources/Workers/{chunk-LGJUI2CE.js → chunk-OGXZVPPM.js} +9 -5
  44. package/dist/resources/Workers/{chunk-PZ2WJWUG.js → chunk-PGSJK77E.js} +6 -6
  45. package/dist/resources/Workers/{chunk-ARPTYYKS.js → chunk-PPH7OFP3.js} +5 -5
  46. package/dist/resources/Workers/{chunk-R4OZKBXH.js → chunk-SH5USDPI.js} +6 -6
  47. package/dist/resources/Workers/{chunk-SV7DDPAC.js → chunk-SOWMRMWA.js} +1 -1
  48. package/dist/resources/Workers/{chunk-RIDPF7PO.js → chunk-STW2DGFI.js} +2 -2
  49. package/dist/resources/Workers/{chunk-CDGHUKQ4.js → chunk-T3XIFPYR.js} +13 -13
  50. package/dist/resources/Workers/chunk-TTUZP4BO.js +501 -0
  51. package/dist/resources/Workers/{chunk-QTZQZY2C.js → chunk-UEXTBDBE.js} +34 -10
  52. package/dist/resources/Workers/{chunk-XUTVA4K5.js → chunk-VOXYEYJT.js} +11 -11
  53. package/dist/resources/Workers/{chunk-AXFRNOVC.js → chunk-X4356LRH.js} +12 -12
  54. package/dist/resources/Workers/{chunk-5HLGKKG3.js → chunk-XGI5BXZY.js} +2 -2
  55. package/dist/resources/Workers/{chunk-SNN7WOC2.js → chunk-Y2ME2IJV.js} +13 -13
  56. package/dist/resources/Workers/{chunk-LGL4P5KL.js → chunk-Y5UQJLYE.js} +6 -6
  57. package/dist/resources/Workers/{chunk-3PW6ZBN4.js → chunk-YJEBABKH.js} +7 -7
  58. package/dist/resources/Workers/{chunk-YBKFS53K.js → chunk-YWTJ2B4B.js} +1 -1
  59. package/dist/resources/Workers/{chunk-5SK36PU4.js → chunk-Z3TIFFGF.js} +7 -7
  60. package/dist/resources/Workers/{chunk-JGG36SQV.js → chunk-ZT7KWISZ.js} +4 -4
  61. package/dist/resources/Workers/combineGeometry.js +24 -23
  62. package/dist/resources/Workers/createBoxGeometry.js +18 -17
  63. package/dist/resources/Workers/createBoxOutlineGeometry.js +16 -15
  64. package/dist/resources/Workers/createCircleGeometry.js +26 -25
  65. package/dist/resources/Workers/createCircleOutlineGeometry.js +19 -18
  66. package/dist/resources/Workers/createCoplanarPolygonGeometry.js +33 -32
  67. package/dist/resources/Workers/createCoplanarPolygonOutlineGeometry.js +31 -30
  68. package/dist/resources/Workers/createCorridorGeometry.js +29 -29
  69. package/dist/resources/Workers/createCorridorOutlineGeometry.js +28 -28
  70. package/dist/resources/Workers/createCylinderGeometry.js +20 -19
  71. package/dist/resources/Workers/createCylinderOutlineGeometry.js +18 -17
  72. package/dist/resources/Workers/createEllipseGeometry.js +26 -25
  73. package/dist/resources/Workers/createEllipseOutlineGeometry.js +19 -18
  74. package/dist/resources/Workers/createEllipsoidGeometry.js +19 -18
  75. package/dist/resources/Workers/createEllipsoidOutlineGeometry.js +18 -17
  76. package/dist/resources/Workers/createFrustumGeometry.js +18 -17
  77. package/dist/resources/Workers/createFrustumOutlineGeometry.js +18 -17
  78. package/dist/resources/Workers/createGeometry.js +54 -33
  79. package/dist/resources/Workers/createGroundPolylineGeometry.js +22 -21
  80. package/dist/resources/Workers/createPlaneGeometry.js +16 -15
  81. package/dist/resources/Workers/createPlaneOutlineGeometry.js +15 -14
  82. package/dist/resources/Workers/createPolygonGeometry.js +32 -166
  83. package/dist/resources/Workers/createPolygonOutlineGeometry.js +30 -29
  84. package/dist/resources/Workers/createPolylineGeometry.js +25 -24
  85. package/dist/resources/Workers/createPolylineVolumeGeometry.js +32 -33
  86. package/dist/resources/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
  87. package/dist/resources/Workers/createRectangleGeometry.js +27 -26
  88. package/dist/resources/Workers/createRectangleOutlineGeometry.js +20 -19
  89. package/dist/resources/Workers/createSimplePolylineGeometry.js +23 -22
  90. package/dist/resources/Workers/createSphereGeometry.js +19 -18
  91. package/dist/resources/Workers/createSphereOutlineGeometry.js +18 -17
  92. package/dist/resources/Workers/createTaskProcessorWorker.js +3 -3
  93. package/dist/resources/Workers/createVectorTileClampedPolylines.js +14 -14
  94. package/dist/resources/Workers/createVectorTileGeometries.js +24 -23
  95. package/dist/resources/Workers/createVectorTilePoints.js +12 -12
  96. package/dist/resources/Workers/createVectorTilePolygons.js +22 -21
  97. package/dist/resources/Workers/createVectorTilePolylines.js +14 -14
  98. package/dist/resources/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -21
  99. package/dist/resources/Workers/createVerticesFromHeightmap.js +22 -21
  100. package/dist/resources/Workers/createVerticesFromQuantizedTerrainMesh.js +19 -18
  101. package/dist/resources/Workers/createWallGeometry.js +24 -23
  102. package/dist/resources/Workers/createWallOutlineGeometry.js +23 -22
  103. package/dist/resources/Workers/decodeDraco.js +11 -11
  104. package/dist/resources/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  105. package/dist/resources/Workers/decodeI3S.js +601 -92
  106. package/dist/resources/Workers/transcodeKTX2.js +7 -7
  107. package/dist/resources/Workers/transferTypedArrayTest.js +1 -1
  108. package/dist/resources/Workers/upsampleQuantizedTerrainMesh.js +22 -21
  109. package/package.json +5 -10
  110. package/dist/resources/Workers/chunk-ATB2I7OS.js +0 -55
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @license
3
3
  * Cesium - https://github.com/CesiumGS/cesium
4
- * Version 1.113
4
+ * Version 1.115
5
5
  *
6
6
  * Copyright 2011-2022 Cesium Contributors
7
7
  *
@@ -25,31 +25,55 @@
25
25
 
26
26
  import {
27
27
  require_draco_decoder_nodejs
28
- } from "./chunk-HPH5HSFE.js";
28
+ } from "./chunk-GATZHF3K.js";
29
+ import {
30
+ Color_default
31
+ } from "./chunk-PGSJK77E.js";
29
32
  import {
30
33
  createTaskProcessorWorker_default
31
- } from "./chunk-MW3CJYLX.js";
34
+ } from "./chunk-3VAZEH7M.js";
32
35
  import {
33
36
  WebMercatorProjection_default
34
- } from "./chunk-Z2SIPUKB.js";
37
+ } from "./chunk-2UPKWTMJ.js";
38
+ import "./chunk-TTUZP4BO.js";
35
39
  import {
36
40
  Cartesian3_default,
37
41
  Cartographic_default,
38
42
  Ellipsoid_default,
39
43
  Matrix3_default
40
- } from "./chunk-LGJUI2CE.js";
44
+ } from "./chunk-OGXZVPPM.js";
41
45
  import {
42
46
  Math_default
43
- } from "./chunk-BP467WX3.js";
44
- import "./chunk-CWJQGBWT.js";
45
- import "./chunk-5HLGKKG3.js";
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";
46
54
  import {
47
55
  __toESM,
48
56
  defined_default
49
- } from "./chunk-YBKFS53K.js";
57
+ } from "./chunk-YWTJ2B4B.js";
50
58
 
51
59
  // packages/engine/Source/Workers/decodeI3S.js
52
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
53
77
  var draco;
54
78
  function bilinearInterpolate(tx, ty, h00, h10, h01, h11) {
55
79
  const a = h00 * (1 - tx) + h10 * tx;
@@ -171,7 +195,317 @@ function cropUVs(vertexCount, uv0s, uvRegions) {
171
195
  uv0s[vertexIndex * 2 + 1] += minV;
172
196
  }
173
197
  }
174
- function generateGltfBuffer(vertexCount, indices, positions, normals, uv0s, colors) {
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) {
175
509
  if (vertexCount === 0 || !defined_default(positions) || positions.length === 0) {
176
510
  return {
177
511
  buffers: [],
@@ -188,22 +522,45 @@ function generateGltfBuffer(vertexCount, indices, positions, normals, uv0s, colo
188
522
  const meshes = [];
189
523
  const nodes = [];
190
524
  const nodesInScene = [];
525
+ const rootExtensions = {};
526
+ const extensionsUsed = [];
191
527
  if (defined_default(indices)) {
192
528
  vertexCount = indices.length;
193
529
  }
194
- const indexArray = new Uint32Array(vertexCount);
195
- if (defined_default(indices)) {
196
- for (let vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex) {
197
- indexArray[vertexIndex] = indices[vertexIndex];
198
- }
199
- } else {
200
- for (let newVertexIndex = 0; newVertexIndex < vertexCount; ++newVertexIndex) {
201
- indexArray[newVertexIndex] = newVertexIndex;
202
- }
203
- }
530
+ const { indexArray, transparentVertexOffset } = generateIndexArray(
531
+ vertexCount,
532
+ indices,
533
+ colors,
534
+ parameters.splitGeometryByColorTransparency
535
+ );
204
536
  const indicesBlob = new Blob([indexArray], { type: "application/binary" });
205
537
  const indicesURL = URL.createObjectURL(indicesBlob);
206
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
+ }
207
564
  const meshPositions = positions.subarray(0, endIndex * 3);
208
565
  const positionsBlob = new Blob([meshPositions], {
209
566
  type: "application/binary"
@@ -237,7 +594,7 @@ function generateGltfBuffer(vertexCount, indices, positions, normals, uv0s, colo
237
594
  const uv0Blob = new Blob([meshUv0s], { type: "application/binary" });
238
595
  uv0URL = URL.createObjectURL(uv0Blob);
239
596
  }
240
- const meshColorsInBytes = defined_default(colors) ? colors.subarray(0, endIndex * 4) : void 0;
597
+ const meshColorsInBytes = defined_default(colors) ? convertColorsArray(colors.subarray(0, endIndex * 4)) : void 0;
241
598
  let colorsURL;
242
599
  if (defined_default(meshColorsInBytes)) {
243
600
  const colorsBlob = new Blob([meshColorsInBytes], {
@@ -245,127 +602,254 @@ function generateGltfBuffer(vertexCount, indices, positions, normals, uv0s, colo
245
602
  });
246
603
  colorsURL = URL.createObjectURL(colorsBlob);
247
604
  }
248
- const posIndex = 0;
249
- let normalIndex = 0;
250
- let uv0Index = 0;
251
- let colorIndex = 0;
252
- let indicesIndex = 0;
253
- let currentIndex = posIndex;
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
+ }
254
624
  const attributes = {};
255
- attributes.POSITION = posIndex;
625
+ const extensions = {};
626
+ attributes.POSITION = accessors.length;
256
627
  buffers.push({
257
628
  uri: positionsURL,
258
629
  byteLength: meshPositions.byteLength
259
630
  });
260
631
  bufferViews.push({
261
- buffer: posIndex,
632
+ buffer: buffers.length - 1,
262
633
  byteOffset: 0,
263
634
  byteLength: meshPositions.byteLength,
264
635
  target: 34962
265
636
  });
266
637
  accessors.push({
267
- bufferView: posIndex,
638
+ bufferView: bufferViews.length - 1,
268
639
  byteOffset: 0,
269
640
  componentType: 5126,
270
- count: vertexCount,
641
+ count: meshPositions.length / 3,
271
642
  type: "VEC3",
272
643
  max: [minX, minY, minZ],
273
644
  min: [maxX, maxY, maxZ]
274
645
  });
275
646
  if (defined_default(normalsURL)) {
276
- ++currentIndex;
277
- normalIndex = currentIndex;
278
- attributes.NORMAL = normalIndex;
647
+ attributes.NORMAL = accessors.length;
279
648
  buffers.push({
280
649
  uri: normalsURL,
281
650
  byteLength: meshNormals.byteLength
282
651
  });
283
652
  bufferViews.push({
284
- buffer: normalIndex,
653
+ buffer: buffers.length - 1,
285
654
  byteOffset: 0,
286
655
  byteLength: meshNormals.byteLength,
287
656
  target: 34962
288
657
  });
289
658
  accessors.push({
290
- bufferView: normalIndex,
659
+ bufferView: bufferViews.length - 1,
291
660
  byteOffset: 0,
292
661
  componentType: 5126,
293
- count: vertexCount,
662
+ count: meshNormals.length / 3,
294
663
  type: "VEC3"
295
664
  });
296
665
  }
297
666
  if (defined_default(uv0URL)) {
298
- ++currentIndex;
299
- uv0Index = currentIndex;
300
- attributes.TEXCOORD_0 = uv0Index;
667
+ attributes.TEXCOORD_0 = accessors.length;
301
668
  buffers.push({
302
669
  uri: uv0URL,
303
670
  byteLength: meshUv0s.byteLength
304
671
  });
305
672
  bufferViews.push({
306
- buffer: uv0Index,
673
+ buffer: buffers.length - 1,
307
674
  byteOffset: 0,
308
675
  byteLength: meshUv0s.byteLength,
309
676
  target: 34962
310
677
  });
311
678
  accessors.push({
312
- bufferView: uv0Index,
679
+ bufferView: bufferViews.length - 1,
313
680
  byteOffset: 0,
314
681
  componentType: 5126,
315
- count: vertexCount,
682
+ count: meshUv0s.length / 2,
316
683
  type: "VEC2"
317
684
  });
318
685
  }
319
686
  if (defined_default(colorsURL)) {
320
- ++currentIndex;
321
- colorIndex = currentIndex;
322
- attributes.COLOR_0 = colorIndex;
687
+ attributes.COLOR_0 = accessors.length;
323
688
  buffers.push({
324
689
  uri: colorsURL,
325
690
  byteLength: meshColorsInBytes.byteLength
326
691
  });
327
692
  bufferViews.push({
328
- buffer: colorIndex,
693
+ buffer: buffers.length - 1,
329
694
  byteOffset: 0,
330
695
  byteLength: meshColorsInBytes.byteLength,
331
696
  target: 34962
332
697
  });
333
698
  accessors.push({
334
- bufferView: colorIndex,
699
+ bufferView: bufferViews.length - 1,
335
700
  byteOffset: 0,
336
- componentType: 5121,
337
- normalized: true,
338
- count: vertexCount,
701
+ componentType: 5126,
702
+ count: meshColorsInBytes.length / 4,
339
703
  type: "VEC4"
340
704
  });
341
705
  }
342
- ++currentIndex;
343
- indicesIndex = currentIndex;
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
+ }
344
806
  buffers.push({
345
807
  uri: indicesURL,
346
808
  byteLength: indexArray.byteLength
347
809
  });
348
810
  bufferViews.push({
349
- buffer: indicesIndex,
811
+ buffer: buffers.length - 1,
350
812
  byteOffset: 0,
351
813
  byteLength: indexArray.byteLength,
352
814
  target: 34963
353
815
  });
354
- accessors.push({
355
- bufferView: indicesIndex,
356
- byteOffset: 0,
357
- componentType: 5125,
358
- count: vertexCount,
359
- type: "SCALAR"
360
- });
361
- meshes.push({
362
- primitives: [
363
- {
364
- attributes,
365
- indices: indicesIndex,
366
- material: 0
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
367
848
  }
368
- ]
849
+ });
850
+ }
851
+ meshes.push({
852
+ primitives: meshPrimitives
369
853
  });
370
854
  nodesInScene.push(0);
371
855
  nodes.push({ mesh: 0 });
@@ -375,7 +859,9 @@ function generateGltfBuffer(vertexCount, indices, positions, normals, uv0s, colo
375
859
  accessors,
376
860
  meshes,
377
861
  nodes,
378
- nodesInScene
862
+ nodesInScene,
863
+ rootExtensions,
864
+ extensionsUsed
379
865
  };
380
866
  }
381
867
  function decode(data, schema, bufferInfo, featureData) {
@@ -774,39 +1260,62 @@ function decodeAndCreateGltf(parameters) {
774
1260
  geometryData["uv-region"]
775
1261
  );
776
1262
  }
777
- const meshData = generateGltfBuffer(
778
- geometryData.vertexCount,
779
- geometryData.indices,
780
- geometryData.positions,
781
- geometryData.normals,
782
- geometryData.uv0s,
783
- geometryData.colors
784
- );
785
- const customAttributes = {};
1263
+ let featureIndex;
786
1264
  if (defined_default(geometryData["feature-index"])) {
787
- customAttributes.positions = geometryData.positions;
788
- customAttributes.indices = geometryData.indices;
789
- customAttributes.featureIndex = geometryData["feature-index"];
790
- customAttributes.cartesianCenter = parameters.cartesianCenter;
791
- customAttributes.parentRotation = parameters.parentRotation;
1265
+ featureIndex = geometryData["feature-index"];
792
1266
  } else if (defined_default(geometryData["faceRange"])) {
793
- customAttributes.positions = geometryData.positions;
794
- customAttributes.indices = geometryData.indices;
795
- customAttributes.sourceURL = parameters.url;
796
- customAttributes.cartesianCenter = parameters.cartesianCenter;
797
- customAttributes.parentRotation = parameters.parentRotation;
798
- customAttributes.featureIndex = new Array(geometryData.positions.length);
1267
+ featureIndex = new Array(geometryData.vertexCount);
799
1268
  for (let range = 0; range < geometryData["faceRange"].length - 1; range += 2) {
800
1269
  const curIndex = range / 2;
801
1270
  const rangeStart = geometryData["faceRange"][range];
802
1271
  const rangeEnd = geometryData["faceRange"][range + 1];
803
1272
  for (let i = rangeStart; i <= rangeEnd; i++) {
804
- customAttributes.featureIndex[i * 3] = curIndex;
805
- customAttributes.featureIndex[i * 3 + 1] = curIndex;
806
- customAttributes.featureIndex[i * 3 + 2] = curIndex;
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;
807
1298
  }
808
1299
  }
809
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
+ };
810
1319
  meshData._customAttributes = customAttributes;
811
1320
  const results = {
812
1321
  meshData