@loaders.gl/tile-converter 3.2.0-alpha.2 → 3.2.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/3d-tiles-attributes-worker.js +1 -1
  2. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +1 -1
  3. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  4. package/dist/converter-cli.d.ts +2 -0
  5. package/dist/converter-cli.d.ts.map +1 -0
  6. package/dist/converter-cli.js +232 -0
  7. package/dist/converter.min.js +68 -68
  8. package/dist/deps-installer/deps-installer.d.ts +11 -1
  9. package/dist/deps-installer/deps-installer.d.ts.map +1 -1
  10. package/dist/deps-installer/deps-installer.js +10 -0
  11. package/dist/dist.min.js +95 -162
  12. package/dist/es5/3d-tiles-attributes-worker.js +1 -1
  13. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  14. package/dist/es5/converter-cli.js +306 -0
  15. package/dist/es5/converter-cli.js.map +1 -0
  16. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  17. package/dist/es5/i3s-attributes-worker.js +1 -1
  18. package/dist/es5/i3s-converter/helpers/geometry-converter.js +4 -4
  19. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  20. package/dist/es5/i3s-converter/i3s-converter.js +64 -43
  21. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  22. package/dist/es5/index.js +0 -24
  23. package/dist/es5/index.js.map +1 -1
  24. package/dist/es5/pgm-loader.js +1 -1
  25. package/dist/esm/3d-tiles-attributes-worker.js +1 -1
  26. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  27. package/dist/esm/converter-cli.js +230 -0
  28. package/dist/esm/converter-cli.js.map +1 -0
  29. package/dist/esm/deps-installer/deps-installer.js.map +1 -1
  30. package/dist/esm/i3s-attributes-worker.js +1 -1
  31. package/dist/esm/i3s-converter/helpers/geometry-converter.js +4 -4
  32. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  33. package/dist/esm/i3s-converter/i3s-converter.js +44 -26
  34. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  35. package/dist/esm/index.js +0 -3
  36. package/dist/esm/index.js.map +1 -1
  37. package/dist/esm/pgm-loader.js +1 -1
  38. package/dist/i3s-attributes-worker.js +1 -1
  39. package/dist/i3s-attributes-worker.js.map +2 -2
  40. package/dist/i3s-converter/helpers/geometry-converter.js +3 -3
  41. package/dist/i3s-converter/i3s-converter.d.ts +0 -2
  42. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  43. package/dist/i3s-converter/i3s-converter.js +34 -16
  44. package/dist/index.d.ts +0 -3
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +1 -7
  47. package/package.json +16 -17
  48. package/src/3d-tiles-converter/3d-tiles-converter.ts +1 -1
  49. package/src/converter-cli.ts +310 -0
  50. package/src/deps-installer/{deps-installer.js → deps-installer.ts} +11 -1
  51. package/src/i3s-converter/helpers/geometry-converter.ts +4 -4
  52. package/src/i3s-converter/i3s-converter.ts +37 -25
  53. package/src/index.ts +0 -5
  54. package/dist/es5/deps-installer/deps-installer.d.ts +0 -10
  55. package/dist/esm/deps-installer/deps-installer.d.ts +0 -10
  56. package/src/deps-installer/deps-installer.d.ts +0 -10
