@loaders.gl/tile-converter 4.0.0-alpha.23 → 4.0.0-alpha.24

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 (92) hide show
  1. package/dist/3d-tiles-converter/helpers/load-i3s.d.ts.map +1 -1
  2. package/dist/converter.min.js +97 -97
  3. package/dist/dist.min.js +237 -182
  4. package/dist/es5/3d-tiles-converter/helpers/load-i3s.js.map +1 -1
  5. package/dist/es5/deps-installer/deps-installer.js +1 -1
  6. package/dist/es5/i3s-converter/helpers/feature-attributes.js +6 -18
  7. package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -1
  8. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +83 -44
  9. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  10. package/dist/es5/i3s-converter/helpers/geometry-converter.js +9 -7
  11. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  12. package/dist/es5/i3s-converter/types.js.map +1 -1
  13. package/dist/es5/pgm-loader.js +11 -3
  14. package/dist/es5/pgm-loader.js.map +1 -1
  15. package/dist/esm/3d-tiles-converter/helpers/load-i3s.js.map +1 -1
  16. package/dist/esm/deps-installer/deps-installer.js +1 -1
  17. package/dist/esm/i3s-converter/helpers/feature-attributes.js +5 -5
  18. package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -1
  19. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +76 -34
  20. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  21. package/dist/esm/i3s-converter/helpers/geometry-converter.js +7 -5
  22. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  23. package/dist/esm/i3s-converter/types.js.map +1 -1
  24. package/dist/esm/pgm-loader.js +7 -4
  25. package/dist/esm/pgm-loader.js.map +1 -1
  26. package/dist/i3s-converter/helpers/feature-attributes.d.ts +6 -6
  27. package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -1
  28. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
  29. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  30. package/dist/i3s-converter/types.d.ts +7 -4
  31. package/dist/i3s-converter/types.d.ts.map +1 -1
  32. package/dist/pgm-loader.d.ts +9 -2
  33. package/dist/pgm-loader.d.ts.map +1 -1
  34. package/package.json +14 -14
  35. package/src/3d-tiles-converter/helpers/load-i3s.ts +1 -0
  36. package/src/i3s-converter/helpers/feature-attributes.ts +14 -11
  37. package/src/i3s-converter/helpers/geometry-attributes.ts +80 -50
  38. package/src/i3s-converter/helpers/geometry-converter.ts +18 -9
  39. package/src/i3s-converter/types.ts +8 -4
  40. package/src/pgm-loader.ts +15 -7
  41. package/dist/3d-tiles-converter/3d-tiles-converter.js +0 -279
  42. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +0 -271
  43. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -23
  44. package/dist/3d-tiles-converter/helpers/load-i3s.js +0 -42
  45. package/dist/3d-tiles-converter/helpers/texture-atlas.js +0 -54
  46. package/dist/3d-tiles-converter/json-templates/tileset.js +0 -43
  47. package/dist/bundle.js +0 -5
  48. package/dist/constants.js +0 -4
  49. package/dist/converter-cli.js +0 -222
  50. package/dist/deps-installer/deps-installer.js +0 -89
  51. package/dist/i3s-converter/helpers/batch-ids-extensions.js +0 -179
  52. package/dist/i3s-converter/helpers/coordinate-converter.js +0 -122
  53. package/dist/i3s-converter/helpers/create-scene-server-path.js +0 -28
  54. package/dist/i3s-converter/helpers/feature-attributes.js +0 -218
  55. package/dist/i3s-converter/helpers/geometry-attributes.js +0 -203
  56. package/dist/i3s-converter/helpers/geometry-converter.js +0 -1321
  57. package/dist/i3s-converter/helpers/gltf-attributes.js +0 -129
  58. package/dist/i3s-converter/helpers/load-3d-tiles.js +0 -99
  59. package/dist/i3s-converter/helpers/node-debug.js +0 -120
  60. package/dist/i3s-converter/helpers/node-index-document.js +0 -271
  61. package/dist/i3s-converter/helpers/node-pages.js +0 -316
  62. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +0 -100
  63. package/dist/i3s-converter/helpers/tileset-traversal.js +0 -29
  64. package/dist/i3s-converter/i3s-converter.js +0 -964
  65. package/dist/i3s-converter/json-templates/geometry-definitions.js +0 -87
  66. package/dist/i3s-converter/json-templates/layers.js +0 -139
  67. package/dist/i3s-converter/json-templates/metadata.js +0 -25
  68. package/dist/i3s-converter/json-templates/node.js +0 -89
  69. package/dist/i3s-converter/json-templates/scene-server.js +0 -31
  70. package/dist/i3s-converter/json-templates/shared-resources.js +0 -129
  71. package/dist/i3s-converter/json-templates/store.js +0 -103
  72. package/dist/i3s-converter/types.js +0 -17
  73. package/dist/i3s-server/app.js +0 -29
  74. package/dist/i3s-server/bin/www.js +0 -37
  75. package/dist/i3s-server/controllers/index-controller.js +0 -31
  76. package/dist/i3s-server/controllers/slpk-controller.js +0 -33
  77. package/dist/i3s-server/routes/index.js +0 -20
  78. package/dist/i3s-server/routes/slpk-router.js +0 -34
  79. package/dist/i3s-server/utils/create-scene-server.js +0 -22
  80. package/dist/i3s-server/utils/server-utils.js +0 -66
  81. package/dist/index.js +0 -10
  82. package/dist/lib/utils/cli-utils.js +0 -82
  83. package/dist/lib/utils/compress-util.js +0 -257
  84. package/dist/lib/utils/file-utils.js +0 -139
  85. package/dist/lib/utils/geometry-utils.js +0 -18
  86. package/dist/lib/utils/lod-conversion-utils.js +0 -76
  87. package/dist/lib/utils/queue.js +0 -18
  88. package/dist/lib/utils/statistic-utills.js +0 -64
  89. package/dist/lib/utils/write-queue.js +0 -80
  90. package/dist/pgm-loader.js +0 -24
  91. package/dist/slpk-extractor/slpk-extractor.js +0 -75
  92. package/dist/slpk-extractor-cli.js +0 -102
