@loaders.gl/tile-converter 4.1.0-alpha.9 → 4.2.0-alpha.1

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 (68) hide show
  1. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  2. package/dist/3d-tiles-converter/3d-tiles-converter.js +4 -4
  3. package/dist/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  4. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
  5. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +8 -0
  6. package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  7. package/dist/3d-tiles-converter/json-templates/tileset.d.ts.map +1 -1
  8. package/dist/3d-tiles-converter/json-templates/tileset.js +3 -0
  9. package/dist/3d-tiles-converter/json-templates/tileset.js.map +1 -1
  10. package/dist/constants.d.ts +1 -0
  11. package/dist/constants.d.ts.map +1 -1
  12. package/dist/constants.js +1 -0
  13. package/dist/constants.js.map +1 -1
  14. package/dist/converter-cli.js +3 -3
  15. package/dist/converter-cli.js.map +1 -1
  16. package/dist/converter.min.cjs +131 -220
  17. package/dist/deps-installer/deps-installer.js +1 -1
  18. package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts +10 -0
  19. package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts.map +1 -1
  20. package/dist/i3s-converter/helpers/attribute-metadata-info.js +5 -0
  21. package/dist/i3s-converter/helpers/attribute-metadata-info.js.map +1 -1
  22. package/dist/i3s-converter/helpers/node-index-document.d.ts +2 -1
  23. package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
  24. package/dist/i3s-converter/helpers/node-index-document.js +6 -8
  25. package/dist/i3s-converter/helpers/node-index-document.js.map +1 -1
  26. package/dist/i3s-converter/helpers/progress.js +1 -1
  27. package/dist/i3s-converter/helpers/progress.js.map +1 -1
  28. package/dist/i3s-converter/i3s-converter.d.ts +32 -0
  29. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  30. package/dist/i3s-converter/i3s-converter.js +195 -47
  31. package/dist/i3s-converter/i3s-converter.js.map +1 -1
  32. package/dist/i3s-converter/types.d.ts +7 -0
  33. package/dist/i3s-converter/types.d.ts.map +1 -1
  34. package/dist/i3s-converter/types.js +8 -0
  35. package/dist/i3s-converter/types.js.map +1 -1
  36. package/dist/i3s-server/bin/i3s-server.min.cjs +76 -76
  37. package/dist/index.cjs +638 -139
  38. package/dist/lib/utils/compress-util.d.ts +0 -37
  39. package/dist/lib/utils/compress-util.d.ts.map +1 -1
  40. package/dist/lib/utils/compress-util.js +1 -149
  41. package/dist/lib/utils/compress-util.js.map +1 -1
  42. package/dist/lib/utils/conversion-dump.d.ts +131 -0
  43. package/dist/lib/utils/conversion-dump.d.ts.map +1 -0
  44. package/dist/lib/utils/conversion-dump.js +191 -0
  45. package/dist/lib/utils/conversion-dump.js.map +1 -0
  46. package/dist/lib/utils/statistic-utills.js +1 -1
  47. package/dist/lib/utils/statistic-utills.js.map +1 -1
  48. package/dist/lib/utils/write-queue.d.ts +6 -1
  49. package/dist/lib/utils/write-queue.d.ts.map +1 -1
  50. package/dist/lib/utils/write-queue.js +15 -3
  51. package/dist/lib/utils/write-queue.js.map +1 -1
  52. package/dist/pgm-loader.js +1 -1
  53. package/dist/slpk-extractor.min.cjs +31 -31
  54. package/package.json +16 -16
  55. package/src/3d-tiles-converter/3d-tiles-converter.ts +5 -4
  56. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +19 -0
  57. package/src/3d-tiles-converter/json-templates/tileset.ts +3 -0
  58. package/src/constants.ts +1 -0
  59. package/src/converter-cli.ts +3 -3
  60. package/src/i3s-converter/helpers/attribute-metadata-info.ts +16 -0
  61. package/src/i3s-converter/helpers/node-index-document.ts +18 -8
  62. package/src/i3s-converter/helpers/progress.ts +1 -1
  63. package/src/i3s-converter/i3s-converter.ts +385 -93
  64. package/src/i3s-converter/types.ts +8 -0
  65. package/src/lib/utils/compress-util.ts +1 -264
  66. package/src/lib/utils/conversion-dump.ts +325 -0
  67. package/src/lib/utils/statistic-utills.ts +1 -1
  68. package/src/lib/utils/write-queue.ts +15 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/tile-converter",