@@ -1,4 +1,14 @@
1
- export class DepsInstaller {
1
+ /**
2
+ * Install external dependencies for converter:
3
+ * * PGM file (implemented);
4
+ * * Draco library (not implemented);
5
+ * * 7z archiver (not implemented);
6
+ */
7
+ export declare class DepsInstaller {
8
+ /**
9
+ * Run instalation
10
+ * @param path destination folder
11
+ */
2
12
  install(path?: string): Promise<void>;
3
13
  }
4
14
  //# sourceMappingURL=deps-installer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deps-installer.d.ts","sourceRoot":"","sources":["../../src/deps-installer/deps-installer.js"],"names":[],"mappings":"AAOA;IACE,sCAYC;CACF"}
1
+ {"version":3,"file":"deps-installer.d.ts","sourceRoot":"","sources":["../../src/deps-installer/deps-installer.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,qBAAa,aAAa;IACxB;;;OAGG;IACG,OAAO,CAAC,IAAI,GAAE,MAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAahD"}
@@ -6,7 +6,17 @@ const zip_1 = require("@loaders.gl/zip");
6
6
  const file_utils_1 = require("../lib/utils/file-utils");
7
7
  const path_1 = require("path");
8
8
  const PGM_LINK = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip';
9
+ /**
10
+ * Install external dependencies for converter:
11
+ * * PGM file (implemented);
12
+ * * Draco library (not implemented);
13
+ * * 7z archiver (not implemented);
14
+ */
9
15
  class DepsInstaller {
16
+ /**
17
+ * Run instalation
18
+ * @param path destination folder
19
+ */
10
20
  async install(path = '') {
11
21
  console.log('Installing "EGM2008-5" model...'); // eslint-disable-line no-console
12
22
  const fileMap = await (0, core_1.load)(PGM_LINK, zip_1.ZipLoader, {});
package/dist/dist.min.js CHANGED
@@ -556,8 +556,8 @@ var require_globals2 = __commonJS({
556
556
  exports.isBrowser = exports.VERSION = void 0;
557
557
  var _isBrowser = _interopRequireDefault(require_is_browser());
558
558
  var _globals = require_globals();
559
- var VERSION18 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
560
- exports.VERSION = VERSION18;
559
+ var VERSION17 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
560
+ exports.VERSION = VERSION17;
561
561
  var isBrowser3 = (0, _isBrowser.default)();
562
562
  exports.isBrowser = isBrowser3;
563
563
  }
@@ -2097,8 +2097,8 @@ var require_globals4 = __commonJS({
2097
2097
  });
2098
2098
  var _isBrowser = _interopRequireDefault(require_is_browser2());
2099
2099
  var _globals = require_globals3();
2100
- var VERSION18 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
2101
- exports.VERSION = VERSION18;
2100
+ var VERSION17 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
2101
+ exports.VERSION = VERSION17;
2102
2102
  var isBrowser3 = (0, _isBrowser.default)();
2103
2103
  exports.isBrowser = isBrowser3;
2104
2104
  }
@@ -17998,7 +17998,7 @@ var require_BufferList = __commonJS({
17998
17998
  this.head = this.tail = null;
17999
17999
  this.length = 0;
18000
18000
  };
18001
- BufferList.prototype.join = function join10(s) {
18001
+ BufferList.prototype.join = function join9(s) {
18002
18002
  if (this.length === 0)
18003
18003
  return "";
18004
18004
  var p = this.head;
@@ -22945,7 +22945,7 @@ var require_buffer_list = __commonJS({
22945
22945
  }
22946
22946
  }, {
22947
22947
  key: "join",
22948
- value: function join10(s) {
22948
+ value: function join9(s) {
22949
22949
  if (this.length === 0)
22950
22950
  return "";
22951
22951
  var p = this.head;
@@ -26657,7 +26657,7 @@ var require_buffer_list2 = __commonJS({
26657
26657
  }
26658
26658
  }, {
26659
26659
  key: "join",
26660
- value: function join10(s) {
26660
+ value: function join9(s) {
26661
26661
  if (this.length === 0)
26662
26662
  return "";
26663
26663
  var p = this.head;
@@ -29799,7 +29799,7 @@ var require_buffer_list3 = __commonJS({
29799
29799
  }
29800
29800
  }, {
29801
29801
  key: "join",
29802
- value: function join10(s) {
29802
+ value: function join9(s) {
29803
29803
  if (this.length === 0)
29804
29804
  return "";
29805
29805
  var p = this.head;
@@ -33171,7 +33171,7 @@ var require_buffer_list4 = __commonJS({
33171
33171
  }
33172
33172
  }, {
33173
33173
  key: "join",
33174
- value: function join10(s) {
33174
+ value: function join9(s) {
33175
33175
  if (this.length === 0)
33176
33176
  return "";
33177
33177
  var p = this.head;
@@ -36545,7 +36545,7 @@ var require_buffer_list5 = __commonJS({
36545
36545
  }
36546
36546
  }, {
36547
36547
  key: "join",
36548
- value: function join10(s) {
36548
+ value: function join9(s) {
36549
36549
  if (this.length === 0)
36550
36550
  return "";
36551
36551
  var p = this.head;
@@ -46941,9 +46941,9 @@ var require_load = __commonJS({
46941
46941
  var require_lib4 = __commonJS({
46942
46942
  "../../node_modules/jszip/lib/index.js"(exports, module2) {
46943
46943
  "use strict";
46944
- function JSZip3() {
46945
- if (!(this instanceof JSZip3)) {
46946
- return new JSZip3();
46944
+ function JSZip2() {
46945
+ if (!(this instanceof JSZip2)) {
46946
+ return new JSZip2();
46947
46947
  }
46948
46948
  if (arguments.length) {
46949
46949
  throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");
@@ -46952,7 +46952,7 @@ var require_lib4 = __commonJS({
46952
46952
  this.comment = null;
46953
46953
  this.root = "";
46954
46954
  this.clone = function() {
46955
- var newObj = new JSZip3();
46955
+ var newObj = new JSZip2();
46956
46956
  for (var i in this) {
46957
46957
  if (typeof this[i] !== "function") {
46958
46958
  newObj[i] = this[i];
@@ -46961,16 +46961,16 @@ var require_lib4 = __commonJS({
46961
46961
  return newObj;
46962
46962
  };
46963
46963
  }
46964
- JSZip3.prototype = require_object();
46965
- JSZip3.prototype.loadAsync = require_load();
46966
- JSZip3.support = require_support();
46967
- JSZip3.defaults = require_defaults();
46968
- JSZip3.version = "3.7.0";
46969
- JSZip3.loadAsync = function(content, options) {
46970
- return new JSZip3().loadAsync(content, options);
46964
+ JSZip2.prototype = require_object();
46965
+ JSZip2.prototype.loadAsync = require_load();
46966
+ JSZip2.support = require_support();
46967
+ JSZip2.defaults = require_defaults();
46968
+ JSZip2.version = "3.7.0";
46969
+ JSZip2.loadAsync = function(content, options) {
46970
+ return new JSZip2().loadAsync(content, options);
46971
46971
  };
46972
- JSZip3.external = require_external();
46973
- module2.exports = JSZip3;
46972
+ JSZip2.external = require_external();
46973
+ module2.exports = JSZip2;
46974
46974
  }
46975
46975
  });
46976
46976
 
@@ -49832,7 +49832,7 @@ var require_init3 = __commonJS({
49832
49832
  var _gltools = require_es510();
49833
49833
  var _probe = require_es53();
49834
49834
  var _env = require_env2();
49835
- var VERSION18 = true ? "8.5.4" : "untranspiled source";
49835
+ var VERSION17 = true ? "8.5.4" : "untranspiled source";
49836
49836
  var STARTUP_MESSAGE = "set luma.log.level=1 (or higher) to trace rendering";
49837
49837
  var StatsManager = function() {
49838
49838
  function StatsManager2() {
@@ -49854,16 +49854,16 @@ var require_init3 = __commonJS({
49854
49854
  }();
49855
49855
  var lumaStats = new StatsManager();
49856
49856
  exports.lumaStats = lumaStats;
49857
- if (_env.global.luma && _env.global.luma.VERSION !== VERSION18) {
49858
- throw new Error("luma.gl - multiple VERSIONs detected: ".concat(_env.global.luma.VERSION, " vs ").concat(VERSION18));
49857
+ if (_env.global.luma && _env.global.luma.VERSION !== VERSION17) {
49858
+ throw new Error("luma.gl - multiple VERSIONs detected: ".concat(_env.global.luma.VERSION, " vs ").concat(VERSION17));
49859
49859
  }
49860
49860
  if (!_env.global.luma) {
49861
49861
  if ((0, _env.isBrowser)()) {
49862
- _gltools.log.log(1, "luma.gl ".concat(VERSION18, " - ").concat(STARTUP_MESSAGE))();
49862
+ _gltools.log.log(1, "luma.gl ".concat(VERSION17, " - ").concat(STARTUP_MESSAGE))();
49863
49863
  }
49864
49864
  _env.global.luma = _env.global.luma || {
49865
- VERSION: VERSION18,
49866
- version: VERSION18,
49865
+ VERSION: VERSION17,
49866
+ version: VERSION17,
49867
49867
  log: _gltools.log,
49868
49868
  stats: lumaStats,
49869
49869
  globals: {
@@ -73404,11 +73404,8 @@ var require_es516 = __commonJS({
73404
73404
 
73405
73405
  // src/index.ts
73406
73406
  __export(exports, {
73407
- DepsInstaller: () => DepsInstaller,
73408
73407
  I3SConverter: () => I3SConverter,
73409
- NodePages: () => NodePages,
73410
- Tiles3DConverter: () => Tiles3DConverter,
73411
- prepareDataForAttributesConversion: () => prepareDataForAttributesConversion
73408
+ Tiles3DConverter: () => Tiles3DConverter
73412
73409
  });
73413
73410
 
73414
73411
  // ../loader-utils/src/lib/env-utils/assert.ts
@@ -74170,10 +74167,12 @@ async function parseWithWorker(loader, data, options, context, parseOnMainThread
74170
74167
  const workerFarm = WorkerFarm.getWorkerFarm(options);
74171
74168
  const workerPool = workerFarm.getWorkerPool({ name: name8, url });
74172
74169
  options = JSON.parse(JSON.stringify(options));
74170
+ context = JSON.parse(JSON.stringify(context || {}));
74173
74171
  const job = await workerPool.startJob("process-on-worker", onMessage2.bind(null, parseOnMainThread));
74174
74172
  job.postMessage("process", {
74175
74173
  input: data,
74176
- options
74174
+ options,
74175
+ context
74177
74176
  });
74178
74177
  const result = await job.result;
74179
74178
  return await result.result;
@@ -75418,6 +75417,12 @@ async function parse(data, loaders, options, context) {
75418
75417
  }
75419
75418
  async function parseWithLoader(loader, data, options, context) {
75420
75419
  validateWorkerVersion(loader);
75420
+ if (isResponse(data)) {
75421
+ const response = data;
75422
+ const { ok, redirected, status, statusText, type, url } = response;
75423
+ const headers = Object.fromEntries(response.headers.entries());
75424
+ context.response = { headers, ok, redirected, status, statusText, type, url };
75425
+ }
75421
75426
  data = await getArrayBufferOrStringFromData(data, loader, options);
75422
75427
  if (loader.parseTextSync && typeof data === "string") {
75423
75428
  options.dataType = "text";
@@ -76895,7 +76900,7 @@ var TILES_LOADED = "Tiles Loaded";
76895
76900
  var TILES_LOADING = "Tiles Loading";
76896
76901
  var TILES_UNLOADED = "Tiles Unloaded";
76897
76902
  var TILES_LOAD_FAILED = "Failed Tile Loads";
76898
- var POINTS_COUNT = "Points";
76903
+ var POINTS_COUNT = "Points/Vertices";
76899
76904
  var TILES_GPU_MEMORY = "Tile Memory Use";
76900
76905
  var Tileset3D = class {
76901
76906
  constructor(json, options) {
@@ -77119,6 +77124,8 @@ var Tileset3D = class {
77119
77124
  tilesRenderable++;
77120
77125
  if (tile.content.pointCount) {
77121
77126
  pointsRenderable += tile.content.pointCount;
77127
+ } else {
77128
+ pointsRenderable += tile.content.vertexCount;
77122
77129
  }
77123
77130
  }
77124
77131
  }
@@ -80358,49 +80365,6 @@ var CompressedTextureLoader = {
80358
80365
  }
80359
80366
  };
80360
80367
 
80361
- // ../textures/src/lib/encoders/encode-ktx2-basis-texture.ts
80362
- async function encodeKTX2BasisTexture(image, options = {}) {
80363
- const { useSRGB = false, qualityLevel = 10, encodeUASTC = false, mipmaps = false } = options;
80364
- const { BasisEncoder } = await loadBasisEncoderModule(options);
80365
- const basisEncoder = new BasisEncoder();
80366
- try {
80367
- const basisFileData = new Uint8Array(image.width * image.height * 4);
80368
- basisEncoder.setCreateKTX2File(true);
80369
- basisEncoder.setKTX2UASTCSupercompression(true);
80370
- basisEncoder.setKTX2SRGBTransferFunc(true);
80371
- basisEncoder.setSliceSourceImage(0, image.data, image.width, image.height, false);
80372
- basisEncoder.setPerceptual(useSRGB);
80373
- basisEncoder.setMipSRGB(useSRGB);
80374
- basisEncoder.setQualityLevel(qualityLevel);
80375
- basisEncoder.setUASTC(encodeUASTC);
80376
- basisEncoder.setMipGen(mipmaps);
80377
- const numOutputBytes = basisEncoder.encode(basisFileData);
80378
- const actualKTX2FileData = basisFileData.subarray(0, numOutputBytes).buffer;
80379
- return actualKTX2FileData;
80380
- } catch (error) {
80381
- console.error("Basis Universal Supercompressed GPU Texture encoder Error: ", error);
80382
- throw error;
80383
- } finally {
80384
- basisEncoder.delete();
80385
- }
80386
- }
80387
-
80388
- // ../textures/src/ktx2-basis-writer.ts
80389
- var KTX2BasisWriter = {
80390
- name: "Basis Universal Supercompressed GPU Texture",
80391
- id: "ktx2-basis-writer",
80392
- module: "textures",
80393
- version: VERSION7,
80394
- extensions: ["ktx2"],
80395
- options: {
80396
- useSRGB: false,
80397
- qualityLevel: 10,
80398
- encodeUASTC: false,
80399
- mipmaps: false
80400
- },
80401
- encode: encodeKTX2BasisTexture
80402
- };
80403
-
80404
80368
  // ../images/src/lib/utils/version.ts
80405
80369
  var VERSION9 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
80406
80370
 
@@ -80853,6 +80817,22 @@ function checkWebPSupport() {
80853
80817
  }
80854
80818
  }
80855
80819
 
80820
+ // ../textures/src/index.ts
80821
+ var KTX2BasisWriterWorker = {
80822
+ name: "Basis Universal Supercompressed GPU Texture",
80823
+ id: isBrowser ? "ktx2-basis-writer" : "ktx2-basis-writer-nodejs",
80824
+ module: "textures",
80825
+ version: VERSION7,
80826
+ extensions: ["ktx2"],
80827
+ worker: true,
80828
+ options: {
80829
+ useSRGB: false,
80830
+ qualityLevel: 10,
80831
+ encodeUASTC: false,
80832
+ mipmaps: false
80833
+ }
80834
+ };
80835
+
80856
80836
  // ../gltf/src/lib/utils/assert.ts
80857
80837
  function assert6(condition, message) {
80858
80838
  if (!condition) {
@@ -82133,7 +82113,7 @@ var GLTFV1Normalizer = class {
82133
82113
  metallicFactor: 1,
82134
82114
  roughnessFactor: 1
82135
82115
  };
82136
- const textureId = material.values && material.values.tex;
82116
+ const textureId = material.values?.tex || material.values?.texture2d_0;
82137
82117
  const textureIndex = json.textures.findIndex((texture) => texture.id === textureId);
82138
82118
  if (textureIndex !== -1) {
82139
82119
  material.pbrMetallicRoughness.baseColorTexture = { index: textureIndex };
@@ -84487,15 +84467,15 @@ function getCompositeTransformationMatrix(node2, matrix) {
84487
84467
  if (nodeMatrix) {
84488
84468
  transformationMatrix = matrix.multiplyRight(nodeMatrix);
84489
84469
  }
84470
+ if (translation) {
84471
+ transformationMatrix = transformationMatrix.translate(translation);
84472
+ }
84490
84473
  if (rotation) {
84491
84474
  transformationMatrix = transformationMatrix.rotateXYZ(rotation);
84492
84475
  }
84493
84476
  if (scale) {
84494
84477
  transformationMatrix = transformationMatrix.scale(scale);
84495
84478
  }
84496
- if (translation) {
84497
- transformationMatrix = transformationMatrix.translate(translation);
84498
- }
84499
84479
  return transformationMatrix;
84500
84480
  }
84501
84481
  function convertNode(node2, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new import_core21.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
@@ -85744,19 +85724,24 @@ var I3SConverter = class {
85744
85724
  this.nodePages.useWriteFunction(writeFileForSlpk);
85745
85725
  }
85746
85726
  await this.loadWorkers();
85747
- const preloadOptions = await this._fetchPreloadOptions();
85748
- const tilesetOptions = { loadOptions: { basis: { format: "rgba32" } } };
85749
- if (preloadOptions.headers) {
85750
- tilesetOptions.loadOptions.fetch = { headers: preloadOptions.headers };
85727
+ try {
85728
+ const preloadOptions = await this._fetchPreloadOptions();
85729
+ const tilesetOptions = { loadOptions: { basis: { format: "rgba32" } } };
85730
+ if (preloadOptions.headers) {
85731
+ tilesetOptions.loadOptions.fetch = { headers: preloadOptions.headers };
85732
+ }
85733
+ Object.assign(tilesetOptions, preloadOptions);
85734
+ const sourceTilesetJson = await load(inputUrl, this.Loader, tilesetOptions.loadOptions);
85735
+ this.sourceTileset = new Tileset3D(sourceTilesetJson, tilesetOptions);
85736
+ await this._createAndSaveTileset(outputPath, tilesetName);
85737
+ await this._finishConversion({ slpk: Boolean(slpk), outputPath, tilesetName });
85738
+ return sourceTilesetJson;
85739
+ } catch (error) {
85740
+ throw error;
85741
+ } finally {
85742
+ const workerFarm = WorkerFarm.getWorkerFarm({});
85743
+ workerFarm.destroy();
85751
85744
  }
85752
- Object.assign(tilesetOptions, preloadOptions);
85753
- const sourceTilesetJson = await load(inputUrl, this.Loader, tilesetOptions.loadOptions);
85754
- this.sourceTileset = new Tileset3D(sourceTilesetJson, tilesetOptions);
85755
- await this._createAndSaveTileset(outputPath, tilesetName);
85756
- await this._finishConversion({ slpk: Boolean(slpk), outputPath, tilesetName });
85757
- const workerFarm = WorkerFarm.getWorkerFarm({});
85758
- workerFarm.destroy();
85759
- return sourceTilesetJson;
85760
85745
  }
85761
85746
  async _createAndSaveTileset(outputPath, tilesetName) {
85762
85747
  const tilesetPath = (0, import_path7.join)(`${outputPath}`, `${tilesetName}`);
@@ -86169,7 +86154,12 @@ var I3SConverter = class {
86169
86154
  await this.writeTextureFile(textureData, "0", format, childPath, slpkChildPath);
86170
86155
  if (this.generateTextures) {
86171
86156
  formats2.push({ name: "1", format: "ktx2" });
86172
- const ktx2TextureData = new Uint8Array(await encode(texture.image, KTX2BasisWriter));
86157
+ const ktx2TextureData = encode(texture.image, KTX2BasisWriterWorker, {
86158
+ ...KTX2BasisWriterWorker.options,
86159
+ source: this.workerSource.ktx2,
86160
+ reuseWorkers: true,
86161
+ _nodeWorkers: true
86162
+ });
86173
86163
  await this.writeTextureFile(ktx2TextureData, "1", "ktx2", childPath, slpkChildPath);
86174
86164
  }
86175
86165
  break;
@@ -86179,7 +86169,7 @@ var I3SConverter = class {
86179
86169
  await this.writeTextureFile(textureData, "1", format, childPath, slpkChildPath);
86180
86170
  if (this.generateTextures) {
86181
86171
  formats2.push({ name: "0", format: "jpg" });
86182
- const decodedFromKTX2TextureData = new Uint8Array(await encode(texture.image.data[0], ImageWriter));
86172
+ const decodedFromKTX2TextureData = encode(texture.image.data[0], ImageWriter);
86183
86173
  await this.writeTextureFile(decodedFromKTX2TextureData, "0", "jpg", childPath, slpkChildPath);
86184
86174
  }
86185
86175
  }
@@ -86433,6 +86423,12 @@ var I3SConverter = class {
86433
86423
  const source2 = await sourceResponse2.text();
86434
86424
  this.workerSource.draco = source2;
86435
86425
  }
86426
+ if (this.generateTextures) {
86427
+ const url = getWorkerURL(KTX2BasisWriterWorker, { ...getGlobalLoaderOptions() });
86428
+ const sourceResponse2 = await fetchFile(url);
86429
+ const source2 = await sourceResponse2.text();
86430
+ this.workerSource.ktx2 = source2;
86431
+ }
86436
86432
  const i3sAttributesWorkerUrl = getWorkerURL(I3SAttributesWorker, { ...getGlobalLoaderOptions() });
86437
86433
  const sourceResponse = await fetchFile(i3sAttributesWorkerUrl);
86438
86434
  const source = await sourceResponse.text();
@@ -86610,6 +86606,7 @@ async function parseI3SNodeGeometry(arrayBuffer, tile, tileset, options) {
86610
86606
  return tile;
86611
86607
  }
86612
86608
  const content = tile.content;
86609
+ const contentByteLength = arrayBuffer.byteLength;
86613
86610
  let attributes;
86614
86611
  let vertexCount;
86615
86612
  let byteOffset = 0;
@@ -86685,7 +86682,7 @@ async function parseI3SNodeGeometry(arrayBuffer, tile, tileset, options) {
86685
86682
  }
86686
86683
  }
86687
86684
  content.vertexCount = vertexCount;
86688
- content.byteLength = arrayBuffer.byteLength;
86685
+ content.byteLength = contentByteLength;
86689
86686
  return tile;
86690
86687
  }
86691
86688
  function updateAttributesMetadata(attributes, decompressedGeometry) {
@@ -87834,74 +87831,10 @@ var Tiles3DConverter = class {
87834
87831
  console.log(`Loading workers source completed!`);
87835
87832
  }
87836
87833
  };
87837
-
87838
- // ../zip/src/zip-loader.ts
87839
- var import_jszip2 = __toModule(require_lib4());
87840
- var VERSION17 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
87841
- var ZipLoader = {
87842
- id: "zip",
87843
- module: "zip",
87844
- name: "Zip Archive",
87845
- version: VERSION17,
87846
- extensions: ["zip"],
87847
- mimeTypes: ["application/zip"],
87848
- category: "archive",
87849
- tests: ["PK"],
87850
- options: {},
87851
- parse: parseZipAsync
87852
- };
87853
- async function parseZipAsync(data, options = {}) {
87854
- const promises = [];
87855
- const fileMap = {};
87856
- try {
87857
- const jsZip = new import_jszip2.default();
87858
- const zip = await jsZip.loadAsync(data, options);
87859
- zip.forEach((relativePath, zipEntry) => {
87860
- const subFilename = zipEntry.name;
87861
- const promise = loadZipEntry(jsZip, subFilename, options).then((arrayBufferOrError) => {
87862
- fileMap[relativePath] = arrayBufferOrError;
87863
- });
87864
- promises.push(promise);
87865
- });
87866
- await Promise.all(promises);
87867
- return fileMap;
87868
- } catch (error) {
87869
- options.log.error(`Unable to read zip archive: ${error}`);
87870
- throw error;
87871
- }
87872
- }
87873
- async function loadZipEntry(jsZip, subFilename, options = {}) {
87874
- try {
87875
- const arrayBuffer = await jsZip.file(subFilename).async(options.dataType || "arraybuffer");
87876
- return arrayBuffer;
87877
- } catch (error) {
87878
- options.log.error(`Unable to read ${subFilename} from zip archive: ${error}`);
87879
- return error;
87880
- }
87881
- }
87882
-
87883
- // src/deps-installer/deps-installer.js
87884
- var import_path9 = __toModule(require("path"));
87885
- var PGM_LINK = "https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip";
87886
- var DepsInstaller = class {
87887
- async install(path2 = "") {
87888
- console.log('Installing "EGM2008-5" model...');
87889
- const fileMap = await load(PGM_LINK, ZipLoader, {});
87890
- let depsPath = process.cwd();
87891
- if (path2) {
87892
- depsPath = (0, import_path9.join)(depsPath, path2);
87893
- }
87894
- await writeFile3(depsPath, new Uint8Array(fileMap["geoids/egm2008-5.pgm"]), "egm2008-5.pgm");
87895
- console.log("All dependencies were installed succesfully.");
87896
- }
87897
- };
87898
87834
  // Annotate the CommonJS export names for ESM import in node:
87899
87835
  0 && (module.exports = {
87900
- DepsInstaller,
87901
87836
  I3SConverter,
87902
- NodePages,
87903
- Tiles3DConverter,
87904
- prepareDataForAttributesConversion
87837
+ Tiles3DConverter
87905
87838
  });
87906
87839
  /*!
87907
87840
  * Determine if an object is a Buffer
@@ -8,7 +8,7 @@ exports._typecheckI3SAttributesWorker = exports.Tile3dAttributesWorker = void 0;
8
8
 
9
9
  var _workerUtils = require("@loaders.gl/worker-utils");
10
10
 
11
- var VERSION = typeof "3.2.0-alpha.2" !== 'undefined' ? "3.2.0-alpha.2" : 'latest';
11
+ var VERSION = typeof "3.2.0-alpha.3" !== 'undefined' ? "3.2.0-alpha.3" : 'latest';
12
12
  var Tile3dAttributesWorker = {
13
13
  id: '3d-tiles-attributes',
14
14
  name: '3DTiles Attributes Worker',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/3d-tiles-converter/3d-tiles-converter.ts"],"names":["I3S","Tiles3DConverter","options","tilesetPath","vertexCounter","conversionStartTime","geoidHeightModel","sourceTileset","attributeStorageInfo","workerSource","inputUrl","outputPath","tilesetName","maxDepth","egmFilePath","process","hrtime","console","log","PGMLoader","loadWorkers","I3SLoader","sourceTilesetJson","Tileset3D","loadOptions","i3s","coordinateSystem","COORDINATE_SYSTEM","LNGLAT_OFFSETS","decodeTextures","tilesetInitializationPromise","rootNode","root","header","obb","mbs","rootTile","boundingVolume","box","geometricError","children","_addChildren","tileset","JSON","stringify","_finishConversion","slpk","workerFarm","WorkerFarm","getWorkerFarm","destroy","parentSourceNode","parentNode","level","childNodeInfo","_loadChildNode","sourceChild","push","contentUrl","_loadTile","content","vertexCount","featureAttributes","_loadChildAttributes","child","i3sAttributesData","tileContent","textureFormat","B3dmConverter","convert","b3dm","uri","id","Uint8Array","unloadContent","nodePages","nodePagesTile","formTileFromNodePages","loader","nodeUrl","_relativeUrlToFullUrl","url","href","isTileHeader","loadContent","Tile3D","baseUrl","relativeUrl","resultArray","split","relativeUrlArray","folder","slice","join","promises","attributeUrls","index","length","attribute","attributeName","name","attributeType","_getAttributeType","I3SAttributeLoader","Promise","all","attributesList","_replaceNestedArrays","Object","assign","attributeValues","valueType","objectIds","attributeObject","key","Array","from","params","filesSize","diff","conversionTime","tile3dAttributesWorkerUrl","Tile3dAttributesWorker","sourceResponse","text","source","tile3dWorkerSource"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,KAAZ;;IAKqBC,gB;AAUnB,8BAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wDAF0B,EAE1B;AACZ,SAAKC,OAAL,GAAe,EAAf;AACA,SAAKC,WAAL,GAAmB,EAAnB;AACA,SAAKC,aAAL,GAAqB,CAArB;AACA,SAAKC,mBAAL,GAA2B,CAAC,CAAD,EAAI,CAAJ,CAA3B;AACA,SAAKC,gBAAL,GAAwB,IAAxB;AACA,SAAKC,aAAL,GAAqB,IAArB;AACA,SAAKC,oBAAL,GAA4B,IAA5B;AACA,SAAKC,YAAL,GAAoB,EAApB;AACD;;;;;+EAWD,iBAAqBP,OAArB;AAAA;AAAA;AAAA;AAAA;AAAA;AAOSQ,gBAAAA,QAPT,GAOqER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EoC,+BAAaC,8CAAb,oBAAyC,6BAAzC,EAFpC;AAAA;AAAA,uBAG+B,qBAAUD,yBAAV,CAH/B;;AAAA;AAGQE,gBAAAA,cAHR;AAAA;AAAA,uBAIuBA,cAAc,CAACC,IAAf,EAJvB;;AAAA;AAIQC,gBAAAA,MAJR;AAME,qBAAKpH,YAAL,CAAkBqH,kBAAlB,GAAuCD,MAAvC;AACA5G,gBAAAA,OAAO,CAACC,GAAR;;AAPF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O","sourcesContent":["import type {AttributeStorageInfo, FeatureAttribute, NodeReference} from '@loaders.gl/i3s';\nimport type {Node3D} from '@loaders.gl/3d-tiles';\n\nimport {join} from 'path';\nimport process from 'process';\nimport transform from 'json-map-transform';\nimport {fetchFile, getLoaderOptions, load} from '@loaders.gl/core';\nimport {I3SLoader, I3SAttributeLoader, COORDINATE_SYSTEM} from '@loaders.gl/i3s';\nimport {Tileset3D, Tile3D} from '@loaders.gl/tiles';\nimport {Geoid} from '@math.gl/geoid';\n\nimport {PGMLoader} from '../pgm-loader';\nimport {i3sObbTo3dTilesObb} from './helpers/i3s-obb-to-3d-tiles-obb';\nimport {convertScreenThresholdToGeometricError} from '../lib/utils/lod-conversion-utils';\nimport {writeFile, removeDir} from '../lib/utils/file-utils';\nimport {calculateFilesSize, timeConverter} from '../lib/utils/statistic-utills';\nimport {TILESET as tilesetTemplate} from './json-templates/tileset';\nimport B3dmConverter from './helpers/b3dm-converter';\nimport {createObbFromMbs} from '../i3s-converter/helpers/coordinate-converter';\nimport {\n I3SAttributesData,\n Tile3dAttributesWorker\n /*transform3DTilesAttributesOnWorker*/\n} from '../3d-tiles-attributes-worker';\nimport {getWorkerURL, WorkerFarm} from '@loaders.gl/worker-utils';\n\nconst I3S = 'I3S';\n\n/**\n * Converter from i3s to 3d-tiles\n */\nexport default class Tiles3DConverter {\n options: any;\n tilesetPath: string;\n vertexCounter: number;\n conversionStartTime: [number, number];\n geoidHeightModel: Geoid | null;\n sourceTileset: Tileset3D | null;\n attributeStorageInfo: AttributeStorageInfo | null;\n workerSource: {[key: string]: string} = {};\n\n constructor() {\n this.options = {};\n this.tilesetPath = '';\n this.vertexCounter = 0;\n this.conversionStartTime = [0, 0];\n this.geoidHeightModel = null;\n this.sourceTileset = null;\n this.attributeStorageInfo = null;\n this.workerSource = {};\n }\n\n /**\n * Convert i3s format data to 3dTiles\n * @param options\n * @param options.inputUrl the url to read the tileset from\n * @param options.outputPath the output filename\n * @param options.tilesetName the output name of the tileset\n * @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format\n * @param options.maxDepth The max tree depth of conversion\n */\n public async convert(options: {\n inputUrl: string;\n outputPath: string;\n tilesetName: string;\n maxDepth: number;\n egmFilePath: string;\n }): Promise<any> {\n const {inputUrl, outputPath, tilesetName, maxDepth, egmFilePath} = options;\n this.conversionStartTime = process.hrtime();\n this.options = {maxDepth};\n\n console.log('Loading egm file...'); // eslint-disable-line\n this.geoidHeightModel = await load(egmFilePath, PGMLoader);\n console.log('Loading egm file completed!'); // eslint-disable-line\n\n await this.loadWorkers();\n\n const sourceTilesetJson = await load(inputUrl, I3SLoader, {});\n\n this.sourceTileset = new Tileset3D(sourceTilesetJson, {\n loadOptions: {\n i3s: {coordinateSystem: COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false}\n }\n });\n\n await this.sourceTileset.tilesetInitializationPromise;\n const rootNode = this.sourceTileset.root!;\n if (!rootNode.header.obb) {\n rootNode.header.obb = createObbFromMbs(rootNode.header.mbs);\n }\n\n this.tilesetPath = join(`${outputPath}`, `${tilesetName}`);\n this.attributeStorageInfo = sourceTilesetJson.attributeStorageInfo;\n // Removing the tilesetPath needed to exclude erroneous files after conversion\n try {\n await removeDir(this.tilesetPath);\n } catch (e) {\n // do nothing\n }\n\n const rootTile: Node3D = {\n boundingVolume: {\n box: i3sObbTo3dTilesObb(rootNode.header.obb, this.geoidHeightModel)\n },\n geometricError: convertScreenThresholdToGeometricError(rootNode),\n children: []\n };\n\n await this._addChildren(rootNode, rootTile, 1);\n\n const tileset = transform({root: rootTile}, tilesetTemplate());\n await writeFile(this.tilesetPath, JSON.stringify(tileset), 'tileset.json');\n\n this._finishConversion({slpk: false, outputPath, tilesetName});\n\n // Clean up worker pools\n const workerFarm = WorkerFarm.getWorkerFarm({});\n workerFarm.destroy();\n }\n\n /**\n * The recursive function of traversal of a nodes tree\n * @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)\n * @param parentNode object in resulting tileset\n * @param level a current level of a tree depth\n */\n private async _addChildren(\n parentSourceNode: Tile3D,\n parentNode: Node3D,\n level: number\n ): Promise<void> {\n if (this.options.maxDepth && level > this.options.maxDepth) {\n return;\n }\n for (const childNodeInfo of parentSourceNode.header.children || []) {\n const sourceChild = await this._loadChildNode(parentSourceNode, childNodeInfo);\n parentSourceNode.children.push(sourceChild);\n if (sourceChild.contentUrl) {\n await this.sourceTileset!._loadTile(sourceChild);\n this.vertexCounter += sourceChild.content.vertexCount;\n\n let featureAttributes: FeatureAttribute | null = null;\n if (this.attributeStorageInfo) {\n featureAttributes = await this._loadChildAttributes(\n sourceChild,\n this.attributeStorageInfo\n );\n }\n\n if (!sourceChild.header.obb) {\n sourceChild.header.obb = createObbFromMbs(sourceChild.header.mbs);\n }\n\n const boundingVolume = {\n box: i3sObbTo3dTilesObb(sourceChild.header.obb, this.geoidHeightModel)\n };\n const child: Node3D = {\n boundingVolume,\n geometricError: convertScreenThresholdToGeometricError(sourceChild),\n children: []\n };\n\n const i3sAttributesData: I3SAttributesData = {\n tileContent: sourceChild.content,\n textureFormat: sourceChild?.header?.textureFormat\n };\n\n // TODO Uncomment when 3d-tiles-attributes-worker will be published on CDN.\n // const b3dm = await transform3DTilesAttributesOnWorker(i3sAttributesData, {\n // source: this.workerSource.tile3dWorkerSource,\n // featureAttributes\n // });\n\n const b3dm = await new B3dmConverter().convert(i3sAttributesData, featureAttributes);\n\n child.content = {\n uri: `${sourceChild.id}.b3dm`,\n boundingVolume\n };\n await writeFile(this.tilesetPath, new Uint8Array(b3dm), `${sourceChild.id}.b3dm`);\n parentNode.children.push(child);\n\n sourceChild.unloadContent();\n await this._addChildren(sourceChild, child, level + 1);\n } else {\n await this._addChildren(sourceChild, parentNode, level + 1);\n }\n }\n }\n\n /**\n * Load a child node having information from the node header\n * @param parentNode a parent node tile object (@loaders.gl/tiles/Tile3D)\n * @param childNodeInfo child information from 3DNodeIndexDocument\n * (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/nodeReference.cmn.md)\n */\n private async _loadChildNode(parentNode: Tile3D, childNodeInfo: NodeReference): Promise<Tile3D> {\n let header;\n if (this.sourceTileset!.tileset.nodePages) {\n console.log(`Node conversion: ${childNodeInfo.id}`); // eslint-disable-line no-console,no-undef\n header = await this.sourceTileset!.tileset.nodePagesTile.formTileFromNodePages(\n childNodeInfo.id\n );\n } else {\n const {loader} = this.sourceTileset!;\n const nodeUrl = this._relativeUrlToFullUrl(parentNode.url, childNodeInfo.href!);\n // load metadata\n const options = {\n i3s: {\n ...this.sourceTileset!.loadOptions,\n isTileHeader: true,\n loadContent: false\n }\n };\n\n console.log(`Node conversion: ${nodeUrl}`); // eslint-disable-line no-console,no-undef\n header = await load(nodeUrl, loader, options);\n }\n return new Tile3D(this.sourceTileset!, header, parentNode);\n }\n\n /**\n * Make an url of a resource from its relative url having the base url\n * @param baseUrl the base url. A resulting url will be related from this url\n * @param relativeUrl a realtive url of a resource\n */\n private _relativeUrlToFullUrl(baseUrl: string, relativeUrl: string): string {\n let resultArray = baseUrl.split('/');\n const relativeUrlArray = relativeUrl.split('/');\n for (const folder of relativeUrlArray) {\n switch (folder) {\n case '.':\n continue; // eslint-disable-line no-continue\n case '..':\n resultArray = resultArray.slice(0, -1);\n break;\n default:\n resultArray.push(folder);\n }\n }\n return resultArray.join('/');\n }\n\n /**\n * Do loading all attributes related to particular node.\n * @param sourceChild\n * @param attributeStorageInfo\n * @returns Promise of attributes object.\n */\n private async _loadChildAttributes(\n sourceChild: Tile3D,\n attributeStorageInfo: AttributeStorageInfo\n ): Promise<FeatureAttribute> {\n const promises: any[] = [];\n const {attributeUrls} = sourceChild.header;\n\n for (let index = 0; index < attributeUrls.length; index++) {\n const inputUrl = attributeUrls[index];\n const attribute = attributeStorageInfo[index];\n const options = {\n attributeName: attribute.name,\n attributeType: this._getAttributeType(attribute)\n };\n\n promises.push(load(inputUrl, I3SAttributeLoader, options));\n }\n const attributesList = await Promise.all(promises);\n this._replaceNestedArrays(attributesList);\n return Object.assign({}, ...attributesList);\n }\n\n /**\n * Returns attribute type for loading attributes\n * @param attribute\n * Workaround for I3S v1.6. There is no attribute.attributeValues.valueType field in attribute.\n * There is an 'Oid32' type if attribute has objectIds property.\n * Doc: https://github.com/Esri/i3s-spec/blob/master/docs/1.6/attributeStorageInfo.cmn.md\n */\n private _getAttributeType(attribute: AttributeStorageInfo): string {\n if (attribute.attributeValues) {\n return attribute.attributeValues.valueType;\n } else if (attribute.objectIds) {\n return 'Oid32';\n }\n return '';\n }\n\n /**\n * Make simple arrays from attribute typed arrays.\n * @param attributesList\n */\n private _replaceNestedArrays(attributesList: FeatureAttribute[]): void {\n for (let index = 0; index < attributesList.length; index++) {\n const attributeObject = attributesList[index];\n\n for (const key in attributeObject) {\n attributeObject[key] = Array.from(attributeObject[key]);\n }\n }\n }\n\n /**\n * Print statistics in the end of conversion\n * @param params - output files data\n */\n private async _finishConversion(params: {\n slpk: boolean;\n outputPath: string;\n tilesetName: string;\n }): Promise<void> {\n const filesSize = await calculateFilesSize(params);\n const diff = process.hrtime(this.conversionStartTime);\n const conversionTime = timeConverter(diff);\n\n console.log(`------------------------------------------------`); // eslint-disable-line\n console.log(`Finish conversion of ${I3S}`); // eslint-disable-line\n console.log(`Total conversion time: ${conversionTime}`); // eslint-disable-line\n console.log(`Vertex count: `, this.vertexCounter); // eslint-disable-line\n console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line\n console.log(`------------------------------------------------`); // eslint-disable-line\n }\n\n private async loadWorkers(): Promise<void> {\n console.log(`Loading workers source...`); // eslint-disable-line no-undef, no-console\n const tile3dAttributesWorkerUrl = getWorkerURL(Tile3dAttributesWorker, {...getLoaderOptions()});\n const sourceResponse = await fetchFile(tile3dAttributesWorkerUrl);\n const source = await sourceResponse.text();\n\n this.workerSource.tile3dWorkerSource = source;\n console.log(`Loading workers source completed!`); // eslint-disable-line no-undef, no-console\n }\n}\n"],"file":"3d-tiles-converter.js"}
1
+ {"version":3,"sources":["../../../src/3d-tiles-converter/3d-tiles-converter.ts"],"names":["I3S","Tiles3DConverter","options","tilesetPath","vertexCounter","conversionStartTime","geoidHeightModel","sourceTileset","attributeStorageInfo","workerSource","inputUrl","outputPath","tilesetName","maxDepth","egmFilePath","process","hrtime","console","log","PGMLoader","loadWorkers","I3SLoader","sourceTilesetJson","Tileset3D","loadOptions","i3s","coordinateSystem","COORDINATE_SYSTEM","LNGLAT_OFFSETS","decodeTextures","tilesetInitializationPromise","rootNode","root","header","obb","mbs","rootTile","boundingVolume","box","geometricError","children","_addChildren","tileset","JSON","stringify","_finishConversion","slpk","workerFarm","WorkerFarm","getWorkerFarm","destroy","parentSourceNode","parentNode","level","childNodeInfo","_loadChildNode","sourceChild","push","contentUrl","_loadTile","content","vertexCount","featureAttributes","_loadChildAttributes","child","i3sAttributesData","tileContent","textureFormat","B3dmConverter","convert","b3dm","uri","id","Uint8Array","unloadContent","nodePages","nodePagesTile","formTileFromNodePages","loader","nodeUrl","_relativeUrlToFullUrl","url","href","isTileHeader","loadContent","Tile3D","baseUrl","relativeUrl","resultArray","split","relativeUrlArray","folder","slice","join","promises","attributeUrls","index","length","attribute","attributeName","name","attributeType","_getAttributeType","I3SAttributeLoader","Promise","all","attributesList","_replaceNestedArrays","Object","assign","attributeValues","valueType","objectIds","attributeObject","key","Array","from","params","filesSize","diff","conversionTime","tile3dAttributesWorkerUrl","Tile3dAttributesWorker","sourceResponse","text","source","tile3dWorkerSource"],"mappings":";;;;;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AAA;AAAA;AAAA,uBAK0B,yCAAmBA,MAAnB,CAL1B;;AAAA;AAKQC,gBAAAA,SALR;AAMQC,gBAAAA,IANR,GAMexG,iBAAQC,MAAR,CAAe,KAAKX,mBAApB,CANf;AAOQmH,gBAAAA,cAPR,GAOyB,oCAAcD,IAAd,CAPzB;AASEtG,gBAAAA,OAAO,CAACC,GAAR;AACAD,gBAAAA,OAAO,CAACC,GAAR,gCAAoClB,GAApC;AACAiB,gBAAAA,OAAO,CAACC,GAAR,kCAAsCsG,cAAtC;AACAvG,gBAAAA,OAAO,CAACC,GAAR,mBAA8B,KAAKd,aAAnC;AACAa,gBAAAA,OAAO,CAACC,GAAR,mBAA8BoG,SAA9B,EAAyC,QAAzC;AACArG,gBAAAA,OAAO,CAACC,GAAR;;AAdF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;mFAiBA;AAAA;AAAA;AAAA;AAAA;AAAA;AACED,gBAAAA,OAAO,CAACC,GAAR;AACMuG,gBAAAA,yBAFR,GAEoC,+BAAaC,8CAAb,oBAAyC,6BAAzC,EAFpC;AAAA;AAAA,uBAG+B,qBAAUD,yBAAV,CAH/B;;AAAA;AAGQE,gBAAAA,cAHR;AAAA;AAAA,uBAIuBA,cAAc,CAACC,IAAf,EAJvB;;AAAA;AAIQC,gBAAAA,MAJR;AAME,qBAAKpH,YAAL,CAAkBqH,kBAAlB,GAAuCD,MAAvC;AACA5G,gBAAAA,OAAO,CAACC,GAAR;;AAPF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O","sourcesContent":["import type {AttributeStorageInfo, FeatureAttribute, NodeReference} from '@loaders.gl/i3s';\nimport type {Node3D} from '@loaders.gl/3d-tiles';\n\nimport {join} from 'path';\nimport process from 'process';\nimport transform from 'json-map-transform';\nimport {fetchFile, getLoaderOptions, load} from '@loaders.gl/core';\nimport {I3SLoader, I3SAttributeLoader, COORDINATE_SYSTEM} from '@loaders.gl/i3s';\nimport {Tileset3D, Tile3D} from '@loaders.gl/tiles';\nimport {Geoid} from '@math.gl/geoid';\n\nimport {PGMLoader} from '../pgm-loader';\nimport {i3sObbTo3dTilesObb} from './helpers/i3s-obb-to-3d-tiles-obb';\nimport {convertScreenThresholdToGeometricError} from '../lib/utils/lod-conversion-utils';\nimport {writeFile, removeDir} from '../lib/utils/file-utils';\nimport {calculateFilesSize, timeConverter} from '../lib/utils/statistic-utills';\nimport {TILESET as tilesetTemplate} from './json-templates/tileset';\nimport B3dmConverter from './helpers/b3dm-converter';\nimport {createObbFromMbs} from '../i3s-converter/helpers/coordinate-converter';\nimport {\n I3SAttributesData,\n Tile3dAttributesWorker\n /*transform3DTilesAttributesOnWorker*/\n} from '../3d-tiles-attributes-worker';\nimport {getWorkerURL, WorkerFarm} from '@loaders.gl/worker-utils';\n\nconst I3S = 'I3S';\n\n/**\n * Converter from i3s to 3d-tiles\n */\nexport default class Tiles3DConverter {\n options: any;\n tilesetPath: string;\n vertexCounter: number;\n conversionStartTime: [number, number];\n geoidHeightModel: Geoid | null;\n sourceTileset: Tileset3D | null;\n attributeStorageInfo: AttributeStorageInfo | null;\n workerSource: {[key: string]: string} = {};\n\n constructor() {\n this.options = {};\n this.tilesetPath = '';\n this.vertexCounter = 0;\n this.conversionStartTime = [0, 0];\n this.geoidHeightModel = null;\n this.sourceTileset = null;\n this.attributeStorageInfo = null;\n this.workerSource = {};\n }\n\n /**\n * Convert i3s format data to 3dTiles\n * @param options\n * @param options.inputUrl the url to read the tileset from\n * @param options.outputPath the output filename\n * @param options.tilesetName the output name of the tileset\n * @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format\n * @param options.maxDepth The max tree depth of conversion\n */\n public async convert(options: {\n inputUrl: string;\n outputPath: string;\n tilesetName: string;\n maxDepth?: number;\n egmFilePath: string;\n }): Promise<any> {\n const {inputUrl, outputPath, tilesetName, maxDepth, egmFilePath} = options;\n this.conversionStartTime = process.hrtime();\n this.options = {maxDepth};\n\n console.log('Loading egm file...'); // eslint-disable-line\n this.geoidHeightModel = await load(egmFilePath, PGMLoader);\n console.log('Loading egm file completed!'); // eslint-disable-line\n\n await this.loadWorkers();\n\n const sourceTilesetJson = await load(inputUrl, I3SLoader, {});\n\n this.sourceTileset = new Tileset3D(sourceTilesetJson, {\n loadOptions: {\n i3s: {coordinateSystem: COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false}\n }\n });\n\n await this.sourceTileset.tilesetInitializationPromise;\n const rootNode = this.sourceTileset.root!;\n if (!rootNode.header.obb) {\n rootNode.header.obb = createObbFromMbs(rootNode.header.mbs);\n }\n\n this.tilesetPath = join(`${outputPath}`, `${tilesetName}`);\n this.attributeStorageInfo = sourceTilesetJson.attributeStorageInfo;\n // Removing the tilesetPath needed to exclude erroneous files after conversion\n try {\n await removeDir(this.tilesetPath);\n } catch (e) {\n // do nothing\n }\n\n const rootTile: Node3D = {\n boundingVolume: {\n box: i3sObbTo3dTilesObb(rootNode.header.obb, this.geoidHeightModel)\n },\n geometricError: convertScreenThresholdToGeometricError(rootNode),\n children: []\n };\n\n await this._addChildren(rootNode, rootTile, 1);\n\n const tileset = transform({root: rootTile}, tilesetTemplate());\n await writeFile(this.tilesetPath, JSON.stringify(tileset), 'tileset.json');\n\n this._finishConversion({slpk: false, outputPath, tilesetName});\n\n // Clean up worker pools\n const workerFarm = WorkerFarm.getWorkerFarm({});\n workerFarm.destroy();\n }\n\n /**\n * The recursive function of traversal of a nodes tree\n * @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)\n * @param parentNode object in resulting tileset\n * @param level a current level of a tree depth\n */\n private async _addChildren(\n parentSourceNode: Tile3D,\n parentNode: Node3D,\n level: number\n ): Promise<void> {\n if (this.options.maxDepth && level > this.options.maxDepth) {\n return;\n }\n for (const childNodeInfo of parentSourceNode.header.children || []) {\n const sourceChild = await this._loadChildNode(parentSourceNode, childNodeInfo);\n parentSourceNode.children.push(sourceChild);\n if (sourceChild.contentUrl) {\n await this.sourceTileset!._loadTile(sourceChild);\n this.vertexCounter += sourceChild.content.vertexCount;\n\n let featureAttributes: FeatureAttribute | null = null;\n if (this.attributeStorageInfo) {\n featureAttributes = await this._loadChildAttributes(\n sourceChild,\n this.attributeStorageInfo\n );\n }\n\n if (!sourceChild.header.obb) {\n sourceChild.header.obb = createObbFromMbs(sourceChild.header.mbs);\n }\n\n const boundingVolume = {\n box: i3sObbTo3dTilesObb(sourceChild.header.obb, this.geoidHeightModel)\n };\n const child: Node3D = {\n boundingVolume,\n geometricError: convertScreenThresholdToGeometricError(sourceChild),\n children: []\n };\n\n const i3sAttributesData: I3SAttributesData = {\n tileContent: sourceChild.content,\n textureFormat: sourceChild?.header?.textureFormat\n };\n\n // TODO Uncomment when 3d-tiles-attributes-worker will be published on CDN.\n // const b3dm = await transform3DTilesAttributesOnWorker(i3sAttributesData, {\n // source: this.workerSource.tile3dWorkerSource,\n // featureAttributes\n // });\n\n const b3dm = await new B3dmConverter().convert(i3sAttributesData, featureAttributes);\n\n child.content = {\n uri: `${sourceChild.id}.b3dm`,\n boundingVolume\n };\n await writeFile(this.tilesetPath, new Uint8Array(b3dm), `${sourceChild.id}.b3dm`);\n parentNode.children.push(child);\n\n sourceChild.unloadContent();\n await this._addChildren(sourceChild, child, level + 1);\n } else {\n await this._addChildren(sourceChild, parentNode, level + 1);\n }\n }\n }\n\n /**\n * Load a child node having information from the node header\n * @param parentNode a parent node tile object (@loaders.gl/tiles/Tile3D)\n * @param childNodeInfo child information from 3DNodeIndexDocument\n * (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/nodeReference.cmn.md)\n */\n private async _loadChildNode(parentNode: Tile3D, childNodeInfo: NodeReference): Promise<Tile3D> {\n let header;\n if (this.sourceTileset!.tileset.nodePages) {\n console.log(`Node conversion: ${childNodeInfo.id}`); // eslint-disable-line no-console,no-undef\n header = await this.sourceTileset!.tileset.nodePagesTile.formTileFromNodePages(\n childNodeInfo.id\n );\n } else {\n const {loader} = this.sourceTileset!;\n const nodeUrl = this._relativeUrlToFullUrl(parentNode.url, childNodeInfo.href!);\n // load metadata\n const options = {\n i3s: {\n ...this.sourceTileset!.loadOptions,\n isTileHeader: true,\n loadContent: false\n }\n };\n\n console.log(`Node conversion: ${nodeUrl}`); // eslint-disable-line no-console,no-undef\n header = await load(nodeUrl, loader, options);\n }\n return new Tile3D(this.sourceTileset!, header, parentNode);\n }\n\n /**\n * Make an url of a resource from its relative url having the base url\n * @param baseUrl the base url. A resulting url will be related from this url\n * @param relativeUrl a realtive url of a resource\n */\n private _relativeUrlToFullUrl(baseUrl: string, relativeUrl: string): string {\n let resultArray = baseUrl.split('/');\n const relativeUrlArray = relativeUrl.split('/');\n for (const folder of relativeUrlArray) {\n switch (folder) {\n case '.':\n continue; // eslint-disable-line no-continue\n case '..':\n resultArray = resultArray.slice(0, -1);\n break;\n default:\n resultArray.push(folder);\n }\n }\n return resultArray.join('/');\n }\n\n /**\n * Do loading all attributes related to particular node.\n * @param sourceChild\n * @param attributeStorageInfo\n * @returns Promise of attributes object.\n */\n private async _loadChildAttributes(\n sourceChild: Tile3D,\n attributeStorageInfo: AttributeStorageInfo\n ): Promise<FeatureAttribute> {\n const promises: any[] = [];\n const {attributeUrls} = sourceChild.header;\n\n for (let index = 0; index < attributeUrls.length; index++) {\n const inputUrl = attributeUrls[index];\n const attribute = attributeStorageInfo[index];\n const options = {\n attributeName: attribute.name,\n attributeType: this._getAttributeType(attribute)\n };\n\n promises.push(load(inputUrl, I3SAttributeLoader, options));\n }\n const attributesList = await Promise.all(promises);\n this._replaceNestedArrays(attributesList);\n return Object.assign({}, ...attributesList);\n }\n\n /**\n * Returns attribute type for loading attributes\n * @param attribute\n * Workaround for I3S v1.6. There is no attribute.attributeValues.valueType field in attribute.\n * There is an 'Oid32' type if attribute has objectIds property.\n * Doc: https://github.com/Esri/i3s-spec/blob/master/docs/1.6/attributeStorageInfo.cmn.md\n */\n private _getAttributeType(attribute: AttributeStorageInfo): string {\n if (attribute.attributeValues) {\n return attribute.attributeValues.valueType;\n } else if (attribute.objectIds) {\n return 'Oid32';\n }\n return '';\n }\n\n /**\n * Make simple arrays from attribute typed arrays.\n * @param attributesList\n */\n private _replaceNestedArrays(attributesList: FeatureAttribute[]): void {\n for (let index = 0; index < attributesList.length; index++) {\n const attributeObject = attributesList[index];\n\n for (const key in attributeObject) {\n attributeObject[key] = Array.from(attributeObject[key]);\n }\n }\n }\n\n /**\n * Print statistics in the end of conversion\n * @param params - output files data\n */\n private async _finishConversion(params: {\n slpk: boolean;\n outputPath: string;\n tilesetName: string;\n }): Promise<void> {\n const filesSize = await calculateFilesSize(params);\n const diff = process.hrtime(this.conversionStartTime);\n const conversionTime = timeConverter(diff);\n\n console.log(`------------------------------------------------`); // eslint-disable-line\n console.log(`Finish conversion of ${I3S}`); // eslint-disable-line\n console.log(`Total conversion time: ${conversionTime}`); // eslint-disable-line\n console.log(`Vertex count: `, this.vertexCounter); // eslint-disable-line\n console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line\n console.log(`------------------------------------------------`); // eslint-disable-line\n }\n\n private async loadWorkers(): Promise<void> {\n console.log(`Loading workers source...`); // eslint-disable-line no-undef, no-console\n const tile3dAttributesWorkerUrl = getWorkerURL(Tile3dAttributesWorker, {...getLoaderOptions()});\n const sourceResponse = await fetchFile(tile3dAttributesWorkerUrl);\n const source = await sourceResponse.text();\n\n this.workerSource.tile3dWorkerSource = source;\n console.log(`Loading workers source completed!`); // eslint-disable-line no-undef, no-console\n }\n}\n"],"file":"3d-tiles-converter.js"}