@loaders.gl/tile-converter 4.3.0-alpha.7 → 4.3.0-alpha.8

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.
@@ -9,7 +9,7 @@ import { ChildProcessProxy } from '@loaders.gl/worker-utils';
9
9
  import { DRACO_EXTERNAL_LIBRARIES, DRACO_EXTERNAL_LIBRARY_URLS } from '@loaders.gl/draco';
10
10
  import { BASIS_EXTERNAL_LIBRARIES } from '@loaders.gl/textures';
11
11
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
12
- const VERSION = typeof "4.3.0-alpha.6" !== 'undefined' ? "4.3.0-alpha.6" : 'latest';
12
+ const VERSION = typeof "4.3.0-alpha.7" !== 'undefined' ? "4.3.0-alpha.7" : 'latest';
13
13
  const PGM_LINK = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip';
14
14
  /**
15
15
  * Install external dependencies for converter:
@@ -1 +1 @@
1
- {"version":3,"file":"i3s-converter.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/i3s-converter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,qBAAqB,EAAC,6CAA0C;AAExE,OAAO,KAAK,EAEV,oBAAoB,EAGpB,+BAA+B,EAChC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAC,cAAc,EAAC,oCAAiC;AAC7D,OAAO,KAAK,EACV,YAAY,EAMb,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAOrC,OAAO,SAAS,gCAA6B;AAkB7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,qBAAqB,EAA8B,MAAM,iBAAiB,CAAC;AAGnF,OAAO,EAGL,cAAc,EAGf,mBAAgB;AAEjB,OAAO,UAAU,oCAAiC;AAkBlD,OAAO,EAAC,QAAQ,EAAC,8BAA2B;AAE5C,OAAO,EAAC,cAAc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AY;IAgCpB;;OAEG;YACW,aAAa;IAQ3B;;;OAGG;YACW,WAAW;IAiBzB;;;;;;OAMG;YAEW,WAAW;IAuDzB;;;;OAIG;YACW,YAAY;IAc1B;;;;;;;;OAQG;YACW,0BAA0B;IAoDxC;;;;;;OAMG;YACW,YAAY;IAwC1B;;;;;;;OAOG;YAEW,WAAW;IAuGzB;;;;;;;;;;OAUG;YACW,iBAAiB;IA0C/B;;;;;;;;;;;;;;OAcG;YAEW,sBAAsB;IA0EpC;;;;;;;;;;;OAWG;YACW,eAAe;IA+C7B;;;;;;;;OAQG;YACW,gBAAgB;IA6C9B;;;;;;;;OAQG;YACW,YAAY;IAgC1B;;;;;;;OAOG;YAEW,aAAa;IA8H3B;;;;;;;;;OASG;YACW,gBAAgB;IA8B9B;;;;;;;OAOG;YACW,gBAAgB;IAkC9B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAa5B;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAU7B;;;;;;OAMG;IACH,OAAO,CAAC,8BAA8B;IAWtC;;;;OAIG;IACH,OAAO,CAAC,0BAA0B;IA4BlC;;;OAGG;YACW,iBAAiB;IAwB/B;;OAEG;YACW,oBAAoB;IAYlC;;OAEG;YACW,qBAAqB;IAiBnC;;OAEG;IACH,OAAO,CAAC,8BAA8B;IAWtC;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;CAG3B"}
@@ -38,6 +38,7 @@ import { analyzeTileContent, mergePreprocessData } from "./helpers/preprocess-3d
38
38
  import { Progress } from "./helpers/progress.js";
39
39
  import { composeHashFile, createZip } from '@loaders.gl/zip';
40
40
  import { ConversionDump } from "../lib/utils/conversion-dump.js";
41
+ // eslint-disable-next-line no-process-env
41
42
  const ION_DEFAULT_TOKEN = process.env?.IonToken;
42
43
  const HARDCODED_NODES_PER_PAGE = 64;
43
44
  const _3D_TILES = '3DTILES';
@@ -11,12 +11,14 @@ import { formErrorHandler, formListeningHandler, normalizePort } from "../utils/
11
11
  // const __filename = fileURLToPath(import.meta.url);
12
12
  // const __dirname = path.dirname(__filename);
13
13
  /** Get port from environment and store in Express. */
14
+ // eslint-disable-next-line no-process-env
14
15
  const httpPort = normalizePort(process.env.PORT || '80');
