@loaders.gl/i3s 3.1.7 → 3.2.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/dist.min.js +118 -62
  2. package/dist/es5/i3s-attribute-loader.js +1 -1
  3. package/dist/es5/i3s-attribute-loader.js.map +1 -1
  4. package/dist/es5/i3s-building-scene-layer-loader.js +1 -1
  5. package/dist/es5/i3s-building-scene-layer-loader.js.map +1 -1
  6. package/dist/es5/i3s-content-loader.js +1 -1
  7. package/dist/es5/i3s-content-loader.js.map +1 -1
  8. package/dist/es5/i3s-loader.js +1 -1
  9. package/dist/es5/i3s-loader.js.map +1 -1
  10. package/dist/es5/i3s-node-page-loader.js +1 -1
  11. package/dist/es5/i3s-node-page-loader.js.map +1 -1
  12. package/dist/es5/index.js.map +1 -1
  13. package/dist/es5/lib/helpers/i3s-nodepages-tiles.js +43 -52
  14. package/dist/es5/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
  15. package/dist/es5/lib/parsers/parse-i3s-tile-content.js +46 -42
  16. package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +1 -1
  17. package/dist/es5/lib/parsers/parse-i3s.js +8 -12
  18. package/dist/es5/lib/parsers/parse-i3s.js.map +1 -1
  19. package/dist/es5/types.js.map +1 -1
  20. package/dist/esm/i3s-attribute-loader.js +1 -1
  21. package/dist/esm/i3s-attribute-loader.js.map +1 -1
  22. package/dist/esm/i3s-building-scene-layer-loader.js +1 -1
  23. package/dist/esm/i3s-building-scene-layer-loader.js.map +1 -1
  24. package/dist/esm/i3s-content-loader.js +1 -1
  25. package/dist/esm/i3s-content-loader.js.map +1 -1
  26. package/dist/esm/i3s-loader.js +1 -1
  27. package/dist/esm/i3s-loader.js.map +1 -1
  28. package/dist/esm/i3s-node-page-loader.js +1 -1
  29. package/dist/esm/i3s-node-page-loader.js.map +1 -1
  30. package/dist/esm/index.js.map +1 -1
  31. package/dist/esm/lib/helpers/i3s-nodepages-tiles.js +8 -2
  32. package/dist/esm/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
  33. package/dist/esm/lib/parsers/parse-i3s-tile-content.js +33 -29
  34. package/dist/esm/lib/parsers/parse-i3s-tile-content.js.map +1 -1
  35. package/dist/esm/lib/parsers/parse-i3s.js +1 -1
  36. package/dist/esm/lib/parsers/parse-i3s.js.map +1 -1
  37. package/dist/esm/types.js.map +1 -1
  38. package/dist/i3s-building-scene-layer-loader.js +1 -1
  39. package/dist/i3s-content-loader.js +1 -1
  40. package/dist/i3s-content-worker.js +141 -68
  41. package/dist/index.d.ts +1 -1
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/lib/helpers/i3s-nodepages-tiles.d.ts.map +1 -1
  44. package/dist/lib/helpers/i3s-nodepages-tiles.js +7 -3
  45. package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -1
  46. package/dist/lib/parsers/parse-i3s-tile-content.js +33 -29
  47. package/dist/lib/parsers/parse-i3s.js +1 -1
  48. package/dist/types.d.ts +100 -34
  49. package/dist/types.d.ts.map +1 -1
  50. package/package.json +9 -9
  51. package/src/i3s-building-scene-layer-loader.ts +1 -1
  52. package/src/i3s-content-loader.ts +1 -1
  53. package/src/index.ts +4 -1
  54. package/src/lib/helpers/i3s-nodepages-tiles.ts +8 -3
  55. package/src/lib/parsers/parse-i3s-tile-content.ts +37 -32
  56. package/src/lib/parsers/parse-i3s.ts +1 -1
  57. package/src/types.ts +97 -34
@@ -55,7 +55,7 @@
55
55
  var nodeVersion = matches && parseFloat(matches[1]) || 0;
56
56
 
57
57
  // ../worker-utils/src/lib/env-utils/version.ts
