@loaders.gl/tile-converter 3.3.0-alpha.1 → 3.3.0-alpha.11
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.d.ts +3 -3
- package/dist/3d-tiles-attributes-worker.d.ts.map +1 -1
- package/dist/3d-tiles-attributes-worker.js +2 -3
- package/dist/3d-tiles-attributes-worker.js.map +3 -3
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +8 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +57 -43
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +5 -5
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +21 -17
- package/dist/converter-cli.js +29 -4
- package/dist/converter.min.js +24 -21
- package/dist/deps-installer/deps-installer.d.ts +5 -1
- package/dist/deps-installer/deps-installer.d.ts.map +1 -1
- package/dist/deps-installer/deps-installer.js +29 -1
- package/dist/dist.min.js +42714 -45782
- package/dist/es5/3d-tiles-attributes-worker.js +4 -7
- package/dist/es5/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +125 -210
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +53 -85
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -8
- package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js +0 -5
- package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
- package/dist/es5/3d-tiles-converter/json-templates/tileset.js +0 -6
- package/dist/es5/3d-tiles-converter/json-templates/tileset.js.map +1 -1
- package/dist/es5/bundle.js +0 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/constants.js.map +1 -1
- package/dist/es5/converter-cli.js +25 -58
- package/dist/es5/converter-cli.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +73 -28
- package/dist/es5/deps-installer/deps-installer.js.map +1 -1
- package/dist/es5/i3s-attributes-worker.js +3 -6
- package/dist/es5/i3s-attributes-worker.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +18 -29
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js +8 -25
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/create-scene-server-path.js +0 -11
- package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/feature-attributes.js +184 -0
- package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js +60 -51
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +504 -350
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js +57 -57
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-debug.js +4 -23
- package/dist/es5/i3s-converter/helpers/node-debug.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 +478 -168
- package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +770 -1131
- 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 -107
- package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/metadata.js +0 -2
- package/dist/es5/i3s-converter/json-templates/metadata.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/node.js +2 -12
- package/dist/es5/i3s-converter/json-templates/node.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/scene-server.js +0 -2
- package/dist/es5/i3s-converter/json-templates/scene-server.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/shared-resources.js +9 -32
- package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/store.js.map +1 -1
- package/dist/es5/i3s-converter/types.js.map +1 -1
- package/dist/es5/i3s-server/app.js +0 -5
- package/dist/es5/i3s-server/app.js.map +1 -1
- package/dist/es5/i3s-server/controllers/index-controller.js +0 -16
- package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -1
- package/dist/es5/i3s-server/routes/index.js +1 -10
- package/dist/es5/i3s-server/routes/index.js.map +1 -1
- package/dist/es5/index.js +0 -3
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/utils/compress-util.js +19 -74
- package/dist/es5/lib/utils/compress-util.js.map +1 -1
- package/dist/es5/lib/utils/file-utils.js +103 -47
- package/dist/es5/lib/utils/file-utils.js.map +1 -1
- package/dist/es5/lib/utils/lod-conversion-utils.js +0 -7
- package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/es5/lib/utils/queue.js +0 -14
- package/dist/es5/lib/utils/queue.js.map +1 -1
- package/dist/es5/lib/utils/statistic-utills.js +1 -46
- package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
- package/dist/es5/lib/utils/write-queue.js +86 -87
- package/dist/es5/lib/utils/write-queue.js.map +1 -1
- package/dist/es5/pgm-loader.js +1 -8
- package/dist/es5/pgm-loader.js.map +1 -1
- package/dist/es5/workers/3d-tiles-attributes-worker.js +2 -9
- package/dist/es5/workers/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/es5/workers/i3s-attributes-worker.js +2 -10
- package/dist/es5/workers/i3s-attributes-worker.js.map +1 -1
- package/dist/esm/3d-tiles-attributes-worker.js +4 -2
- package/dist/esm/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +60 -77
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +29 -50
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +1 -0
- package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js +1 -4
- package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
- package/dist/esm/3d-tiles-converter/json-templates/tileset.js +0 -3
- package/dist/esm/3d-tiles-converter/json-templates/tileset.js.map +1 -1
- package/dist/esm/bundle.js +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/converter-cli.js +26 -43
- package/dist/esm/converter-cli.js.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +30 -4
- package/dist/esm/deps-installer/deps-installer.js.map +1 -1
- package/dist/esm/i3s-attributes-worker.js +3 -1
- package/dist/esm/i3s-attributes-worker.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +20 -24
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js +11 -12
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/create-scene-server-path.js +1 -0
- package/dist/esm/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/feature-attributes.js +158 -0
- package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js +39 -33
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +286 -192
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js +59 -48
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/node-debug.js +3 -13
- package/dist/esm/i3s-converter/helpers/node-debug.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 +161 -87
- package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +217 -509
- 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 -95
- package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/metadata.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/node.js +0 -4
- package/dist/esm/i3s-converter/json-templates/node.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/scene-server.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/shared-resources.js +3 -15
- package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/store.js.map +1 -1
- package/dist/esm/i3s-converter/types.js.map +1 -1
- package/dist/esm/i3s-server/app.js +0 -5
- package/dist/esm/i3s-server/app.js.map +1 -1
- package/dist/esm/i3s-server/controllers/index-controller.js +0 -5
- package/dist/esm/i3s-server/controllers/index-controller.js.map +1 -1
- package/dist/esm/i3s-server/routes/index.js +0 -3
- package/dist/esm/i3s-server/routes/index.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/utils/compress-util.js +19 -12
- package/dist/esm/lib/utils/compress-util.js.map +1 -1
- package/dist/esm/lib/utils/file-utils.js +54 -11
- package/dist/esm/lib/utils/file-utils.js.map +1 -1
- package/dist/esm/lib/utils/lod-conversion-utils.js +2 -6
- package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/esm/lib/utils/queue.js +0 -4
- package/dist/esm/lib/utils/queue.js.map +1 -1
- package/dist/esm/lib/utils/statistic-utills.js +0 -11
- package/dist/esm/lib/utils/statistic-utills.js.map +1 -1
- package/dist/esm/lib/utils/write-queue.js +29 -28
- package/dist/esm/lib/utils/write-queue.js.map +1 -1
- package/dist/esm/pgm-loader.js +3 -1
- package/dist/esm/pgm-loader.js.map +1 -1
- package/dist/esm/workers/3d-tiles-attributes-worker.js +4 -1
- package/dist/esm/workers/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/esm/workers/i3s-attributes-worker.js +4 -1
- package/dist/esm/workers/i3s-attributes-worker.js.map +1 -1
- package/dist/i3s-attributes-worker.d.ts +7 -3
- package/dist/i3s-attributes-worker.d.ts.map +1 -1
- package/dist/i3s-attributes-worker.js +2 -3
- package/dist/i3s-attributes-worker.js.map +3 -3
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +5 -6
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +18 -4
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts +2 -2
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/coordinate-converter.js +8 -6
- package/dist/i3s-converter/helpers/feature-attributes.d.ts +56 -0
- package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/feature-attributes.js +216 -0
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-attributes.js +42 -17
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +18 -6
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +337 -92
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/gltf-attributes.js +51 -32
- 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 +81 -42
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-pages.js +201 -93
- package/dist/i3s-converter/i3s-converter.d.ts +52 -108
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +223 -421
- 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 +37 -55
- 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 +19 -2
- package/dist/lib/utils/write-queue.d.ts.map +1 -1
- package/dist/lib/utils/write-queue.js +26 -7
- package/dist/pgm-loader.d.ts.map +1 -1
- package/dist/pgm-loader.js +2 -1
- package/dist/workers/3d-tiles-attributes-worker.js +1 -1
- package/dist/workers/i3s-attributes-worker.js +1 -1
- package/package.json +18 -16
- package/src/3d-tiles-attributes-worker.ts +1 -1
- package/src/3d-tiles-converter/3d-tiles-converter.ts +71 -55
- package/src/3d-tiles-converter/helpers/b3dm-converter.ts +25 -18
- package/src/converter-cli.ts +38 -4
- package/src/deps-installer/deps-installer.ts +38 -2
- package/src/i3s-attributes-worker.ts +5 -1
- package/src/i3s-converter/helpers/batch-ids-extensions.ts +38 -14
- package/src/i3s-converter/helpers/coordinate-converter.ts +10 -8
- package/src/i3s-converter/helpers/feature-attributes.ts +247 -0
- package/src/i3s-converter/helpers/geometry-attributes.ts +46 -18
- package/src/i3s-converter/helpers/geometry-converter.ts +405 -108
- package/src/i3s-converter/helpers/gltf-attributes.ts +55 -35
- package/src/i3s-converter/helpers/node-index-document.ts +315 -0
- package/src/i3s-converter/helpers/node-pages.ts +222 -109
- package/src/i3s-converter/i3s-converter.ts +269 -500
- 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 +31 -51
- package/src/lib/utils/file-utils.ts +62 -7
- package/src/lib/utils/write-queue.ts +43 -10
- package/src/pgm-loader.ts +2 -2
- package/src/workers/3d-tiles-attributes-worker.ts +1 -1
- package/src/workers/i3s-attributes-worker.ts +2 -1
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
|
|
3
2
|
var _process$env;
|
|
4
|
-
|
|
5
3
|
import { load, encode, fetchFile, getLoaderOptions, isBrowser } from '@loaders.gl/core';
|
|
6
4
|
import { Tileset3D } from '@loaders.gl/tiles';
|
|
7
5
|
import { CesiumIonLoader, Tiles3DLoader } from '@loaders.gl/3d-tiles';
|
|
@@ -11,16 +9,17 @@ import process from 'process';
|
|
|
11
9
|
import transform from 'json-map-transform';
|
|
12
10
|
import md5 from 'md5';
|
|
13
11
|
import NodePages from './helpers/node-pages';
|
|
14
|
-
import { writeFile, removeDir, writeFileForSlpk } from '../lib/utils/file-utils';
|
|
15
|
-
import { compressWithChildProcess
|
|
12
|
+
import { writeFile, removeDir, writeFileForSlpk, removeFile } from '../lib/utils/file-utils';
|
|
13
|
+
import { compressFileWithGzip, compressWithChildProcess
|
|
14
|
+
} from '../lib/utils/compress-util';
|
|
16
15
|
import { calculateFilesSize, timeConverter } from '../lib/utils/statistic-utills';
|
|
17
|
-
import convertB3dmToI3sGeometry from './helpers/geometry-converter';
|
|
16
|
+
import convertB3dmToI3sGeometry, { getPropertyTable } from './helpers/geometry-converter';
|
|
18
17
|
import { createBoundingVolumes, convertBoundingVolumeToI3SFullExtent } from './helpers/coordinate-converter';
|
|
19
18
|
import { createSceneServerPath } from './helpers/create-scene-server-path';
|
|
20
19
|
import { convertGeometricErrorToScreenThreshold } from '../lib/utils/lod-conversion-utils';
|
|
21
20
|
import { PGMLoader } from '../pgm-loader';
|
|
22
21
|
import { LAYERS as layersTemplate } from './json-templates/layers';
|
|
23
|
-
import {
|
|
22
|
+
import { GEOMETRY_DEFINITION as geometryDefinitionTemlate } from './json-templates/geometry-definitions';
|
|
24
23
|
import { SHARED_RESOURCES as sharedResourcesTemplate } from './json-templates/shared-resources';
|
|
25
24
|
import { validateNodeBoundingVolumes } from './helpers/node-debug';
|
|
26
25
|
import { KTX2BasisWriterWorker } from '@loaders.gl/textures';
|
|
@@ -30,65 +29,49 @@ import { DracoWriterWorker } from '@loaders.gl/draco';
|
|
|
30
29
|
import WriteQueue from '../lib/utils/write-queue';
|
|
31
30
|
import { I3SAttributesWorker } from '../i3s-attributes-worker';
|
|
32
31
|
import { BROWSER_ERROR_MESSAGE } from '../constants';
|
|
33
|
-
|
|
32
|
+
import { createdStorageAttribute, createFieldAttribute, createPopupInfo, getAttributeType, getFieldAttributeType } from './helpers/feature-attributes';
|
|
33
|
+
import { NodeIndexDocument } from './helpers/node-index-document';
|
|
34
|
+
const ION_DEFAULT_TOKEN = ((_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env.IonToken) ||
|
|
35
|
+
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWMxMzcyYy0zZjJkLTQwODctODNlNi01MDRkZmMzMjIxOWIiLCJpZCI6OTYyMCwic2NvcGVzIjpbImFzbCIsImFzciIsImdjIl0sImlhdCI6MTU2Mjg2NjI3M30.1FNiClUyk00YH_nWfSGpiQAjR5V2OvREDq1PJ5QMjWQ';
|
|
34
36
|
const HARDCODED_NODES_PER_PAGE = 64;
|
|
35
37
|
const _3D_TILES = '3DTILES';
|
|
36
38
|
const _3D_OBJECT_LAYER_TYPE = '3DObject';
|
|
37
|
-
const STRING_TYPE = 'string';
|
|
38
|
-
const SHORT_INT_TYPE = 'Int32';
|
|
39
|
-
const DOUBLE_TYPE = 'double';
|
|
40
|
-
const OBJECT_ID_TYPE = 'OBJECTID';
|
|
41
39
|
const REFRESH_TOKEN_TIMEOUT = 1800;
|
|
42
40
|
const CESIUM_DATASET_PREFIX = 'https://';
|
|
41
|
+
|
|
43
42
|
export default class I3SConverter {
|
|
44
43
|
constructor() {
|
|
45
44
|
_defineProperty(this, "nodePages", void 0);
|
|
46
|
-
|
|
47
45
|
_defineProperty(this, "options", void 0);
|
|
48
|
-
|
|
49
46
|
_defineProperty(this, "layers0Path", void 0);
|
|
50
|
-
|
|
51
47
|
_defineProperty(this, "materialMap", void 0);
|
|
52
|
-
|
|
53
48
|
_defineProperty(this, "materialDefinitions", void 0);
|
|
54
|
-
|
|
49
|
+
_defineProperty(this, "geometryMap", void 0);
|
|
50
|
+
_defineProperty(this, "geometryConfigs", void 0);
|
|
55
51
|
_defineProperty(this, "vertexCounter", void 0);
|
|
56
|
-
|
|
57
52
|
_defineProperty(this, "layers0", void 0);
|
|
58
|
-
|
|
59
53
|
_defineProperty(this, "featuresHashArray", void 0);
|
|
60
|
-
|
|
61
54
|
_defineProperty(this, "refinementCounter", void 0);
|
|
62
|
-
|
|
63
55
|
_defineProperty(this, "validate", void 0);
|
|
64
|
-
|
|
65
56
|
_defineProperty(this, "boundingVolumeWarnings", []);
|
|
66
|
-
|
|
67
57
|
_defineProperty(this, "conversionStartTime", [0, 0]);
|
|
68
|
-
|
|
69
58
|
_defineProperty(this, "refreshTokenTime", [0, 0]);
|
|
70
|
-
|
|
71
59
|
_defineProperty(this, "sourceTileset", null);
|
|
72
|
-
|
|
73
60
|
_defineProperty(this, "geoidHeightModel", null);
|
|
74
|
-
|
|
75
61
|
_defineProperty(this, "Loader", Tiles3DLoader);
|
|
76
|
-
|
|
77
62
|
_defineProperty(this, "generateTextures", void 0);
|
|
78
|
-
|
|
79
63
|
_defineProperty(this, "generateBoundingVolumes", void 0);
|
|
80
|
-
|
|
81
64
|
_defineProperty(this, "layersHasTexture", void 0);
|
|
82
|
-
|
|
83
65
|
_defineProperty(this, "workerSource", {});
|
|
84
|
-
|
|
85
66
|
_defineProperty(this, "writeQueue", new WriteQueue());
|
|
86
|
-
|
|
87
|
-
this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);
|
|
67
|
+
_defineProperty(this, "compressList", null);
|
|
68
|
+
this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE, this);
|
|
88
69
|
this.options = {};
|
|
89
70
|
this.layers0Path = '';
|
|
90
71
|
this.materialMap = new Map();
|
|
91
72
|
this.materialDefinitions = [];
|
|
73
|
+
this.geometryMap = new Map();
|
|
74
|
+
this.geometryConfigs = [];
|
|
92
75
|
this.vertexCounter = 0;
|
|
93
76
|
this.layers0 = null;
|
|
94
77
|
this.featuresHashArray = [];
|
|
@@ -100,6 +83,7 @@ export default class I3SConverter {
|
|
|
100
83
|
this.generateTextures = false;
|
|
101
84
|
this.generateBoundingVolumes = false;
|
|
102
85
|
this.layersHasTexture = false;
|
|
86
|
+
this.compressList = null;
|
|
103
87
|
}
|
|
104
88
|
|
|
105
89
|
async convert(options) {
|
|
@@ -107,7 +91,6 @@ export default class I3SConverter {
|
|
|
107
91
|
console.log(BROWSER_ERROR_MESSAGE);
|
|
108
92
|
return BROWSER_ERROR_MESSAGE;
|
|
109
93
|
}
|
|
110
|
-
|
|
111
94
|
this.conversionStartTime = process.hrtime();
|
|
112
95
|
const {
|
|
113
96
|
tilesetName,
|
|
@@ -116,12 +99,14 @@ export default class I3SConverter {
|
|
|
116
99
|
inputUrl,
|
|
117
100
|
validate,
|
|
118
101
|
outputPath,
|
|
119
|
-
draco,
|
|
102
|
+
draco = true,
|
|
120
103
|
sevenZipExe,
|
|
121
104
|
maxDepth,
|
|
122
105
|
token,
|
|
123
106
|
generateTextures,
|
|
124
|
-
generateBoundingVolumes
|
|
107
|
+
generateBoundingVolumes,
|
|
108
|
+
instantNodeWriting = false,
|
|
109
|
+
mergeMaterials = true
|
|
125
110
|
} = options;
|
|
126
111
|
this.options = {
|
|
127
112
|
maxDepth,
|
|
@@ -130,8 +115,11 @@ export default class I3SConverter {
|
|
|
130
115
|
egmFilePath,
|
|
131
116
|
draco,
|
|
132
117
|
token,
|
|
133
|
-
inputUrl
|
|
118
|
+
inputUrl,
|
|
119
|
+
instantNodeWriting,
|
|
120
|
+
mergeMaterials
|
|
134
121
|
};
|
|
122
|
+
this.compressList = this.options.instantNodeWriting && [] || null;
|
|
135
123
|
this.validate = Boolean(validate);
|
|
136
124
|
this.Loader = inputUrl.indexOf(CESIUM_DATASET_PREFIX) !== -1 ? CesiumIonLoader : Tiles3DLoader;
|
|
137
125
|
this.generateTextures = Boolean(generateTextures);
|
|
@@ -145,29 +133,35 @@ export default class I3SConverter {
|
|
|
145
133
|
if (slpk) {
|
|
146
134
|
this.nodePages.useWriteFunction(writeFileForSlpk);
|
|
147
135
|
}
|
|
148
|
-
|
|
149
136
|
await this.loadWorkers();
|
|
150
|
-
|
|
151
137
|
try {
|
|
138
|
+
var _sourceTilesetJson$ro, _sourceTilesetJson$ro2;
|
|
152
139
|
const preloadOptions = await this._fetchPreloadOptions();
|
|
153
140
|
const tilesetOptions = {
|
|
154
141
|
loadOptions: {
|
|
142
|
+
_nodeWorkers: true,
|
|
143
|
+
reuseWorkers: true,
|
|
155
144
|
basis: {
|
|
156
145
|
format: 'rgba32'
|
|
146
|
+
},
|
|
147
|
+
'basis-nodejs': {
|
|
148
|
+
format: 'rgba32',
|
|
149
|
+
workerUrl: './modules/textures/dist/basis-nodejs-worker.js'
|
|
150
|
+
},
|
|
151
|
+
'draco-nodejs': {
|
|
152
|
+
workerUrl: './modules/draco/dist/draco-nodejs-worker.js'
|
|
157
153
|
}
|
|
158
154
|
}
|
|
159
155
|
};
|
|
160
|
-
|
|
161
156
|
if (preloadOptions.headers) {
|
|
162
157
|
tilesetOptions.loadOptions.fetch = {
|
|
163
158
|
headers: preloadOptions.headers
|
|
164
159
|
};
|
|
165
160
|
}
|
|
166
|
-
|
|
167
161
|
Object.assign(tilesetOptions, preloadOptions);
|
|
168
162
|
const sourceTilesetJson = await load(inputUrl, this.Loader, tilesetOptions.loadOptions);
|
|
169
163
|
this.sourceTileset = new Tileset3D(sourceTilesetJson, tilesetOptions);
|
|
170
|
-
await this._createAndSaveTileset(outputPath, tilesetName);
|
|
164
|
+
await this._createAndSaveTileset(outputPath, tilesetName, sourceTilesetJson === null || sourceTilesetJson === void 0 ? void 0 : (_sourceTilesetJson$ro = sourceTilesetJson.root) === null || _sourceTilesetJson$ro === void 0 ? void 0 : (_sourceTilesetJson$ro2 = _sourceTilesetJson$ro.boundingVolume) === null || _sourceTilesetJson$ro2 === void 0 ? void 0 : _sourceTilesetJson$ro2.region);
|
|
171
165
|
await this._finishConversion({
|
|
172
166
|
slpk: Boolean(slpk),
|
|
173
167
|
outputPath,
|
|
@@ -182,50 +176,54 @@ export default class I3SConverter {
|
|
|
182
176
|
}
|
|
183
177
|
}
|
|
184
178
|
|
|
185
|
-
async _createAndSaveTileset(outputPath, tilesetName) {
|
|
179
|
+
async _createAndSaveTileset(outputPath, tilesetName, boundingVolumeRegion) {
|
|
186
180
|
const tilesetPath = join("".concat(outputPath), "".concat(tilesetName));
|
|
187
|
-
|
|
188
181
|
try {
|
|
189
182
|
await removeDir(tilesetPath);
|
|
190
|
-
} catch (e) {
|
|
191
|
-
|
|
183
|
+
} catch (e) {
|
|
184
|
+
}
|
|
192
185
|
this.layers0Path = join(tilesetPath, 'SceneServer', 'layers', '0');
|
|
193
|
-
|
|
194
|
-
this._formLayers0(tilesetName);
|
|
195
|
-
|
|
186
|
+
this._formLayers0(tilesetName, boundingVolumeRegion);
|
|
196
187
|
this.materialDefinitions = [];
|
|
197
188
|
this.materialMap = new Map();
|
|
198
189
|
const sourceRootTile = this.sourceTileset.root;
|
|
199
190
|
const boundingVolumes = createBoundingVolumes(sourceRootTile, this.geoidHeightModel);
|
|
200
|
-
|
|
191
|
+
await this.nodePages.push({
|
|
201
192
|
index: 0,
|
|
202
193
|
lodThreshold: 0,
|
|
203
194
|
obb: boundingVolumes.obb,
|
|
204
195
|
children: []
|
|
205
196
|
});
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
const root0 = this._formRootNodeIndexDocument(boundingVolumes);
|
|
209
|
-
|
|
210
|
-
await this._convertNodesTree(root0, sourceRootTile, parentId, boundingVolumes);
|
|
197
|
+
const rootNode = await NodeIndexDocument.createRootNode(boundingVolumes, this);
|
|
198
|
+
await this._convertNodesTree(rootNode, sourceRootTile);
|
|
211
199
|
this.layers0.materialDefinitions = this.materialDefinitions;
|
|
212
|
-
|
|
200
|
+
this.layers0.geometryDefinitions = transform(this.geometryConfigs.map(config => ({
|
|
201
|
+
geometryConfig: {
|
|
202
|
+
...config,
|
|
203
|
+
draco: this.options.draco
|
|
204
|
+
}
|
|
205
|
+
})), geometryDefinitionTemlate());
|
|
213
206
|
if (this.layersHasTexture === false) {
|
|
214
207
|
this.layers0.store.defaultGeometrySchema.ordering = this.layers0.store.defaultGeometrySchema.ordering.filter(attribute => attribute !== 'uv0');
|
|
215
208
|
}
|
|
216
|
-
|
|
217
209
|
await this._writeLayers0();
|
|
218
210
|
createSceneServerPath(tilesetName, this.layers0, tilesetPath);
|
|
219
|
-
|
|
220
|
-
|
|
211
|
+
for (const filePath of this.compressList || []) {
|
|
212
|
+
await compressFileWithGzip(filePath);
|
|
213
|
+
await removeFile(filePath);
|
|
214
|
+
}
|
|
215
|
+
await this.nodePages.save();
|
|
221
216
|
await this.writeQueue.finalize();
|
|
222
217
|
await this._createSlpk(tilesetPath);
|
|
223
218
|
}
|
|
224
219
|
|
|
225
|
-
_formLayers0(tilesetName) {
|
|
220
|
+
_formLayers0(tilesetName, boundingVolumeRegion) {
|
|
226
221
|
var _this$sourceTileset, _this$sourceTileset2, _this$sourceTileset2$;
|
|
227
|
-
|
|
228
222
|
const fullExtent = convertBoundingVolumeToI3SFullExtent(((_this$sourceTileset = this.sourceTileset) === null || _this$sourceTileset === void 0 ? void 0 : _this$sourceTileset.boundingVolume) || ((_this$sourceTileset2 = this.sourceTileset) === null || _this$sourceTileset2 === void 0 ? void 0 : (_this$sourceTileset2$ = _this$sourceTileset2.root) === null || _this$sourceTileset2$ === void 0 ? void 0 : _this$sourceTileset2$.boundingVolume));
|
|
223
|
+
if (boundingVolumeRegion) {
|
|
224
|
+
fullExtent.zmin = boundingVolumeRegion[4];
|
|
225
|
+
fullExtent.zmax = boundingVolumeRegion[5];
|
|
226
|
+
}
|
|
229
227
|
const extent = [fullExtent.xmin, fullExtent.ymin, fullExtent.xmax, fullExtent.ymax];
|
|
230
228
|
const layers0data = {
|
|
231
229
|
version: "{".concat(uuidv4().toUpperCase(), "}"),
|
|
@@ -245,81 +243,34 @@ export default class I3SConverter {
|
|
|
245
243
|
this.layers0 = transform(layers0data, layersTemplate());
|
|
246
244
|
}
|
|
247
245
|
|
|
248
|
-
|
|
249
|
-
const root0data = {
|
|
250
|
-
version: "{".concat(uuidv4().toUpperCase(), "}"),
|
|
251
|
-
id: 'root',
|
|
252
|
-
level: 0,
|
|
253
|
-
lodSelection: [{
|
|
254
|
-
metricType: 'maxScreenThresholdSQ',
|
|
255
|
-
maxError: 0
|
|
256
|
-
}, {
|
|
257
|
-
metricType: 'maxScreenThreshold',
|
|
258
|
-
maxError: 0
|
|
259
|
-
}],
|
|
260
|
-
...boundingVolumes,
|
|
261
|
-
children: []
|
|
262
|
-
};
|
|
263
|
-
return transform(root0data, nodeTemplate());
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
async _convertNodesTree(root0, sourceRootTile, parentId, boundingVolumes) {
|
|
246
|
+
async _convertNodesTree(rootNode, sourceRootTile) {
|
|
267
247
|
await this.sourceTileset._loadTile(sourceRootTile);
|
|
268
|
-
|
|
269
248
|
if (this.isContentSupported(sourceRootTile)) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
href: './1',
|
|
274
|
-
...boundingVolumes
|
|
275
|
-
});
|
|
276
|
-
const [child] = await this._createNode(root0, sourceRootTile, parentId, 0);
|
|
277
|
-
const childPath = join(this.layers0Path, 'nodes', child.path);
|
|
278
|
-
|
|
279
|
-
if (this.options.slpk) {
|
|
280
|
-
this.writeQueue.enqueue({
|
|
281
|
-
archiveKey: 'nodes/1/3dNodeIndexDocument.json.gz',
|
|
282
|
-
writePromise: writeFileForSlpk(childPath, JSON.stringify(child), '3dNodeIndexDocument.json')
|
|
283
|
-
});
|
|
284
|
-
} else {
|
|
285
|
-
this.writeQueue.enqueue({
|
|
286
|
-
writePromise: writeFile(childPath, JSON.stringify(child))
|
|
287
|
-
});
|
|
249
|
+
const childNodes = await this._createNode(rootNode, sourceRootTile, 0);
|
|
250
|
+
for (const childNode of childNodes) {
|
|
251
|
+
await childNode.save();
|
|
288
252
|
}
|
|
253
|
+
await rootNode.addChildren(childNodes);
|
|
289
254
|
} else {
|
|
290
255
|
await this._addChildrenWithNeighborsAndWriteFile({
|
|
291
|
-
parentNode:
|
|
256
|
+
parentNode: rootNode,
|
|
292
257
|
sourceTiles: sourceRootTile.children,
|
|
293
|
-
parentId,
|
|
294
258
|
level: 1
|
|
295
259
|
});
|
|
296
260
|
}
|
|
297
|
-
|
|
298
261
|
await sourceRootTile.unloadContent();
|
|
262
|
+
await rootNode.save();
|
|
299
263
|
}
|
|
300
264
|
|
|
301
265
|
async _writeLayers0() {
|
|
302
266
|
if (this.options.slpk) {
|
|
303
|
-
this.writeQueue.enqueue({
|
|
267
|
+
await this.writeQueue.enqueue({
|
|
304
268
|
archiveKey: '3dSceneLayer.json.gz',
|
|
305
|
-
writePromise: writeFileForSlpk(this.layers0Path, JSON.stringify(this.layers0), '3dSceneLayer.json')
|
|
269
|
+
writePromise: () => writeFileForSlpk(this.layers0Path, JSON.stringify(this.layers0), '3dSceneLayer.json')
|
|
306
270
|
});
|
|
307
271
|
} else {
|
|
308
|
-
this.writeQueue.enqueue({
|
|
309
|
-
writePromise: writeFile(this.layers0Path, JSON.stringify(this.layers0))
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
async _writeNodeIndexDocument(root0, nodePath, rootPath) {
|
|
315
|
-
if (this.options.slpk) {
|
|
316
|
-
this.writeQueue.enqueue({
|
|
317
|
-
archiveKey: "nodes/".concat(nodePath, "/3dNodeIndexDocument.json.gz"),
|
|
318
|
-
writePromise: writeFileForSlpk(rootPath, JSON.stringify(root0), '3dNodeIndexDocument.json')
|
|
319
|
-
});
|
|
320
|
-
} else {
|
|
321
|
-
this.writeQueue.enqueue({
|
|
322
|
-
writePromise: writeFile(rootPath, JSON.stringify(root0))
|
|
272
|
+
await this.writeQueue.enqueue({
|
|
273
|
+
writePromise: () => writeFile(this.layers0Path, JSON.stringify(this.layers0))
|
|
323
274
|
});
|
|
324
275
|
}
|
|
325
276
|
}
|
|
@@ -332,115 +283,89 @@ export default class I3SConverter {
|
|
|
332
283
|
|
|
333
284
|
try {
|
|
334
285
|
await removeDir(tilesetPath);
|
|
335
|
-
} catch (e) {
|
|
286
|
+
} catch (e) {
|
|
287
|
+
}
|
|
336
288
|
}
|
|
337
289
|
}
|
|
338
290
|
|
|
339
291
|
async _addChildrenWithNeighborsAndWriteFile(data) {
|
|
340
|
-
|
|
341
|
-
await
|
|
342
|
-
|
|
292
|
+
await this._addChildren(data);
|
|
293
|
+
await data.parentNode.addNeighbors();
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
async convertNestedTileset(_ref) {
|
|
297
|
+
let {
|
|
298
|
+
parentNode,
|
|
299
|
+
sourceTile,
|
|
300
|
+
level
|
|
301
|
+
} = _ref;
|
|
302
|
+
await this.sourceTileset._loadTile(sourceTile);
|
|
303
|
+
await this._addChildren({
|
|
304
|
+
parentNode,
|
|
305
|
+
sourceTiles: sourceTile.children,
|
|
306
|
+
level: level + 1
|
|
343
307
|
});
|
|
344
|
-
await
|
|
308
|
+
await sourceTile.unloadContent();
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
async convertNode(_ref2) {
|
|
312
|
+
let {
|
|
313
|
+
parentNode,
|
|
314
|
+
sourceTile,
|
|
315
|
+
level
|
|
316
|
+
} = _ref2;
|
|
317
|
+
const childNodes = await this._createNode(parentNode, sourceTile, level);
|
|
318
|
+
await parentNode.addChildren(childNodes);
|
|
345
319
|
}
|
|
346
320
|
|
|
347
321
|
async _addChildren(data) {
|
|
348
322
|
const {
|
|
349
|
-
childNodes,
|
|
350
323
|
sourceTiles,
|
|
351
324
|
parentNode,
|
|
352
|
-
parentId,
|
|
353
325
|
level
|
|
354
326
|
} = data;
|
|
355
|
-
|
|
356
327
|
if (this.options.maxDepth && level > this.options.maxDepth) {
|
|
357
328
|
return;
|
|
358
329
|
}
|
|
359
|
-
|
|
360
330
|
for (const sourceTile of sourceTiles) {
|
|
361
331
|
if (sourceTile.type === 'json') {
|
|
362
|
-
await this.
|
|
363
|
-
await this._addChildren({
|
|
332
|
+
await this.convertNestedTileset({
|
|
364
333
|
parentNode,
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
parentId,
|
|
368
|
-
level: level + 1
|
|
334
|
+
sourceTile,
|
|
335
|
+
level
|
|
369
336
|
});
|
|
370
|
-
await sourceTile.unloadContent();
|
|
371
337
|
} else {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
id: child.id,
|
|
378
|
-
href: "../".concat(child.path),
|
|
379
|
-
obb: child.obb,
|
|
380
|
-
mbs: child.mbs
|
|
381
|
-
});
|
|
382
|
-
childNodes.push(child);
|
|
383
|
-
}
|
|
338
|
+
await this.convertNode({
|
|
339
|
+
parentNode,
|
|
340
|
+
sourceTile,
|
|
341
|
+
level
|
|
342
|
+
});
|
|
384
343
|
}
|
|
385
|
-
|
|
386
344
|
if (sourceTile.id) {
|
|
387
345
|
console.log(sourceTile.id);
|
|
388
346
|
}
|
|
389
347
|
}
|
|
390
348
|
}
|
|
391
349
|
|
|
392
|
-
async
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
const childPath = join(this.layers0Path, 'nodes', node.path);
|
|
397
|
-
const nodePath = node.path;
|
|
398
|
-
delete node.path;
|
|
399
|
-
|
|
400
|
-
if (Number(parentNode === null || parentNode === void 0 ? void 0 : (_parentNode$children = parentNode.children) === null || _parentNode$children === void 0 ? void 0 : _parentNode$children.length) < 1000) {
|
|
401
|
-
for (const neighbor of parentNode.children || []) {
|
|
402
|
-
if (node.id === neighbor.id) {
|
|
403
|
-
continue;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
if (node.neighbors) {
|
|
407
|
-
node.neighbors.push({ ...neighbor
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
} else {
|
|
412
|
-
console.warn("Node ".concat(node.id, ": neighbors attribute is omited because of large number of neigbors"));
|
|
413
|
-
delete node.neighbors;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
await this._writeNodeIndexDocument(node, nodePath, childPath);
|
|
417
|
-
node.neighbors = [];
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
async _createNode(parentTile, sourceTile, parentId, level) {
|
|
422
|
-
var _sourceTile$content;
|
|
423
|
-
|
|
424
|
-
if (this.validate) {
|
|
425
|
-
this._checkAddRefinementTypeForTile(sourceTile);
|
|
426
|
-
}
|
|
427
|
-
|
|
350
|
+
async _createNode(parentNode, sourceTile, level) {
|
|
351
|
+
var _this$layers, _this$layers$attribut;
|
|
352
|
+
this._checkAddRefinementTypeForTile(sourceTile);
|
|
428
353
|
await this._updateTilesetOptions();
|
|
429
354
|
await this.sourceTileset._loadTile(sourceTile);
|
|
430
355
|
let boundingVolumes = createBoundingVolumes(sourceTile, this.geoidHeightModel);
|
|
431
|
-
const
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
this._convertAttributeStorageInfo(sourceTile.content);
|
|
356
|
+
const propertyTable = getPropertyTable(sourceTile.content);
|
|
357
|
+
if (propertyTable && !((_this$layers = this.layers0) !== null && _this$layers !== void 0 && (_this$layers$attribut = _this$layers.attributeStorageInfo) !== null && _this$layers$attribut !== void 0 && _this$layers$attribut.length)) {
|
|
358
|
+
this._convertPropertyTableToNodeAttributes(propertyTable);
|
|
435
359
|
}
|
|
436
|
-
|
|
437
|
-
const resourcesData = await this._convertResources(sourceTile);
|
|
360
|
+
const resourcesData = await this._convertResources(sourceTile, parentNode.inPageId, propertyTable);
|
|
438
361
|
const nodes = [];
|
|
362
|
+
const nodeIds = [];
|
|
439
363
|
const nodesInPage = [];
|
|
440
364
|
const emptyResources = {
|
|
441
365
|
geometry: null,
|
|
442
366
|
compressedGeometry: null,
|
|
443
367
|
texture: null,
|
|
368
|
+
hasUvRegions: false,
|
|
444
369
|
sharedResources: null,
|
|
445
370
|
meshMaterial: null,
|
|
446
371
|
vertexCount: null,
|
|
@@ -448,77 +373,66 @@ export default class I3SConverter {
|
|
|
448
373
|
featureCount: null,
|
|
449
374
|
boundingVolumes: null
|
|
450
375
|
};
|
|
451
|
-
|
|
452
376
|
for (const resources of resourcesData || [emptyResources]) {
|
|
453
377
|
this.layersHasTexture = this.layersHasTexture || Boolean(resources.texture);
|
|
454
|
-
|
|
455
378
|
if (this.generateBoundingVolumes && resources.boundingVolumes) {
|
|
456
379
|
boundingVolumes = resources.boundingVolumes;
|
|
457
380
|
}
|
|
458
|
-
|
|
459
381
|
const lodSelection = convertGeometricErrorToScreenThreshold(sourceTile, boundingVolumes);
|
|
460
382
|
const maxScreenThresholdSQ = lodSelection.find(val => val.metricType === 'maxScreenThresholdSQ') || {
|
|
461
383
|
maxError: 0
|
|
462
384
|
};
|
|
463
|
-
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
385
|
+
const nodeInPage = await this._updateNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentNode.inPageId, resources);
|
|
386
|
+
const nodeData = await NodeIndexDocument.createNodeIndexDocument(parentNode, boundingVolumes, lodSelection, nodeInPage, resources);
|
|
387
|
+
const node = await new NodeIndexDocument(nodeInPage.index, this).addData(nodeData);
|
|
388
|
+
nodes.push(node);
|
|
468
389
|
if (nodeInPage.mesh) {
|
|
469
|
-
await this._writeResources(resources, node.
|
|
390
|
+
await this._writeResources(resources, node.id);
|
|
470
391
|
}
|
|
471
|
-
|
|
472
392
|
if (this.validate) {
|
|
473
|
-
this.boundingVolumeWarnings = validateNodeBoundingVolumes(
|
|
474
|
-
|
|
393
|
+
this.boundingVolumeWarnings = validateNodeBoundingVolumes(nodeData);
|
|
475
394
|
if (this.boundingVolumeWarnings && this.boundingVolumeWarnings.length) {
|
|
476
395
|
console.warn('Bounding Volume Warnings: ', ...this.boundingVolumeWarnings);
|
|
477
396
|
}
|
|
478
397
|
}
|
|
479
398
|
|
|
480
|
-
|
|
399
|
+
nodeIds.push(nodeInPage.index);
|
|
481
400
|
nodesInPage.push(nodeInPage);
|
|
482
401
|
}
|
|
483
|
-
|
|
484
402
|
sourceTile.unloadContent();
|
|
485
403
|
await this._addChildrenWithNeighborsAndWriteFile({
|
|
486
404
|
parentNode: nodes[0],
|
|
487
405
|
sourceTiles: sourceTile.children,
|
|
488
|
-
parentId: nodesInPage[0].index,
|
|
489
406
|
level: level + 1
|
|
490
407
|
});
|
|
491
408
|
return nodes;
|
|
492
409
|
}
|
|
493
410
|
|
|
494
|
-
|
|
495
|
-
var _this$layers, _this$layers$attribut;
|
|
496
|
-
|
|
497
|
-
const batchTable = sourceTileContent && sourceTileContent.batchTableJson;
|
|
498
|
-
|
|
499
|
-
if (batchTable && !((_this$layers = this.layers0) !== null && _this$layers !== void 0 && (_this$layers$attribut = _this$layers.attributeStorageInfo) !== null && _this$layers$attribut !== void 0 && _this$layers$attribut.length)) {
|
|
500
|
-
this._convertBatchTableInfoToNodeAttributes(batchTable);
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
async _convertResources(sourceTile) {
|
|
411
|
+
async _convertResources(sourceTile, parentId, propertyTable) {
|
|
505
412
|
var _this$layers2;
|
|
506
|
-
|
|
507
413
|
if (!this.isContentSupported(sourceTile)) {
|
|
508
414
|
return null;
|
|
509
415
|
}
|
|
510
|
-
|
|
511
|
-
|
|
416
|
+
const draftObb = {
|
|
417
|
+
center: [],
|
|
418
|
+
halfSize: [],
|
|
419
|
+
quaternion: []
|
|
420
|
+
};
|
|
421
|
+
const resourcesData = await convertB3dmToI3sGeometry(sourceTile.content, async () => (await this.nodePages.push({
|
|
422
|
+
index: 0,
|
|
423
|
+
obb: draftObb
|
|
424
|
+
}, parentId)).index, propertyTable, this.featuresHashArray, (_this$layers2 = this.layers0) === null || _this$layers2 === void 0 ? void 0 : _this$layers2.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.options.mergeMaterials, this.geoidHeightModel, this.workerSource);
|
|
512
425
|
return resourcesData;
|
|
513
426
|
}
|
|
514
427
|
|
|
515
|
-
|
|
428
|
+
async _updateNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentId, resources) {
|
|
516
429
|
const {
|
|
517
430
|
meshMaterial,
|
|
518
431
|
texture,
|
|
519
432
|
vertexCount,
|
|
520
433
|
featureCount,
|
|
521
|
-
geometry
|
|
434
|
+
geometry,
|
|
435
|
+
hasUvRegions
|
|
522
436
|
} = resources;
|
|
523
437
|
const nodeInPage = {
|
|
524
438
|
index: 0,
|
|
@@ -526,11 +440,10 @@ export default class I3SConverter {
|
|
|
526
440
|
obb: boundingVolumes.obb,
|
|
527
441
|
children: []
|
|
528
442
|
};
|
|
529
|
-
|
|
530
443
|
if (geometry && this.isContentSupported(sourceTile)) {
|
|
531
444
|
nodeInPage.mesh = {
|
|
532
445
|
geometry: {
|
|
533
|
-
definition: texture
|
|
446
|
+
definition: this.findOrCreateGeometryDefinition(Boolean(texture), hasUvRegions),
|
|
534
447
|
resource: 0
|
|
535
448
|
},
|
|
536
449
|
attribute: {
|
|
@@ -541,86 +454,30 @@ export default class I3SConverter {
|
|
|
541
454
|
}
|
|
542
455
|
};
|
|
543
456
|
}
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
457
|
+
let nodeId = resources.nodeId;
|
|
458
|
+
let node;
|
|
459
|
+
if (!nodeId) {
|
|
460
|
+
node = await this.nodePages.push(nodeInPage, parentId);
|
|
461
|
+
} else {
|
|
462
|
+
node = await this.nodePages.getNodeById(nodeId);
|
|
463
|
+
}
|
|
464
|
+
NodePages.updateAll(node, nodeInPage);
|
|
547
465
|
if (meshMaterial) {
|
|
548
|
-
|
|
466
|
+
NodePages.updateMaterialByNodeId(node, this._findOrCreateMaterial(meshMaterial));
|
|
549
467
|
}
|
|
550
|
-
|
|
551
468
|
if (texture) {
|
|
552
469
|
const texelCountHint = texture.image.height * texture.image.width;
|
|
553
|
-
|
|
470
|
+
NodePages.updateTexelCountHintByNodeId(node, texelCountHint);
|
|
554
471
|
}
|
|
555
|
-
|
|
556
472
|
if (vertexCount) {
|
|
557
473
|
this.vertexCounter += vertexCount;
|
|
558
|
-
|
|
474
|
+
NodePages.updateVertexCountByNodeId(node, vertexCount);
|
|
559
475
|
}
|
|
560
|
-
|
|
561
|
-
this.nodePages.updateNodeAttributeByNodeId(nodeId);
|
|
562
|
-
|
|
476
|
+
NodePages.updateNodeAttributeByNodeId(node);
|
|
563
477
|
if (featureCount) {
|
|
564
|
-
|
|
478
|
+
NodePages.updateFeatureCountByNodeId(node, featureCount);
|
|
565
479
|
}
|
|
566
|
-
|
|
567
|
-
return nodeInPage;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
_createNodeIndexDocument(parentNode, boundingVolumes, lodSelection, nodeInPage, resources) {
|
|
571
|
-
const {
|
|
572
|
-
texture,
|
|
573
|
-
attributes
|
|
574
|
-
} = resources;
|
|
575
|
-
const nodeId = nodeInPage.index;
|
|
576
|
-
const nodeData = {
|
|
577
|
-
version: parentNode.version,
|
|
578
|
-
id: nodeId.toString(),
|
|
579
|
-
path: nodeId.toString(),
|
|
580
|
-
level: parentNode.level + 1,
|
|
581
|
-
...boundingVolumes,
|
|
582
|
-
lodSelection,
|
|
583
|
-
parentNode: {
|
|
584
|
-
id: parentNode.id,
|
|
585
|
-
href: "../".concat(parentNode.id),
|
|
586
|
-
mbs: parentNode.mbs,
|
|
587
|
-
obb: parentNode.obb
|
|
588
|
-
},
|
|
589
|
-
children: [],
|
|
590
|
-
neighbors: []
|
|
591
|
-
};
|
|
592
|
-
const node = transform(nodeData, nodeTemplate());
|
|
593
|
-
|
|
594
|
-
if (nodeInPage.mesh) {
|
|
595
|
-
var _this$layers3, _this$layers3$attribu;
|
|
596
|
-
|
|
597
|
-
node.geometryData = [{
|
|
598
|
-
href: './geometries/0'
|
|
599
|
-
}];
|
|
600
|
-
node.sharedResource = {
|
|
601
|
-
href: './shared'
|
|
602
|
-
};
|
|
603
|
-
|
|
604
|
-
if (texture) {
|
|
605
|
-
node.textureData = [{
|
|
606
|
-
href: './textures/0'
|
|
607
|
-
}, {
|
|
608
|
-
href: './textures/1'
|
|
609
|
-
}];
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
if (attributes && attributes.length && (_this$layers3 = this.layers0) !== null && _this$layers3 !== void 0 && (_this$layers3$attribu = _this$layers3.attributeStorageInfo) !== null && _this$layers3$attribu !== void 0 && _this$layers3$attribu.length) {
|
|
613
|
-
node.attributeData = [];
|
|
614
|
-
|
|
615
|
-
for (let index = 0; index < attributes.length; index++) {
|
|
616
|
-
const folderName = this.layers0.attributeStorageInfo[index].key;
|
|
617
|
-
node.attributeData.push({
|
|
618
|
-
href: "./attributes/".concat(folderName, "/0")
|
|
619
|
-
});
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
|
|
480
|
+
this.nodePages.saveNode(node);
|
|
624
481
|
return node;
|
|
625
482
|
}
|
|
626
483
|
|
|
@@ -643,28 +500,27 @@ export default class I3SConverter {
|
|
|
643
500
|
async _writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath) {
|
|
644
501
|
if (this.options.slpk) {
|
|
645
502
|
const slpkGeometryPath = join(childPath, 'geometries');
|
|
646
|
-
this.writeQueue.enqueue({
|
|
503
|
+
await this.writeQueue.enqueue({
|
|
647
504
|
archiveKey: "".concat(slpkChildPath, "/geometries/0.bin.gz"),
|
|
648
|
-
writePromise: writeFileForSlpk(slpkGeometryPath, geometryBuffer, '0.bin')
|
|
505
|
+
writePromise: () => writeFileForSlpk(slpkGeometryPath, geometryBuffer, '0.bin')
|
|
649
506
|
});
|
|
650
507
|
} else {
|
|
651
508
|
const geometryPath = join(childPath, 'geometries/0/');
|
|
652
|
-
this.writeQueue.enqueue({
|
|
653
|
-
writePromise: writeFile(geometryPath, geometryBuffer, 'index.bin')
|
|
509
|
+
await this.writeQueue.enqueue({
|
|
510
|
+
writePromise: () => writeFile(geometryPath, geometryBuffer, 'index.bin')
|
|
654
511
|
});
|
|
655
512
|
}
|
|
656
|
-
|
|
657
513
|
if (this.options.draco) {
|
|
658
514
|
if (this.options.slpk) {
|
|
659
515
|
const slpkCompressedGeometryPath = join(childPath, 'geometries');
|
|
660
|
-
this.writeQueue.enqueue({
|
|
516
|
+
await this.writeQueue.enqueue({
|
|
661
517
|
archiveKey: "".concat(slpkChildPath, "/geometries/1.bin.gz"),
|
|
662
|
-
writePromise: writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, '1.bin')
|
|
518
|
+
writePromise: () => writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, '1.bin')
|
|
663
519
|
});
|
|
664
520
|
} else {
|
|
665
521
|
const compressedGeometryPath = join(childPath, 'geometries/1/');
|
|
666
|
-
this.writeQueue.enqueue({
|
|
667
|
-
writePromise: writeFile(compressedGeometryPath, compressedGeometry, 'index.bin')
|
|
522
|
+
await this.writeQueue.enqueue({
|
|
523
|
+
writePromise: () => writeFile(compressedGeometryPath, compressedGeometry, 'index.bin')
|
|
668
524
|
});
|
|
669
525
|
}
|
|
670
526
|
}
|
|
@@ -674,21 +530,19 @@ export default class I3SConverter {
|
|
|
674
530
|
if (!sharedResources) {
|
|
675
531
|
return;
|
|
676
532
|
}
|
|
677
|
-
|
|
678
533
|
sharedResources.nodePath = nodePath;
|
|
679
534
|
const sharedData = transform(sharedResources, sharedResourcesTemplate());
|
|
680
535
|
const sharedDataStr = JSON.stringify(sharedData);
|
|
681
|
-
|
|
682
536
|
if (this.options.slpk) {
|
|
683
537
|
const slpkSharedPath = join(childPath, 'shared');
|
|
684
|
-
this.writeQueue.enqueue({
|
|
538
|
+
await this.writeQueue.enqueue({
|
|
685
539
|
archiveKey: "".concat(slpkChildPath, "/shared/sharedResource.json.gz"),
|
|
686
|
-
writePromise: writeFileForSlpk(slpkSharedPath, sharedDataStr, 'sharedResource.json')
|
|
540
|
+
writePromise: () => writeFileForSlpk(slpkSharedPath, sharedDataStr, 'sharedResource.json')
|
|
687
541
|
});
|
|
688
542
|
} else {
|
|
689
543
|
const sharedPath = join(childPath, 'shared/');
|
|
690
|
-
this.writeQueue.enqueue({
|
|
691
|
-
writePromise: writeFile(sharedPath, sharedDataStr)
|
|
544
|
+
await this.writeQueue.enqueue({
|
|
545
|
+
writePromise: () => writeFile(sharedPath, sharedDataStr)
|
|
692
546
|
});
|
|
693
547
|
}
|
|
694
548
|
}
|
|
@@ -696,10 +550,8 @@ export default class I3SConverter {
|
|
|
696
550
|
async _writeTexture(texture, childPath, slpkChildPath) {
|
|
697
551
|
if (texture) {
|
|
698
552
|
const format = this._getFormatByMimeType(texture === null || texture === void 0 ? void 0 : texture.mimeType);
|
|
699
|
-
|
|
700
553
|
const formats = [];
|
|
701
554
|
const textureData = texture.bufferView.data;
|
|
702
|
-
|
|
703
555
|
switch (format) {
|
|
704
556
|
case 'jpg':
|
|
705
557
|
case 'png':
|
|
@@ -709,7 +561,6 @@ export default class I3SConverter {
|
|
|
709
561
|
format
|
|
710
562
|
});
|
|
711
563
|
await this.writeTextureFile(textureData, '0', format, childPath, slpkChildPath);
|
|
712
|
-
|
|
713
564
|
if (this.generateTextures) {
|
|
714
565
|
formats.push({
|
|
715
566
|
name: '1',
|
|
@@ -717,19 +568,19 @@ export default class I3SConverter {
|
|
|
717
568
|
});
|
|
718
569
|
const copyArrayBuffer = texture.image.data.subarray();
|
|
719
570
|
const arrayToEncode = new Uint8Array(copyArrayBuffer);
|
|
720
|
-
const ktx2TextureData = encode({
|
|
571
|
+
const ktx2TextureData = encode({
|
|
572
|
+
...texture.image,
|
|
721
573
|
data: arrayToEncode
|
|
722
|
-
}, KTX2BasisWriterWorker, {
|
|
574
|
+
}, KTX2BasisWriterWorker, {
|
|
575
|
+
...KTX2BasisWriterWorker.options,
|
|
723
576
|
source: this.workerSource.ktx2,
|
|
724
577
|
reuseWorkers: true,
|
|
725
578
|
_nodeWorkers: true
|
|
726
579
|
});
|
|
727
580
|
await this.writeTextureFile(ktx2TextureData, '1', 'ktx2', childPath, slpkChildPath);
|
|
728
581
|
}
|
|
729
|
-
|
|
730
582
|
break;
|
|
731
583
|
}
|
|
732
|
-
|
|
733
584
|
case 'ktx2':
|
|
734
585
|
{
|
|
735
586
|
formats.push({
|
|
@@ -737,7 +588,6 @@ export default class I3SConverter {
|
|
|
737
588
|
format
|
|
738
589
|
});
|
|
739
590
|
await this.writeTextureFile(textureData, '1', format, childPath, slpkChildPath);
|
|
740
|
-
|
|
741
591
|
if (this.generateTextures) {
|
|
742
592
|
formats.push({
|
|
743
593
|
name: '0',
|
|
@@ -748,11 +598,14 @@ export default class I3SConverter {
|
|
|
748
598
|
}
|
|
749
599
|
}
|
|
750
600
|
}
|
|
751
|
-
|
|
752
601
|
if (!this.layers0.textureSetDefinitions.length) {
|
|
753
602
|
this.layers0.textureSetDefinitions.push({
|
|
754
603
|
formats
|
|
755
604
|
});
|
|
605
|
+
this.layers0.textureSetDefinitions.push({
|
|
606
|
+
formats,
|
|
607
|
+
atlas: true
|
|
608
|
+
});
|
|
756
609
|
}
|
|
757
610
|
}
|
|
758
611
|
}
|
|
@@ -761,36 +614,37 @@ export default class I3SConverter {
|
|
|
761
614
|
if (this.options.slpk) {
|
|
762
615
|
const slpkTexturePath = join(childPath, 'textures');
|
|
763
616
|
const compress = false;
|
|
764
|
-
this.writeQueue.enqueue({
|
|
617
|
+
await this.writeQueue.enqueue({
|
|
765
618
|
archiveKey: "".concat(slpkChildPath, "/textures/").concat(name, ".").concat(format),
|
|
766
|
-
writePromise: writeFileForSlpk(slpkTexturePath, textureData, "".concat(name, ".").concat(format), compress)
|
|
619
|
+
writePromise: () => writeFileForSlpk(slpkTexturePath, textureData, "".concat(name, ".").concat(format), compress)
|
|
767
620
|
});
|
|
768
621
|
} else {
|
|
769
622
|
const texturePath = join(childPath, "textures/".concat(name, "/"));
|
|
770
|
-
this.writeQueue.enqueue({
|
|
771
|
-
writePromise: writeFile(texturePath, textureData, "index.".concat(format))
|
|
623
|
+
await this.writeQueue.enqueue({
|
|
624
|
+
writePromise: () => writeFile(texturePath, textureData, "index.".concat(format))
|
|
772
625
|
});
|
|
773
626
|
}
|
|
774
627
|
}
|
|
775
628
|
|
|
776
|
-
async _writeAttributes(
|
|
777
|
-
var _this$
|
|
778
|
-
|
|
779
|
-
|
|
629
|
+
async _writeAttributes() {
|
|
630
|
+
var _this$layers3, _this$layers3$attribu;
|
|
631
|
+
let attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
632
|
+
let childPath = arguments.length > 1 ? arguments[1] : undefined;
|
|
633
|
+
let slpkChildPath = arguments.length > 2 ? arguments[2] : undefined;
|
|
634
|
+
if (attributes !== null && attributes !== void 0 && attributes.length && (_this$layers3 = this.layers0) !== null && _this$layers3 !== void 0 && (_this$layers3$attribu = _this$layers3.attributeStorageInfo) !== null && _this$layers3$attribu !== void 0 && _this$layers3$attribu.length) {
|
|
780
635
|
for (let index = 0; index < attributes.length; index++) {
|
|
781
636
|
const folderName = this.layers0.attributeStorageInfo[index].key;
|
|
782
637
|
const fileBuffer = new Uint8Array(attributes[index]);
|
|
783
|
-
|
|
784
638
|
if (this.options.slpk) {
|
|
785
639
|
const slpkAttributesPath = join(childPath, 'attributes', folderName);
|
|
786
|
-
this.writeQueue.enqueue({
|
|
640
|
+
await this.writeQueue.enqueue({
|
|
787
641
|
archiveKey: "".concat(slpkChildPath, "/attributes/").concat(folderName, ".bin.gz"),
|
|
788
|
-
writePromise: writeFileForSlpk(slpkAttributesPath, fileBuffer, '0.bin')
|
|
642
|
+
writePromise: () => writeFileForSlpk(slpkAttributesPath, fileBuffer, '0.bin')
|
|
789
643
|
});
|
|
790
644
|
} else {
|
|
791
645
|
const attributesPath = join(childPath, "attributes/".concat(folderName, "/0"));
|
|
792
|
-
this.writeQueue.enqueue({
|
|
793
|
-
writePromise: writeFile(attributesPath, fileBuffer, 'index.bin')
|
|
646
|
+
await this.writeQueue.enqueue({
|
|
647
|
+
writePromise: () => writeFile(attributesPath, fileBuffer, 'index.bin')
|
|
794
648
|
});
|
|
795
649
|
}
|
|
796
650
|
}
|
|
@@ -801,13 +655,10 @@ export default class I3SConverter {
|
|
|
801
655
|
switch (mimeType) {
|
|
802
656
|
case 'image/jpeg':
|
|
803
657
|
return 'jpg';
|
|
804
|
-
|
|
805
658
|
case 'image/png':
|
|
806
659
|
return 'png';
|
|
807
|
-
|
|
808
660
|
case 'image/ktx2':
|
|
809
661
|
return 'ktx2';
|
|
810
|
-
|
|
811
662
|
default:
|
|
812
663
|
return 'jpg';
|
|
813
664
|
}
|
|
@@ -815,130 +666,41 @@ export default class I3SConverter {
|
|
|
815
666
|
|
|
816
667
|
_findOrCreateMaterial(material) {
|
|
817
668
|
const hash = md5(JSON.stringify(material));
|
|
818
|
-
|
|
819
669
|
if (this.materialMap.has(hash)) {
|
|
820
|
-
return this.materialMap.get(hash);
|
|
670
|
+
return this.materialMap.get(hash) || 0;
|
|
821
671
|
}
|
|
822
|
-
|
|
823
672
|
const newMaterialId = this.materialDefinitions.push(material) - 1;
|
|
824
673
|
this.materialMap.set(hash, newMaterialId);
|
|
825
674
|
return newMaterialId;
|
|
826
675
|
}
|
|
827
676
|
|
|
828
|
-
|
|
829
|
-
const
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
ordering: ['attributeValues'],
|
|
833
|
-
header: [{
|
|
834
|
-
property: 'count',
|
|
835
|
-
valueType: 'UInt32'
|
|
836
|
-
}],
|
|
837
|
-
attributeValues: {
|
|
838
|
-
valueType: 'Int32',
|
|
839
|
-
valuesPerElement: 1
|
|
840
|
-
}
|
|
677
|
+
findOrCreateGeometryDefinition(hasTexture, hasUvRegions) {
|
|
678
|
+
const geometryConfig = {
|
|
679
|
+
hasTexture,
|
|
680
|
+
hasUvRegions
|
|
841
681
|
};
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
this._setupIdAttribute(storageAttribute);
|
|
846
|
-
|
|
847
|
-
break;
|
|
848
|
-
|
|
849
|
-
case STRING_TYPE:
|
|
850
|
-
this._setupStringAttribute(storageAttribute);
|
|
851
|
-
|
|
852
|
-
break;
|
|
853
|
-
|
|
854
|
-
case DOUBLE_TYPE:
|
|
855
|
-
this._setupDoubleAttribute(storageAttribute);
|
|
856
|
-
|
|
857
|
-
break;
|
|
858
|
-
|
|
859
|
-
case SHORT_INT_TYPE:
|
|
860
|
-
break;
|
|
861
|
-
|
|
862
|
-
default:
|
|
863
|
-
this._setupStringAttribute(storageAttribute);
|
|
864
|
-
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
return storageAttribute;
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
getAttributeType(key, attribute) {
|
|
871
|
-
if (key === OBJECT_ID_TYPE) {
|
|
872
|
-
return OBJECT_ID_TYPE;
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
if (typeof attribute === STRING_TYPE) {
|
|
876
|
-
return STRING_TYPE;
|
|
877
|
-
} else if (typeof attribute === 'number') {
|
|
878
|
-
return Number.isInteger(attribute) ? SHORT_INT_TYPE : DOUBLE_TYPE;
|
|
682
|
+
const hash = md5(JSON.stringify(geometryConfig));
|
|
683
|
+
if (this.geometryMap.has(hash)) {
|
|
684
|
+
return this.geometryMap.get(hash) || 0;
|
|
879
685
|
}
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
_setupStringAttribute(storageAttribute) {
|
|
885
|
-
storageAttribute.ordering.unshift('attributeByteCounts');
|
|
886
|
-
storageAttribute.header.push({
|
|
887
|
-
property: 'attributeValuesByteCount',
|
|
888
|
-
valueType: 'UInt32'
|
|
889
|
-
});
|
|
890
|
-
storageAttribute.attributeValues = {
|
|
891
|
-
valueType: 'String',
|
|
892
|
-
encoding: 'UTF-8',
|
|
893
|
-
valuesPerElement: 1
|
|
894
|
-
};
|
|
895
|
-
storageAttribute.attributeByteCounts = {
|
|
896
|
-
valueType: 'UInt32',
|
|
897
|
-
valuesPerElement: 1
|
|
898
|
-
};
|
|
686
|
+
const newGeometryId = this.geometryConfigs.push(geometryConfig) - 1;
|
|
687
|
+
this.geometryMap.set(hash, newGeometryId);
|
|
688
|
+
return newGeometryId;
|
|
899
689
|
}
|
|
900
690
|
|
|
901
|
-
|
|
902
|
-
storageAttribute.attributeValues = {
|
|
903
|
-
valueType: 'Oid32',
|
|
904
|
-
valuesPerElement: 1
|
|
905
|
-
};
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
_setupDoubleAttribute(storageAttribute) {
|
|
909
|
-
storageAttribute.attributeValues = {
|
|
910
|
-
valueType: 'Float64',
|
|
911
|
-
valuesPerElement: 1
|
|
912
|
-
};
|
|
913
|
-
}
|
|
914
|
-
|
|
915
|
-
_createFieldAttribute(key, fieldAttributeType) {
|
|
916
|
-
return {
|
|
917
|
-
name: key,
|
|
918
|
-
type: fieldAttributeType,
|
|
919
|
-
alias: key
|
|
920
|
-
};
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
_convertBatchTableInfoToNodeAttributes(batchTable) {
|
|
691
|
+
_convertPropertyTableToNodeAttributes(propertyTable) {
|
|
924
692
|
let attributeIndex = 0;
|
|
925
|
-
const
|
|
693
|
+
const propertyTableWithObjectId = {
|
|
926
694
|
OBJECTID: [0],
|
|
927
|
-
...
|
|
695
|
+
...propertyTable
|
|
928
696
|
};
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
const
|
|
932
|
-
const
|
|
933
|
-
|
|
934
|
-
const
|
|
935
|
-
|
|
936
|
-
const fieldAttributeType = this._getFieldAttributeType(attributeType);
|
|
937
|
-
|
|
938
|
-
const fieldAttribute = this._createFieldAttribute(key, fieldAttributeType);
|
|
939
|
-
|
|
940
|
-
const popupInfo = this._createPopupInfo(batchTableWithObjectId);
|
|
941
|
-
|
|
697
|
+
for (const key in propertyTableWithObjectId) {
|
|
698
|
+
const firstAttribute = propertyTableWithObjectId[key][0];
|
|
699
|
+
const attributeType = getAttributeType(key, firstAttribute);
|
|
700
|
+
const storageAttribute = createdStorageAttribute(attributeIndex, key, attributeType);
|
|
701
|
+
const fieldAttributeType = getFieldAttributeType(attributeType);
|
|
702
|
+
const fieldAttribute = createFieldAttribute(key, fieldAttributeType);
|
|
703
|
+
const popupInfo = createPopupInfo(propertyTableWithObjectId);
|
|
942
704
|
this.layers0.attributeStorageInfo.push(storageAttribute);
|
|
943
705
|
this.layers0.fields.push(fieldAttribute);
|
|
944
706
|
this.layers0.popupInfo = popupInfo;
|
|
@@ -947,54 +709,6 @@ export default class I3SConverter {
|
|
|
947
709
|
}
|
|
948
710
|
}
|
|
949
711
|
|
|
950
|
-
_getFieldAttributeType(attributeType) {
|
|
951
|
-
switch (attributeType) {
|
|
952
|
-
case OBJECT_ID_TYPE:
|
|
953
|
-
return 'esriFieldTypeOID';
|
|
954
|
-
|
|
955
|
-
case STRING_TYPE:
|
|
956
|
-
return 'esriFieldTypeString';
|
|
957
|
-
|
|
958
|
-
case SHORT_INT_TYPE:
|
|
959
|
-
return 'esriFieldTypeInteger';
|
|
960
|
-
|
|
961
|
-
case DOUBLE_TYPE:
|
|
962
|
-
return 'esriFieldTypeDouble';
|
|
963
|
-
|
|
964
|
-
default:
|
|
965
|
-
return 'esriFieldTypeString';
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
_createPopupInfo(batchTable) {
|
|
970
|
-
const title = '{OBJECTID}';
|
|
971
|
-
const mediaInfos = [];
|
|
972
|
-
const fieldInfos = [];
|
|
973
|
-
const popupElements = [];
|
|
974
|
-
const expressionInfos = [];
|
|
975
|
-
|
|
976
|
-
for (const key in batchTable) {
|
|
977
|
-
fieldInfos.push({
|
|
978
|
-
fieldName: key,
|
|
979
|
-
visible: true,
|
|
980
|
-
isEditable: false,
|
|
981
|
-
label: key
|
|
982
|
-
});
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
popupElements.push({
|
|
986
|
-
fieldInfos,
|
|
987
|
-
type: 'fields'
|
|
988
|
-
});
|
|
989
|
-
return {
|
|
990
|
-
title,
|
|
991
|
-
mediaInfos,
|
|
992
|
-
popupElements,
|
|
993
|
-
fieldInfos,
|
|
994
|
-
expressionInfos
|
|
995
|
-
};
|
|
996
|
-
}
|
|
997
|
-
|
|
998
712
|
async _finishConversion(params) {
|
|
999
713
|
const {
|
|
1000
714
|
tilesCount,
|
|
@@ -1017,7 +731,6 @@ export default class I3SConverter {
|
|
|
1017
731
|
if (!this.Loader.preload) {
|
|
1018
732
|
return {};
|
|
1019
733
|
}
|
|
1020
|
-
|
|
1021
734
|
const options = {
|
|
1022
735
|
'cesium-ion': {
|
|
1023
736
|
accessToken: this.options.token || ION_DEFAULT_TOKEN
|
|
@@ -1025,26 +738,26 @@ export default class I3SConverter {
|
|
|
1025
738
|
};
|
|
1026
739
|
const preloadOptions = await this.Loader.preload(this.options.inputUrl, options);
|
|
1027
740
|
this.refreshTokenTime = process.hrtime();
|
|
1028
|
-
return {
|
|
741
|
+
return {
|
|
742
|
+
...options,
|
|
1029
743
|
...preloadOptions
|
|
1030
744
|
};
|
|
1031
745
|
}
|
|
1032
746
|
|
|
1033
747
|
async _updateTilesetOptions() {
|
|
1034
748
|
const diff = process.hrtime(this.refreshTokenTime);
|
|
1035
|
-
|
|
1036
749
|
if (diff[0] < REFRESH_TOKEN_TIMEOUT) {
|
|
1037
750
|
return;
|
|
1038
751
|
}
|
|
1039
|
-
|
|
1040
752
|
this.refreshTokenTime = process.hrtime();
|
|
1041
753
|
const preloadOptions = await this._fetchPreloadOptions();
|
|
1042
|
-
this.sourceTileset.options = {
|
|
754
|
+
this.sourceTileset.options = {
|
|
755
|
+
...this.sourceTileset.options,
|
|
1043
756
|
...preloadOptions
|
|
1044
757
|
};
|
|
1045
|
-
|
|
1046
758
|
if (preloadOptions.headers) {
|
|
1047
|
-
this.sourceTileset.loadOptions.fetch = {
|
|
759
|
+
this.sourceTileset.loadOptions.fetch = {
|
|
760
|
+
...this.sourceTileset.loadOptions.fetch,
|
|
1048
761
|
headers: preloadOptions.headers
|
|
1049
762
|
};
|
|
1050
763
|
console.log('Authorization Bearer token has been updated');
|
|
@@ -1053,7 +766,6 @@ export default class I3SConverter {
|
|
|
1053
766
|
|
|
1054
767
|
_checkAddRefinementTypeForTile(tile) {
|
|
1055
768
|
const ADD_TILE_REFINEMENT = 1;
|
|
1056
|
-
|
|
1057
769
|
if (tile.refine === ADD_TILE_REFINEMENT) {
|
|
1058
770
|
this.refinementCounter.tilesWithAddRefineCount += 1;
|
|
1059
771
|
console.warn('This tile uses "ADD" type of refinement');
|
|
@@ -1061,39 +773,35 @@ export default class I3SConverter {
|
|
|
1061
773
|
|
|
1062
774
|
this.refinementCounter.tilesCount += 1;
|
|
1063
775
|
}
|
|
1064
|
-
|
|
1065
776
|
isContentSupported(sourceRootTile) {
|
|
1066
777
|
var _sourceRootTile$conte;
|
|
1067
|
-
|
|
1068
778
|
return ['b3dm', 'glTF'].includes(sourceRootTile === null || sourceRootTile === void 0 ? void 0 : (_sourceRootTile$conte = sourceRootTile.content) === null || _sourceRootTile$conte === void 0 ? void 0 : _sourceRootTile$conte.type);
|
|
1069
779
|
}
|
|
1070
|
-
|
|
1071
780
|
async loadWorkers() {
|
|
1072
781
|
console.log("Loading workers source...");
|
|
1073
|
-
|
|
1074
782
|
if (this.options.draco) {
|
|
1075
|
-
const url = getWorkerURL(DracoWriterWorker, {
|
|
783
|
+
const url = getWorkerURL(DracoWriterWorker, {
|
|
784
|
+
...getLoaderOptions()
|
|
1076
785
|
});
|
|
1077
786
|
const sourceResponse = await fetchFile(url);
|
|
1078
787
|
const source = await sourceResponse.text();
|
|
1079
788
|
this.workerSource.draco = source;
|
|
1080
789
|
}
|
|
1081
|
-
|
|
1082
790
|
if (this.generateTextures) {
|
|
1083
|
-
const url = getWorkerURL(KTX2BasisWriterWorker, {
|
|
791
|
+
const url = getWorkerURL(KTX2BasisWriterWorker, {
|
|
792
|
+
...getLoaderOptions()
|
|
1084
793
|
});
|
|
1085
794
|
const sourceResponse = await fetchFile(url);
|
|
1086
795
|
const source = await sourceResponse.text();
|
|
1087
796
|
this.workerSource.ktx2 = source;
|
|
1088
797
|
}
|
|
1089
|
-
|
|
1090
|
-
|
|
798
|
+
const i3sAttributesWorkerUrl = getWorkerURL(I3SAttributesWorker, {
|
|
799
|
+
...getLoaderOptions()
|
|
1091
800
|
});
|
|
1092
801
|
const sourceResponse = await fetchFile(i3sAttributesWorkerUrl);
|
|
1093
802
|
const source = await sourceResponse.text();
|
|
1094
803
|
this.workerSource.I3SAttributes = source;
|
|
1095
804
|
console.log("Loading workers source completed!");
|
|
1096
805
|
}
|
|
1097
|
-
|
|
1098
806
|
}
|
|
1099
807
|
//# sourceMappingURL=i3s-converter.js.map
|