15
16
  if (httpPort === false) {
16
17
  // eslint-disable-next-line no-console
17
18
  console.error('Incorrect HTTP port');
18
19
  process.exit(1); // eslint-disable-line no-process-exit
19
20
  }
21
+ // eslint-disable-next-line no-process-env
20
22
  const httpsPort = normalizePort(process.env.HTTPS_PORT || '443');
21
23
  if (httpsPort === false) {
22
24
  // eslint-disable-next-line no-console
package/dist/index.cjs CHANGED
@@ -2325,7 +2325,7 @@ function convertScreenThresholdToGeometricError(node) {
2325
2325
 
2326
2326
  // dist/pgm-loader.js
2327
2327
  var import_geoid = require("@math.gl/geoid");
2328
- var VERSION = true ? "4.3.0-alpha.6" : "latest";
2328
+ var VERSION = true ? "4.3.0-alpha.7" : "latest";
2329
2329
  var PGMLoader = {
2330
2330
  dataType: null,
2331
2331
  batchType: null,
@@ -4024,7 +4024,7 @@ var ConversionDump = class {
4024
4024
  * @param currentOptions - converter options
4025
4025
  */
4026
4026
  async createDump(currentOptions) {
4027
- const { tilesetName, slpk, egmFilePath, inputUrl, outputPath, draco = true, maxDepth, token, generateTextures, generateBoundingVolumes, mergeMaterials: mergeMaterials2 = true, metadataClass, analyze = false } = currentOptions;
4027
+ const { tilesetName, slpk, egmFilePath, inputUrl, outputPath, draco = true, maxDepth, token, generateTextures, generateBoundingVolumes, mergeMaterials: mergeMaterials2 = true, metadataClass, analyze = false, outputVersion = "1.1" } = currentOptions;
4028
4028
  this.options = {
4029
4029
  tilesetName,
4030
4030
  slpk,
@@ -4038,7 +4038,8 @@ var ConversionDump = class {
4038
4038
  generateBoundingVolumes,
4039
4039
  mergeMaterials: mergeMaterials2,
4040
4040
  metadataClass,
4041
- analyze
4041
+ analyze,
4042
+ outputVersion
4042
4043
  };
4043
4044
  const dumpFilename = (0, import_path6.join)(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`);
4044
4045
  if (await isFileExists(dumpFilename)) {
@@ -5411,11 +5412,13 @@ var TILESET = () => ({
5411
5412
  // dist/3d-tiles-converter/3d-tiles-converter.js
5412
5413
  var import_worker_utils2 = require("@loaders.gl/worker-utils");
5413
5414
 
5414
- // dist/3d-tiles-converter/helpers/b3dm-converter.js
5415
+ // dist/3d-tiles-converter/helpers/3d-tiles-content-converter.js
5415
5416
  var import_core12 = require("@loaders.gl/core");
5416
5417
  var import_gltf6 = require("@loaders.gl/gltf");
5417
5418
  var import_d_tiles3 = require("@loaders.gl/3d-tiles");
5419
+ var import_d_tiles4 = require("@loaders.gl/3d-tiles");
5418
5420
  var import_core13 = require("@math.gl/core");
5421
+ var import_types5 = require("@math.gl/types");
5419
5422
  var import_geospatial6 = require("@math.gl/geospatial");
5420
5423
 
5421
5424
  // dist/3d-tiles-converter/helpers/texture-atlas.js
@@ -5449,38 +5452,45 @@ function normalizeRegions(regions) {
5449
5452
  return normalizedRegions;
5450
5453
  }
5451
5454
 
5452
- // dist/3d-tiles-converter/helpers/b3dm-converter.js
5455
+ // dist/3d-tiles-converter/helpers/3d-tiles-content-converter.js
5453
5456
  var Z_UP_TO_Y_UP_MATRIX = new import_core13.Matrix4([1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
5454
5457
  var scratchVector2 = new import_core13.Vector3();
5455
5458
  var KHR_MATERIALS_UNLIT = "KHR_materials_unlit";
5456
5459
  var METALLIC_FACTOR_DEFAULT = 1;
5457
5460
  var ROUGHNESS_FACTOR_DEFAULT = 1;
5458
- var B3dmConverter = class {
5461
+ var Tiles3DContentConverter = class {
5459
5462
  // @ts-expect-error
5460
5463
  rtcCenter;
5461
5464
  i3sTile;
5465
+ tileType;
5466
+ constructor(options = { outputVersion: "1.1" }) {
5467
+ this.tileType = options.outputVersion === "1.0" ? import_d_tiles4.TILE3D_TYPE.BATCHED_3D_MODEL : import_d_tiles4.TILE3D_TYPE.GLTF;
5468
+ }
5462
5469
  /**
5463
5470
  * The starter of content conversion
5464
5471
  * @param i3sTile - Tile3D instance for I3S node
5465
5472
  * @returns - encoded content
5466
5473
  */
5467
- async convert(i3sAttributesData, featureAttributes = null) {
5468
- const gltf = await this.buildGLTF(i3sAttributesData, featureAttributes);
5469
- const b3dm = (0, import_core12.encodeSync)({
5470
- gltfEncoded: new Uint8Array(gltf),
5471
- type: "b3dm",
5472
- featuresLength: this._getFeaturesLength(featureAttributes),
5473
- batchTable: featureAttributes
5474
- }, import_d_tiles3.Tile3DWriter);
5475
- return b3dm;
5474
+ async convert(i3sAttributesData, featureAttributes = null, attributeStorageInfo) {
5475
+ const gltf = await this.buildGLTF(i3sAttributesData, featureAttributes, attributeStorageInfo);
5476
+ if (this.tileType === import_d_tiles4.TILE3D_TYPE.BATCHED_3D_MODEL) {
5477
+ const b3dm = (0, import_core12.encodeSync)({
5478
+ gltfEncoded: new Uint8Array(gltf),
5479
+ type: "b3dm",
5480
+ featuresLength: this._getFeaturesLength(featureAttributes),
5481
+ batchTable: featureAttributes
5482
+ }, import_d_tiles3.Tile3DWriter);
5483
+ return b3dm;
5484
+ }
5485
+ return gltf;
5476
5486
  }
5477
5487
  /**
5478
5488
  * Build and encode gltf
5479
5489
  * @param i3sTile - Tile3D instance for I3S node
5480
5490
  * @returns - encoded glb content
5481
5491
  */
5482
- // eslint-disable-next-line max-statements
5483
- async buildGLTF(i3sAttributesData, featureAttributes) {
5492
+ // eslint-disable-next-line complexity, max-statements
5493
+ async buildGLTF(i3sAttributesData, featureAttributes, attributeStorageInfo) {
5484
5494
  const { tileContent, textureFormat, box } = i3sAttributesData;
5485
5495
  const { material, attributes, indices: originalIndices, modelMatrix } = tileContent;
5486
5496
  const gltfBuilder = new import_gltf6.GLTFScenegraph();
@@ -5511,13 +5521,97 @@ var B3dmConverter = class {
5511
5521
  material: materialIndex,
5512
5522
  mode: 4
5513
5523
  });
5524
+ if (this.tileType === import_d_tiles4.TILE3D_TYPE.GLTF) {
5525
+ this._createMetadataExtensions(gltfBuilder, meshIndex, featureAttributes, attributeStorageInfo, tileContent);
5526
+ }
5514
5527
  const transformMatrix = this._generateTransformMatrix(cartesianOrigin);
5515
5528
  const nodeIndex = gltfBuilder.addNode({ meshIndex, matrix: transformMatrix });
5516
5529
  const sceneIndex = gltfBuilder.addScene({ nodeIndices: [nodeIndex] });
5517
5530
  gltfBuilder.setDefaultScene(sceneIndex);
5518
5531
  gltfBuilder.createBinaryChunk();
5519
- const gltfBuffer = (0, import_core12.encodeSync)(gltfBuilder.gltf, import_gltf6.GLTFWriter);
5520
- return gltfBuffer;
5532
+ return (0, import_core12.encodeSync)(gltfBuilder.gltf, import_gltf6.GLTFWriter, { gltfBuilder });
5533
+ }
5534
+ _createMetadataExtensions(gltfBuilder, meshIndex, featureAttributes, attributeStorageInfo, tileContent) {
5535
+ var _a2;
5536
+ const propertyAttributes = this._createPropertyAttibutes(featureAttributes, attributeStorageInfo);
5537
+ const tableIndex = (0, import_gltf6.createExtStructuralMetadata)(gltfBuilder, propertyAttributes);
5538
+ const mesh = gltfBuilder.getMesh(meshIndex);
5539
+ for (const primitive of mesh.primitives) {
5540
+ if ((_a2 = tileContent.attributes._BATCHID) == null ? void 0 : _a2.value) {
5541
+ (0, import_gltf6.createExtMeshFeatures)(gltfBuilder, primitive, tileContent.attributes._BATCHID.value, tableIndex);
5542
+ }
5543
+ }
5544
+ }
5545
+ _createPropertyAttibutes(featureAttributes, attributeStorageInfo) {
5546
+ if (!featureAttributes || !attributeStorageInfo) {
5547
+ return [];
5548
+ }
5549
+ const propertyAttributeArray = [];
5550
+ for (const attributeName in featureAttributes) {
5551
+ const propertyAttribute = this._convertAttributeStorageInfoToPropertyAttribute(attributeName, attributeStorageInfo, featureAttributes);
5552
+ if (propertyAttribute) {
5553
+ propertyAttributeArray.push(propertyAttribute);
5554
+ }
5555
+ }
5556
+ return propertyAttributeArray;
5557
+ }
5558
+ // eslint-disable-next-line complexity
5559
+ _convertAttributeStorageInfoToPropertyAttribute(attributeName, attributeStorageInfo, featureAttributes) {
5560
+ const attributeValues = featureAttributes[attributeName];
5561
+ const info = attributeStorageInfo.find((e) => e.name === attributeName);
5562
+ if (!info) {
5563
+ return null;
5564
+ }
5565
+ const attributeMetadata = info.attributeValues;
5566
+ if (!(attributeMetadata == null ? void 0 : attributeMetadata.valueType)) {
5567
+ return null;
5568
+ }
5569
+ let elementType;
5570
+ let componentType;
5571
+ switch (attributeMetadata.valueType.toLowerCase()) {
5572
+ case "oid32":
5573
+ elementType = "SCALAR";
5574
+ componentType = "UINT32";
5575
+ break;
5576
+ case "int32":
5577
+ elementType = "SCALAR";
5578
+ componentType = "INT32";
5579
+ break;
5580
+ case "uint32":
5581
+ elementType = "SCALAR";
5582
+ componentType = "UINT32";
5583
+ break;
5584
+ case "int16":
5585
+ elementType = "SCALAR";
5586
+ componentType = "INT16";
5587
+ break;
5588
+ case "uint16":
5589
+ elementType = "SCALAR";
5590
+ componentType = "UINT16";
5591
+ break;
5592
+ case "float64":
5593
+ elementType = "SCALAR";
5594
+ componentType = "FLOAT64";
5595
+ break;
5596
+ case "string":
5597
+ elementType = "STRING";
5598
+ break;
5599
+ default:
5600
+ elementType = "";
5601
+ break;
5602
+ }
5603
+ const propertyAttribute = {
5604
+ name: attributeName,
5605
+ elementType,
5606
+ componentType,
5607
+ values: []
5608
+ };
5609
+ if ((0, import_types5.isTypedArray)(attributeValues)) {
5610
+ propertyAttribute.values = Array.from(attributeValues);
5611
+ } else if (attributeValues !== null) {
5612
+ propertyAttribute.values = attributeValues;
5613
+ }
5614
+ return propertyAttribute;
5521
5615
  }
5522
5616
  /**
5523
5617
  * Update gltfBuilder with texture from I3S tile
@@ -5806,6 +5900,7 @@ var Tiles3DConverter = class {
5806
5900
  };
5807
5901
  conversionDump;
5808
5902
  progress;
5903
+ fileExt;
5809
5904
  constructor() {
5810
5905
  this.options = {};
5811
5906
  this.tilesetPath = "";
@@ -5817,12 +5912,14 @@ var Tiles3DConverter = class {
5817
5912
  this.workerSource = {};
5818
5913
  this.conversionDump = new ConversionDump();
5819
5914
  this.progress = new Progress();
5915
+ this.fileExt = "";
5820
5916
  }
5821
5917
  /**
5822
5918
  * Convert i3s format data to 3dTiles
5823
5919
  * @param options
5824
5920
  * @param options.inputUrl the url to read the tileset from
5825
5921
  * @param options.outputPath the output filename
5922
+ * @param options.outputVersion the version of 3DTiles
5826
5923
  * @param options.tilesetName the output name of the tileset
5827
5924
  * @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format
5828
5925
  * @param options.maxDepth The max tree depth of conversion
@@ -5834,9 +5931,10 @@ var Tiles3DConverter = class {
5834
5931
  console.log(BROWSER_ERROR_MESSAGE);
5835
5932
  return BROWSER_ERROR_MESSAGE;
5836
5933
  }
5837
- const { inputUrl, outputPath, tilesetName, maxDepth, egmFilePath, inquirer, analyze } = options;
5934
+ const { inputUrl, outputPath, outputVersion, tilesetName, maxDepth, egmFilePath, inquirer, analyze } = options;
5838
5935
  this.conversionStartTime = import_process5.default.hrtime();
5839
- this.options = { maxDepth, inquirer };
5936
+ this.options = { maxDepth, inquirer, outputVersion };
5937
+ this.fileExt = this.options.outputVersion === "1.0" ? "b3dm" : "glb";
5840
5938
  console.log("Loading egm file...");
5841
5939
  this.geoidHeightModel = await (0, import_core15.load)(egmFilePath, PGMLoader);
5842
5940
  console.log("Loading egm file completed!");
@@ -5891,7 +5989,7 @@ var Tiles3DConverter = class {
5891
5989
  refine: "REPLACE"
5892
5990
  };
5893
5991
  await this._addChildren(rootNode, rootTile, 1);
5894
- const tileset = (0, import_json_map_transform10.default)({ root: rootTile }, TILESET());
5992
+ const tileset = (0, import_json_map_transform10.default)({ asset: { version: outputVersion }, root: rootTile }, TILESET());
5895
5993
  await writeFile(this.tilesetPath, JSON.stringify(tileset), "tileset.json");
5896
5994
  await this.conversionDump.deleteDumpFile();
5897
5995
  this.progress.stopMonitoring();
@@ -5938,7 +6036,7 @@ var Tiles3DConverter = class {
5938
6036
  let nextParentNode = parentNode;
5939
6037
  const sourceChild = await this._loadChildNode(parentSourceNode, childNodeInfo);
5940
6038
  if (sourceChild.contentUrl) {
5941
- if (this.conversionDump.restored && this.conversionDump.isFileConversionComplete(`${sourceChild.id}.b3dm`) && (sourceChild.obb || sourceChild.mbs)) {
6039
+ if (this.conversionDump.restored && this.conversionDump.isFileConversionComplete(`${sourceChild.id}.${this.fileExt}`) && (sourceChild.obb || sourceChild.mbs)) {
5942
6040
  const { child: child2 } = this._createChildAndBoundingVolume(sourceChild);
5943
6041
  parentNode.children.push(child2);
5944
6042
  await this._addChildren(sourceChild, child2, level + 1);
@@ -5960,11 +6058,11 @@ var Tiles3DConverter = class {
5960
6058
  box: boundingVolume.box || [],
5961
6059
  textureFormat: sourceChild.textureFormat
5962
6060
  };
5963
- const b3dmConverter = new B3dmConverter();
5964
- const b3dm = await b3dmConverter.convert(i3sAttributesData, featureAttributes);
5965
- await this.conversionDump.addNode(`${sourceChild.id}.b3dm`, sourceChild.id);
5966
- await writeFile(this.tilesetPath, new Uint8Array(b3dm), `${sourceChild.id}.b3dm`);
5967
- await this.conversionDump.updateConvertedNodesDumpFile(`${sourceChild.id}.b3dm`, sourceChild.id, true);
6061
+ const converter = new Tiles3DContentConverter({ outputVersion: this.options.outputVersion });
6062
+ const contentData = await converter.convert(i3sAttributesData, featureAttributes, this.attributeStorageInfo);
6063
+ await this.conversionDump.addNode(`${sourceChild.id}.${this.fileExt}`, sourceChild.id);
6064
+ await writeFile(this.tilesetPath, new Uint8Array(contentData), `${sourceChild.id}.${this.fileExt}`);
6065
+ await this.conversionDump.updateConvertedNodesDumpFile(`${sourceChild.id}.${this.fileExt}`, sourceChild.id, true);
5968
6066
  parentNode.children.push(child);
5969
6067
  nextParentNode = child;
5970
6068
  }
@@ -6037,7 +6135,7 @@ var Tiles3DConverter = class {
6037
6135
  geometricError: convertScreenThresholdToGeometricError(sourceChild),
6038
6136
  children: [],
6039
6137
  content: {
6040
- uri: `${sourceChild.id}.b3dm`,
6138
+ uri: `${sourceChild.id}.${this.fileExt}`,
6041
6139
  boundingVolume
6042
6140
  }
6043
6141
  };