58
- var VERSION = true ? "3.1.7" : DEFAULT_VERSION;
58
+ var VERSION = true ? "3.2.0-alpha.2" : DEFAULT_VERSION;
59
59
  if (false) {
60
60
  console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
61
61
  }
@@ -87,13 +87,13 @@
87
87
  // ../worker-utils/src/lib/worker-farm/worker-job.ts
88
88
  var WorkerJob = class {
89
89
  constructor(jobName, workerThread) {
90
- this.name = jobName;
91
- this.workerThread = workerThread;
92
90
  this.isRunning = true;
93
91
  this._resolve = () => {
94
92
  };
95
93
  this._reject = () => {
96
94
  };
95
+ this.name = jobName;
96
+ this.workerThread = workerThread;
97
97
  this.result = new Promise((resolve, reject) => {
98
98
  this._resolve = resolve;
99
99
  this._reject = reject;
@@ -118,6 +118,16 @@
118
118
  }
119
119
  };
120
120
 
121
+ // ../worker-utils/src/lib/node/worker_threads-browser.js
122
+ var Worker2 = class {
123
+ on(message, cb) {
124
+ }
125
+ postMessage(...args) {
126
+ }
127
+ terminate() {
128
+ }
129
+ };
130
+
121
131
  // ../worker-utils/src/lib/worker-utils/get-loadable-worker-url.ts
122
132
  var workerURLCache = new Map();
123
133
  function getLoadableWorkerURL(props) {
@@ -205,10 +215,10 @@
205
215
  this.url = url;
206
216
  this.onMessage = NOOP;
207
217
  this.onError = (error) => console.log(error);
208
- this.worker = this._createBrowserWorker();
218
+ this.worker = isBrowser2 ? this._createBrowserWorker() : this._createNodeWorker();
209
219
  }
210
220
  static isSupported() {
211
- return typeof Worker !== "undefined";
221
+ return typeof Worker !== "undefined" && isBrowser2 || typeof Worker2 !== void 0;
212
222
  }
213
223
  destroy() {
214
224
  this.onMessage = NOOP;
@@ -251,6 +261,27 @@
251
261
  worker.onmessageerror = (event) => console.error(event);
252
262
  return worker;
253
263
  }
264
+ _createNodeWorker() {
265
+ let worker;
266
+ if (this.url) {
267
+ const absolute = this.url.includes(":/") || this.url.startsWith("/");
268
+ const url = absolute ? this.url : `./${this.url}`;
269
+ worker = new Worker2(url, { eval: false });
270
+ } else if (this.source) {
271
+ worker = new Worker2(this.source, { eval: true });
272
+ } else {
273
+ throw new Error("no worker");
274
+ }
275
+ worker.on("message", (data) => {
276
+ this.onMessage(data);
277
+ });
278
+ worker.on("error", (error) => {
279
+ this.onError(error);
280
+ });
281
+ worker.on("exit", (code) => {
282
+ });
283
+ return worker;
284
+ }
254
285
  };
255
286
 
256
287
  // ../worker-utils/src/lib/worker-farm/worker-pool.ts
@@ -271,6 +302,9 @@
271
302
  this.url = props.url;
272
303
  this.setProps(props);
273
304
  }
305
+ static isSupported() {
306
+ return WorkerThread.isSupported();
307
+ }
274
308
  destroy() {
275
309
  this.idleQueue.forEach((worker) => worker.destroy());
276
310
  this.isDestroyed = true;
@@ -360,9 +394,9 @@
360
394
  var DEFAULT_PROPS = {
361
395
  maxConcurrency: 3,
362
396
  maxMobileConcurrency: 1,
397
+ reuseWorkers: true,
363
398
  onDebug: () => {
364
- },
365
- reuseWorkers: true
399
+ }
366
400
  };
