@loaders.gl/tile-converter 4.0.0-alpha.10 → 4.0.0-alpha.12
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/bin/slpk-extractor.js +4 -0
- package/dist/3d-tiles-attributes-worker.js +1 -1
- package/dist/converter-cli.js +18 -84
- package/dist/converter.min.js +50 -50
- package/dist/dist.min.js +21 -18
- package/dist/es5/3d-tiles-attributes-worker.js +1 -1
- package/dist/es5/converter-cli.js +18 -63
- package/dist/es5/converter-cli.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +1 -1
- package/dist/es5/i3s-attributes-worker.js +1 -1
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js +2 -2
- package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +59 -38
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/lib/utils/cli-utils.js +57 -0
- package/dist/es5/lib/utils/cli-utils.js.map +1 -0
- package/dist/es5/pgm-loader.js +1 -1
- package/dist/es5/slpk-extractor/helpers/file-handle-provider.js +181 -0
- package/dist/es5/slpk-extractor/helpers/file-handle-provider.js.map +1 -0
- package/dist/es5/slpk-extractor/slpk-extractor.js +172 -0
- package/dist/es5/slpk-extractor/slpk-extractor.js.map +1 -0
- package/dist/es5/slpk-extractor-cli.js +117 -0
- package/dist/es5/slpk-extractor-cli.js.map +1 -0
- package/dist/esm/3d-tiles-attributes-worker.js +1 -1
- package/dist/esm/converter-cli.js +1 -46
- package/dist/esm/converter-cli.js.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +1 -1
- package/dist/esm/i3s-attributes-worker.js +1 -1
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js +1 -1
- package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +22 -9
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/lib/utils/cli-utils.js +47 -0
- package/dist/esm/lib/utils/cli-utils.js.map +1 -0
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/esm/slpk-extractor/helpers/file-handle-provider.js +43 -0
- package/dist/esm/slpk-extractor/helpers/file-handle-provider.js.map +1 -0
- package/dist/esm/slpk-extractor/slpk-extractor.js +63 -0
- package/dist/esm/slpk-extractor/slpk-extractor.js.map +1 -0
- package/dist/esm/slpk-extractor-cli.js +74 -0
- package/dist/esm/slpk-extractor-cli.js.map +1 -0
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts +1 -2
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/coordinate-converter.js +1 -2
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts +1 -1
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/gltf-attributes.js +2 -1
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +2 -3
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +1 -2
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +21 -6
- package/dist/lib/utils/cli-utils.d.ts +34 -0
- package/dist/lib/utils/cli-utils.d.ts.map +1 -0
- package/dist/lib/utils/cli-utils.js +82 -0
- package/dist/slpk-extractor/helpers/file-handle-provider.d.ts +48 -0
- package/dist/slpk-extractor/helpers/file-handle-provider.d.ts.map +1 -0
- package/dist/slpk-extractor/helpers/file-handle-provider.js +71 -0
- package/dist/slpk-extractor/slpk-extractor.d.ts +23 -0
- package/dist/slpk-extractor/slpk-extractor.d.ts.map +1 -0
- package/dist/slpk-extractor/slpk-extractor.js +78 -0
- package/dist/slpk-extractor-cli.d.ts +17 -0
- package/dist/slpk-extractor-cli.d.ts.map +1 -0
- package/dist/slpk-extractor-cli.js +102 -0
- package/dist/slpk-extractor.min.js +189 -0
- package/package.json +17 -15
- package/src/converter-cli.ts +7 -72
- package/src/i3s-converter/helpers/coordinate-converter.ts +1 -2
- package/src/i3s-converter/helpers/gltf-attributes.ts +7 -8
- package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +1 -3
- package/src/i3s-converter/i3s-converter.ts +24 -7
- package/src/lib/utils/cli-utils.ts +78 -0
- package/src/slpk-extractor/helpers/file-handle-provider.ts +91 -0
- package/src/slpk-extractor/slpk-extractor.ts +102 -0
- package/src/slpk-extractor-cli.ts +128 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import '@loaders.gl/polyfills';
|
|
2
|
+
import SLPKExtractor from './slpk-extractor/slpk-extractor';
|
|
3
|
+
import { getURLValue, validateOptionsWithEqual } from './lib/utils/cli-utils';
|
|
4
|
+
async function main() {
|
|
5
|
+
const [,, ...args] = process.argv;
|
|
6
|
+
if (args.length === 0) {
|
|
7
|
+
printHelp();
|
|
8
|
+
}
|
|
9
|
+
const validatedOptionsArr = validateOptionsWithEqual(args);
|
|
10
|
+
const options = parseOptions(validatedOptionsArr);
|
|
11
|
+
const validatedOptions = validateOptions(options);
|
|
12
|
+
await convert(validatedOptions);
|
|
13
|
+
}
|
|
14
|
+
main().catch(error => {
|
|
15
|
+
console.log(error);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
});
|
|
18
|
+
function printHelp() {
|
|
19
|
+
console.log('cli: converter slpk to I3S...');
|
|
20
|
+
console.log('--output [Output folder, default: "data" folder]');
|
|
21
|
+
console.log('--tileset [SLPK file]');
|
|
22
|
+
process.exit(0);
|
|
23
|
+
}
|
|
24
|
+
async function convert(options) {
|
|
25
|
+
console.log("------------------------------------------------");
|
|
26
|
+
console.log("Starting conversion of SLPK");
|
|
27
|
+
console.log("------------------------------------------------");
|
|
28
|
+
const slpkExtractor = new SLPKExtractor();
|
|
29
|
+
slpkExtractor.extract({
|
|
30
|
+
inputUrl: options.tileset,
|
|
31
|
+
outputPath: options.output
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function validateOptions(options) {
|
|
35
|
+
const mandatoryOptionsWithExceptions = {
|
|
36
|
+
output: () => console.log('Missed: --output [Output path name]'),
|
|
37
|
+
tileset: () => console.log('Missed: --tileset [SLPK file]')
|
|
38
|
+
};
|
|
39
|
+
const exceptions = [];
|
|
40
|
+
for (const mandatoryOption in mandatoryOptionsWithExceptions) {
|
|
41
|
+
const optionValue = options[mandatoryOption];
|
|
42
|
+
if (!optionValue) {
|
|
43
|
+
exceptions.push(mandatoryOptionsWithExceptions[mandatoryOption]);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (exceptions.length) {
|
|
47
|
+
exceptions.forEach(exeption => exeption());
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
return options;
|
|
51
|
+
}
|
|
52
|
+
function parseOptions(args) {
|
|
53
|
+
const opts = {};
|
|
54
|
+
args.forEach((arg, index) => {
|
|
55
|
+
if (arg.indexOf('--') === 0) {
|
|
56
|
+
switch (arg) {
|
|
57
|
+
case '--tileset':
|
|
58
|
+
opts.tileset = getURLValue(index, args);
|
|
59
|
+
break;
|
|
60
|
+
case '--output':
|
|
61
|
+
opts.output = getURLValue(index, args);
|
|
62
|
+
break;
|
|
63
|
+
case '--help':
|
|
64
|
+
printHelp();
|
|
65
|
+
break;
|
|
66
|
+
default:
|
|
67
|
+
console.warn("Unknown option ".concat(arg));
|
|
68
|
+
process.exit(0);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return opts;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=slpk-extractor-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slpk-extractor-cli.js","names":["SLPKExtractor","getURLValue","validateOptionsWithEqual","main","args","process","argv","length","printHelp","validatedOptionsArr","options","parseOptions","validatedOptions","validateOptions","convert","catch","error","console","log","exit","slpkExtractor","extract","inputUrl","tileset","outputPath","output","mandatoryOptionsWithExceptions","exceptions","mandatoryOption","optionValue","push","forEach","exeption","opts","arg","index","indexOf","warn","concat"],"sources":["../../src/slpk-extractor-cli.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport '@loaders.gl/polyfills';\nimport SLPKExtractor from './slpk-extractor/slpk-extractor';\nimport {getURLValue, validateOptionsWithEqual} from './lib/utils/cli-utils';\n\ntype SLPKExtractionOptions = {\n /** \"tileset.json\" file (3DTiles) / \"http://..../SceneServer/layers/0\" resource (I3S) */\n tileset?: string;\n /** Output folder. This folder will be created by converter if doesn't exist. It is relative to the converter path.\n * Default: \"data\" folder */\n output?: string;\n};\n\n/* During validation we check that particular options are defined so they can't be undefined */\nexport type ValidatedSLPKExtractionOptions = SLPKExtractionOptions & {\n /** slpk file */\n tileset: string;\n /** Output folder. This folder will be created by converter if doesn't exist. It is relative to the converter path.\n * Default: \"data\" folder */\n output: string;\n};\n\n/**\n * CLI entry\n * @returns\n */\nasync function main() {\n const [, , ...args] = process.argv;\n\n if (args.length === 0) {\n printHelp();\n }\n\n const validatedOptionsArr = validateOptionsWithEqual(args);\n\n const options: SLPKExtractionOptions = parseOptions(validatedOptionsArr);\n\n const validatedOptions: ValidatedSLPKExtractionOptions = validateOptions(options);\n\n await convert(validatedOptions);\n}\n\nmain().catch((error) => {\n console.log(error);\n process.exit(1); // eslint-disable-line\n});\n\n/**\n * Output for `npx slpk-extractor --help`\n */\nfunction printHelp(): void {\n console.log('cli: converter slpk to I3S...');\n console.log('--output [Output folder, default: \"data\" folder]');\n console.log('--tileset [SLPK file]');\n process.exit(0); // eslint-disable-line\n}\n\n/**\n * Run extraction process\n * @param options validated slpk-extractor options\n */\nasync function convert(options: ValidatedSLPKExtractionOptions) {\n console.log(`------------------------------------------------`); // eslint-disable-line\n console.log(`Starting conversion of SLPK`); // eslint-disable-line\n console.log(`------------------------------------------------`); // eslint-disable-line\n const slpkExtractor = new SLPKExtractor();\n slpkExtractor.extract({\n inputUrl: options.tileset,\n outputPath: options.output\n });\n}\n\n// OPTIONS\n/**\n * Validate input options of the CLI command\n * @param options - input options of the CLI command\n * @returns validated options\n */\nfunction validateOptions(options: SLPKExtractionOptions): ValidatedSLPKExtractionOptions {\n const mandatoryOptionsWithExceptions: {\n [key: string]: () => void;\n } = {\n output: () => console.log('Missed: --output [Output path name]'),\n tileset: () => console.log('Missed: --tileset [SLPK file]')\n };\n const exceptions: (() => void)[] = [];\n for (const mandatoryOption in mandatoryOptionsWithExceptions) {\n const optionValue = options[mandatoryOption];\n if (!optionValue) {\n exceptions.push(mandatoryOptionsWithExceptions[mandatoryOption]);\n }\n }\n if (exceptions.length) {\n exceptions.forEach((exeption) => exeption());\n process.exit(1);\n }\n return <ValidatedSLPKExtractionOptions>options;\n}\n\n/**\n * Parse option from the cli arguments array\n * @param args\n * @returns\n */\nfunction parseOptions(args: string[]): SLPKExtractionOptions {\n const opts: SLPKExtractionOptions = {};\n\n // eslint-disable-next-line complexity\n args.forEach((arg, index) => {\n if (arg.indexOf('--') === 0) {\n switch (arg) {\n case '--tileset':\n opts.tileset = getURLValue(index, args);\n break;\n case '--output':\n opts.output = getURLValue(index, args);\n break;\n case '--help':\n printHelp();\n break;\n default:\n console.warn(`Unknown option ${arg}`);\n process.exit(0); // eslint-disable-line\n }\n }\n });\n return opts;\n}\n"],"mappings":"AACA,OAAO,uBAAuB;AAC9B,OAAOA,aAAa,MAAM,iCAAiC;AAC3D,SAAQC,WAAW,EAAEC,wBAAwB,QAAO,uBAAuB;AAuB3E,eAAeC,IAAIA,CAAA,EAAG;EACpB,MAAM,IAAK,GAAGC,IAAI,CAAC,GAAGC,OAAO,CAACC,IAAI;EAElC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D,MAAMS,UAA0B,GAAG,EAAE;EACrC,KAAK,MAAMC,eAAe,IAAIF,8BAA8B,EAAE;IAC5D,MAAMG,WAAW,GAAGnB,OAAO,CAACkB,eAAe,CAAC;IAC5C,IAAI,CAACC,WAAW,EAAE;MAChBF,UAAU,CAACG,IAAI,CAACJ,8BAA8B,CAACE,eAAe,CAAC,CAAC;IAClE;EACF;EACA,IAAID,UAAU,CAACpB,MAAM,EAAE;IACrBoB,UAAU,CAACI,OAAO,CAAEC,QAAQ,IAAKA,QAAQ,CAAC,CAAC,CAAC;IAC5C3B,OAAO,CAACc,IAAI,CAAC,CAAC,CAAC;EACjB;EACA,OAAuCT,OAAO;AAChD;AAOA,SAASC,YAAYA,CAACP,IAAc,EAAyB;EAC3D,MAAM6B,IAA2B,GAAG,CAAC,CAAC;EAGtC7B,IAAI,CAAC2B,OAAO,CAAC,CAACG,GAAG,EAAEC,KAAK,KAAK;IAC3B,IAAID,GAAG,CAACE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;MAC3B,QAAQF,GAAG;QACT,KAAK,WAAW;UACdD,IAAI,CAACV,OAAO,GAAGtB,WAAW,CAACkC,KAAK,EAAE/B,IAAI,CAAC;UACvC;QACF,KAAK,UAAU;UACb6B,IAAI,CAACR,MAAM,GAAGxB,WAAW,CAACkC,KAAK,EAAE/B,IAAI,CAAC;UACtC;QACF,KAAK,QAAQ;UACXI,SAAS,CAAC,CAAC;UACX;QACF;UACES,OAAO,CAACoB,IAAI,mBAAAC,MAAA,CAAmBJ,GAAG,CAAE,CAAC;UACrC7B,OAAO,CAACc,IAAI,CAAC,CAAC,CAAC;MACnB;IACF;EACF,CAAC,CAAC;EACF,OAAOc,IAAI;AACb"}
|
|
@@ -26,7 +26,6 @@ export declare function createBoundingVolumesFromGeometry(cartesianPositions: Fl
|
|
|
26
26
|
export declare function convertPositionsToVectors(positions: Float32Array): Vector3[];
|
|
27
27
|
/**
|
|
28
28
|
* Convert common coordinate to fullExtent https://github.com/Esri/i3s-spec/blob/master/docs/1.8/fullExtent.cmn.md
|
|
29
|
-
* @param
|
|
30
29
|
* @param boundingVolume
|
|
31
30
|
* @returns - fullExtent object
|
|
32
31
|
*/
|
|
@@ -34,7 +33,7 @@ export declare function convertBoundingVolumeToI3SFullExtent(boundingVolume: Ori
|
|
|
34
33
|
/**
|
|
35
34
|
* Creates oriented boundinb box from mbs.
|
|
36
35
|
* @param mbs - Minimum Bounding Sphere
|
|
37
|
-
* @returns - Oriented
|
|
36
|
+
* @returns - Oriented Bounding Box
|
|
38
37
|
*/
|
|
39
38
|
export declare function createObbFromMbs(mbs: Mbs): Obb;
|
|
40
39
|
//# sourceMappingURL=coordinate-converter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordinate-converter.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/coordinate-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,eAAe,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAE3E,OAAO,EAAsB,OAAO,EAAC,MAAM,eAAe,CAAC;AAE3D,OAAO,EACL,mBAAmB,EAGnB,cAAc,EACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAErC;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,oBAAoB,EAAE,mBAAmB,GAAG,cAAc,EAC1D,gBAAgB,EAAE,KAAK,GACtB,eAAe,CAgCjB;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAC/C,kBAAkB,EAAE,YAAY,EAChC,gBAAgB,EAAE,KAAK,GACtB;IAAC,GAAG,EAAE,GAAG,CAAC;IAAC,GAAG,EAAE,GAAG,CAAA;CAAC,CAoBtB;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,YAAY,GAAG,OAAO,EAAE,CAW5E;AAED
|
|
1
|
+
{"version":3,"file":"coordinate-converter.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/coordinate-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,eAAe,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAE3E,OAAO,EAAsB,OAAO,EAAC,MAAM,eAAe,CAAC;AAE3D,OAAO,EACL,mBAAmB,EAGnB,cAAc,EACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAErC;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,oBAAoB,EAAE,mBAAmB,GAAG,cAAc,EAC1D,gBAAgB,EAAE,KAAK,GACtB,eAAe,CAgCjB;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAC/C,kBAAkB,EAAE,YAAY,EAChC,gBAAgB,EAAE,KAAK,GACtB;IAAC,GAAG,EAAE,GAAG,CAAC;IAAC,GAAG,EAAE,GAAG,CAAA;CAAC,CAoBtB;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,YAAY,GAAG,OAAO,EAAE,CAW5E;AAED;;;;GAIG;AACH,wBAAgB,oCAAoC,CAClD,cAAc,EAAE,mBAAmB,GAAG,cAAc,GACnD,UAAU,CA4BZ;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAK9C"}
|
|
@@ -81,7 +81,6 @@ function convertPositionsToVectors(positions) {
|
|
|
81
81
|
exports.convertPositionsToVectors = convertPositionsToVectors;
|
|
82
82
|
/**
|
|
83
83
|
* Convert common coordinate to fullExtent https://github.com/Esri/i3s-spec/blob/master/docs/1.8/fullExtent.cmn.md
|
|
84
|
-
* @param
|
|
85
84
|
* @param boundingVolume
|
|
86
85
|
* @returns - fullExtent object
|
|
87
86
|
*/
|
|
@@ -112,7 +111,7 @@ exports.convertBoundingVolumeToI3SFullExtent = convertBoundingVolumeToI3SFullExt
|
|
|
112
111
|
/**
|
|
113
112
|
* Creates oriented boundinb box from mbs.
|
|
114
113
|
* @param mbs - Minimum Bounding Sphere
|
|
115
|
-
* @returns - Oriented
|
|
114
|
+
* @returns - Oriented Bounding Box
|
|
116
115
|
*/
|
|
117
116
|
function createObbFromMbs(mbs) {
|
|
118
117
|
const radius = mbs[3];
|
|
@@ -8,7 +8,7 @@ import { BoundingSphere, OrientedBoundingBox } from '@math.gl/culling';
|
|
|
8
8
|
* @param tileTransform - transformation matrix of the tile, calculated recursively multiplying
|
|
9
9
|
* transform of all parent tiles and transform of the current tile
|
|
10
10
|
* @param boundingVolume - initialized bounding volume of the source tile
|
|
11
|
-
* @returns
|
|
11
|
+
* @returns 3DTiles content data, prepared for conversion
|
|
12
12
|
*/
|
|
13
13
|
export declare function prepareDataForAttributesConversion(tileContent: Tiles3DTileContent, tileTransform: Matrix4, boundingVolume: OrientedBoundingBox | BoundingSphere): B3DMAttributesData;
|
|
14
14
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gltf-attributes.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/gltf-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAE7D,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"gltf-attributes.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/gltf-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAE7D,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAC,OAAO,EAAc,OAAO,EAAC,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AAGrE;;;;;;;GAOG;AACH,wBAAgB,kCAAkC,CAChD,WAAW,EAAE,kBAAkB,EAC/B,aAAa,EAAE,OAAO,EACtB,cAAc,EAAE,mBAAmB,GAAG,cAAc,GACnD,kBAAkB,CAyCpB;AAqBD;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,kBAAkB,EAC/B,aAAa,EAAE,OAAO,EACtB,cAAc,EAAE,mBAAmB,GAAG,cAAc,GACnD;IAAC,WAAW,EAAE,OAAO,CAAC;IAAC,kBAAkB,EAAE,OAAO,CAAA;CAAC,CAkCrD"}
|
|
@@ -9,7 +9,7 @@ const geospatial_1 = require("@math.gl/geospatial");
|
|
|
9
9
|
* @param tileTransform - transformation matrix of the tile, calculated recursively multiplying
|
|
10
10
|
* transform of all parent tiles and transform of the current tile
|
|
11
11
|
* @param boundingVolume - initialized bounding volume of the source tile
|
|
12
|
-
* @returns
|
|
12
|
+
* @returns 3DTiles content data, prepared for conversion
|
|
13
13
|
*/
|
|
14
14
|
function prepareDataForAttributesConversion(tileContent, tileTransform, boundingVolume) {
|
|
15
15
|
let nodes = tileContent.gltf?.scene?.nodes ||
|
|
@@ -48,6 +48,7 @@ exports.prepareDataForAttributesConversion = prepareDataForAttributesConversion;
|
|
|
48
48
|
/**
|
|
49
49
|
* Keep only values for glTF attributes to pass data to worker thread.
|
|
50
50
|
* @param attributes - geometry attributes
|
|
51
|
+
* @returns attributes with only `value` item
|
|
51
52
|
*/
|
|
52
53
|
function getB3DMAttributesWithoutBufferView(attributes) {
|
|
53
54
|
const attributesWithoutBufferView = {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Tiles3DTileContent
|
|
1
|
+
import { Tiles3DTileContent } from '@loaders.gl/3d-tiles';
|
|
2
2
|
import { GltfPrimitiveModeString, PreprocessData } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* glTF primitive modes
|
|
@@ -8,11 +8,10 @@ export declare const GLTF_PRIMITIVE_MODES: GltfPrimitiveModeString[];
|
|
|
8
8
|
/**
|
|
9
9
|
* Analyze tile content. This function is used during preprocess stage of
|
|
10
10
|
* conversion
|
|
11
|
-
* @param tile - 3DTiles tile JSON metadata
|
|
12
11
|
* @param tileContent - 3DTiles tile content ArrayBuffer
|
|
13
12
|
* @returns
|
|
14
13
|
*/
|
|
15
|
-
export declare const analyzeTileContent: (
|
|
14
|
+
export declare const analyzeTileContent: (tileContent: Tiles3DTileContent | null) => Promise<PreprocessData>;
|
|
16
15
|
/**
|
|
17
16
|
* Merge object2 into object1
|
|
18
17
|
* @param object1
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preprocess-3d-tiles.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/preprocess-3d-tiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"preprocess-3d-tiles.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/preprocess-3d-tiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,uBAAuB,EAAE,cAAc,EAAC,MAAM,UAAU,CAAC;AAIjE;;;GAGG;AACH,eAAO,MAAM,oBAAoB,2BAQhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,gBAChB,kBAAkB,GAAG,IAAI,KACrC,QAAQ,cAAc,CAmBxB,CAAC;AAqBF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,YAAa,cAAc,WAAW,cAAc,KAAG,IAKtF,CAAC"}
|
|
@@ -20,11 +20,10 @@ exports.GLTF_PRIMITIVE_MODES = [
|
|
|
20
20
|
/**
|
|
21
21
|
* Analyze tile content. This function is used during preprocess stage of
|
|
22
22
|
* conversion
|
|
23
|
-
* @param tile - 3DTiles tile JSON metadata
|
|
24
23
|
* @param tileContent - 3DTiles tile content ArrayBuffer
|
|
25
24
|
* @returns
|
|
26
25
|
*/
|
|
27
|
-
const analyzeTileContent = async (
|
|
26
|
+
const analyzeTileContent = async (tileContent) => {
|
|
28
27
|
const result = {
|
|
29
28
|
meshTopologyTypes: new Set()
|
|
30
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i3s-converter.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/i3s-converter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,oBAAoB,EAGpB,+BAA+B,EAChC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EACV,YAAY,EAIb,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAOrC,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAuB7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,qBAAqB,EAA8B,MAAM,iBAAiB,CAAC;AAGnF,OAAO,EAGL,cAAc,EAEf,MAAM,SAAS,CAAC;AAGjB,OAAO,UAAU,MAAM,0BAA0B,CAAC;AA4BlD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,GAAG,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,mBAAmB,EAAE,qBAAqB,EAAE,CAAC;IAC7C,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,eAAe,EAAE;QAAC,UAAU,EAAE,OAAO,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAC,EAAE,CAAC;IAChE,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;IAC7B,iBAAiB,EAAE,MAAM,EAA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,CAAC,EAAE,OAAO,CAAC;QAC3B,uBAAuB,CAAC,EAAE,OAAO,CAAC;QAClC,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC9B,GAAG,OAAO,CAAC,MAAM,CAAC;IA4EnB;;;;OAIG;YACW,oBAAoB;IA4BlC;;;;;OAKG;YACW,WAAW;IA6BzB;;;;OAIG;YACW,qBAAqB;IA2EnC;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAgCpB;;OAEG;YACW,aAAa;IAc3B;;;OAGG;YACW,WAAW;IAsCzB;;;;;;OAMG;YACW,WAAW;IAiCzB;;;;OAIG;YACW,YAAY;IAc1B;;;;;;;OAOG;YACW,WAAW;IAsGzB;;;;;;;;;;OAUG;YACW,iBAAiB;IAiC/B;;;;;;;;;;;;;;OAcG;YACW,sBAAsB;IA+DpC;;;;;;;;;OASG;YACW,eAAe;IAiB7B;;;;;;OAMG;YACW,gBAAgB;IAoC9B;;;;;;OAMG;YACW,YAAY;IAwB1B;;;;;OAKG;YACW,aAAa;IA+D3B;;;;;;;OAOG;YACW,gBAAgB;IAwB9B;;;;;OAKG;YACW,gBAAgB;IA0B9B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAa5B;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAU7B;;;;;;OAMG;IACH,OAAO,CAAC,8BAA8B;IAWtC;;;OAGG;IACH,OAAO,CAAC,qCAAqC;IAyB7C;;;OAGG;YACW,iBAAiB;IAqB/B;;OAEG;YACW,oBAAoB;IAYlC;;OAEG;YACW,qBAAqB;IAiBnC;;OAEG;IACH,OAAO,CAAC,8BAA8B;IAWtC;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;YAIZ,WAAW;CAsB1B"}
|
|
@@ -227,11 +227,17 @@ class I3SConverter {
|
|
|
227
227
|
if (sourceTile.id) {
|
|
228
228
|
console.log(`[analyze]: ${sourceTile.id}`); // eslint-disable-line
|
|
229
229
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
230
|
+
let tileContent = null;
|
|
231
|
+
try {
|
|
232
|
+
tileContent = await (0, load_3d_tiles_1.loadTile3DContent)(this.sourceTileset, sourceTile, {
|
|
233
|
+
...this.loadOptions,
|
|
234
|
+
'3d-tiles': { ...this.loadOptions['3d-tiles'], loadGLTF: false }
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
console.log(`[warning]: Failed to load ${sourceTile.contentUrl}. An I3S tile with empty content will be added to the output tileset`);
|
|
239
|
+
}
|
|
240
|
+
const tilePreprocessData = await (0, preprocess_3d_tiles_1.analyzeTileContent)(tileContent);
|
|
235
241
|
(0, preprocess_3d_tiles_1.mergePreprocessData)(this.preprocessData, tilePreprocessData);
|
|
236
242
|
return null;
|
|
237
243
|
}
|
|
@@ -430,7 +436,13 @@ class I3SConverter {
|
|
|
430
436
|
async _createNode(parentNode, sourceTile, transformationMatrix) {
|
|
431
437
|
this._checkAddRefinementTypeForTile(sourceTile);
|
|
432
438
|
await this._updateTilesetOptions();
|
|
433
|
-
|
|
439
|
+
let tileContent = null;
|
|
440
|
+
try {
|
|
441
|
+
tileContent = await (0, load_3d_tiles_1.loadTile3DContent)(this.sourceTileset, sourceTile, this.loadOptions);
|
|
442
|
+
}
|
|
443
|
+
catch (error) {
|
|
444
|
+
console.log(`[warning]: Failed to load ${sourceTile.contentUrl}`);
|
|
445
|
+
}
|
|
434
446
|
const sourceBoundingVolume = (0, tiles_1.createBoundingVolume)(sourceTile.boundingVolume, transformationMatrix, null);
|
|
435
447
|
let boundingVolumes = (0, coordinate_converter_1.createBoundingVolumes)(sourceBoundingVolume, this.geoidHeightModel);
|
|
436
448
|
const propertyTable = (0, geometry_converter_1.getPropertyTable)(tileContent);
|
|
@@ -546,6 +558,9 @@ class I3SConverter {
|
|
|
546
558
|
else {
|
|
547
559
|
node = await this.nodePages.getNodeById(nodeId);
|
|
548
560
|
}
|
|
561
|
+
if (!nodeInPage.mesh) {
|
|
562
|
+
console.log(`[warning]: node ${node.index} is created with empty content`);
|
|
563
|
+
}
|
|
549
564
|
node_pages_1.default.updateAll(node, nodeInPage);
|
|
550
565
|
if (meshMaterial) {
|
|
551
566
|
node_pages_1.default.updateMaterialByNodeId(node, this._findOrCreateMaterial(meshMaterial));
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get string option value from cli arguments
|
|
3
|
+
* @param index - option's name index in the argument's array.
|
|
4
|
+
* The value of the option should be next to name of the option.
|
|
5
|
+
* @param args - cli arguments array
|
|
6
|
+
* @returns - string value of the option
|
|
7
|
+
*/
|
|
8
|
+
export declare function getStringValue(index: number, args: string[]): string;
|
|
9
|
+
/**
|
|
10
|
+
* Modyfy URL path to be compatible with fetch
|
|
11
|
+
* @param index - option's name index in the argument's array.
|
|
12
|
+
* The value of the option should be next to name of the option.
|
|
13
|
+
* @param args - cli arguments array
|
|
14
|
+
* @returns - string value of the option
|
|
15
|
+
*/
|
|
16
|
+
export declare function getURLValue(index: number, args: string[]): string;
|
|
17
|
+
export declare function validateOptionsWithEqual(args: string[]): string[];
|
|
18
|
+
/**
|
|
19
|
+
* Get integer option value from cli arguments
|
|
20
|
+
* @param index - option's name index in the argument's array
|
|
21
|
+
* The value of the option should be next to name of the option.
|
|
22
|
+
* @param args - cli arguments array
|
|
23
|
+
* @returns - number value of the option
|
|
24
|
+
*/
|
|
25
|
+
export declare function getIntegerValue(index: number, args: string[]): number;
|
|
26
|
+
/**
|
|
27
|
+
* Get boolean option value from cli arguments
|
|
28
|
+
* @param index - option's name index in the argument's array
|
|
29
|
+
* The value of the option should be next to name of the option.
|
|
30
|
+
* @param args - cli arguments array
|
|
31
|
+
* @returns - boolean value of the option
|
|
32
|
+
*/
|
|
33
|
+
export declare function getBooleanValue(index: number, args: string[]): boolean;
|
|
34
|
+
//# sourceMappingURL=cli-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/cli-utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CASpE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAKjE;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAWjE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAOrE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAStE"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBooleanValue = exports.getIntegerValue = exports.validateOptionsWithEqual = exports.getURLValue = exports.getStringValue = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Get string option value from cli arguments
|
|
6
|
+
* @param index - option's name index in the argument's array.
|
|
7
|
+
* The value of the option should be next to name of the option.
|
|
8
|
+
* @param args - cli arguments array
|
|
9
|
+
* @returns - string value of the option
|
|
10
|
+
*/
|
|
11
|
+
function getStringValue(index, args) {
|
|
12
|
+
if (index + 1 >= args.length) {
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
const value = args[index + 1];
|
|
16
|
+
if (value.indexOf('--') === 0) {
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
exports.getStringValue = getStringValue;
|
|
22
|
+
/**
|
|
23
|
+
* Modyfy URL path to be compatible with fetch
|
|
24
|
+
* @param index - option's name index in the argument's array.
|
|
25
|
+
* The value of the option should be next to name of the option.
|
|
26
|
+
* @param args - cli arguments array
|
|
27
|
+
* @returns - string value of the option
|
|
28
|
+
*/
|
|
29
|
+
function getURLValue(index, args) {
|
|
30
|
+
const value = getStringValue(index, args);
|
|
31
|
+
console.log(`Input tileset value: ${value}`);
|
|
32
|
+
console.log(`Modified tileset value: ${value.replace(/\\/g, '/')}`);
|
|
33
|
+
return value.replace(/\\/g, '/');
|
|
34
|
+
}
|
|
35
|
+
exports.getURLValue = getURLValue;
|
|
36
|
+
function validateOptionsWithEqual(args) {
|
|
37
|
+
return args.reduce((acc, curr) => {
|
|
38
|
+
const equalSignIndex = curr.indexOf('=');
|
|
39
|
+
const beforeEqual = curr.slice(0, equalSignIndex);
|
|
40
|
+
const afterEqual = curr.slice(equalSignIndex + 1, curr.length);
|
|
41
|
+
const condition = curr.includes('=') && curr.startsWith('--') && afterEqual;
|
|
42
|
+
if (condition) {
|
|
43
|
+
return acc.concat(beforeEqual, afterEqual);
|
|
44
|
+
}
|
|
45
|
+
return acc.concat(curr);
|
|
46
|
+
}, []);
|
|
47
|
+
}
|
|
48
|
+
exports.validateOptionsWithEqual = validateOptionsWithEqual;
|
|
49
|
+
/**
|
|
50
|
+
* Get integer option value from cli arguments
|
|
51
|
+
* @param index - option's name index in the argument's array
|
|
52
|
+
* The value of the option should be next to name of the option.
|
|
53
|
+
* @param args - cli arguments array
|
|
54
|
+
* @returns - number value of the option
|
|
55
|
+
*/
|
|
56
|
+
function getIntegerValue(index, args) {
|
|
57
|
+
const stringValue = getStringValue(index, args);
|
|
58
|
+
const result = Number.parseInt(stringValue);
|
|
59
|
+
if (isFinite(result)) {
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
return NaN;
|
|
63
|
+
}
|
|
64
|
+
exports.getIntegerValue = getIntegerValue;
|
|
65
|
+
/**
|
|
66
|
+
* Get boolean option value from cli arguments
|
|
67
|
+
* @param index - option's name index in the argument's array
|
|
68
|
+
* The value of the option should be next to name of the option.
|
|
69
|
+
* @param args - cli arguments array
|
|
70
|
+
* @returns - boolean value of the option
|
|
71
|
+
*/
|
|
72
|
+
function getBooleanValue(index, args) {
|
|
73
|
+
const stringValue = getStringValue(index, args).toLowerCase().trim();
|
|
74
|
+
if (['--no-draco', '--split-nodes'].includes(args[index]) && !stringValue) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (!stringValue || stringValue === 'true') {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
exports.getBooleanValue = getBooleanValue;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { FileProvider } from '@loaders.gl/i3s';
|
|
3
|
+
import { PathLike } from 'fs';
|
|
4
|
+
/**
|
|
5
|
+
* Provides file data using node fs library
|
|
6
|
+
*/
|
|
7
|
+
export declare class FileHandleProvider implements FileProvider {
|
|
8
|
+
/**
|
|
9
|
+
* Returns a new copy of FileHandleProvider
|
|
10
|
+
* @param path The path to the file in file system
|
|
11
|
+
*/
|
|
12
|
+
static from(path: PathLike): Promise<FileHandleProvider>;
|
|
13
|
+
/**
|
|
14
|
+
* The FileHandle from which data is provided
|
|
15
|
+
*/
|
|
16
|
+
private fileDescriptor;
|
|
17
|
+
/**
|
|
18
|
+
* The file length in bytes
|
|
19
|
+
*/
|
|
20
|
+
private size;
|
|
21
|
+
private constructor();
|
|
22
|
+
/**
|
|
23
|
+
* Gets an unsigned 8-bit integer (unsigned byte) at the specified byte offset from the start of the file.
|
|
24
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
25
|
+
*/
|
|
26
|
+
getUint8(offset: number): Promise<number>;
|
|
27
|
+
/**
|
|
28
|
+
* Gets an unsigned 16-bit integer (unsigned byte) at the specified byte offset from the start of the file.
|
|
29
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
30
|
+
*/
|
|
31
|
+
getUint16(offset: number): Promise<number>;
|
|
32
|
+
/**
|
|
33
|
+
* Gets an unsigned 32-bit integer (unsigned byte) at the specified byte offset from the start of the file.
|
|
34
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
35
|
+
*/
|
|
36
|
+
getUint32(offset: number): Promise<number>;
|
|
37
|
+
/**
|
|
38
|
+
* returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
|
|
39
|
+
* @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
|
|
40
|
+
* @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
|
|
41
|
+
*/
|
|
42
|
+
slice(startOffset: number, endOffset: number): Promise<ArrayBuffer>;
|
|
43
|
+
/**
|
|
44
|
+
* the length (in bytes) of the data.
|
|
45
|
+
*/
|
|
46
|
+
get length(): number;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=file-handle-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-handle-provider.d.ts","sourceRoot":"","sources":["../../../src/slpk-extractor/helpers/file-handle-provider.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAyB,QAAQ,EAAC,MAAM,IAAI,CAAC;AAEpD;;GAEG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IACrD;;;OAGG;WACU,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAK9D;;OAEG;IACH,OAAO,CAAC,cAAc,CAAwB;IAE9C;;OAEG;IACH,OAAO,CAAC,IAAI,CAAS;IAErB,OAAO;IAKP;;;OAGG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAU/C;;;OAGG;IACG,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAUhD;;;OAGG;IACG,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAUhD;;;;OAIG;IACG,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAMzE;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;CACF"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileHandleProvider = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
/**
|
|
6
|
+
* Provides file data using node fs library
|
|
7
|
+
*/
|
|
8
|
+
class FileHandleProvider {
|
|
9
|
+
/**
|
|
10
|
+
* Returns a new copy of FileHandleProvider
|
|
11
|
+
* @param path The path to the file in file system
|
|
12
|
+
*/
|
|
13
|
+
static async from(path) {
|
|
14
|
+
const fileDescriptor = await fs_1.promises.open(path);
|
|
15
|
+
return new FileHandleProvider(fileDescriptor, (await fileDescriptor.stat()).size);
|
|
16
|
+
}
|
|
17
|
+
constructor(fileDescriptor, size) {
|
|
18
|
+
this.fileDescriptor = fileDescriptor;
|
|
19
|
+
this.size = size;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Gets an unsigned 8-bit integer (unsigned byte) at the specified byte offset from the start of the file.
|
|
23
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
24
|
+
*/
|
|
25
|
+
async getUint8(offset) {
|
|
26
|
+
const val = new Uint8Array((await this.fileDescriptor.read(Buffer.alloc(1), 0, 1, offset)).buffer.buffer).at(0);
|
|
27
|
+
if (val === undefined) {
|
|
28
|
+
throw new Error('something went wrong');
|
|
29
|
+
}
|
|
30
|
+
return val;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Gets an unsigned 16-bit integer (unsigned byte) at the specified byte offset from the start of the file.
|
|
34
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
35
|
+
*/
|
|
36
|
+
async getUint16(offset) {
|
|
37
|
+
const val = new Uint16Array((await this.fileDescriptor.read(Buffer.alloc(2), 0, 2, offset)).buffer.buffer).at(0);
|
|
38
|
+
if (val === undefined) {
|
|
39
|
+
throw new Error('something went wrong');
|
|
40
|
+
}
|
|
41
|
+
return val;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Gets an unsigned 32-bit integer (unsigned byte) at the specified byte offset from the start of the file.
|
|
45
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
46
|
+
*/
|
|
47
|
+
async getUint32(offset) {
|
|
48
|
+
const val = new Uint32Array((await this.fileDescriptor.read(Buffer.alloc(4), 0, 4, offset)).buffer.buffer).at(0);
|
|
49
|
+
if (val === undefined) {
|
|
50
|
+
throw new Error('something went wrong');
|
|
51
|
+
}
|
|
52
|
+
return val;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
|
|
56
|
+
* @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
|
|
57
|
+
* @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
|
|
58
|
+
*/
|
|
59
|
+
async slice(startOffset, endOffset) {
|
|
60
|
+
const length = endOffset - startOffset;
|
|
61
|
+
return (await this.fileDescriptor.read(Buffer.alloc(length), 0, length, startOffset)).buffer
|
|
62
|
+
.buffer;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* the length (in bytes) of the data.
|
|
66
|
+
*/
|
|
67
|
+
get length() {
|
|
68
|
+
return this.size;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.FileHandleProvider = FileHandleProvider;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converter from slpk to i3s
|
|
3
|
+
*/
|
|
4
|
+
export default class SLPKExtractor {
|
|
5
|
+
/**
|
|
6
|
+
* extract slpk to i3s
|
|
7
|
+
* @param options
|
|
8
|
+
* @param options.inputUrl the url to read SLPK file
|
|
9
|
+
* @param options.outputPath the output filename
|
|
10
|
+
*/
|
|
11
|
+
extract(options: {
|
|
12
|
+
inputUrl: string;
|
|
13
|
+
outputPath: string;
|
|
14
|
+
}): Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Defines file name and path for i3s format
|
|
17
|
+
* @param fileName initial file name and path
|
|
18
|
+
*/
|
|
19
|
+
private correctIndexNames;
|
|
20
|
+
private unGzip;
|
|
21
|
+
private writeFile;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=slpk-extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slpk-extractor.d.ts","sourceRoot":"","sources":["../../src/slpk-extractor/slpk-extractor.ts"],"names":[],"mappings":"AA0BA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC;;;;;OAKG;IACU,OAAO,CAAC,OAAO,EAAE;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IA8BtF;;;OAGG;IACH,OAAO,CAAC,iBAAiB;YAYX,MAAM;YAUN,SAAS;CASxB"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@loaders.gl/core");
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const file_handle_provider_1 = require("./helpers/file-handle-provider");
|
|
6
|
+
const i3s_1 = require("@loaders.gl/i3s");
|
|
7
|
+
const loader_utils_1 = require("@loaders.gl/loader-utils");
|
|
8
|
+
const compression_1 = require("@loaders.gl/compression");
|
|
9
|
+
const file_utils_1 = require("../lib/utils/file-utils");
|
|
10
|
+
/**
|
|
11
|
+
* names of files that should be changed to index
|
|
12
|
+
*/
|
|
13
|
+
const indexNames = [
|
|
14
|
+
'3dSceneLayer.json.gz',
|
|
15
|
+
'3dNodeIndexDocument.json.gz',
|
|
16
|
+
'sharedResource.json.gz'
|
|
17
|
+
];
|
|
18
|
+
/**
|
|
19
|
+
* Converter from slpk to i3s
|
|
20
|
+
*/
|
|
21
|
+
class SLPKExtractor {
|
|
22
|
+
/**
|
|
23
|
+
* extract slpk to i3s
|
|
24
|
+
* @param options
|
|
25
|
+
* @param options.inputUrl the url to read SLPK file
|
|
26
|
+
* @param options.outputPath the output filename
|
|
27
|
+
*/
|
|
28
|
+
async extract(options) {
|
|
29
|
+
if (core_1.isBrowser) {
|
|
30
|
+
console.log(constants_1.BROWSER_ERROR_MESSAGE);
|
|
31
|
+
return constants_1.BROWSER_ERROR_MESSAGE;
|
|
32
|
+
}
|
|
33
|
+
const { inputUrl } = options;
|
|
34
|
+
const provider = await file_handle_provider_1.FileHandleProvider.from(inputUrl);
|
|
35
|
+
let localHeader = await (0, i3s_1.parseZipLocalFileHeader)(0, provider);
|
|
36
|
+
while (localHeader) {
|
|
37
|
+
await this.writeFile(await this.unGzip({
|
|
38
|
+
name: this.correctIndexNames(localHeader.fileName),
|
|
39
|
+
data: await provider.slice(localHeader.fileDataOffset, localHeader.fileDataOffset + localHeader.compressedSize)
|
|
40
|
+
}), options.outputPath);
|
|
41
|
+
localHeader = await (0, i3s_1.parseZipLocalFileHeader)(localHeader?.fileDataOffset + localHeader?.compressedSize, provider);
|
|
42
|
+
}
|
|
43
|
+
return 'success';
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Defines file name and path for i3s format
|
|
47
|
+
* @param fileName initial file name and path
|
|
48
|
+
*/
|
|
49
|
+
correctIndexNames(fileName) {
|
|
50
|
+
if (indexNames.includes(loader_utils_1.path.filename(loader_utils_1.path.join('/', fileName)))) {
|
|
51
|
+
return loader_utils_1.path.join(loader_utils_1.path.dirname(fileName), 'index.json.gz');
|
|
52
|
+
}
|
|
53
|
+
// finds path with name part and extention part
|
|
54
|
+
let parts = /^(.*\/[^\/\.]*)(\..+)$/.exec(fileName);
|
|
55
|
+
if (!parts) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
return `${parts?.at(1)}/index${parts?.at(2)}`;
|
|
59
|
+
}
|
|
60
|
+
async unGzip(file) {
|
|
61
|
+
if (/\.gz$/.test(file.name ?? '')) {
|
|
62
|
+
const compression = new compression_1.GZipCompression();
|
|
63
|
+
const decompressedData = await compression.decompress(file.data);
|
|
64
|
+
return { data: decompressedData, name: (file.name ?? '').slice(0, -3) };
|
|
65
|
+
}
|
|
66
|
+
return Promise.resolve(file);
|
|
67
|
+
}
|
|
68
|
+
async writeFile(options, outputPath) {
|
|
69
|
+
if (!options.name) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const finalPath = loader_utils_1.path.join(outputPath, options.name);
|
|
73
|
+
const dirName = loader_utils_1.path.dirname(finalPath);
|
|
74
|
+
const fileName = loader_utils_1.path.filename(finalPath);
|
|
75
|
+
await (0, file_utils_1.writeFile)(dirName, options.data, fileName);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.default = SLPKExtractor;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import '@loaders.gl/polyfills';
|
|
2
|
+
type SLPKExtractionOptions = {
|
|
3
|
+
/** "tileset.json" file (3DTiles) / "http://..../SceneServer/layers/0" resource (I3S) */
|
|
4
|
+
tileset?: string;
|
|
5
|
+
/** Output folder. This folder will be created by converter if doesn't exist. It is relative to the converter path.
|
|
6
|
+
* Default: "data" folder */
|
|
7
|
+
output?: string;
|
|
8
|
+
};
|
|
9
|
+
export type ValidatedSLPKExtractionOptions = SLPKExtractionOptions & {
|
|
10
|
+
/** slpk file */
|
|
11
|
+
tileset: string;
|
|
12
|
+
/** Output folder. This folder will be created by converter if doesn't exist. It is relative to the converter path.
|
|
13
|
+
* Default: "data" folder */
|
|
14
|
+
output: string;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=slpk-extractor-cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slpk-extractor-cli.d.ts","sourceRoot":"","sources":["../src/slpk-extractor-cli.ts"],"names":[],"mappings":"AACA,OAAO,uBAAuB,CAAC;AAI/B,KAAK,qBAAqB,GAAG;IAC3B,wFAAwF;IACxF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;gCAC4B;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAGF,MAAM,MAAM,8BAA8B,GAAG,qBAAqB,GAAG;IACnE,gBAAgB;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB;gCAC4B;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
|