3
- "version": "4.1.0-alpha.9",
3
+ "version": "4.2.0-alpha.1",
4
4
  "description": "Converter",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,9 +21,9 @@
21
21
  "module": "dist/index.js",
22
22
  "exports": {
23
23
  ".": {
24
+ "types": "./dist/index.d.ts",
24
25
  "import": "./dist/index.js",
25
- "require": "./dist/index.cjs",
26
- "types": "./dist/index.d.ts"
26
+ "require": "./dist/index.cjs"
27
27
  }
28
28
  },
29
29
  "sideEffects": false,
@@ -52,18 +52,18 @@
52
52
  "build-i3s-server-bundle": "esbuild src/i3s-server/bin/www.ts --outfile=dist/i3s-server/bin/i3s-server.min.cjs --platform=node --target=esnext,node14 --minify --bundle --define:__VERSION__=\\\"$npm_package_version\\\""
53
53
  },
54
54
  "dependencies": {
55
- "@loaders.gl/3d-tiles": "4.1.0-alpha.9",
56
- "@loaders.gl/crypto": "4.1.0-alpha.9",
57
- "@loaders.gl/draco": "4.1.0-alpha.9",
58
- "@loaders.gl/gltf": "4.1.0-alpha.9",
59
- "@loaders.gl/i3s": "4.1.0-alpha.9",
60
- "@loaders.gl/images": "4.1.0-alpha.9",
61
- "@loaders.gl/loader-utils": "4.1.0-alpha.9",
62
- "@loaders.gl/polyfills": "4.1.0-alpha.9",
63
- "@loaders.gl/textures": "4.1.0-alpha.9",
64
- "@loaders.gl/tiles": "4.1.0-alpha.9",
65
- "@loaders.gl/worker-utils": "4.1.0-alpha.9",
66
- "@loaders.gl/zip": "4.1.0-alpha.9",
55
+ "@loaders.gl/3d-tiles": "4.2.0-alpha.1",
56
+ "@loaders.gl/crypto": "4.2.0-alpha.1",
57
+ "@loaders.gl/draco": "4.2.0-alpha.1",
58
+ "@loaders.gl/gltf": "4.2.0-alpha.1",
59
+ "@loaders.gl/i3s": "4.2.0-alpha.1",
60
+ "@loaders.gl/images": "4.2.0-alpha.1",
61
+ "@loaders.gl/loader-utils": "4.2.0-alpha.1",
62
+ "@loaders.gl/polyfills": "4.2.0-alpha.1",
63
+ "@loaders.gl/textures": "4.2.0-alpha.1",
64
+ "@loaders.gl/tiles": "4.2.0-alpha.1",
65
+ "@loaders.gl/worker-utils": "4.2.0-alpha.1",
66
+ "@loaders.gl/zip": "4.2.0-alpha.1",
67
67
  "@math.gl/core": "^4.0.0",
68
68
  "@math.gl/culling": "^4.0.0",
69
69
  "@math.gl/geoid": "^4.0.0",
@@ -87,7 +87,7 @@
87
87
  "join-images": "^1.1.3",
88
88
  "sharp": "^0.31.3"
89
89
  },