367
401
  var WorkerFarm = class {
368
402
  constructor(props) {
@@ -383,6 +417,7 @@
383
417
  for (const workerPool of this.workerPools.values()) {
384
418
  workerPool.destroy();
385
419
  }
420
+ this.workerPools = new Map();
386
421
  }
387
422
  setProps(props) {
388
423
  this.props = { ...this.props, ...props };
@@ -415,16 +450,33 @@
415
450
  };
416
451
 
417
452
  // ../worker-utils/src/lib/worker-farm/worker-body.ts
453
+ function getParentPort() {
454
+ let parentPort;
455
+ try {
456
+ eval("globalThis.parentPort = require('worker_threads').parentPort");
457
+ parentPort = globalThis.parentPort;
458
+ } catch {
459
+ }
460
+ return parentPort;
461
+ }
418
462
  var onMessageWrapperMap = new Map();
419
463
  var WorkerBody = class {
464
+ static inWorkerThread() {
465
+ return typeof self !== "undefined" || Boolean(getParentPort());
466
+ }
420
467
  static set onmessage(onMessage2) {
421
- self.onmessage = (message) => {
422
- if (!isKnownMessage(message)) {
423
- return;
424
- }
425
- const { type, payload } = message.data;
468
+ function handleMessage(message) {
469
+ const parentPort3 = getParentPort();
470
+ const { type, payload } = parentPort3 ? message : message.data;
426
471
  onMessage2(type, payload);
427
- };
472
+ }
473
+ const parentPort2 = getParentPort();
474
+ if (parentPort2) {
475
+ parentPort2.on("message", handleMessage);
476
+ parentPort2.on("exit", () => console.debug("Node worker closing"));
477
+ } else {
478
+ globalThis.onmessage = handleMessage;
479
+ }
428
480
  }
429
481
  static addEventListener(onMessage2) {
430
482
  let onMessageWrapper = onMessageWrapperMap.get(onMessage2);
@@ -433,22 +485,36 @@
433
485
  if (!isKnownMessage(message)) {
434
486
  return;
435
487
  }
436
- const { type, payload } = message.data;
488
+ const parentPort3 = getParentPort();
489
+ const { type, payload } = parentPort3 ? message : message.data;
437
490
  onMessage2(type, payload);
438
491
  };
439
492
  }
440
- self.addEventListener("message", onMessageWrapper);
493
+ const parentPort2 = getParentPort();
494
+ if (parentPort2) {
495
+ console.error("not implemented");
496
+ } else {
497
+ globalThis.addEventListener("message", onMessageWrapper);
498
+ }
441
499
  }
442
500
  static removeEventListener(onMessage2) {
443
501
  const onMessageWrapper = onMessageWrapperMap.get(onMessage2);
444
502
  onMessageWrapperMap.delete(onMessage2);
445
- self.removeEventListener("message", onMessageWrapper);
503
+ const parentPort2 = getParentPort();
504
+ if (parentPort2) {
505
+ console.error("not implemented");
506
+ } else {
507
+ globalThis.removeEventListener("message", onMessageWrapper);
508
+ }
446
509
  }
447
510
  static postMessage(type, payload) {
448
- if (self) {
449
- const data = { source: "loaders.gl", type, payload };
450
- const transferList = getTransferList(payload);
451
- self.postMessage(data, transferList);
511
+ const data = { source: "loaders.gl", type, payload };
512
+ const transferList = getTransferList(payload);
513
+ const parentPort2 = getParentPort();
514
+ if (parentPort2) {
515
+ parentPort2.postMessage(data, transferList);
516
+ } else {
517
+ globalThis.postMessage(data, transferList);
452
518
  }
453
519
  }
454
520
  };
@@ -458,7 +524,7 @@
458
524
  }
459
525
 
460
526
  // ../worker-utils/src/lib/worker-api/get-worker-url.ts
