@loaders.gl/tile-converter 4.1.0-alpha.4 → 4.1.0-alpha.6
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/converter-cli.js +41 -4
- package/dist/converter-cli.js.map +1 -1
- package/dist/converter.min.cjs +103 -103
- package/dist/deps-installer/deps-installer.js +1 -1
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +4 -0
- package/dist/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/i3s-server/bin/i3s-server.min.cjs +40 -40
- package/dist/index.cjs +4 -0
- package/dist/pgm-loader.js +1 -1
- package/package.json +14 -14
- package/src/converter-cli.ts +58 -4
- package/src/i3s-converter/i3s-converter.ts +5 -1
package/dist/index.cjs
CHANGED
|
@@ -3134,6 +3134,7 @@ function isAllVerticesInsideBoundingVolume(boundingVolume, positions) {
|
|
|
3134
3134
|
|
|
3135
3135
|
// src/i3s-converter/i3s-converter.ts
|
|
3136
3136
|
var import_textures = require("@loaders.gl/textures");
|
|
3137
|
+
var import_loader_utils4 = require("@loaders.gl/loader-utils");
|
|
3137
3138
|
var import_images = require("@loaders.gl/images");
|
|
3138
3139
|
var import_worker_utils2 = require("@loaders.gl/worker-utils");
|
|
3139
3140
|
|
|
@@ -3903,6 +3904,7 @@ var Progress = class {
|
|
|
3903
3904
|
};
|
|
3904
3905
|
|
|
3905
3906
|
// src/i3s-converter/i3s-converter.ts
|
|
3907
|
+
var import_zip = require("@loaders.gl/zip");
|
|
3906
3908
|
var _a;
|
|
3907
3909
|
var ION_DEFAULT_TOKEN = (_a = import_process3.default.env) == null ? void 0 : _a.IonToken;
|
|
3908
3910
|
var HARDCODED_NODES_PER_PAGE = 64;
|
|
@@ -4296,6 +4298,8 @@ var I3SConverter = class {
|
|
|
4296
4298
|
".",
|
|
4297
4299
|
this.options.sevenZipExe
|
|
4298
4300
|
);
|
|
4301
|
+
const hashTable = await (0, import_zip.composeHashFile)(new import_loader_utils4.FileHandleFile(slpkFileName));
|
|
4302
|
+
await (0, import_zip.addOneFile)(slpkFileName, hashTable, "@specialIndexFileHASH128@");
|
|
4299
4303
|
try {
|
|
4300
4304
|
await removeDir(tilesetPath);
|
|
4301
4305
|
} catch (e) {
|
package/dist/pgm-loader.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Geoid, parsePGM } from '@math.gl/geoid';
|
|
2
|
-
const VERSION = typeof "4.1.0-alpha.
|
|
2
|
+
const VERSION = typeof "4.1.0-alpha.6" !== 'undefined' ? "4.1.0-alpha.6" : 'latest';
|
|
3
3
|
export { Geoid };
|
|
4
4
|
export const PGMLoader = {
|
|
5
5
|
name: 'PGM - Netpbm grayscale image format',
|
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.6",
|
|
4
4
|
"description": "Converter",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -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.6",
|
|
56
|
+
"@loaders.gl/crypto": "4.1.0-alpha.6",
|
|
57
|
+
"@loaders.gl/draco": "4.1.0-alpha.6",
|
|
58
|
+
"@loaders.gl/gltf": "4.1.0-alpha.6",
|
|
59
|
+
"@loaders.gl/i3s": "4.1.0-alpha.6",
|
|
60
|
+
"@loaders.gl/images": "4.1.0-alpha.6",
|
|
61
|
+
"@loaders.gl/loader-utils": "4.1.0-alpha.6",
|
|
62
|
+
"@loaders.gl/polyfills": "4.1.0-alpha.6",
|
|
63
|
+
"@loaders.gl/textures": "4.1.0-alpha.6",
|
|
64
|
+
"@loaders.gl/tiles": "4.1.0-alpha.6",
|
|
65
|
+
"@loaders.gl/worker-utils": "4.1.0-alpha.6",
|
|
66
|
+
"@loaders.gl/zip": "4.1.0-alpha.6",
|
|
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": "fd58d91e05ebfd89ab8998a87157bf07c43997a5",
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@types/express": "^4.17.17",
|
|
93
93
|
"@types/node": "^20.4.2"
|
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} 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(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;
|
|
@@ -51,7 +51,7 @@ import {GEOMETRY_DEFINITION as geometryDefinitionTemlate} from './json-templates
|
|
|
51
51
|
import {SHARED_RESOURCES as sharedResourcesTemplate} from './json-templates/shared-resources';
|
|
52
52
|
import {validateNodeBoundingVolumes} from './helpers/node-debug';
|
|
53
53
|
import {KTX2BasisWriterWorker} from '@loaders.gl/textures';
|
|
54
|
-
import {LoaderWithParser} from '@loaders.gl/loader-utils';
|
|
54
|
+
import {FileHandleFile, LoaderWithParser} from '@loaders.gl/loader-utils';
|
|
55
55
|
import {I3SMaterialDefinition, TextureSetDefinitionFormats} from '@loaders.gl/i3s';
|
|
56
56
|
import {ImageWriter} from '@loaders.gl/images';
|
|
57
57
|
import {GLTFImagePostprocessed} from '@loaders.gl/gltf';
|
|
@@ -81,6 +81,7 @@ import {createBoundingVolume} from '@loaders.gl/tiles';
|
|
|
81
81
|
import {TraversalConversionProps, traverseDatasetWith} from './helpers/tileset-traversal';
|
|
82
82
|
import {analyzeTileContent, mergePreprocessData} from './helpers/preprocess-3d-tiles';
|
|
83
83
|
import {Progress} from './helpers/progress';
|
|
84
|
+
import {addOneFile, composeHashFile} from '@loaders.gl/zip';
|
|
84
85
|
|
|
85
86
|
const ION_DEFAULT_TOKEN = process.env?.IonToken;
|
|
86
87
|
const HARDCODED_NODES_PER_PAGE = 64;
|
|
@@ -564,6 +565,9 @@ export default class I3SConverter {
|
|
|
564
565
|
this.options.sevenZipExe
|
|
565
566
|
);
|
|
566
567
|
|
|
568
|
+
const hashTable = await composeHashFile(new FileHandleFile(slpkFileName));
|
|
569
|
+
await addOneFile(slpkFileName, hashTable, '@specialIndexFileHASH128@');
|
|
570
|
+
|
|
567
571
|
// TODO: `addFileToZip` corrupts archive so it can't be validated with windows i3s_converter.exe
|
|
568
572
|
// const fileHash128Path = `${tilesetPath}/@specialIndexFileHASH128@`;
|
|
569
573
|
// try {
|