@loaders.gl/tile-converter 4.1.0-alpha.1 → 4.1.0-alpha.11
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.
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +8 -0
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/converter-cli.js +41 -4
- package/dist/converter-cli.js.map +1 -1
- package/dist/converter.min.cjs +131 -220
- package/dist/deps-installer/deps-installer.d.ts.map +1 -1
- package/dist/deps-installer/deps-installer.js +4 -3
- package/dist/deps-installer/deps-installer.js.map +1 -1
- package/dist/i3s-converter/i3s-converter.d.ts +14 -0
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +73 -19
- package/dist/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/i3s-converter/types.d.ts +7 -0
- package/dist/i3s-converter/types.d.ts.map +1 -1
- package/dist/i3s-converter/types.js +8 -0
- package/dist/i3s-converter/types.js.map +1 -1
- package/dist/i3s-server/bin/i3s-server.min.cjs +80 -80
- package/dist/index.cjs +365 -93
- package/dist/lib/utils/compress-util.d.ts +0 -37
- package/dist/lib/utils/compress-util.d.ts.map +1 -1
- package/dist/lib/utils/compress-util.js +1 -149
- package/dist/lib/utils/compress-util.js.map +1 -1
- package/dist/lib/utils/conversion-dump.d.ts +81 -0
- package/dist/lib/utils/conversion-dump.d.ts.map +1 -0
- package/dist/lib/utils/conversion-dump.js +131 -0
- package/dist/lib/utils/conversion-dump.js.map +1 -0
- package/dist/lib/utils/statistic-utills.d.ts +23 -6
- package/dist/lib/utils/write-queue.d.ts +6 -1
- package/dist/lib/utils/write-queue.d.ts.map +1 -1
- package/dist/lib/utils/write-queue.js +15 -3
- package/dist/lib/utils/write-queue.js.map +1 -1
- package/dist/pgm-loader.js +1 -1
- package/dist/pgm-loader.js.map +1 -1
- package/dist/slpk-extractor.min.cjs +46 -46
- package/package.json +16 -16
- package/src/3d-tiles-converter/helpers/b3dm-converter.ts +19 -0
- package/src/constants.ts +1 -0
- package/src/converter-cli.ts +58 -4
- package/src/deps-installer/deps-installer.ts +3 -2
- package/src/i3s-converter/i3s-converter.ts +191 -51
- package/src/i3s-converter/types.ts +8 -0
- package/src/lib/utils/compress-util.ts +1 -264
- package/src/lib/utils/conversion-dump.ts +203 -0
- package/src/lib/utils/write-queue.ts +15 -2
- package/dist/lib/utils/statistic-utills.d.js +0 -2
- package/dist/lib/utils/statistic-utills.d.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/tile-converter",
|
|
3
|
-
"version": "4.1.0-alpha.
|
|
3
|
+
"version": "4.1.0-alpha.11",
|
|
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.
|
|
56
|
-
"@loaders.gl/crypto": "4.1.0-alpha.
|
|
57
|
-
"@loaders.gl/draco": "4.1.0-alpha.
|
|
58
|
-
"@loaders.gl/gltf": "4.1.0-alpha.
|
|
59
|
-
"@loaders.gl/i3s": "4.1.0-alpha.
|
|
60
|
-
"@loaders.gl/images": "4.1.0-alpha.
|
|
61
|
-
"@loaders.gl/loader-utils": "4.1.0-alpha.
|
|
62
|
-
"@loaders.gl/polyfills": "4.1.0-alpha.
|
|
63
|
-
"@loaders.gl/textures": "4.1.0-alpha.
|
|
64
|
-
"@loaders.gl/tiles": "4.1.0-alpha.
|
|
65
|
-
"@loaders.gl/worker-utils": "4.1.0-alpha.
|
|
66
|
-
"@loaders.gl/zip": "4.1.0-alpha.
|
|
55
|
+
"@loaders.gl/3d-tiles": "4.1.0-alpha.11",
|
|
56
|
+
"@loaders.gl/crypto": "4.1.0-alpha.11",
|
|
57
|
+
"@loaders.gl/draco": "4.1.0-alpha.11",
|
|
58
|
+
"@loaders.gl/gltf": "4.1.0-alpha.11",
|
|
59
|
+
"@loaders.gl/i3s": "4.1.0-alpha.11",
|
|
60
|
+
"@loaders.gl/images": "4.1.0-alpha.11",
|
|
61
|
+
"@loaders.gl/loader-utils": "4.1.0-alpha.11",
|
|
62
|
+
"@loaders.gl/polyfills": "4.1.0-alpha.11",
|
|
63
|
+
"@loaders.gl/textures": "4.1.0-alpha.11",
|
|
64
|
+
"@loaders.gl/tiles": "4.1.0-alpha.11",
|
|
65
|
+
"@loaders.gl/worker-utils": "4.1.0-alpha.11",
|
|
66
|
+
"@loaders.gl/zip": "4.1.0-alpha.11",
|
|
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": "
|
|
90
|
+
"gitHead": "5d3e23bf93762b48c8c1d6d926ede7a97fe43ab0",
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@types/express": "^4.17.17",
|
|
93
93
|
"@types/node": "^20.4.2"
|
|
@@ -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
|
|
package/src/constants.ts
CHANGED
package/src/converter-cli.ts
CHANGED
|
@@ -11,6 +11,9 @@ import {
|
|
|
11
11
|
getURLValue,
|
|
12
12
|
validateOptionsWithEqual
|
|
13
13
|
} from './lib/utils/cli-utils';
|
|
14
|
+
import {addOneFile, composeHashFile, makeZipCDHeaderIterator} from '@loaders.gl/zip';
|
|
15
|
+
import {FileHandleFile} from '@loaders.gl/loader-utils';
|
|
16
|
+
import {copyFile} from 'node:fs/promises';
|
|
14
17
|
|
|
15
18
|
type TileConversionOptions = {
|
|
16
19
|
/** "I3S" - for I3S to 3DTiles conversion, "3DTILES" for 3DTiles to I3S conversion */
|
|
@@ -50,6 +53,8 @@ type TileConversionOptions = {
|
|
|
50
53
|
maxDepth?: number;
|
|
51
54
|
/** 3DTiles->I3S only. Whether the converter generates *.slpk (Scene Layer Package) I3S output file */
|
|
52
55
|
slpk: boolean;
|
|
56
|
+
/** adds hash file to the slpk if there's no one */
|
|
57
|
+
addHash: boolean;
|
|
53
58
|
/** Feature metadata class from EXT_FEATURE_METADATA or EXT_STRUCTURAL_METADATA extensions */
|
|
54
59
|
metadataClass?: string;
|
|
55
60
|
/** With this options the tileset content will be analyzed without conversion */
|
|
@@ -92,6 +97,48 @@ async function main() {
|
|
|
92
97
|
return;
|
|
93
98
|
}
|
|
94
99
|
|
|
100
|
+
if (options.addHash) {
|
|
101
|
+
const validatedOptions = validateOptions(options, true);
|
|
102
|
+
let finalPath = validatedOptions.tileset;
|
|
103
|
+
if (validatedOptions.output === 'data') {
|
|
104
|
+
const nameWithoutExt = validatedOptions.tileset.substring(
|
|
105
|
+
0,
|
|
106
|
+
validatedOptions.tileset.length - 5
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
const result = await inquirer.prompt<{isNewFileRequired: boolean}>([
|
|
110
|
+
{
|
|
111
|
+
name: 'isNewFileRequired',
|
|
112
|
+
type: 'list',
|
|
113
|
+
message: 'What would you like to do?',
|
|
114
|
+
choices: [
|
|
115
|
+
{
|
|
116
|
+
name: 'Add hash file to the current SLPK file',
|
|
117
|
+
value: false
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: `Create a new file ${nameWithoutExt}-hash.slpk with hash file inside`,
|
|
121
|
+
value: true
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
]);
|
|
126
|
+
|
|
127
|
+
if (result.isNewFileRequired) {
|
|
128
|
+
finalPath = `${nameWithoutExt}-hash.slpk`;
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
finalPath = validatedOptions.output;
|
|
132
|
+
}
|
|
133
|
+
if (finalPath !== validatedOptions.tileset) {
|
|
134
|
+
await copyFile(validatedOptions.tileset, finalPath);
|
|
135
|
+
}
|
|
136
|
+
const hashTable = await composeHashFile(makeZipCDHeaderIterator(new FileHandleFile(finalPath)));
|
|
137
|
+
await addOneFile(finalPath, hashTable, '@specialIndexFileHASH128@');
|
|
138
|
+
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
95
142
|
const validatedOptions: ValidatedTileConversionOptions = validateOptions(options);
|
|
96
143
|
|
|
97
144
|
await convert(validatedOptions);
|
|
@@ -199,7 +246,10 @@ async function convert(options: ValidatedTileConversionOptions) {
|
|
|
199
246
|
* @param options - input options of the CLI command
|
|
200
247
|
* @returns validated options
|
|
201
248
|
*/
|
|
202
|
-
function validateOptions(
|
|
249
|
+
function validateOptions(
|
|
250
|
+
options: TileConversionOptions,
|
|
251
|
+
addHash?: boolean
|
|
252
|
+
): ValidatedTileConversionOptions {
|
|
203
253
|
const mandatoryOptionsWithExceptions: {
|
|
204
254
|
[key: string]: {
|
|
205
255
|
getMessage: () => void;
|
|
@@ -208,7 +258,7 @@ function validateOptions(options: TileConversionOptions): ValidatedTileConversio
|
|
|
208
258
|
} = {
|
|
209
259
|
name: {
|
|
210
260
|
getMessage: () => console.log('Missed: --name [Tileset name]'),
|
|
211
|
-
condition: (value: any) => Boolean(value) || Boolean(options.analyze)
|
|
261
|
+
condition: (value: any) => addHash || Boolean(value) || Boolean(options.analyze)
|
|
212
262
|
},
|
|
213
263
|
output: {getMessage: () => console.log('Missed: --output [Output path name]')},
|
|
214
264
|
sevenZipExe: {getMessage: () => console.log('Missed: --7zExe [7z archiver executable path]')},
|
|
@@ -218,7 +268,7 @@ function validateOptions(options: TileConversionOptions): ValidatedTileConversio
|
|
|
218
268
|
getMessage: () =>
|
|
219
269
|
console.log('Missed/Incorrect: --input-type [tileset input type: I3S or 3DTILES]'),
|
|
220
270
|
condition: (value) =>
|
|
221
|
-
Boolean(value) && Object.values(TILESET_TYPE).includes(value.toUpperCase())
|
|
271
|
+
addHash || (Boolean(value) && Object.values(TILESET_TYPE).includes(value.toUpperCase()))
|
|
222
272
|
}
|
|
223
273
|
};
|
|
224
274
|
const exceptions: (() => void)[] = [];
|
|
@@ -256,7 +306,8 @@ function parseOptions(args: string[]): TileConversionOptions {
|
|
|
256
306
|
generateTextures: false,
|
|
257
307
|
generateBoundingVolumes: false,
|
|
258
308
|
validate: false,
|
|
259
|
-
slpk: false
|
|
309
|
+
slpk: false,
|
|
310
|
+
addHash: false
|
|
260
311
|
};
|
|
261
312
|
|
|
262
313
|
// eslint-disable-next-line complexity
|
|
@@ -287,6 +338,9 @@ function parseOptions(args: string[]): TileConversionOptions {
|
|
|
287
338
|
case '--slpk':
|
|
288
339
|
opts.slpk = getBooleanValue(index, args);
|
|
289
340
|
break;
|
|
341
|
+
case '--add-hash':
|
|
342
|
+
opts.addHash = getBooleanValue(index, args);
|
|
343
|
+
break;
|
|
290
344
|
case '--7zExe':
|
|
291
345
|
opts.sevenZipExe = getStringValue(index, args);
|
|
292
346
|
break;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {load, fetchFile} from '@loaders.gl/core';
|
|
2
2
|
import {ZipLoader} from '@loaders.gl/zip';
|
|
3
3
|
import {writeFile} from '../lib/utils/file-utils';
|
|
4
|
-
import {join} from 'path';
|
|
4
|
+
import {join, dirname} from 'path';
|
|
5
5
|
import {ChildProcessProxy} from '@loaders.gl/worker-utils';
|
|
6
6
|
import {DRACO_EXTERNAL_LIBRARIES, DRACO_EXTERNAL_LIBRARY_URLS} from '@loaders.gl/draco';
|
|
7
7
|
import {BASIS_EXTERNAL_LIBRARIES} from '@loaders.gl/textures';
|
|
@@ -80,8 +80,9 @@ export class DepsInstaller {
|
|
|
80
80
|
|
|
81
81
|
console.log('Installing "join-images" npm package');
|
|
82
82
|
const childProcess = new ChildProcessProxy();
|
|
83
|
+
const nodeDir = dirname(process.execPath);
|
|
83
84
|
await childProcess.start({
|
|
84
|
-
command: process.platform === 'win32' ? 'npm.cmd' : 'npm'
|
|
85
|
+
command: `${nodeDir}/${process.platform === 'win32' ? 'npm.cmd' : 'npm'}`,
|
|
85
86
|
// `npm install sharp join-images` works unstable. It fails because installed `sharp` version
|
|
86
87
|
// may be different from the version required by `join-images`. Pointing to specific versions
|
|
87
88
|
// resolve this issue
|