461
- var NPM_TAG = "latest";
527
+ var NPM_TAG = "beta";
462
528
  function getWorkerURL(worker, options = {}) {
463
529
  const workerOptions = options[worker.id] || {};
464
530
  const workerFile = `${worker.id}-worker.js`;
@@ -493,7 +559,7 @@
493
559
 
494
560
  // ../worker-utils/src/lib/library-utils/library-utils.ts
495
561
  var node = __toModule(require_require_utils());
496
- var LATEST = "latest";
562
+ var LATEST = "beta";
497
563
  var VERSION2 = typeof VERSION !== "undefined" ? VERSION : LATEST;
498
564
  var loadLibraryPromises = {};
499
565
  async function loadLibrary(libraryUrl, moduleName = null, options = {}) {
@@ -564,7 +630,7 @@
564
630
  // ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
565
631
  var requestId = 0;
566
632
  function createLoaderWorker(loader) {
567
- if (typeof self === "undefined") {
633
+ if (!WorkerBody.inWorkerThread()) {
568
634
  return;
569
635
  }
570
636
  WorkerBody.onmessage = async (type, payload) => {
@@ -640,6 +706,9 @@
640
706
  if (!WorkerFarm.isSupported()) {
641
707
  return false;
642
708
  }
709
+ if (!isBrowser2 && !options?._nodeWorkers) {
710
+ return false;
711
+ }
643
712
  return loader.worker && options?.worker;
644
713
  }
645
714
  async function parseWithWorker(loader, data, options, context, parseOnMainThread2) {
@@ -932,7 +1001,7 @@
932
1001
  text += ` ${await response.text()}`;
933
1002
  }
934
1003
  message += text;
935
- message = message.length > 60 ? `${message.slice(60)}...` : message;
1004
+ message = message.length > 60 ? `${message.slice(0, 60)}...` : message;
936
1005
  } catch (error) {
937
1006
  }
938
1007
  return message;
@@ -1016,7 +1085,7 @@
1016
1085
  var process_ = globals3.process || {};
1017
1086
 
1018
1087
  // ../../node_modules/probe.gl/dist/esm/utils/globals.js
1019
- var VERSION3 = true ? "3.1.7" : "untranspiled source";
1088
+ var VERSION3 = true ? "3.2.0-alpha.2" : "untranspiled source";
1020
1089
  var isBrowser4 = isBrowser3();
1021
1090
 
1022
1091
  // ../../node_modules/probe.gl/dist/esm/utils/local-storage.js
@@ -1549,7 +1618,8 @@
1549
1618
  worker: true,
1550
1619
  maxConcurrency: 3,
1551
1620
  maxMobileConcurrency: 1,
1552
- reuseWorkers: true,
1621
+ reuseWorkers: isBrowser,
1622
+ _nodeWorkers: false,
1553
1623
  _workerType: "",
1554
1624
  limit: 0,
1555
1625
  _limitMB: 0,
@@ -1761,7 +1831,7 @@
1761
1831
  var process_2 = globals4.process || {};
1762
1832
 
1763
1833
  // ../../node_modules/@probe.gl/env/dist/esm/utils/globals.js
1764
- var VERSION4 = true ? "3.1.7" : "untranspiled source";
1834
+ var VERSION4 = true ? "3.2.0-alpha.2" : "untranspiled source";
1765
1835
  var isBrowser6 = isBrowser5();
1766
1836
 
1767
1837
  // ../../node_modules/@probe.gl/log/dist/esm/utils/local-storage.js
@@ -4877,7 +4947,7 @@
4877
4947
  };
4878
4948
 
4879
4949
  // ../images/src/lib/utils/version.ts
4880
- var VERSION5 = true ? "3.1.7" : "latest";
4950
+ var VERSION5 = true ? "3.2.0-alpha.2" : "latest";
4881
4951
 
4882
4952
  // ../images/src/lib/category-api/image-type.ts
4883
4953
  var { _parseImageNode } = globalThis;
@@ -5225,7 +5295,7 @@
5225
5295
  };
5226
5296
 
5227
5297
  // ../draco/src/lib/utils/version.ts
5228
- var VERSION6 = true ? "3.1.7" : "latest";
5298
+ var VERSION6 = true ? "3.2.0-alpha.2" : "latest";
5229
5299
 
5230
5300
  // ../draco/src/draco-loader.ts
5231
5301
  var DEFAULT_DRACO_OPTIONS = {
@@ -6209,10 +6279,10 @@
6209
6279
  }
6210
6280
 
6211
6281
  // ../textures/src/lib/utils/version.ts
6212
- var VERSION7 = true ? "3.1.7" : "latest";
6282
+ var VERSION7 = true ? "3.2.0-alpha.2" : "beta";
6213
6283
 
6214
6284
  // ../textures/src/lib/parsers/basis-module-loader.ts
6215
- var VERSION8 = true ? "3.1.7" : "latest";
6285
+ var VERSION8 = true ? "3.2.0-alpha.2" : "beta";
6216
6286
  var BASIS_CDN_ENCODER_WASM = `https://unpkg.com/@loaders.gl/textures@${VERSION8}/dist/libs/basis_encoder.wasm`;
6217
6287
  var BASIS_CDN_ENCODER_JS = `https://unpkg.com/@loaders.gl/textures@${VERSION8}/dist/libs/basis_encoder.js`;
6218
6288
  var loadBasisTranscoderPromise;
@@ -6693,7 +6763,7 @@
6693
6763
  const basisFile = new BasisFile(new Uint8Array(data));
6694
6764
  try {
6695
6765
  if (!basisFile.startTranscoding()) {
6696
- return null;
6766
+ throw new Error("Failed to start basis transcoding");
6697
6767
  }
6698
6768
  const imageCount = basisFile.getNumImages();
6699
6769
  const images = [];
@@ -6719,22 +6789,22 @@
6719
6789
  const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
6720
6790
  const decodedData = new Uint8Array(decodedSize);
6721
6791
  if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
6722
- return null;
6792
+ throw new Error("failed to start Basis transcoding");
6723
6793
  }
6724
6794
  return {
6725
6795
  width,
6726
6796
  height,
6727
6797
  data: decodedData,
6728
6798
  compressed,
6729
- hasAlpha,
6730
- format
6799
+ format,
6800
+ hasAlpha
6731
6801
  };
6732
6802
  }