@@ -1,43 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TILESET = void 0;
7
- const json_map_transform_1 = __importDefault(require("json-map-transform"));
8
- const ASSET = () => ({
9
- version: {
10
- path: 'version',
11
- default: '1.0'
12
- }
13
- });
14
- const TILE = () => ({
15
- boundingVolume: {
16
- path: 'boundingVolume'
17
- },
18
- geometricError: {
19
- path: 'geometricError'
20
- },
21
- content: {
22
- path: 'content'
23
- },
24
- children: {
25
- path: 'children',
26
- transform: (val) => val.map((tile) => (0, json_map_transform_1.default)(tile, TILE()))
27
- }
28
- });
29
- const TILESET = () => ({
30
- asset: {
31
- path: 'asset',
32
- transform: (val) => (0, json_map_transform_1.default)(val, ASSET())
33
- },
34
- geometricError: {
35
- path: 'root',
36
- transform: (val) => val.geometricError
37
- },
38
- root: {
39
- path: 'root',
40
- transform: (val) => (0, json_map_transform_1.default)(val, TILE())
41
- }
42
- });
43
- exports.TILESET = TILESET;
package/dist/bundle.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- // @ts-nocheck
3
- const moduleExports = require('./index');
4
- globalThis.loaders = globalThis.loaders || {};
5
- module.exports = Object.assign(globalThis.loaders, moduleExports);
package/dist/constants.js DELETED
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BROWSER_ERROR_MESSAGE = void 0;
4
- exports.BROWSER_ERROR_MESSAGE = 'Tile converter does not work in browser, only in node js environment';
@@ -1,222 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- /* eslint-disable no-console */
7
- require("@loaders.gl/polyfills");
8
- const path_1 = require("path");
9
- const inquirer_1 = __importDefault(require("inquirer"));
10
- const tile_converter_1 = require("@loaders.gl/tile-converter");
11
- const deps_installer_1 = require("./deps-installer/deps-installer");
12
- const cli_utils_1 = require("./lib/utils/cli-utils");
13
- const TILESET_TYPE = {
14
- I3S: 'I3S',
15
- _3DTILES: '3DTILES'
16
- };
17
- /**
18
- * CLI entry
19
- * @returns
20
- */
21
- async function main() {
22
- const [, , ...args] = process.argv;
23
- if (args.length === 0) {
24
- printHelp();
25
- }
26
- const validatedOptionsArr = (0, cli_utils_1.validateOptionsWithEqual)(args);
27
- const options = parseOptions(validatedOptionsArr);
28
- if (options.installDependencies) {
29
- const depthInstaller = new deps_installer_1.DepsInstaller();
30
- depthInstaller.install('deps');
31
- return;
32
- }
33
- const validatedOptions = validateOptions(options);
34
- await convert(validatedOptions);
35
- }
36
- main().catch((error) => {
37
- console.log(error);
38
- process.exit(1); // eslint-disable-line
39
- });
40
- /**
41
- * Output for `npx tile-converter --help`
42
- */
43
- function printHelp() {
44
- console.log('cli: converter 3dTiles to I3S or I3S to 3dTiles...');
45
- console.log('--install-dependencies [Run the script for installing dependencies. Run this options separate from others. Now "*.pgm" file installation is implemented]');
46
- console.log('--max-depth [Maximal depth of hierarchical tiles tree traversal, default: infinite]');
47
- console.log('--name [Tileset name]');
48
- console.log('--output [Output folder, default: "data" folder]');
49
- console.log('--instant-node-writing [Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed]');
50
- console.log('--split-nodes [Prevent to merge similar materials that could lead to incorrect visualization (I3S to 3DTiles conversion only)]');
51
- console.log('--slpk [Generate slpk (Scene Layer Packages) I3S output file]');
52
- console.log('--tileset [tileset.json file (3DTiles) / http://..../SceneServer/layers/0 resource (I3S)]');
53
- console.log('--input-type [tileset input type: I3S or 3DTILES]');
54
- console.log('--7zExe [location of 7z.exe archiver to create slpk on Windows, default: "C:\\Program Files\\7-Zip\\7z.exe"]');
55
- console.log('--egm [location of Earth Gravity Model *.pgm file to convert heights from ellipsoidal to gravity-related format. A model file can be loaded from GeographicLib https://geographiclib.sourceforge.io/html/geoid.html], default: "./deps/egm2008-5.zip"');
56
- console.log('--token [Token for Cesium ION tilesets authentication]');
57
- console.log('--no-draco [Disable draco compression for geometry]');
58
- console.log('--generate-textures [Enable KTX2 textures generation if only one of (JPG, PNG) texture is provided or generate JPG texture if only KTX2 is provided]');
59
- console.log('--generate-bounding-volumes [Generate obb and mbs bounding volumes from geometry]');
60
- console.log('--metadata-class [One of the list of feature metadata classes, detected by converter on "analyze" stage, default: not set]');
61
- console.log('--validate [Enable validation]');
62
- process.exit(0); // eslint-disable-line
63
- }
64
- /**
65
- * Run conversion process
66
- * @param options validated tile-converter options
67
- */
68
- async function convert(options) {
69
- console.log(`------------------------------------------------`); // eslint-disable-line
70
- console.log(`Starting conversion of ${options.inputType}`); // eslint-disable-line
71
- console.log(`------------------------------------------------`); // eslint-disable-line
72
- const inputType = options.inputType.toUpperCase();
73
- switch (inputType) {
74
- case TILESET_TYPE.I3S:
75
- const tiles3DConverter = new tile_converter_1.Tiles3DConverter();
76
- tiles3DConverter.convert({
77
- inputUrl: options.tileset,
78
- outputPath: options.output,
79
- tilesetName: options.name,
80
- maxDepth: options.maxDepth,
81
- egmFilePath: options.egm
82
- });
83
- break;
84
- case TILESET_TYPE._3DTILES:
85
- const converter = new tile_converter_1.I3SConverter();
86
- await converter.convert({
87
- inputUrl: options.tileset,
88
- outputPath: options.output,
89
- tilesetName: options.name,
90
- maxDepth: options.maxDepth,
91
- slpk: options.slpk,
92
- sevenZipExe: options.sevenZipExe,
93
- egmFilePath: options.egm,
94
- token: options.token,
95
- draco: options.draco,
96
- mergeMaterials: options.mergeMaterials,
97
- generateTextures: options.generateTextures,
98
- generateBoundingVolumes: options.generateBoundingVolumes,
99
- validate: options.validate,
100
- instantNodeWriting: options.instantNodeWriting,
101
- inquirer: inquirer_1.default
102
- });
103
- break;
104
- default:
105
- printHelp();
106
- }
107
- }
108
- // OPTIONS
109
- /**
110
- * Validate input options of the CLI command
111
- * @param options - input options of the CLI command
112
- * @returns validated options
113
- */
114
- function validateOptions(options) {
115
- const mandatoryOptionsWithExceptions = {
116
- name: () => console.log('Missed: --name [Tileset name]'),
117
- output: () => console.log('Missed: --output [Output path name]'),
118
- sevenZipExe: () => console.log('Missed: --7zExe [7z archiver executable path]'),
119
- egm: () => console.log('Missed: --egm [*.pgm earth gravity model file path]'),
120
- tileset: () => console.log('Missed: --tileset [tileset.json file]'),
121
- inputType: () => console.log('Missed/Incorrect: --input-type [tileset input type: I3S or 3DTILES]')
122
- };
123
- const exceptions = [];
124
- for (const mandatoryOption in mandatoryOptionsWithExceptions) {
125
- const optionValue = options[mandatoryOption];
126
- const isWrongInputType = Boolean(optionValue) &&
127
- mandatoryOption === 'inputType' &&
128
- !Object.values(TILESET_TYPE).includes(optionValue.toUpperCase());
129
- if (!optionValue || isWrongInputType) {
130
- exceptions.push(mandatoryOptionsWithExceptions[mandatoryOption]);
131
- }
132
- }
133
- if (exceptions.length) {
134
- exceptions.forEach((exeption) => exeption());
135
- process.exit(1);
136
- }
137
- return options;
138
- }
139
- /**
140
- * Parse option from the cli arguments array
141
- * @param args
142
- * @returns
143
- */
144
- function parseOptions(args) {
145
- const opts = {
146
- output: 'data',
147
- instantNodeWriting: false,
148
- mergeMaterials: true,
149
- sevenZipExe: 'C:\\Program Files\\7-Zip\\7z.exe',
150
- egm: (0, path_1.join)(process.cwd(), 'deps', 'egm2008-5.pgm'),
151
- draco: true,
152
- installDependencies: false,
153
- generateTextures: false,
154
- generateBoundingVolumes: false,
155
- validate: false,
156
- slpk: false
157
- };
158
- // eslint-disable-next-line complexity
159
- args.forEach((arg, index) => {
160
- if (arg.indexOf('--') === 0) {
161
- switch (arg) {
162
- case '--input-type':
163
- opts.inputType = (0, cli_utils_1.getStringValue)(index, args);
164
- break;
165
- case '--tileset':
166
- opts.tileset = (0, cli_utils_1.getURLValue)(index, args);
167
- break;
168
- case '--name':
169
- opts.name = (0, cli_utils_1.getStringValue)(index, args);
170
- break;
171
- case '--output':
172
- opts.output = (0, cli_utils_1.getStringValue)(index, args);
173
- break;
174
- case '--instant-node-writing':
175
- opts.instantNodeWriting = (0, cli_utils_1.getBooleanValue)(index, args);
176
- break;
177
- case '--split-nodes':
178
- opts.mergeMaterials = (0, cli_utils_1.getBooleanValue)(index, args);
179
- break;
180
- case '--max-depth':
181
- opts.maxDepth = (0, cli_utils_1.getIntegerValue)(index, args);
182
- break;
183
- case '--slpk':
184
- opts.slpk = (0, cli_utils_1.getBooleanValue)(index, args);
185
- break;
186
- case '--7zExe':
187
- opts.sevenZipExe = (0, cli_utils_1.getStringValue)(index, args);
188
- break;
189
- case '--egm':
190
- opts.egm = (0, cli_utils_1.getStringValue)(index, args);
191
- break;
192
- case '--token':
193
- opts.token = (0, cli_utils_1.getStringValue)(index, args);
194
- break;
195
- case '--no-draco':
196
- opts.draco = (0, cli_utils_1.getBooleanValue)(index, args);
197
- break;
198
- case '--validate':
199
- opts.validate = (0, cli_utils_1.getBooleanValue)(index, args);
200
- break;
201
- case '--install-dependencies':
202
- opts.installDependencies = (0, cli_utils_1.getBooleanValue)(index, args);
203
- break;
204
- case '--generate-textures':
205
- opts.generateTextures = (0, cli_utils_1.getBooleanValue)(index, args);
206
- break;
207
- case '--generate-bounding-volumes':
208
- opts.generateBoundingVolumes = (0, cli_utils_1.getBooleanValue)(index, args);
209
- break;
210
- case '--metadata-class':
211
- opts.metadataClass = (0, cli_utils_1.getStringValue)(index, args);
212
- case '--help':
213
- printHelp();
214
- break;
215
- default:
216
- console.warn(`Unknown option ${arg}`);
217
- process.exit(0); // eslint-disable-line
218
- }
219
- }
220
- });
221
- return opts;
222
- }
@@ -1,89 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DepsInstaller = void 0;
4
- const core_1 = require("@loaders.gl/core");
5
- const zip_1 = require("@loaders.gl/zip");
6
- const file_utils_1 = require("../lib/utils/file-utils");
7
- const path_1 = require("path");
8
- const worker_utils_1 = require("@loaders.gl/worker-utils");
9
- const draco_1 = require("@loaders.gl/draco");
10
- const textures_1 = require("@loaders.gl/textures");
11
- // @ts-ignore TS2304: Cannot find name '__VERSION__'.
12
- const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';
13
- const PGM_LINK = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip';
14
- /**
15
- * Install external dependencies for converter:
16
- * * PGM file (implemented);
17
- * * Draco library (not implemented);
18
- * * 7z archiver (not implemented);
19
- */
20
- class DepsInstaller {
21
- /**
22
- * Run instalation
23
- * @param path destination folder
24
- * @param workersPath destination folder for workers.
25
- * This path is '' by default and is not used by tile-converter.
26
- * It is used in tests to prevent rewriting actual workers during tests running
27
- */
28
- async install(path = '') {
29
- console.log('Installing "EGM2008-5" model...'); // eslint-disable-line no-console
30
- const fileMap = await (0, core_1.load)(PGM_LINK, zip_1.ZipLoader, {});
31
- let depsPath = process.cwd();
32
- if (path) {
33
- depsPath = (0, path_1.join)(depsPath, path);
34
- }
35
- await (0, file_utils_1.writeFile)(depsPath, new Uint8Array(fileMap['geoids/egm2008-5.pgm']), 'egm2008-5.pgm');
36
- console.log('Installing "I3S Content Loader" worker'); // eslint-disable-line no-console
37
- await this.installFromNpm('i3s', 'i3s-content-worker-node.js');
38
- console.log('Installing "Draco Loader" worker'); // eslint-disable-line no-console
39
- await this.installFromNpm('draco', 'draco-worker-node.js');
40
- console.log('Installing "Draco Writer" worker'); // eslint-disable-line no-console
41
- await this.installFromNpm('draco', 'draco-writer-worker-node.js');
42
- console.log('Installing "Basis Loader" worker'); // eslint-disable-line no-console
43
- await this.installFromNpm('textures', 'basis-worker-node.js');
44
- console.log('Installing "KTX2 Basis Writer" worker'); // eslint-disable-line no-console
45
- await this.installFromNpm('textures', 'ktx2-basis-writer-worker-node.js');
46
- console.log('Installing "Draco decoder" library'); // eslint-disable-line no-console
47
- await this.installFromUrl(draco_1.DRACO_EXTERNAL_LIBRARY_URLS[draco_1.DRACO_EXTERNAL_LIBRARIES.DECODER], 'draco', draco_1.DRACO_EXTERNAL_LIBRARIES.DECODER);
48
- await this.installFromUrl(draco_1.DRACO_EXTERNAL_LIBRARY_URLS[draco_1.DRACO_EXTERNAL_LIBRARIES.DECODER_WASM], 'draco', draco_1.DRACO_EXTERNAL_LIBRARIES.DECODER_WASM);
49
- console.log('Installing "Draco encoder" library'); // eslint-disable-line no-console
50
- await this.installFromUrl(draco_1.DRACO_EXTERNAL_LIBRARY_URLS[draco_1.DRACO_EXTERNAL_LIBRARIES.ENCODER], 'draco', draco_1.DRACO_EXTERNAL_LIBRARIES.ENCODER);
51
- console.log('Installing "Basis transcoder" library'); // eslint-disable-line no-console
52
- await this.installFromNpm('textures', textures_1.BASIS_EXTERNAL_LIBRARIES.TRANSCODER, 'libs');
53
- await this.installFromNpm('textures', textures_1.BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, 'libs');
54
- console.log('Installing "Basis encoder" library'); // eslint-disable-line no-console
55
- await this.installFromNpm('textures', textures_1.BASIS_EXTERNAL_LIBRARIES.ENCODER, 'libs');
56
- await this.installFromNpm('textures', textures_1.BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, 'libs');
57
- console.log('Installing "join-images" npm package');
58
- const childProcess = new worker_utils_1.ChildProcessProxy();
59
- await childProcess.start({
60
- command: process.platform === 'win32' ? 'npm.cmd' : 'npm',
61
- // `npm install sharp join-images` works unstable. It fails because installed `sharp` version
62
- // may be different from the version required by `join-images`. Pointing to specific versions
63
- // resolve this issue
64
- arguments: ['install', 'sharp@0.30.4', 'join-images@1.1.3'],
65
- wait: 0,
66
- ignoreStderr: true
67
- });
68
- console.log('All dependencies were installed succesfully.'); // eslint-disable-line no-console
69
- }
70
- async installFromNpm(module, name, extraPath = '') {
71
- const fileResponse = await (0, core_1.fetchFile)(`https://unpkg.com/@loaders.gl/${module}@${VERSION}/dist/${extraPath}/${name}`);
72
- const fileData = await fileResponse.arrayBuffer();
73
- if (!fileData) {
74
- return;
75
- }
76
- const path = (0, path_1.join)(process.cwd(), 'modules', module, 'dist', extraPath);
77
- await (0, file_utils_1.writeFile)(path, fileData, name);
78
- }
79
- async installFromUrl(url, module, name) {
80
- const fileResponse = await (0, core_1.fetchFile)(url);
81
- const fileData = await fileResponse.arrayBuffer();
82
- if (!fileData) {
83
- return;
84
- }
85
- const path = (0, path_1.join)(process.cwd(), 'modules', module, 'dist', 'libs');
86
- await (0, file_utils_1.writeFile)(path, fileData, name);
87
- }
88
- }
89
- exports.DepsInstaller = DepsInstaller;
@@ -1,179 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleBatchIdsExtensions = exports.getTextureByMetadataClass = void 0;
4
- const math_1 = require("@loaders.gl/math");
5
- const gltf_1 = require("@loaders.gl/gltf");
6
- /**
7
- * Get featureTexture by metadataClass
8
- * @param tileContent - 3d tile content
9
- * @param metadataClass - user selected feature metadata class name
10
- * @returns featureTexture key
11
- */
12
- function getTextureByMetadataClass(tileContent, metadataClass) {
13
- const extFeatureMetadata = tileContent.gltf?.extensions?.[gltf_1.EXT_FEATURE_METADATA];
14
- if (!extFeatureMetadata?.featureTextures) {
15
- return null;
16
- }
17
- for (const textureKey in extFeatureMetadata.featureTextures) {
18
- const texture = extFeatureMetadata.featureTextures[textureKey];
19
- if (texture.class === metadataClass) {
20
- return textureKey;
21
- }
22
- }
23
- return null;
24
- }
25
- exports.getTextureByMetadataClass = getTextureByMetadataClass;
26
- /**
27
- * Getting batchIds from 3DTilesNext extensions.
28
- * @param attributes - gltf accessors
29
- * @param primitive - gltf primitive data
30
- * @param images - gltf texture images
31
- * @param featureTexture - feature texture key
32
- * @return array of batch IDs
33
- */
34
- function handleBatchIdsExtensions(attributes, primitive, images, featureTexture) {
35
- const extensions = primitive?.extensions;
36
- if (!extensions) {
37
- return [];
38
- }
39
- for (const [extensionName, extensionData] of Object.entries(extensions || {})) {
40
- switch (extensionName) {
41
- case gltf_1.EXT_FEATURE_METADATA:
42
- return handleExtFeatureMetadataExtension(attributes, extensionData, images, featureTexture);
43
- case gltf_1.EXT_MESH_FEATURES:
44
- return handleExtMeshFeaturesExtension(attributes, extensionData);
45
- case gltf_1.EXT_STRUCTURAL_METADATA:
46
- return handleExtStructuralMetadataExtension(attributes, extensionData);
47
- default:
48
- return [];
49
- }
50
- }
51
- return [];
52
- }
53
- exports.handleBatchIdsExtensions = handleBatchIdsExtensions;
54
- function handleExtStructuralMetadataExtension(attributes, extStructuralMetadata) {
55
- // Take only first extension object to get batchIds attribute name.
56
- const dataAttributeNames = extStructuralMetadata?.dataAttributeNames;
57
- if (dataAttributeNames?.length) {
58
- // Let's use the first element of the array
59
- // TODO: What to do with others if any?
60
- const batchIdsAttribute = attributes[dataAttributeNames[0]];
61
- return batchIdsAttribute.value;
62
- }
63
- return [];
64
- }
65
- /**
66
- * Getting batchIds from EXT_mesh_features extensions.
67
- * @param attributes - gltf accessors
68
- * @param extMeshFeatures - EXT_mesh_features extension
69
- * @returns an array of attribute values
70
- */
71
- function handleExtMeshFeaturesExtension(attributes, extMeshFeatures) {
72
- const dataAttributeNames = extMeshFeatures?.dataAttributeNames;
73
- if (dataAttributeNames?.length) {
74
- // Let's use the first element of the array
75
- // TODO: What to do with others if any?
76
- const batchIdsAttribute = attributes[dataAttributeNames[0]];
77
- return batchIdsAttribute.value;
78
- }
79
- return [];
80
- }
81
- /**
82
- * Get batchIds from EXT_feature_metadata extension.
83
- * Docs - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata
84
- * @param attributes - glTF attributes
85
- * @param extFeatureMetadata - primitive-level EXT_FEATURE_METADATA extension data
86
- * @param textures - texture images
87
- * @param featureTexture - feature texture key
88
- */
89
- function handleExtFeatureMetadataExtension(attributes, extFeatureMetadata, images, featureTexture) {
90
- // Take only first extension object to get batchIds attribute name.
91
- const featureIdAttribute = extFeatureMetadata?.featureIdAttributes?.[0];
92
- if (featureIdAttribute?.featureIds?.attribute) {
93
- const batchIdsAttribute = attributes[featureIdAttribute.featureIds.attribute];
94
- return batchIdsAttribute.value;
95
- }
96
- if (featureIdAttribute?.featureIds?.hasOwnProperty('constant') &&
97
- featureIdAttribute?.featureIds?.hasOwnProperty('divisor')) {
98
- const featuresCount = attributes?.POSITIONS?.value.length / 3 || 0;
99
- return generateImplicitFeatureIds(featuresCount, featureIdAttribute.featureIds.constant, featureIdAttribute.featureIds.divisor);
100
- }
101
- // Take only first extension object to get batchIds attribute name.
102
- const featureIdTexture = extFeatureMetadata?.featureIdTextures && extFeatureMetadata?.featureIdTextures[0];
103
- if (featureIdTexture) {
104
- const textureAttributeIndex = featureIdTexture?.featureIds?.texture?.texCoord || 0;
105
- const textCoordAttribute = `TEXCOORD_${textureAttributeIndex}`;
106
- const textureCoordinates = attributes[textCoordAttribute].value;
107
- return generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, images);
108
- }
109
- if (featureTexture) {
110
- const batchIdsAttribute = attributes[featureTexture];
111
- return batchIdsAttribute.value;
112
- }
113
- return [];
114
- }
115
- /**
116
- * Generates implicit feature ids
117
- * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#implicit-feature-ids
118
- * @param featuresCount
119
- * @param constant
120
- * @param devisor
121
- */
122
- function generateImplicitFeatureIds(featuresCount, constant = 0, divisor = 0) {
123
- let featureIds = [];
124
- if (divisor > 0) {
125
- let currentValue = constant;
126
- let devisorCounter = divisor;
127
- for (let index = 0; index < featuresCount; index++) {
128
- featureIds.push(currentValue);
129
- devisorCounter -= 1;
130
- if (devisorCounter === 0) {
131
- currentValue++;
132
- devisorCounter = divisor;
133
- }
134
- }
135
- }
136
- else {
137
- featureIds = Array(featuresCount).fill(constant, 0, featuresCount);
138
- }
139
- return featureIds;
140
- }
141
- /**
142
- * Get batchIds from texture.
143
- * @param primitive
144
- * @param featureIdTextures
145
- */
146
- function generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, images) {
147
- if (!images?.length) {
148
- return [];
149
- }
150
- const CHANNELS_MAP = {
151
- r: 0,
152
- g: 1,
153
- b: 2,
154
- a: 3
155
- };
156
- const textureIndex = featureIdTexture?.featureIds?.texture?.index;
157
- const featureChannel = featureIdTexture?.featureIds?.channels;
158
- if (!featureChannel || textureIndex === undefined) {
159
- return [];
160
- }
161
- const image = images[textureIndex];
162
- const batchIds = [];
163
- const channels = CHANNELS_MAP[featureChannel];
164
- if (image && image?.width && image?.height && image?.components) {
165
- for (let index = 0; index < textureCoordinates.length; index += 2) {
166
- const u = textureCoordinates[index];
167
- const v = textureCoordinates[index + 1];
168
- const tx = Math.min(((0, math_1.emod)(u) * image.width) | 0, image.width - 1);
169
- const ty = Math.min(((0, math_1.emod)(v) * image.height) | 0, image.height - 1);
170
- const offset = (ty * image.width + tx) * image.components + channels;
171
- const batchId = new Uint8Array(image.data)[offset];
172
- batchIds.push(batchId);
173
- }
174
- }
175
- else {
176
- console.warn(`Can't get batch Ids from ${image?.mimeType || ''} compressed texture`);
177
- }
178
- return batchIds;
179
- }
@@ -1,122 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createObbFromMbs = exports.convertBoundingVolumeToI3SFullExtent = exports.convertPositionsToVectors = exports.createBoundingVolumesFromGeometry = exports.createBoundingVolumes = void 0;
4
- const core_1 = require("@math.gl/core");
5
- const geospatial_1 = require("@math.gl/geospatial");
6
- const culling_1 = require("@math.gl/culling");
7
- /**
8
- * Create bounding volumes object from tile and geoid height model.
9
- * @param sourceBoundingVolume - initialized bounding volume of the source tile
10
- * @param geoidHeightModel - instance of Geoid class that converts elevation from geoidal to ellipsoidal and back
11
- * @returns - Bounding volumes object
12
- */
13
- function createBoundingVolumes(sourceBoundingVolume, geoidHeightModel) {
14
- let radius;
15
- let halfSize;
16
- let quaternion;
17
- const cartographicCenter = geospatial_1.Ellipsoid.WGS84.cartesianToCartographic(sourceBoundingVolume.center, new core_1.Vector3());
18
- cartographicCenter[2] =
19
- cartographicCenter[2] -
20
- geoidHeightModel.getHeight(cartographicCenter[1], cartographicCenter[0]);
21
- if (sourceBoundingVolume instanceof culling_1.OrientedBoundingBox) {
22
- halfSize = sourceBoundingVolume.halfSize;
23
- radius = new core_1.Vector3(halfSize[0], halfSize[1], halfSize[2]).len();
24
- quaternion = sourceBoundingVolume.quaternion;
25
- }
26
- else {
27
- radius = sourceBoundingVolume.radius;
28
- halfSize = [radius, radius, radius];
29
- quaternion = new core_1.Quaternion()
30
- .fromMatrix3(new core_1.Matrix3([halfSize[0], 0, 0, 0, halfSize[1], 0, 0, 0, halfSize[2]]))
31
- .normalize();
32
- }
33
- return {
34
- mbs: [cartographicCenter[0], cartographicCenter[1], cartographicCenter[2], radius],
35
- obb: {
36
- center: [cartographicCenter[0], cartographicCenter[1], cartographicCenter[2]],
37
- halfSize,
38
- quaternion
39
- }
40
- };
41
- }
42
- exports.createBoundingVolumes = createBoundingVolumes;
43
- /**
44
- * Generates bounding volumes from geometry positions
45
- * @param cartesianPositions
46
- * @param geoidHeightModel
47
- */
48
- function createBoundingVolumesFromGeometry(cartesianPositions, geoidHeightModel) {
49
- const positionVectors = convertPositionsToVectors(cartesianPositions);
50
- const geometryObb = (0, culling_1.makeOrientedBoundingBoxFromPoints)(positionVectors);
51
- const geometryMbs = (0, culling_1.makeBoundingSphereFromPoints)(positionVectors);
52
- let mbsCenter = geospatial_1.Ellipsoid.WGS84.cartesianToCartographic(geometryMbs.center, new core_1.Vector3());
53
- let obbCenter = geospatial_1.Ellipsoid.WGS84.cartesianToCartographic(geometryObb.center, new core_1.Vector3());
54
- mbsCenter[2] = mbsCenter[2] - geoidHeightModel.getHeight(mbsCenter[1], mbsCenter[0]);
55
- obbCenter[2] = obbCenter[2] - geoidHeightModel.getHeight(obbCenter[1], obbCenter[0]);
56
- return {
57
- mbs: [mbsCenter[0], mbsCenter[1], mbsCenter[2], geometryMbs.radius],
58
- obb: {
59
- center: obbCenter,
60
- halfSize: geometryObb.halfSize,
61
- quaternion: geometryObb.quaternion
62
- }
63
- };
64
- }
65
- exports.createBoundingVolumesFromGeometry = createBoundingVolumesFromGeometry;
66
- /**
67
- * Create array of posisitons where each vertex is vector
68
- * @param {array} positions
69
- * @returns {Vector3[]}
70
- */
71
- function convertPositionsToVectors(positions) {
72
- const result = [];
73
- for (let i = 0; i < positions.length; i += 3) {
74
- // TODO: (perf) new Vector3 is not optimal but required in `makeOrientedBoundingBoxFromPoints`.
75
- // modify `makeOrientedBoundingBoxFromPoints` to use scratch vectors
76
- const positionVector = new core_1.Vector3([positions[i], positions[i + 1], positions[i + 2]]);
77
- result.push(positionVector);
78
- }
79
- return result;
80
- }
81
- exports.convertPositionsToVectors = convertPositionsToVectors;
82
- /**
83
- * Convert common coordinate to fullExtent https://github.com/Esri/i3s-spec/blob/master/docs/1.8/fullExtent.cmn.md
84
- * @param boundingVolume
85
- * @returns - fullExtent object
86
- */
87
- function convertBoundingVolumeToI3SFullExtent(boundingVolume) {
88
- let sphere;
89
- if (boundingVolume instanceof culling_1.BoundingSphere) {
90
- sphere = boundingVolume;
91
- }
92
- else {
93
- sphere = boundingVolume.getBoundingSphere();
94
- }
95
- const center = sphere.center;
96
- const radius = sphere.radius;
97
- const vertexMax = geospatial_1.Ellipsoid.WGS84.cartesianToCartographic(new core_1.Vector3(center[0] + radius, center[1] + radius, center[2] + radius), new core_1.Vector3());
98
- const vertexMin = geospatial_1.Ellipsoid.WGS84.cartesianToCartographic(new core_1.Vector3(center[0] - radius, center[1] - radius, center[2] - radius), new core_1.Vector3());
99
- // Converter sometimes returns min values that are bigger then max,
100
- // so we should check and take bigger value from max and smaller for nim
101
- return {
102
- xmin: Math.min(vertexMin[0], vertexMax[0]),
103
- xmax: Math.max(vertexMin[0], vertexMax[0]),
104
- ymin: Math.min(vertexMin[1], vertexMax[1]),
105
- ymax: Math.max(vertexMin[1], vertexMax[1]),
106
- zmin: Math.min(vertexMin[2], vertexMax[2]),
107
- zmax: Math.max(vertexMin[2], vertexMax[2])
108
- };
109
- }
110
- exports.convertBoundingVolumeToI3SFullExtent = convertBoundingVolumeToI3SFullExtent;
111
- /**
112
- * Creates oriented boundinb box from mbs.
113
- * @param mbs - Minimum Bounding Sphere
114
- * @returns - Oriented Bounding Box
115
- */
116
- function createObbFromMbs(mbs) {
117
- const radius = mbs[3];
118
- const center = new core_1.Vector3(mbs[0], mbs[1], mbs[2]);
119
- const halfAxex = new core_1.Matrix3([radius, 0, 0, 0, radius, 0, 0, 0, radius]);
120
- return new culling_1.OrientedBoundingBox(center, halfAxex);
121
- }
122
- exports.createObbFromMbs = createObbFromMbs;