@loaders.gl/tile-converter 3.3.0-alpha.8 → 3.4.0-alpha.1
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-attributes-worker.js +1 -1
- package/dist/converter-cli.js +14 -2
- package/dist/converter.min.js +22 -22
- package/dist/deps-installer/deps-installer.d.ts.map +1 -1
- package/dist/deps-installer/deps-installer.js +8 -0
- package/dist/dist.min.js +1014 -693
- package/dist/es5/3d-tiles-attributes-worker.js +1 -1
- package/dist/es5/converter-cli.js +14 -2
- package/dist/es5/converter-cli.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +13 -2
- package/dist/es5/deps-installer/deps-installer.js.map +1 -1
- package/dist/es5/i3s-attributes-worker.js +1 -1
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js +16 -7
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +363 -113
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js +6 -11
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-index-document.js +517 -0
- package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/node-pages.js +455 -173
- package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +549 -618
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/geometry-definitions.js +107 -0
- package/dist/es5/i3s-converter/json-templates/geometry-definitions.js.map +1 -0
- package/dist/es5/i3s-converter/json-templates/layers.js +2 -93
- package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/shared-resources.js +3 -3
- package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -1
- package/dist/es5/i3s-converter/types.js.map +1 -1
- package/dist/es5/lib/utils/file-utils.js +93 -9
- package/dist/es5/lib/utils/file-utils.js.map +1 -1
- package/dist/es5/lib/utils/write-queue.js +38 -25
- package/dist/es5/lib/utils/write-queue.js.map +1 -1
- package/dist/es5/pgm-loader.js +1 -1
- package/dist/es5/workers/i3s-attributes-worker.js +1 -1
- package/dist/es5/workers/i3s-attributes-worker.js.map +1 -1
- package/dist/esm/3d-tiles-attributes-worker.js +1 -1
- package/dist/esm/converter-cli.js +14 -2
- package/dist/esm/converter-cli.js.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +9 -1
- package/dist/esm/deps-installer/deps-installer.js.map +1 -1
- package/dist/esm/i3s-attributes-worker.js +1 -1
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js +16 -7
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +150 -40
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js +6 -9
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/node-index-document.js +202 -0
- package/dist/esm/i3s-converter/helpers/node-index-document.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/node-pages.js +162 -76
- package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +115 -220
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/geometry-definitions.js +89 -0
- package/dist/esm/i3s-converter/json-templates/geometry-definitions.js.map +1 -0
- package/dist/esm/i3s-converter/json-templates/layers.js +2 -85
- package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/shared-resources.js +3 -3
- package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +1 -1
- package/dist/esm/i3s-converter/types.js.map +1 -1
- package/dist/esm/lib/utils/file-utils.js +44 -3
- package/dist/esm/lib/utils/file-utils.js.map +1 -1
- package/dist/esm/lib/utils/write-queue.js +19 -10
- package/dist/esm/lib/utils/write-queue.js.map +1 -1
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/esm/workers/i3s-attributes-worker.js +1 -1
- package/dist/esm/workers/i3s-attributes-worker.js.map +1 -1
- package/dist/i3s-attributes-worker.js +2 -2
- package/dist/i3s-attributes-worker.js.map +2 -2
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +3 -3
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +3 -3
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-attributes.js +16 -10
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +8 -4
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +200 -44
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/gltf-attributes.js +2 -3
- package/dist/i3s-converter/helpers/node-index-document.d.ts +95 -0
- package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/node-index-document.js +250 -0
- package/dist/i3s-converter/helpers/node-pages.d.ts +78 -43
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-pages.js +194 -93
- package/dist/i3s-converter/i3s-converter.d.ts +33 -58
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +122 -233
- package/dist/i3s-converter/json-templates/geometry-definitions.d.ts +7 -0
- package/dist/i3s-converter/json-templates/geometry-definitions.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/geometry-definitions.js +87 -0
- package/dist/i3s-converter/json-templates/layers.d.ts +1 -30
- package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -1
- package/dist/i3s-converter/json-templates/layers.js +2 -86
- package/dist/i3s-converter/json-templates/shared-resources.js +3 -3
- package/dist/i3s-converter/types.d.ts +28 -2
- package/dist/i3s-converter/types.d.ts.map +1 -1
- package/dist/lib/utils/file-utils.d.ts +17 -1
- package/dist/lib/utils/file-utils.d.ts.map +1 -1
- package/dist/lib/utils/file-utils.js +64 -7
- package/dist/lib/utils/write-queue.d.ts +18 -2
- package/dist/lib/utils/write-queue.d.ts.map +1 -1
- package/dist/lib/utils/write-queue.js +18 -12
- package/dist/workers/i3s-attributes-worker.js +1 -1
- package/package.json +23 -19
- package/src/converter-cli.ts +22 -2
- package/src/deps-installer/deps-installer.ts +9 -0
- package/src/i3s-converter/helpers/batch-ids-extensions.ts +3 -3
- package/src/i3s-converter/helpers/geometry-attributes.ts +16 -11
- package/src/i3s-converter/helpers/geometry-converter.ts +217 -48
- package/src/i3s-converter/helpers/gltf-attributes.ts +2 -3
- package/src/i3s-converter/helpers/node-index-document.ts +315 -0
- package/src/i3s-converter/helpers/node-pages.ts +215 -110
- package/src/i3s-converter/i3s-converter.ts +170 -312
- package/src/i3s-converter/json-templates/geometry-definitions.ts +83 -0
- package/src/i3s-converter/json-templates/layers.ts +2 -91
- package/src/i3s-converter/json-templates/shared-resources.ts +3 -3
- package/src/i3s-converter/types.ts +29 -2
- package/src/lib/utils/file-utils.ts +62 -7
- package/src/lib/utils/write-queue.ts +36 -15
- package/src/workers/i3s-attributes-worker.ts +2 -1
package/src/converter-cli.ts
CHANGED
|
@@ -14,6 +14,10 @@ type TileConversionOptions = {
|
|
|
14
14
|
/** Output folder. This folder will be created by converter if doesn't exist. It is relative to the converter path.
|
|
15
15
|
* Default: "data" folder */
|
|
16
16
|
output: string;
|
|
17
|
+
/** Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed */
|
|
18
|
+
instantNodeWriting: boolean;
|
|
19
|
+
/** Try to merge similar materials to be able to merge meshes into one node (I3S to 3DTiles conversion only) */
|
|
20
|
+
mergeMaterials: boolean;
|
|
17
21
|
/** 3DTiles->I3S only. location of 7z.exe archiver to create slpk on Windows OS, default: "C:\Program Files\7-Zip\7z.exe" */
|
|
18
22
|
sevenZipExe: string;
|
|
19
23
|
/** location of the Earth Gravity Model (*.pgm) file to convert heights from ellipsoidal to gravity-related format,
|
|
@@ -99,6 +103,12 @@ function printHelp(): void {
|
|
|
99
103
|
);
|
|
100
104
|
console.log('--name [Tileset name]');
|
|
101
105
|
console.log('--output [Output folder, default: "data" folder]');
|
|
106
|
+
console.log(
|
|
107
|
+
'--instant-node-writing [Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed]'
|
|
108
|
+
);
|
|
109
|
+
console.log(
|
|
110
|
+
'--split-nodes [Prevent to merge similar materials that could lead to incorrect visualization (I3S to 3DTiles conversion only)]'
|
|
111
|
+
);
|
|
102
112
|
console.log('--slpk [Generate slpk (Scene Layer Packages) I3S output file]');
|
|
103
113
|
console.log(
|
|
104
114
|
'--tileset [tileset.json file (3DTiles) / http://..../SceneServer/layers/0 resource (I3S)]'
|
|
@@ -154,9 +164,11 @@ async function convert(options: ValidatedTileConversionOptions) {
|
|
|
154
164
|
egmFilePath: options.egm,
|
|
155
165
|
token: options.token,
|
|
156
166
|
draco: options.draco,
|
|
167
|
+
mergeMaterials: options.mergeMaterials,
|
|
157
168
|
generateTextures: options.generateTextures,
|
|
158
169
|
generateBoundingVolumes: options.generateBoundingVolumes,
|
|
159
|
-
validate: options.validate
|
|
170
|
+
validate: options.validate,
|
|
171
|
+
instantNodeWriting: options.instantNodeWriting
|
|
160
172
|
});
|
|
161
173
|
break;
|
|
162
174
|
default:
|
|
@@ -222,6 +234,8 @@ function validateOptionsWithEqual(args: string[]): string[] {
|
|
|
222
234
|
function parseOptions(args: string[]): TileConversionOptions {
|
|
223
235
|
const opts: TileConversionOptions = {
|
|
224
236
|
output: 'data',
|
|
237
|
+
instantNodeWriting: false,
|
|
238
|
+
mergeMaterials: true,
|
|
225
239
|
sevenZipExe: 'C:\\Program Files\\7-Zip\\7z.exe',
|
|
226
240
|
egm: join(process.cwd(), 'deps', 'egm2008-5.pgm'),
|
|
227
241
|
draco: true,
|
|
@@ -248,6 +262,12 @@ function parseOptions(args: string[]): TileConversionOptions {
|
|
|
248
262
|
case '--output':
|
|
249
263
|
opts.output = getStringValue(index, args);
|
|
250
264
|
break;
|
|
265
|
+
case '--instant-node-writing':
|
|
266
|
+
opts.instantNodeWriting = getBooleanValue(index, args);
|
|
267
|
+
break;
|
|
268
|
+
case '--split-nodes':
|
|
269
|
+
opts.mergeMaterials = getBooleanValue(index, args);
|
|
270
|
+
break;
|
|
251
271
|
case '--max-depth':
|
|
252
272
|
opts.maxDepth = getIntegerValue(index, args);
|
|
253
273
|
break;
|
|
@@ -340,7 +360,7 @@ function getIntegerValue(index: number, args: string[]): number {
|
|
|
340
360
|
|
|
341
361
|
function getBooleanValue(index: number, args: string[]): boolean {
|
|
342
362
|
const stringValue: string = getStringValue(index, args).toLowerCase().trim();
|
|
343
|
-
if (
|
|
363
|
+
if (['--no-draco', '--split-nodes'].includes(args[index]) && !stringValue) {
|
|
344
364
|
return false;
|
|
345
365
|
}
|
|
346
366
|
if (!stringValue || stringValue === 'true') {
|
|
@@ -2,6 +2,7 @@ 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
4
|
import {join} from 'path';
|
|
5
|
+
import {ChildProcessProxy} from '@loaders.gl/worker-utils';
|
|
5
6
|
|
|
6
7
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
7
8
|
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';
|
|
@@ -42,6 +43,14 @@ export class DepsInstaller {
|
|
|
42
43
|
console.log('Installing "Basis Loader worker"'); // eslint-disable-line no-console
|
|
43
44
|
await this.installWorker('textures', 'basis-nodejs-worker.js', workersPath);
|
|
44
45
|
|
|
46
|
+
console.log('Installing "join-images" npm package');
|
|
47
|
+
const childProcess = new ChildProcessProxy();
|
|
48
|
+
await childProcess.start({
|
|
49
|
+
command: 'npm',
|
|
50
|
+
arguments: ['install', 'sharp', 'join-images'],
|
|
51
|
+
wait: 0
|
|
52
|
+
});
|
|
53
|
+
|
|
45
54
|
console.log('All dependencies were installed succesfully.'); // eslint-disable-line no-console
|
|
46
55
|
}
|
|
47
56
|
|
|
@@ -13,9 +13,9 @@ const EXT_FEATURE_METADATA = 'EXT_feature_metadata';
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Getting batchIds from 3DTilesNext extensions.
|
|
16
|
-
* @param attributes
|
|
17
|
-
* @param primitive
|
|
18
|
-
* @param
|
|
16
|
+
* @param attributes - gltf accessors
|
|
17
|
+
* @param primitive - gltf primitive data
|
|
18
|
+
* @param images - gltf texture images
|
|
19
19
|
*/
|
|
20
20
|
export function handleBatchIdsExtensions(
|
|
21
21
|
attributes: {
|
|
@@ -10,7 +10,7 @@ const POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;
|
|
|
10
10
|
* @returns attirbutes with featureCount, featureIds and changed faceRange.
|
|
11
11
|
*/
|
|
12
12
|
export function generateAttributes(attributes: ConvertedAttributes): GeometryAttributes {
|
|
13
|
-
const {positions, normals, texCoords, colors, featureIndices} = attributes;
|
|
13
|
+
const {positions, normals, texCoords, colors, uvRegions, featureIndices} = attributes;
|
|
14
14
|
const triangleCount = positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;
|
|
15
15
|
|
|
16
16
|
if (!featureIndices.length) {
|
|
@@ -21,7 +21,8 @@ export function generateAttributes(attributes: ConvertedAttributes): GeometryAtt
|
|
|
21
21
|
positions,
|
|
22
22
|
normals,
|
|
23
23
|
texCoords,
|
|
24
|
-
colors
|
|
24
|
+
colors,
|
|
25
|
+
uvRegions
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
28
|
|
|
@@ -113,6 +114,7 @@ function makeAttributeObjects(attributes: GeometryAttributes): GroupedByFeatureI
|
|
|
113
114
|
positions,
|
|
114
115
|
normals,
|
|
115
116
|
colors,
|
|
117
|
+
uvRegions,
|
|
116
118
|
texCoords,
|
|
117
119
|
faceRange = new Uint32Array(0)
|
|
118
120
|
} = attributes;
|
|
@@ -122,16 +124,16 @@ function makeAttributeObjects(attributes: GeometryAttributes): GroupedByFeatureI
|
|
|
122
124
|
let normalsList = new Float32Array(normals);
|
|
123
125
|
let colorsList = new Uint8Array(colors);
|
|
124
126
|
let texCoordsList = new Float32Array(texCoords);
|
|
125
|
-
|
|
126
|
-
let faceRangeIndex = 0;
|
|
127
|
+
let uvRegionsList = new Uint16Array(uvRegions);
|
|
127
128
|
|
|
128
129
|
for (let index = 0; index < featureIds.length; index++) {
|
|
129
|
-
const startIndex = faceRange[index
|
|
130
|
-
const endIndex = faceRange[index
|
|
130
|
+
const startIndex = faceRange[index * 2];
|
|
131
|
+
const endIndex = faceRange[index * 2 + 1];
|
|
131
132
|
|
|
132
133
|
const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);
|
|
133
134
|
const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);
|
|
134
135
|
const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);
|
|
136
|
+
const uvRegionsCount = getSliceAttributeCount('uvRegions', startIndex, endIndex);
|
|
135
137
|
const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);
|
|
136
138
|
|
|
137
139
|
groupedData.push({
|
|
@@ -139,15 +141,15 @@ function makeAttributeObjects(attributes: GeometryAttributes): GroupedByFeatureI
|
|
|
139
141
|
positions: positionsList.slice(0, positionsCount),
|
|
140
142
|
normals: normalsList.slice(0, normalsCount),
|
|
141
143
|
colors: colorsList.slice(0, colorsCount),
|
|
144
|
+
uvRegions: uvRegionsList.slice(0, uvRegionsCount),
|
|
142
145
|
texCoords: texCoordsList.slice(0, texCoordsCount)
|
|
143
146
|
});
|
|
144
147
|
|
|
145
148
|
positionsList = positionsList.slice(positionsCount);
|
|
146
149
|
normalsList = normalsList.slice(normalsCount);
|
|
147
150
|
colorsList = colorsList.slice(colorsCount);
|
|
151
|
+
uvRegionsList = uvRegionsList.slice(uvRegionsCount);
|
|
148
152
|
texCoordsList = texCoordsList.slice(texCoordsCount);
|
|
149
|
-
|
|
150
|
-
faceRangeIndex += 1;
|
|
151
153
|
}
|
|
152
154
|
|
|
153
155
|
return groupedData.sort((first, second) => first.featureId - second.featureId);
|
|
@@ -165,7 +167,7 @@ function getSliceAttributeCount(
|
|
|
165
167
|
startIndex: number,
|
|
166
168
|
endIndex: number
|
|
167
169
|
): number {
|
|
168
|
-
const
|
|
170
|
+
const itemsPerVertex4 = 4;
|
|
169
171
|
const texCoordsPerVertex = 2;
|
|
170
172
|
|
|
171
173
|
const trianglesCount = endIndex - startIndex + 1;
|
|
@@ -176,7 +178,8 @@ function getSliceAttributeCount(
|
|
|
176
178
|
case 'normals':
|
|
177
179
|
return trianglesCount * POSITIONS_AND_NORMALS_PER_TRIANGLE;
|
|
178
180
|
case 'colors':
|
|
179
|
-
|
|
181
|
+
case 'uvRegions':
|
|
182
|
+
return vertexCount * itemsPerVertex4;
|
|
180
183
|
case 'texCoords':
|
|
181
184
|
return vertexCount * texCoordsPerVertex;
|
|
182
185
|
default:
|
|
@@ -232,6 +235,7 @@ function groupAttributesAndRangesByFeatureId(
|
|
|
232
235
|
let positions = new Float32Array(firstAttributeObject.positions);
|
|
233
236
|
let normals = new Float32Array(firstAttributeObject.normals);
|
|
234
237
|
let colors = new Uint8Array(firstAttributeObject.colors);
|
|
238
|
+
let uvRegions = new Uint16Array(firstAttributeObject.uvRegions);
|
|
235
239
|
let texCoords = new Float32Array(firstAttributeObject.texCoords);
|
|
236
240
|
const range = [0];
|
|
237
241
|
|
|
@@ -245,6 +249,7 @@ function groupAttributesAndRangesByFeatureId(
|
|
|
245
249
|
positions = concatenateTypedArrays(positions, currentAttributesObject.positions);
|
|
246
250
|
normals = concatenateTypedArrays(normals, currentAttributesObject.normals);
|
|
247
251
|
colors = concatenateTypedArrays(colors, currentAttributesObject.colors);
|
|
252
|
+
uvRegions = concatenateTypedArrays(uvRegions, currentAttributesObject.uvRegions);
|
|
248
253
|
texCoords = concatenateTypedArrays(texCoords, currentAttributesObject.texCoords);
|
|
249
254
|
|
|
250
255
|
const groupedObject = unifiedObjects[objIndex];
|
|
@@ -258,5 +263,5 @@ function groupAttributesAndRangesByFeatureId(
|
|
|
258
263
|
range.push(positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);
|
|
259
264
|
|
|
260
265
|
const faceRange = new Uint32Array(range);
|
|
261
|
-
return {faceRange, featureIds, positions, normals, colors, texCoords, featureCount};
|
|
266
|
+
return {faceRange, featureIds, positions, normals, colors, uvRegions, texCoords, featureCount};
|
|
262
267
|
}
|