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