90
- "gitHead": "0291d4d78d71202385d0368942f84778d6aafa82",
90
+ "gitHead": "d4da81f4d8fb2a3b43b0e025109cf7ccfb317d4c",
91
91
  "devDependencies": {
92
92
  "@types/express": "^4.17.17",
93
93
  "@types/node": "^20.4.2"
@@ -44,6 +44,8 @@ export default class Tiles3DConverter {
44
44
  loaderOptions: I3SLoaderOptions = {
45
45
  _nodeWorkers: true,
46
46
  reuseWorkers: true,
47
+ // TODO: converter freezes in the end because of i3s-content-worker
48
+ worker: false,
47
49
  i3s: {coordinateSystem: COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false},
48
50
  // We need to load local fs workers because nodejs can't load workers from the Internet
49
51
  'i3s-content': {
@@ -115,7 +117,8 @@ export default class Tiles3DConverter {
115
117
  box: i3sObbTo3dTilesObb(rootNode.obb, this.geoidHeightModel)
116
118
  },
117
119
  geometricError: convertScreenThresholdToGeometricError(rootNode),
118
- children: []
120
+ children: [],
121
+ refine: 'REPLACE'
119
122
  };
120
123
 
121
124
  await this._addChildren(rootNode, rootTile, 1);
@@ -208,11 +211,9 @@ export default class Tiles3DConverter {
208
211
  if (this.options.maxDepth && level > this.options.maxDepth) {
209
212
  return;
210
213
  }
211
- const promises: Promise<void>[] = [];
212
214
  for (const childNodeInfo of parentSourceNode.children || []) {
213
- promises.push(this.convertChildNode(parentSourceNode, parentNode, level, childNodeInfo));
215
+ await this.convertChildNode(parentSourceNode, parentNode, level, childNodeInfo);
214
216
  }
215
- await Promise.all(promises);
216
217
  }
217
218
 
218
219
  /**
@@ -9,6 +9,9 @@ import {generateSyntheticIndices} from '../../lib/utils/geometry-utils';
9
9
 
10
10
  const Z_UP_TO_Y_UP_MATRIX = new Matrix4([1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
11
11
  const scratchVector = new Vector3();
12
+ const KHR_MATERIALS_UNLIT = 'KHR_materials_unlit';
13
+ const METALLIC_FACTOR_DEFAULT = 1.0;
14
+ const ROUGHNESS_FACTOR_DEFAULT = 1.0;
12
15
 
13
16
  export type I3SAttributesData = {
14
17
  tileContent: I3STileContent;
@@ -60,6 +63,22 @@ export default class B3dmConverter {
60
63
  const gltfBuilder = new GLTFScenegraph();
61
64
 
62
65
  const textureIndex = await this._addI3sTextureToGLTF(tileContent, textureFormat, gltfBuilder);
66
+
67
+ // Add KHR_MATERIALS_UNLIT extension in the following cases:
68
+ // - metallicFactor or roughnessFactor are set to default values
69
+ // - metallicFactor or roughnessFactor are not set
70
+ const pbrMetallicRoughness = material?.pbrMetallicRoughness;
71
+ if (
72
+ pbrMetallicRoughness &&
73
+ (pbrMetallicRoughness.metallicFactor === undefined ||
74
+ pbrMetallicRoughness.metallicFactor === METALLIC_FACTOR_DEFAULT) &&
75
+ (pbrMetallicRoughness.roughnessFactor === undefined ||
76
+ pbrMetallicRoughness.roughnessFactor === ROUGHNESS_FACTOR_DEFAULT)
77
+ ) {
78
+ gltfBuilder.addObjectExtension(material, KHR_MATERIALS_UNLIT, {});
79
+ gltfBuilder.addExtension(KHR_MATERIALS_UNLIT);
80
+ }
81
+
63
82
  const pbrMaterialInfo = this._convertI3sMaterialToGLTFMaterial(material, textureIndex);
64
83
  const materialIndex = gltfBuilder.addMaterial(pbrMaterialInfo);
65
84
 
@@ -14,6 +14,9 @@ const TILE = () => ({
14
14
  geometricError: {
15
15
  path: 'geometricError'
16
16
  },
17
+ refine: {
18
+ path: 'refine'
19
+ },
17
20
  content: {
18
21
  path: 'content'
19
22
  },
package/src/constants.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export const BROWSER_ERROR_MESSAGE =
2
2
  'Tile converter does not work in browser, only in node js environment';
3
+ export const DUMP_FILE_SUFFIX = '.dump.json';
@@ -11,7 +11,7 @@ import {
11
11
  getURLValue,
12
12
  validateOptionsWithEqual
13
13
  } from './lib/utils/cli-utils';
14
- import {addOneFile, composeHashFile} from '@loaders.gl/zip';
14
+ import {addOneFile, composeHashFile, makeZipCDHeaderIterator} from '@loaders.gl/zip';
15
15
  import {FileHandleFile} from '@loaders.gl/loader-utils';
16
16
  import {copyFile} from 'node:fs/promises';
17
17
 
@@ -133,7 +133,7 @@ async function main() {
133
133
  if (finalPath !== validatedOptions.tileset) {
134
134
  await copyFile(validatedOptions.tileset, finalPath);
135
135
  }
136
- const hashTable = await composeHashFile(new FileHandleFile(finalPath));
136
+ const hashTable = await composeHashFile(makeZipCDHeaderIterator(new FileHandleFile(finalPath)));
137
137
  await addOneFile(finalPath, hashTable, '@specialIndexFileHASH128@');
138
138
 
139
139
  return;
@@ -205,7 +205,7 @@ async function convert(options: ValidatedTileConversionOptions) {
205
205
  switch (inputType) {
206
206
  case TILESET_TYPE.I3S:
207
207
  const tiles3DConverter = new Tiles3DConverter();
208
- tiles3DConverter.convert({
208
+ await tiles3DConverter.convert({
209
209
  inputUrl: options.tileset,
210
210
  outputPath: options.output,
211
211
  tilesetName: options.name,
@@ -9,6 +9,12 @@ import type {
9
9
 
10
10
  import {AttributeType} from '../types';
11
11
 
12
+ export type AttributeMetadataInfoObject = {
13
+ attributeStorageInfo: AttributeStorageInfo[];
14
+ fields: Field[];
15
+ popupInfo: PopupInfo | undefined;
16
+ };
17
+
12
18
  export class AttributeMetadataInfo {
13
19
  private _attributeStorageInfo: AttributeStorageInfo[];
14
20
  private _fields: Field[];
@@ -95,6 +101,16 @@ export class AttributeMetadataInfo {
95
101
  }
96
102
  }
97
103
 
104
+ /**
105
+ * Set AttributeMetadataInfo from object
106
+ * @param object - object with AttributeMetadataInfo props
107
+ */
108
+ fromObject(object: AttributeMetadataInfoObject) {
109
+ this._attributeStorageInfo = object.attributeStorageInfo;
110
+ this._fields = object.fields;
111
+ this._popupInfo = object.popupInfo;
112
+ }
113
+
98
114
  /**
99
115
  * Generates storage attribute for map segmentation.
100
116
  * @param attributeIndex - order index of attribute (f_0, f_1 ...).
@@ -12,6 +12,7 @@ import {openJson, writeFile, writeFileForSlpk} from '../../lib/utils/file-utils'
12
12
  import I3SConverter from '../i3s-converter';
13
13
  import {NODE as nodeTemplate} from '../json-templates/node';
14
14
  import {I3SConvertedResources} from '../types';
15
+ import {DumpMetadata} from '../../lib/utils/conversion-dump';
15
16
 
16
17
  /**
17
18
  * Wrapper for https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md data
@@ -287,9 +288,8 @@ export class NodeIndexDocument {
287
288
  boundingVolumes: BoundingVolumes,
288
289
  lodSelection: LodSelection[],
289
290
  nodeInPage: NodeInPage,
290
- resources: I3SConvertedResources
291
+ resources: I3SConvertedResources | DumpMetadata
291
292
  ): Promise<Node3DIndexDocument> {
292
- const {texture, attributes} = resources;
293
293
  const nodeId = nodeInPage.index!;
294
294
  const parentNodeData = await parentNode.load();
295
295
  const nodeData = {
@@ -313,19 +313,29 @@ export class NodeIndexDocument {
313
313
  node.geometryData = [{href: './geometries/0'}];
314
314
  node.sharedResource = {href: './shared'};
315
315
 
316
- if (texture) {
316
+ if (
317
+ ('texture' in resources && resources.texture) ||
318
+ ('texelCountHint' in resources && resources.texelCountHint)
319
+ ) {
317
320
  node.textureData = [{href: './textures/0'}, {href: './textures/1'}];
318
321
  }
319
322
 
320
323
  if (
321
- attributes &&
322
- attributes.length &&
323
- parentNode.converter.layers0?.attributeStorageInfo?.length
324
+ ('attributes' in resources &&
325
+ resources.attributes &&
326
+ resources.attributes.length &&
327
+ parentNode.converter.layers0?.attributeStorageInfo?.length) ||
328
+ ('attributesCount' in resources &&
329
+ resources.attributesCount &&
330
+ parentNode.converter.layers0?.attributeStorageInfo?.length)
324
331
  ) {
332
+ const attributesLength =
333
+ ('attributes' in resources ? resources.attributes?.length : resources.attributesCount) ||
334
+ 0;
325
335
  node.attributeData = [];
326
336
  const minimumLength =
327
- attributes.length < parentNode.converter.layers0.attributeStorageInfo.length
328
- ? attributes.length
337
+ attributesLength < parentNode.converter.layers0.attributeStorageInfo.length
338
+ ? attributesLength
329
339
  : parentNode.converter.layers0.attributeStorageInfo.length;
330
340
  for (let index = 0; index < minimumLength; index++) {
331
341
  const folderName = parentNode.converter.layers0.attributeStorageInfo[index].key;
@@ -119,7 +119,7 @@ export class Progress {
119
119
  * @returns Number of milliseconds remaining
120
120
  */
121
121
  getTimeRemaining(): {timeRemaining: number; trust: boolean} | null {
122
- if (!this._stepsDone || !this.startTime) {
122
+ if (!this._stepsTotal || !this._stepsDone || !this.startTime) {
123
123
  return null;
124
124
  }
125
125