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

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 (60) 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/deps-installer/deps-installer.js.map +1 -1
  19. package/dist/i3s-converter/helpers/progress.js +1 -1
  20. package/dist/i3s-converter/helpers/progress.js.map +1 -1
  21. package/dist/i3s-converter/i3s-converter.d.ts +14 -0
  22. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  23. package/dist/i3s-converter/i3s-converter.js +76 -25
  24. package/dist/i3s-converter/i3s-converter.js.map +1 -1
  25. package/dist/i3s-converter/types.d.ts +7 -0
  26. package/dist/i3s-converter/types.d.ts.map +1 -1
  27. package/dist/i3s-converter/types.js +8 -0
  28. package/dist/i3s-converter/types.js.map +1 -1
  29. package/dist/i3s-server/bin/i3s-server.min.cjs +76 -76
  30. package/dist/index.cjs +376 -104
  31. package/dist/lib/utils/compress-util.d.ts +0 -37
  32. package/dist/lib/utils/compress-util.d.ts.map +1 -1
  33. package/dist/lib/utils/compress-util.js +1 -149
  34. package/dist/lib/utils/compress-util.js.map +1 -1
  35. package/dist/lib/utils/conversion-dump.d.ts +81 -0
  36. package/dist/lib/utils/conversion-dump.d.ts.map +1 -0
  37. package/dist/lib/utils/conversion-dump.js +131 -0
  38. package/dist/lib/utils/conversion-dump.js.map +1 -0
  39. package/dist/lib/utils/statistic-utills.js +1 -1
  40. package/dist/lib/utils/statistic-utills.js.map +1 -1
  41. package/dist/lib/utils/write-queue.d.ts +6 -1
  42. package/dist/lib/utils/write-queue.d.ts.map +1 -1
  43. package/dist/lib/utils/write-queue.js +15 -3
  44. package/dist/lib/utils/write-queue.js.map +1 -1
  45. package/dist/pgm-loader.js +1 -1
  46. package/dist/pgm-loader.js.map +1 -1
  47. package/dist/slpk-extractor.min.cjs +31 -31
  48. package/package.json +16 -16
  49. package/src/3d-tiles-converter/3d-tiles-converter.ts +5 -4
  50. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +19 -0
  51. package/src/3d-tiles-converter/json-templates/tileset.ts +3 -0
  52. package/src/constants.ts +1 -0
  53. package/src/converter-cli.ts +3 -3
  54. package/src/i3s-converter/helpers/progress.ts +1 -1
  55. package/src/i3s-converter/i3s-converter.ts +192 -57
  56. package/src/i3s-converter/types.ts +8 -0
  57. package/src/lib/utils/compress-util.ts +1 -264
  58. package/src/lib/utils/conversion-dump.ts +203 -0
  59. package/src/lib/utils/statistic-utills.ts +1 -1
  60. 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.1.0",
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.1.0",
56
+ "@loaders.gl/crypto": "4.1.0",
57
+ "@loaders.gl/draco": "4.1.0",
58
+ "@loaders.gl/gltf": "4.1.0",
59
+ "@loaders.gl/i3s": "4.1.0",
60
+ "@loaders.gl/images": "4.1.0",
61
+ "@loaders.gl/loader-utils": "4.1.0",
62
+ "@loaders.gl/polyfills": "4.1.0",
63
+ "@loaders.gl/textures": "4.1.0",
64
+ "@loaders.gl/tiles": "4.1.0",
65
+ "@loaders.gl/worker-utils": "4.1.0",
66
+ "@loaders.gl/zip": "4.1.0",
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": "75961cc7a6ed6679018c0e3fb6eb5c3c74d97bdb",
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,
@@ -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