@loaders.gl/tile-converter 4.3.0-alpha.6 → 4.3.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +3 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +15 -11
- package/dist/3d-tiles-converter/helpers/{b3dm-converter.d.ts → 3d-tiles-content-converter.d.ts} +13 -6
- package/dist/3d-tiles-converter/helpers/3d-tiles-content-converter.d.ts.map +1 -0
- package/dist/3d-tiles-converter/helpers/{b3dm-converter.js → 3d-tiles-content-converter.js} +110 -16
- package/dist/converter-cli.js +15 -0
- package/dist/converter.min.cjs +95 -95
- package/dist/deps-installer/deps-installer.d.ts.map +1 -1
- package/dist/deps-installer/deps-installer.js +4 -3
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +6 -1
- package/dist/i3s-server/bin/www.js +2 -0
- package/dist/index.cjs +132 -30
- package/dist/index.cjs.map +4 -4
- package/dist/lib/utils/conversion-dump.d.ts +1 -0
- package/dist/lib/utils/conversion-dump.d.ts.map +1 -1
- package/dist/lib/utils/conversion-dump.js +3 -2
- package/dist/pgm-loader.js +1 -1
- package/package.json +20 -20
- package/src/3d-tiles-converter/3d-tiles-converter.ts +40 -14
- package/src/3d-tiles-converter/helpers/{b3dm-converter.ts → 3d-tiles-content-converter.ts} +157 -20
- package/src/converter-cli.ts +22 -0
- package/src/deps-installer/deps-installer.ts +3 -2
- package/src/i3s-converter/i3s-converter.ts +6 -1
- package/src/i3s-server/bin/www.ts +2 -0
- package/src/lib/utils/conversion-dump.ts +5 -2
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deps-installer.d.ts","sourceRoot":"","sources":["../../src/deps-installer/deps-installer.ts"],"names":[],"mappings":"AAiBA;;;;;GAKG;AACH,qBAAa,aAAa;IACxB;;;;;;OAMG;IAEG,OAAO,CAAC,IAAI,GAAE,MAAW,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"deps-installer.d.ts","sourceRoot":"","sources":["../../src/deps-installer/deps-installer.ts"],"names":[],"mappings":"AAiBA;;;;;GAKG;AACH,qBAAa,aAAa;IACxB;;;;;;OAMG;IAEG,OAAO,CAAC,IAAI,GAAE,MAAW,GAAG,OAAO,CAAC,IAAI,CAAC;YAuEjC,cAAc;YAiBd,cAAc;CAS7B"}
|
|
@@ -9,7 +9,7 @@ import { ChildProcessProxy } from '@loaders.gl/worker-utils';
|
|
|
9
9
|
import { DRACO_EXTERNAL_LIBRARIES, DRACO_EXTERNAL_LIBRARY_URLS } from '@loaders.gl/draco';
|
|
10
10
|
import { BASIS_EXTERNAL_LIBRARIES } from '@loaders.gl/textures';
|
|
11
11
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
12
|
-
const VERSION = typeof "4.3.0-alpha.
|
|
12
|
+
const VERSION = typeof "4.3.0-alpha.7" !== 'undefined' ? "4.3.0-alpha.7" : 'latest';
|
|
13
13
|
const PGM_LINK = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip';
|
|
14
14
|
/**
|
|
15
15
|
* Install external dependencies for converter:
|
|
@@ -60,13 +60,14 @@ export class DepsInstaller {
|
|
|
60
60
|
const childProcess = new ChildProcessProxy();
|
|
61
61
|
const nodeDir = dirname(process.execPath);
|
|
62
62
|
await childProcess.start({
|
|
63
|
-
command:
|
|
63
|
+
command: `"${nodeDir}/${process.platform === 'win32' ? 'npm.cmd' : 'npm'}"`,
|
|
64
64
|
// `npm install sharp join-images` works unstable. It fails because installed `sharp` version
|
|
65
65
|
// may be different from the version required by `join-images`. Pointing to specific versions
|
|
66
66
|
// resolve this issue
|
|
67
67
|
arguments: ['install', 'sharp@0.30.4', 'join-images@1.1.3'],
|
|
68
68
|
wait: 0,
|
|
69
|
-
ignoreStderr: true
|
|
69
|
+
ignoreStderr: true,
|
|
70
|
+
spawn: { shell: true }
|
|
70
71
|
});
|
|
71
72
|
console.log('All dependencies were installed succesfully.'); // eslint-disable-line no-console
|
|
72
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i3s-converter.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/i3s-converter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,qBAAqB,EAAC,6CAA0C;AAExE,OAAO,KAAK,EAEV,oBAAoB,EAGpB,+BAA+B,EAChC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAC,cAAc,EAAC,oCAAiC;AAC7D,OAAO,KAAK,EACV,YAAY,EAMb,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAOrC,OAAO,SAAS,gCAA6B;AAkB7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,qBAAqB,EAA8B,MAAM,iBAAiB,CAAC;AAGnF,OAAO,EAGL,cAAc,EAGf,mBAAgB;AAEjB,OAAO,UAAU,oCAAiC;AAkBlD,OAAO,EAAC,QAAQ,EAAC,8BAA2B;AAE5C,OAAO,EAAC,cAAc,EAAsC,wCAAqC;AACjG,OAAO,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"i3s-converter.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/i3s-converter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,qBAAqB,EAAC,6CAA0C;AAExE,OAAO,KAAK,EAEV,oBAAoB,EAGpB,+BAA+B,EAChC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAC,cAAc,EAAC,oCAAiC;AAC7D,OAAO,KAAK,EACV,YAAY,EAMb,MAAM,iBAAiB,CAAC;AAGzB,OA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AO,CAAC,MAAM,CAAC;IAwFvD;;;;OAIG;YACW,oBAAoB;IAkDlC;;;;;OAKG;YACW,WAAW;IA+BzB;;;OAGG;YACW,mBAAmB;IAiCjC;;;;OAIG;YAEW,qBAAqB;IAwHnC;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAgCpB;;OAEG;YACW,aAAa;IAQ3B;;;OAGG;YACW,WAAW;IAiBzB;;;;;;OAMG;YAEW,WAAW;IAuDzB;;;;OAIG;YACW,YAAY;IAc1B;;;;;;;;OAQG;YACW,0BAA0B;IAoDxC;;;;;;OAMG;YACW,YAAY;IAwC1B;;;;;;;OAOG;YAEW,WAAW;IAuGzB;;;;;;;;;;OAUG;YACW,iBAAiB;IA0C/B;;;;;;;;;;;;;;OAcG;YAEW,sBAAsB;IA0EpC;;;;;;;;;;;OAWG;YACW,eAAe;IA+C7B;;;;;;;;OAQG;YACW,gBAAgB;IA6C9B;;;;;;;;OAQG;YACW,YAAY;IAgC1B;;;;;;;OAOG;YAEW,aAAa;IA8H3B;;;;;;;;;OASG;YACW,gBAAgB;IA8B9B;;;;;;;OAOG;YACW,gBAAgB;IAkC9B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAa5B;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAU7B;;;;;;OAMG;IACH,OAAO,CAAC,8BAA8B;IAWtC;;;;OAIG;IACH,OAAO,CAAC,0BAA0B;IA4BlC;;;OAGG;YACW,iBAAiB;IAwB/B;;OAEG;YACW,oBAAoB;IAYlC;;OAEG;YACW,qBAAqB;IAiBnC;;OAEG;IACH,OAAO,CAAC,8BAA8B;IAWtC;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;CAG3B"}
|
|
@@ -38,6 +38,7 @@ import { analyzeTileContent, mergePreprocessData } from "./helpers/preprocess-3d
|
|
|
38
38
|
import { Progress } from "./helpers/progress.js";
|
|
39
39
|
import { composeHashFile, createZip } from '@loaders.gl/zip';
|
|
40
40
|
import { ConversionDump } from "../lib/utils/conversion-dump.js";
|
|
41
|
+
// eslint-disable-next-line no-process-env
|
|
41
42
|
const ION_DEFAULT_TOKEN = process.env?.IonToken;
|
|
42
43
|
const HARDCODED_NODES_PER_PAGE = 64;
|
|
43
44
|
const _3D_TILES = '3DTILES';
|
|
@@ -1121,7 +1122,11 @@ export default class I3SConverter {
|
|
|
1121
1122
|
const addRefinementPercentage = tilesWithAddRefineCount
|
|
1122
1123
|
? (tilesWithAddRefineCount / tilesCount) * 100
|
|
1123
1124
|
: 0;
|
|
1124
|
-
const filesSize = await calculateDatasetSize(
|
|
1125
|
+
const filesSize = await calculateDatasetSize({
|
|
1126
|
+
outputPath: params.outputPath,
|
|
1127
|
+
tilesetName: params.tilesetName,
|
|
1128
|
+
slpk: true
|
|
1129
|
+
});
|
|
1125
1130
|
const diff = process.hrtime(this.conversionStartTime);
|
|
1126
1131
|
const conversionTime = timeConverter(diff);
|
|
1127
1132
|
console.log('------------------------------------------------'); // eslint-disable-line no-undef, no-console
|
|
@@ -11,12 +11,14 @@ import { formErrorHandler, formListeningHandler, normalizePort } from "../utils/
|
|
|
11
11
|
// const __filename = fileURLToPath(import.meta.url);
|
|
12
12
|
// const __dirname = path.dirname(__filename);
|
|
13
13
|
/** Get port from environment and store in Express. */
|
|
14
|
+
// eslint-disable-next-line no-process-env
|
|
14
15
|
const httpPort = normalizePort(process.env.PORT || '80');
|
|
15
16
|
if (httpPort === false) {
|
|
16
17
|
// eslint-disable-next-line no-console
|
|
17
18
|
console.error('Incorrect HTTP port');
|
|
18
19
|
process.exit(1); // eslint-disable-line no-process-exit
|
|
19
20
|
}
|
|
21
|
+
// eslint-disable-next-line no-process-env
|
|
20
22
|
const httpsPort = normalizePort(process.env.HTTPS_PORT || '443');
|
|
21
23
|
if (httpsPort === false) {
|
|
22
24
|
// eslint-disable-next-line no-console
|
package/dist/index.cjs
CHANGED
|
@@ -2325,7 +2325,7 @@ function convertScreenThresholdToGeometricError(node) {
|
|
|
2325
2325
|
|
|
2326
2326
|
// dist/pgm-loader.js
|
|
2327
2327
|
var import_geoid = require("@math.gl/geoid");
|
|
2328
|
-
var VERSION = true ? "4.3.0-alpha.
|
|
2328
|
+
var VERSION = true ? "4.3.0-alpha.7" : "latest";
|
|
2329
2329
|
var PGMLoader = {
|
|
2330
2330
|
dataType: null,
|
|
2331
2331
|
batchType: null,
|
|
@@ -4024,7 +4024,7 @@ var ConversionDump = class {
|
|
|
4024
4024
|
* @param currentOptions - converter options
|
|
4025
4025
|
*/
|
|
4026
4026
|
async createDump(currentOptions) {
|
|
4027
|
-
const { tilesetName, slpk, egmFilePath, inputUrl, outputPath, draco = true, maxDepth, token, generateTextures, generateBoundingVolumes, mergeMaterials: mergeMaterials2 = true, metadataClass, analyze = false } = currentOptions;
|
|
4027
|
+
const { tilesetName, slpk, egmFilePath, inputUrl, outputPath, draco = true, maxDepth, token, generateTextures, generateBoundingVolumes, mergeMaterials: mergeMaterials2 = true, metadataClass, analyze = false, outputVersion = "1.1" } = currentOptions;
|
|
4028
4028
|
this.options = {
|
|
4029
4029
|
tilesetName,
|
|
4030
4030
|
slpk,
|
|
@@ -4038,7 +4038,8 @@ var ConversionDump = class {
|
|
|
4038
4038
|
generateBoundingVolumes,
|
|
4039
4039
|
mergeMaterials: mergeMaterials2,
|
|
4040
4040
|
metadataClass,
|
|
4041
|
-
analyze
|
|
4041
|
+
analyze,
|
|
4042
|
+
outputVersion
|
|
4042
4043
|
};
|
|
4043
4044
|
const dumpFilename = (0, import_path6.join)(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`);
|
|
4044
4045
|
if (await isFileExists(dumpFilename)) {
|
|
@@ -5277,7 +5278,11 @@ var I3SConverter = class {
|
|
|
5277
5278
|
async _finishConversion(params) {
|
|
5278
5279
|
const { tilesCount, tilesWithAddRefineCount } = this.refinementCounter;
|
|
5279
5280
|
const addRefinementPercentage = tilesWithAddRefineCount ? tilesWithAddRefineCount / tilesCount * 100 : 0;
|
|
5280
|
-
const filesSize = await calculateDatasetSize(
|
|
5281
|
+
const filesSize = await calculateDatasetSize({
|
|
5282
|
+
outputPath: params.outputPath,
|
|
5283
|
+
tilesetName: params.tilesetName,
|
|
5284
|
+
slpk: true
|
|
5285
|
+
});
|
|
5281
5286
|
const diff = import_process4.default.hrtime(this.conversionStartTime);
|
|
5282
5287
|
const conversionTime = timeConverter(diff);
|
|
5283
5288
|
console.log("------------------------------------------------");
|
|
@@ -5407,11 +5412,13 @@ var TILESET = () => ({
|
|
|
5407
5412
|
// dist/3d-tiles-converter/3d-tiles-converter.js
|
|
5408
5413
|
var import_worker_utils2 = require("@loaders.gl/worker-utils");
|
|
5409
5414
|
|
|
5410
|
-
// dist/3d-tiles-converter/helpers/
|
|
5415
|
+
// dist/3d-tiles-converter/helpers/3d-tiles-content-converter.js
|
|
5411
5416
|
var import_core12 = require("@loaders.gl/core");
|
|
5412
5417
|
var import_gltf6 = require("@loaders.gl/gltf");
|
|
5413
5418
|
var import_d_tiles3 = require("@loaders.gl/3d-tiles");
|
|
5419
|
+
var import_d_tiles4 = require("@loaders.gl/3d-tiles");
|
|
5414
5420
|
var import_core13 = require("@math.gl/core");
|
|
5421
|
+
var import_types5 = require("@math.gl/types");
|
|
5415
5422
|
var import_geospatial6 = require("@math.gl/geospatial");
|
|
5416
5423
|
|
|
5417
5424
|
// dist/3d-tiles-converter/helpers/texture-atlas.js
|
|
@@ -5445,38 +5452,45 @@ function normalizeRegions(regions) {
|
|
|
5445
5452
|
return normalizedRegions;
|
|
5446
5453
|
}
|
|
5447
5454
|
|
|
5448
|
-
// dist/3d-tiles-converter/helpers/
|
|
5455
|
+
// dist/3d-tiles-converter/helpers/3d-tiles-content-converter.js
|
|
5449
5456
|
var Z_UP_TO_Y_UP_MATRIX = new import_core13.Matrix4([1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
|
|
5450
5457
|
var scratchVector2 = new import_core13.Vector3();
|
|
5451
5458
|
var KHR_MATERIALS_UNLIT = "KHR_materials_unlit";
|
|
5452
5459
|
var METALLIC_FACTOR_DEFAULT = 1;
|
|
5453
5460
|
var ROUGHNESS_FACTOR_DEFAULT = 1;
|
|
5454
|
-
var
|
|
5461
|
+
var Tiles3DContentConverter = class {
|
|
5455
5462
|
// @ts-expect-error
|
|
5456
5463
|
rtcCenter;
|
|
5457
5464
|
i3sTile;
|
|
5465
|
+
tileType;
|
|
5466
|
+
constructor(options = { outputVersion: "1.1" }) {
|
|
5467
|
+
this.tileType = options.outputVersion === "1.0" ? import_d_tiles4.TILE3D_TYPE.BATCHED_3D_MODEL : import_d_tiles4.TILE3D_TYPE.GLTF;
|
|
5468
|
+
}
|
|
5458
5469
|
/**
|
|
5459
5470
|
* The starter of content conversion
|
|
5460
5471
|
* @param i3sTile - Tile3D instance for I3S node
|
|
5461
5472
|
* @returns - encoded content
|
|
5462
5473
|
*/
|
|
5463
|
-
async convert(i3sAttributesData, featureAttributes = null) {
|
|
5464
|
-
const gltf = await this.buildGLTF(i3sAttributesData, featureAttributes);
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5474
|
+
async convert(i3sAttributesData, featureAttributes = null, attributeStorageInfo) {
|
|
5475
|
+
const gltf = await this.buildGLTF(i3sAttributesData, featureAttributes, attributeStorageInfo);
|
|
5476
|
+
if (this.tileType === import_d_tiles4.TILE3D_TYPE.BATCHED_3D_MODEL) {
|
|
5477
|
+
const b3dm = (0, import_core12.encodeSync)({
|
|
5478
|
+
gltfEncoded: new Uint8Array(gltf),
|
|
5479
|
+
type: "b3dm",
|
|
5480
|
+
featuresLength: this._getFeaturesLength(featureAttributes),
|
|
5481
|
+
batchTable: featureAttributes
|
|
5482
|
+
}, import_d_tiles3.Tile3DWriter);
|
|
5483
|
+
return b3dm;
|
|
5484
|
+
}
|
|
5485
|
+
return gltf;
|
|
5472
5486
|
}
|
|
5473
5487
|
/**
|
|
5474
5488
|
* Build and encode gltf
|
|
5475
5489
|
* @param i3sTile - Tile3D instance for I3S node
|
|
5476
5490
|
* @returns - encoded glb content
|
|
5477
5491
|
*/
|
|
5478
|
-
// eslint-disable-next-line max-statements
|
|
5479
|
-
async buildGLTF(i3sAttributesData, featureAttributes) {
|
|
5492
|
+
// eslint-disable-next-line complexity, max-statements
|
|
5493
|
+
async buildGLTF(i3sAttributesData, featureAttributes, attributeStorageInfo) {
|
|
5480
5494
|
const { tileContent, textureFormat, box } = i3sAttributesData;
|
|
5481
5495
|
const { material, attributes, indices: originalIndices, modelMatrix } = tileContent;
|
|
5482
5496
|
const gltfBuilder = new import_gltf6.GLTFScenegraph();
|
|
@@ -5507,13 +5521,97 @@ var B3dmConverter = class {
|
|
|
5507
5521
|
material: materialIndex,
|
|
5508
5522
|
mode: 4
|
|
5509
5523
|
});
|
|
5524
|
+
if (this.tileType === import_d_tiles4.TILE3D_TYPE.GLTF) {
|
|
5525
|
+
this._createMetadataExtensions(gltfBuilder, meshIndex, featureAttributes, attributeStorageInfo, tileContent);
|
|
5526
|
+
}
|
|
5510
5527
|
const transformMatrix = this._generateTransformMatrix(cartesianOrigin);
|
|
5511
5528
|
const nodeIndex = gltfBuilder.addNode({ meshIndex, matrix: transformMatrix });
|
|
5512
5529
|
const sceneIndex = gltfBuilder.addScene({ nodeIndices: [nodeIndex] });
|
|
5513
5530
|
gltfBuilder.setDefaultScene(sceneIndex);
|
|
5514
5531
|
gltfBuilder.createBinaryChunk();
|
|
5515
|
-
|
|
5516
|
-
|
|
5532
|
+
return (0, import_core12.encodeSync)(gltfBuilder.gltf, import_gltf6.GLTFWriter, { gltfBuilder });
|
|
5533
|
+
}
|
|
5534
|
+
_createMetadataExtensions(gltfBuilder, meshIndex, featureAttributes, attributeStorageInfo, tileContent) {
|
|
5535
|
+
var _a2;
|
|
5536
|
+
const propertyAttributes = this._createPropertyAttibutes(featureAttributes, attributeStorageInfo);
|
|
5537
|
+
const tableIndex = (0, import_gltf6.createExtStructuralMetadata)(gltfBuilder, propertyAttributes);
|
|
5538
|
+
const mesh = gltfBuilder.getMesh(meshIndex);
|
|
5539
|
+
for (const primitive of mesh.primitives) {
|
|
5540
|
+
if ((_a2 = tileContent.attributes._BATCHID) == null ? void 0 : _a2.value) {
|
|
5541
|
+
(0, import_gltf6.createExtMeshFeatures)(gltfBuilder, primitive, tileContent.attributes._BATCHID.value, tableIndex);
|
|
5542
|
+
}
|
|
5543
|
+
}
|
|
5544
|
+
}
|
|
5545
|
+
_createPropertyAttibutes(featureAttributes, attributeStorageInfo) {
|
|
5546
|
+
if (!featureAttributes || !attributeStorageInfo) {
|
|
5547
|
+
return [];
|
|
5548
|
+
}
|
|
5549
|
+
const propertyAttributeArray = [];
|
|
5550
|
+
for (const attributeName in featureAttributes) {
|
|
5551
|
+
const propertyAttribute = this._convertAttributeStorageInfoToPropertyAttribute(attributeName, attributeStorageInfo, featureAttributes);
|
|
5552
|
+
if (propertyAttribute) {
|
|
5553
|
+
propertyAttributeArray.push(propertyAttribute);
|
|
5554
|
+
}
|
|
5555
|
+
}
|
|
5556
|
+
return propertyAttributeArray;
|
|
5557
|
+
}
|
|
5558
|
+
// eslint-disable-next-line complexity
|
|
5559
|
+
_convertAttributeStorageInfoToPropertyAttribute(attributeName, attributeStorageInfo, featureAttributes) {
|
|
5560
|
+
const attributeValues = featureAttributes[attributeName];
|
|
5561
|
+
const info = attributeStorageInfo.find((e) => e.name === attributeName);
|
|
5562
|
+
if (!info) {
|
|
5563
|
+
return null;
|
|
5564
|
+
}
|
|
5565
|
+
const attributeMetadata = info.attributeValues;
|
|
5566
|
+
if (!(attributeMetadata == null ? void 0 : attributeMetadata.valueType)) {
|
|
5567
|
+
return null;
|
|
5568
|
+
}
|
|
5569
|
+
let elementType;
|
|
5570
|
+
let componentType;
|
|
5571
|
+
switch (attributeMetadata.valueType.toLowerCase()) {
|
|
5572
|
+
case "oid32":
|
|
5573
|
+
elementType = "SCALAR";
|
|
5574
|
+
componentType = "UINT32";
|
|
5575
|
+
break;
|
|
5576
|
+
case "int32":
|
|
5577
|
+
elementType = "SCALAR";
|
|
5578
|
+
componentType = "INT32";
|
|
5579
|
+
break;
|
|
5580
|
+
case "uint32":
|
|
5581
|
+
elementType = "SCALAR";
|
|
5582
|
+
componentType = "UINT32";
|
|
5583
|
+
break;
|
|
5584
|
+
case "int16":
|
|
5585
|
+
elementType = "SCALAR";
|
|
5586
|
+
componentType = "INT16";
|
|
5587
|
+
break;
|
|
5588
|
+
case "uint16":
|
|
5589
|
+
elementType = "SCALAR";
|
|
5590
|
+
componentType = "UINT16";
|
|
5591
|
+
break;
|
|
5592
|
+
case "float64":
|
|
5593
|
+
elementType = "SCALAR";
|
|
5594
|
+
componentType = "FLOAT64";
|
|
5595
|
+
break;
|
|
5596
|
+
case "string":
|
|
5597
|
+
elementType = "STRING";
|
|
5598
|
+
break;
|
|
5599
|
+
default:
|
|
5600
|
+
elementType = "";
|
|
5601
|
+
break;
|
|
5602
|
+
}
|
|
5603
|
+
const propertyAttribute = {
|
|
5604
|
+
name: attributeName,
|
|
5605
|
+
elementType,
|
|
5606
|
+
componentType,
|
|
5607
|
+
values: []
|
|
5608
|
+
};
|
|
5609
|
+
if ((0, import_types5.isTypedArray)(attributeValues)) {
|
|
5610
|
+
propertyAttribute.values = Array.from(attributeValues);
|
|
5611
|
+
} else if (attributeValues !== null) {
|
|
5612
|
+
propertyAttribute.values = attributeValues;
|
|
5613
|
+
}
|
|
5614
|
+
return propertyAttribute;
|
|
5517
5615
|
}
|
|
5518
5616
|
/**
|
|
5519
5617
|
* Update gltfBuilder with texture from I3S tile
|
|
@@ -5802,6 +5900,7 @@ var Tiles3DConverter = class {
|
|
|
5802
5900
|
};
|
|
5803
5901
|
conversionDump;
|
|
5804
5902
|
progress;
|
|
5903
|
+
fileExt;
|
|
5805
5904
|
constructor() {
|
|
5806
5905
|
this.options = {};
|
|
5807
5906
|
this.tilesetPath = "";
|
|
@@ -5813,12 +5912,14 @@ var Tiles3DConverter = class {
|
|
|
5813
5912
|
this.workerSource = {};
|
|
5814
5913
|
this.conversionDump = new ConversionDump();
|
|
5815
5914
|
this.progress = new Progress();
|
|
5915
|
+
this.fileExt = "";
|
|
5816
5916
|
}
|
|
5817
5917
|
/**
|
|
5818
5918
|
* Convert i3s format data to 3dTiles
|
|
5819
5919
|
* @param options
|
|
5820
5920
|
* @param options.inputUrl the url to read the tileset from
|
|
5821
5921
|
* @param options.outputPath the output filename
|
|
5922
|
+
* @param options.outputVersion the version of 3DTiles
|
|
5822
5923
|
* @param options.tilesetName the output name of the tileset
|
|
5823
5924
|
* @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format
|
|
5824
5925
|
* @param options.maxDepth The max tree depth of conversion
|
|
@@ -5830,9 +5931,10 @@ var Tiles3DConverter = class {
|
|
|
5830
5931
|
console.log(BROWSER_ERROR_MESSAGE);
|
|
5831
5932
|
return BROWSER_ERROR_MESSAGE;
|
|
5832
5933
|
}
|
|
5833
|
-
const { inputUrl, outputPath, tilesetName, maxDepth, egmFilePath, inquirer, analyze } = options;
|
|
5934
|
+
const { inputUrl, outputPath, outputVersion, tilesetName, maxDepth, egmFilePath, inquirer, analyze } = options;
|
|
5834
5935
|
this.conversionStartTime = import_process5.default.hrtime();
|
|
5835
|
-
this.options = { maxDepth, inquirer };
|
|
5936
|
+
this.options = { maxDepth, inquirer, outputVersion };
|
|
5937
|
+
this.fileExt = this.options.outputVersion === "1.0" ? "b3dm" : "glb";
|
|
5836
5938
|
console.log("Loading egm file...");
|
|
5837
5939
|
this.geoidHeightModel = await (0, import_core15.load)(egmFilePath, PGMLoader);
|
|
5838
5940
|
console.log("Loading egm file completed!");
|
|
@@ -5887,7 +5989,7 @@ var Tiles3DConverter = class {
|
|
|
5887
5989
|
refine: "REPLACE"
|
|
5888
5990
|
};
|
|
5889
5991
|
await this._addChildren(rootNode, rootTile, 1);
|
|
5890
|
-
const tileset = (0, import_json_map_transform10.default)({ root: rootTile }, TILESET());
|
|
5992
|
+
const tileset = (0, import_json_map_transform10.default)({ asset: { version: outputVersion }, root: rootTile }, TILESET());
|
|
5891
5993
|
await writeFile(this.tilesetPath, JSON.stringify(tileset), "tileset.json");
|
|
5892
5994
|
await this.conversionDump.deleteDumpFile();
|
|
5893
5995
|
this.progress.stopMonitoring();
|
|
@@ -5934,7 +6036,7 @@ var Tiles3DConverter = class {
|
|
|
5934
6036
|
let nextParentNode = parentNode;
|
|
5935
6037
|
const sourceChild = await this._loadChildNode(parentSourceNode, childNodeInfo);
|
|
5936
6038
|
if (sourceChild.contentUrl) {
|
|
5937
|
-
if (this.conversionDump.restored && this.conversionDump.isFileConversionComplete(`${sourceChild.id}.
|
|
6039
|
+
if (this.conversionDump.restored && this.conversionDump.isFileConversionComplete(`${sourceChild.id}.${this.fileExt}`) && (sourceChild.obb || sourceChild.mbs)) {
|
|
5938
6040
|
const { child: child2 } = this._createChildAndBoundingVolume(sourceChild);
|
|
5939
6041
|
parentNode.children.push(child2);
|
|
5940
6042
|
await this._addChildren(sourceChild, child2, level + 1);
|
|
@@ -5956,11 +6058,11 @@ var Tiles3DConverter = class {
|
|
|
5956
6058
|
box: boundingVolume.box || [],
|
|
5957
6059
|
textureFormat: sourceChild.textureFormat
|
|
5958
6060
|
};
|
|
5959
|
-
const
|
|
5960
|
-
const
|
|
5961
|
-
await this.conversionDump.addNode(`${sourceChild.id}.
|
|
5962
|
-
await writeFile(this.tilesetPath, new Uint8Array(
|
|
5963
|
-
await this.conversionDump.updateConvertedNodesDumpFile(`${sourceChild.id}.
|
|
6061
|
+
const converter = new Tiles3DContentConverter({ outputVersion: this.options.outputVersion });
|
|
6062
|
+
const contentData = await converter.convert(i3sAttributesData, featureAttributes, this.attributeStorageInfo);
|
|
6063
|
+
await this.conversionDump.addNode(`${sourceChild.id}.${this.fileExt}`, sourceChild.id);
|
|
6064
|
+
await writeFile(this.tilesetPath, new Uint8Array(contentData), `${sourceChild.id}.${this.fileExt}`);
|
|
6065
|
+
await this.conversionDump.updateConvertedNodesDumpFile(`${sourceChild.id}.${this.fileExt}`, sourceChild.id, true);
|
|
5964
6066
|
parentNode.children.push(child);
|
|
5965
6067
|
nextParentNode = child;
|
|
5966
6068
|
}
|
|
@@ -6033,7 +6135,7 @@ var Tiles3DConverter = class {
|
|
|
6033
6135
|
geometricError: convertScreenThresholdToGeometricError(sourceChild),
|
|
6034
6136
|
children: [],
|
|
6035
6137
|
content: {
|
|
6036
|
-
uri: `${sourceChild.id}.
|
|
6138
|
+
uri: `${sourceChild.id}.${this.fileExt}`,
|
|
6037
6139
|
boundingVolume
|
|
6038
6140
|
}
|
|
6039
6141
|
};
|