6733
6803
  function parseKTX2File(KTX2File, data, options) {
6734
6804
  const ktx2File = new KTX2File(new Uint8Array(data));
6735
6805
  try {
6736
6806
  if (!ktx2File.startTranscoding()) {
6737
- return null;
6807
+ throw new Error("failed to start KTX2 transcoding");
6738
6808
  }
6739
6809
  const levelsCount = ktx2File.getLevels();
6740
6810
  const levels = [];
@@ -6742,7 +6812,7 @@
6742
6812
  levels.push(transcodeKTX2Image(ktx2File, levelIndex, options));
6743
6813
  break;
6744
6814
  }
6745
- return levels;
6815
+ return [levels];
6746
6816
  } finally {
6747
6817
  ktx2File.close();
6748
6818
  ktx2File.delete();
@@ -6754,14 +6824,14 @@
6754
6824
  const decodedSize = ktx2File.getImageTranscodedSizeInBytes(levelIndex, 0, 0, basisFormat);
6755
6825
  const decodedData = new Uint8Array(decodedSize);
6756
6826
  if (!ktx2File.transcodeImage(decodedData, levelIndex, 0, 0, basisFormat, 0, -1, -1)) {
6757
- return null;
6827
+ throw new Error("Failed to transcode KTX2 image");
6758
6828
  }
6759
6829
  return {
6760
6830
  width,
6761
6831
  height,
6762
6832
  data: decodedData,
6763
6833
  compressed,
6764
- alphaFlag,
6834
+ hasAlpha: alphaFlag,
6765
6835
  format
6766
6836
  };
6767
6837
  }
@@ -7147,7 +7217,7 @@
7147
7217
  containerFormat: "ktx2",
7148
7218
  module: "encoder"
7149
7219
  };
7150
- return await parseBasis(arrayBuffer, options);
7220
+ return (await parseBasis(arrayBuffer, options))[0];
7151
7221
  }
7152
7222
  return parseCompressedTexture(arrayBuffer);
7153
7223
  }
@@ -7881,7 +7951,10 @@
7881
7951
  tile.content.texture = await parse(arrayBuffer2, loader, options2);
7882
7952
  }
7883
7953
  } else if (loader === CompressedTextureLoader || loader === BasisLoader) {
7884
- const texture = await load(arrayBuffer2, loader, tile.textureLoaderOptions);
7954
+ let texture = await load(arrayBuffer2, loader, tile.textureLoaderOptions);
7955
+ if (loader === BasisLoader) {
7956
+ texture = texture[0];
7957
+ }
7885
7958
  tile.content.texture = {
7886
7959
  compressed: true,
7887
7960
  mipmaps: false,
@@ -8033,38 +8106,38 @@
8033
8106
  byteOffset
8034
8107
  };
8035
8108
  }
8036
- function normalizeAttributes(arrayBuffer, byteOffset, vertexAttributes, vertexCount, attributesOrder) {
8109
+ function normalizeAttributes(arrayBuffer, byteOffset, vertexAttributes, attributeCount, attributesOrder) {
8037
8110
  const attributes = {};
8038
8111
  for (const attribute of attributesOrder) {
8039
8112
  if (vertexAttributes[attribute]) {
8040
8113
  const { valueType, valuesPerElement } = vertexAttributes[attribute];
8041
- const count = vertexCount;
8042
- if (byteOffset + count * valuesPerElement > arrayBuffer.byteLength) {
8114
+ if (byteOffset + attributeCount * valuesPerElement * sizeOf(valueType) <= arrayBuffer.byteLength) {
8115
+ const buffer = arrayBuffer.slice(byteOffset);
8116
+ let value;
8117
+ if (valueType === "UInt64") {
8118
+ value = parseUint64Values(buffer, attributeCount * valuesPerElement, sizeOf(valueType));
8119
+ } else {
8120
+ const TypedArrayType = getConstructorForDataFormat(valueType);
8121
+ value = new TypedArrayType(buffer, 0, attributeCount * valuesPerElement);
8122
+ }
8123
+ attributes[attribute] = {
8124
+ value,
8125
+ type: GL_TYPE_MAP[valueType],
8126
+ size: valuesPerElement
8127
+ };
8128
+ switch (attribute) {
8129
+ case "color":
8130
+ attributes.color.normalized = true;
8131
+ break;
8132
+ case "position":
8133
+ case "region":
8134
+ case "normal":
8135
+ default:
8136
+ }
8137
+ byteOffset = byteOffset + attributeCount * valuesPerElement * sizeOf(valueType);
8138
+ } else if (attribute !== "uv0") {
8043
8139
  break;
8044
8140
  }
8045
- const buffer = arrayBuffer.slice(byteOffset);
8046
- let value;
8047
- if (valueType === "UInt64") {
8048
- value = parseUint64Values(buffer, count * valuesPerElement, sizeOf(valueType));
8049
- } else {
8050
- const TypedArrayType = getConstructorForDataFormat(valueType);
8051
- value = new TypedArrayType(buffer, 0, count * valuesPerElement);
8052
- }
8053
- attributes[attribute] = {
8054
- value,
8055
- type: GL_TYPE_MAP[valueType],
8056
- size: valuesPerElement
8057
- };
8058
- switch (attribute) {
8059
- case "color":
8060
- attributes.color.normalized = true;
8061
- break;
8062
- case "position":
8063
- case "region":
8064
- case "normal":
8065
- default:
8066
- }
8067
- byteOffset = byteOffset + count * valuesPerElement * sizeOf(valueType);
8068
8141
  }
8069
8142
  }
8070
8143
  return { attributes, byteOffset };
@@ -8215,7 +8288,7 @@
8215
8288
  }
8216
8289
 
8217
8290
  // src/i3s-content-loader.ts
8218
- var VERSION9 = true ? "3.1.7" : "latest";
8291
+ var VERSION9 = true ? "3.2.0-alpha.2" : "beta";
8219
8292
  var I3SContentLoader = {
8220
8293
  name: "I3S Content (Indexed Scene Layers)",
8221
8294
  id: "i3s-content",
package/dist/index.d.ts CHANGED
@@ -2,6 +2,6 @@ export { I3SLoader } from './i3s-loader';
2
2
  export { I3SContentLoader } from './i3s-content-loader';
3
3
  export { I3SAttributeLoader, loadFeatureAttributes } from './i3s-attribute-loader';
4
4
  export { I3SBuildingSceneLayerLoader } from './i3s-building-scene-layer-loader';
5
- export type { BoundingVolumes, Mbs, Obb, SceneLayer3D, AttributeStorageInfo, Field, ESRIField, PopupInfo, Node3DIndexDocument, LodSelection, NodeReference, Resource, MaxScreenThresholdSQ, NodeInPage, SharedResources, Attribute, Extent, FeatureAttribute, FieldInfo, I3SMaterialDefinition } from './types';
5
+ export type { BoundingVolumes, Mbs, Obb, SceneLayer3D, AttributeStorageInfo, Field, ESRIField, PopupInfo, Node3DIndexDocument, LodSelection, NodeReference, Resource, MaxScreenThresholdSQ, NodeInPage, SharedResources, Attribute, Extent, FeatureAttribute, FieldInfo, I3SMaterialDefinition, TextureDefinitionInfo, MaterialDefinitionInfo, FullExtent } from './types';
6
6
  export { COORDINATE_SYSTEM } from './lib/parsers/constants';
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAC,kBAAkB,EAAE,qBAAqB,EAAC,MAAM,wBAAwB,CAAC;AACjF,OAAO,EAAC,2BAA2B,EAAC,MAAM,mCAAmC,CAAC;AAC9E,YAAY,EACV,eAAe,EACf,GAAG,EACH,GAAG,EACH,YAAY,EACZ,oBAAoB,EACpB,KAAK,EACL,SAAS,EACT,SAAS,EACT,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,oBAAoB,EACpB,UAAU,EACV,eAAe,EACf,SAAS,EACT,MAAM,EACN,gBAAgB,EAChB,SAAS,EACT,qBAAqB,EACtB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAC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,CAAM;IAC5F,OAAO,CAAC,oBAAoB,CAA4B;IAExD;;;;;OAKG;gBACS,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,aAAa;IAS7D;;;OAGG;IACG,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAqBlD;;;OAGG;IAEG,qBAAqB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IA4D/D;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;IA6BrB;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAiBvB;;;;;;;OAOG;IACH,OAAO,CAAC,0BAA0B;IAuBlC;;;;OAIG;IACH,OAAO,CAAC,wCAAwC;IA2BhD;;;OAGG;IACH,OAAO,CAAC,0BAA0B;CAuBnC"}
@@ -51,14 +51,18 @@ class I3SNodePagesTiles {
51
51
  * Forms tile header using node and tileset data
52
52
  * @param id - id of node through all node pages
53
53
  */
54
- // eslint-disable-next-line complexity
54
+ // eslint-disable-next-line complexity, max-statements
55
55
  async formTileFromNodePages(id) {
56
56
  const node = await this.getNodeById(id);
57
57
  const children = [];
58
+ const childNodesPromises = [];
58
59
  for (const child of node.children || []) {
59
- const childNode = await this.getNodeById(child);
60
+ childNodesPromises.push(this.getNodeById(child));
61
+ }
62
+ const childNodes = await Promise.all(childNodesPromises);
63
+ for (const childNode of childNodes) {
60
64
  children.push({
61
- id: child.toString(),
65
+ id: childNode.index.toString(),
62
66
  obb: childNode.obb
63
67
  });
64
68
  }
@@ -1 +1 @@
1
- {"version":3,"file":"parse-i3s-tile-content.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-i3s-tile-content.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAK3E,OAAO,EACL,gBAAgB,EAChB,aAAa,EAQd,MAAM,aAAa,CAAC;AAuBrB,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,gBAAgB,EACzB,OAAO,CAAC,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,aAAa,0BA+CxB"}
1
+ {"version":3,"file":"parse-i3s-tile-content.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-i3s-tile-content.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAK3E,OAAO,EACL,gBAAgB,EAChB,aAAa,EAQd,MAAM,aAAa,CAAC;AAuBrB,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,gBAAgB,EACzB,OAAO,CAAC,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,aAAa,0BAkDxB"}
@@ -50,7 +50,10 @@ async function parseI3STileContent(arrayBuffer, tile, tileset, options, context)
50
50
  }
51
51
  }
52
52
  else if (loader === textures_1.CompressedTextureLoader || loader === textures_1.BasisLoader) {
53
- const texture = await (0, core_1.load)(arrayBuffer, loader, tile.textureLoaderOptions);
53
+ let texture = await (0, core_1.load)(arrayBuffer, loader, tile.textureLoaderOptions);
54
+ if (loader === textures_1.BasisLoader) {
55
+ texture = texture[0];
56
+ }
54
57
  tile.content.texture = {
55
58
  compressed: true,
56
59
  mipmaps: false,
@@ -220,47 +223,48 @@ function parseHeaders(tileset, arrayBuffer) {
220
223
  };
221
224
  }
222
225
  /* eslint-enable max-statements */
223
- function normalizeAttributes(arrayBuffer, byteOffset, vertexAttributes, vertexCount, attributesOrder) {
226
+ function normalizeAttributes(arrayBuffer, byteOffset, vertexAttributes, attributeCount, attributesOrder) {
224
227
  const attributes = {};
225
228
  // the order of attributes depend on the order being added to the vertexAttributes object
226
229
  for (const attribute of attributesOrder) {
227
230
  if (vertexAttributes[attribute]) {
228
231
  const { valueType, valuesPerElement } = vertexAttributes[attribute];
229
- // update count and byteOffset count by calculating from defaultGeometrySchema + binnary content
230
- const count = vertexCount;
231
232
  // protect from arrayBuffer read overunns by NOT assuming node has regions always even though its declared in defaultGeometrySchema.
232
233
  // In i3s 1.6: client is required to decide that based on ./shared resource of the node (materialDefinitions.[Mat_id].params.vertexRegions == true)
233
234
  // In i3s 1.7 the property has been rolled into the 3d scene layer json/node pages.
234
235
  // Code below does not account when the bytelength is actually bigger than
235
236
  // the calculated value (b\c the tile potentially could have mesh segmentation information).
236
237
  // In those cases tiles without regions could fail or have garbage values.
237
- if (byteOffset + count * valuesPerElement > arrayBuffer.byteLength) {
238
- break;
239
- }
240
- const buffer = arrayBuffer.slice(byteOffset);
241
- let value;
242
- if (valueType === 'UInt64') {
243
- value = parseUint64Values(buffer, count * valuesPerElement, (0, constants_1.sizeOf)(valueType));
244
- }
245
- else {
246
- const TypedArrayType = (0, constants_1.getConstructorForDataFormat)(valueType);
247
- value = new TypedArrayType(buffer, 0, count * valuesPerElement);
238
+ if (byteOffset + attributeCount * valuesPerElement * (0, constants_1.sizeOf)(valueType) <=
239
+ arrayBuffer.byteLength) {
240
+ const buffer = arrayBuffer.slice(byteOffset);
241
+ let value;
242
+ if (valueType === 'UInt64') {
243
+ value = parseUint64Values(buffer, attributeCount * valuesPerElement, (0, constants_1.sizeOf)(valueType));
244
+ }
245
+ else {
246
+ const TypedArrayType = (0, constants_1.getConstructorForDataFormat)(valueType);
247
+ value = new TypedArrayType(buffer, 0, attributeCount * valuesPerElement);
248
+ }
249
+ attributes[attribute] = {
250
+ value,
251
+ type: constants_1.GL_TYPE_MAP[valueType],
252
+ size: valuesPerElement
253
+ };
254
+ switch (attribute) {
255
+ case 'color':
256
+ attributes.color.normalized = true;
257
+ break;
258
+ case 'position':
259
+ case 'region':
260
+ case 'normal':
261
+ default:
262
+ }
263
+ byteOffset = byteOffset + attributeCount * valuesPerElement * (0, constants_1.sizeOf)(valueType);
248
264
  }
249
- attributes[attribute] = {
250
- value,
251
- type: constants_1.GL_TYPE_MAP[valueType],
252
- size: valuesPerElement
253
- };
254
- switch (attribute) {
255
- case 'color':
256
- attributes.color.normalized = true;
257
- break;
258
- case 'position':
259
- case 'region':
260
- case 'normal':
261
- default:
265
+ else if (attribute !== 'uv0') {
266
+ break;
262
267
  }
263
- byteOffset = byteOffset + count * valuesPerElement * (0, constants_1.sizeOf)(valueType);
264
268
  }
265
269
  }
266
270
  return { attributes, byteOffset };
@@ -70,7 +70,7 @@ async function normalizeTilesetData(tileset, options, context) {
70
70
  tileset.url = context.url;
71
71
  if (tileset.nodePages) {
72
72
  tileset.nodePagesTile = new i3s_nodepages_tiles_1.default(tileset, options);
73
- tileset.root = await tileset.nodePagesTile.formTileFromNodePages(0);
73
+ tileset.root = tileset.nodePagesTile.formTileFromNodePages(0);
74
74
  }
75
75
  else {
76
76
  const rootNodeUrl = (0, url_utils_1.getUrlWithToken)(`${tileset.url}/nodes/root`, options.i3s?.token);