@loaders.gl/tile-converter 3.3.0-alpha.1 → 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 +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 +61034 -64112
- 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 +507 -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 +794 -1125
- 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 +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 +235 -508
- 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 +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 +234 -420
- 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 +306 -0
- package/src/i3s-converter/helpers/node-pages.ts +222 -109
- package/src/i3s-converter/i3s-converter.ts +279 -499
- 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,108 @@ 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
|
-
|
|
330
|
+
const promises = [];
|
|
360
331
|
for (const sourceTile of sourceTiles) {
|
|
361
332
|
if (sourceTile.type === 'json') {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
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
|
+
}
|
|
371
346
|
} else {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
id: child.id,
|
|
378
|
-
href: "../".concat(child.path),
|
|
379
|
-
obb: child.obb,
|
|
380
|
-
mbs: child.mbs
|
|
347
|
+
if (this.options.instantNodeWriting) {
|
|
348
|
+
await this.convertNode({
|
|
349
|
+
parentNode,
|
|
350
|
+
sourceTile,
|
|
351
|
+
level
|
|
381
352
|
});
|
|
382
|
-
|
|
353
|
+
} else {
|
|
354
|
+
promises.push(this.convertNode({
|
|
355
|
+
parentNode,
|
|
356
|
+
sourceTile,
|
|
357
|
+
level
|
|
358
|
+
}));
|
|
383
359
|
}
|
|
384
360
|
}
|
|
385
|
-
|
|
386
361
|
if (sourceTile.id) {
|
|
387
362
|
console.log(sourceTile.id);
|
|
388
363
|
}
|
|
389
364
|
}
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
async _addNeighborsAndWriteFile(parentNode, childNodes) {
|
|
393
|
-
for (const node of childNodes) {
|
|
394
|
-
var _parentNode$children;
|
|
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
365
|
|
|
406
|
-
|
|
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
|
-
}
|
|
366
|
+
await Promise.all(promises);
|
|
419
367
|
}
|
|
420
368
|
|
|
421
|
-
async _createNode(
|
|
422
|
-
var
|
|
423
|
-
|
|
424
|
-
if (this.validate) {
|
|
425
|
-
this._checkAddRefinementTypeForTile(sourceTile);
|
|
426
|
-
}
|
|
427
|
-
|
|
369
|
+
async _createNode(parentNode, sourceTile, level) {
|
|
370
|
+
var _this$layers, _this$layers$attribut;
|
|
371
|
+
this._checkAddRefinementTypeForTile(sourceTile);
|
|
428
372
|
await this._updateTilesetOptions();
|
|
429
373
|
await this.sourceTileset._loadTile(sourceTile);
|
|
430
374
|
let boundingVolumes = createBoundingVolumes(sourceTile, this.geoidHeightModel);
|
|
431
|
-
const
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
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);
|
|
435
378
|
}
|
|
436
|
-
|
|
437
|
-
const resourcesData = await this._convertResources(sourceTile);
|
|
379
|
+
const resourcesData = await this._convertResources(sourceTile, parentNode.inPageId, propertyTable);
|
|
438
380
|
const nodes = [];
|
|
381
|
+
const nodeIds = [];
|
|
439
382
|
const nodesInPage = [];
|
|
440
383
|
const emptyResources = {
|
|
441
384
|
geometry: null,
|
|
442
385
|
compressedGeometry: null,
|
|
443
386
|
texture: null,
|
|
387
|
+
hasUvRegions: false,
|
|
444
388
|
sharedResources: null,
|
|
445
389
|
meshMaterial: null,
|
|
446
390
|
vertexCount: null,
|
|
@@ -448,77 +392,66 @@ export default class I3SConverter {
|
|
|
448
392
|
featureCount: null,
|
|
449
393
|
boundingVolumes: null
|
|
450
394
|
};
|
|
451
|
-
|
|
452
395
|
for (const resources of resourcesData || [emptyResources]) {
|
|
453
396
|
this.layersHasTexture = this.layersHasTexture || Boolean(resources.texture);
|
|
454
|
-
|
|
455
397
|
if (this.generateBoundingVolumes && resources.boundingVolumes) {
|
|
456
398
|
boundingVolumes = resources.boundingVolumes;
|
|
457
399
|
}
|
|
458
|
-
|
|
459
400
|
const lodSelection = convertGeometricErrorToScreenThreshold(sourceTile, boundingVolumes);
|
|
460
401
|
const maxScreenThresholdSQ = lodSelection.find(val => val.metricType === 'maxScreenThresholdSQ') || {
|
|
461
402
|
maxError: 0
|
|
462
403
|
};
|
|
463
|
-
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
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);
|
|
468
408
|
if (nodeInPage.mesh) {
|
|
469
|
-
await this._writeResources(resources, node.
|
|
409
|
+
await this._writeResources(resources, node.id);
|
|
470
410
|
}
|
|
471
|
-
|
|
472
411
|
if (this.validate) {
|
|
473
|
-
this.boundingVolumeWarnings = validateNodeBoundingVolumes(
|
|
474
|
-
|
|
412
|
+
this.boundingVolumeWarnings = validateNodeBoundingVolumes(nodeData);
|
|
475
413
|
if (this.boundingVolumeWarnings && this.boundingVolumeWarnings.length) {
|
|
476
414
|
console.warn('Bounding Volume Warnings: ', ...this.boundingVolumeWarnings);
|
|
477
415
|
}
|
|
478
416
|
}
|
|
479
417
|
|
|
480
|
-
|
|
418
|
+
nodeIds.push(nodeInPage.index);
|
|
481
419
|
nodesInPage.push(nodeInPage);
|
|
482
420
|
}
|
|
483
|
-
|
|
484
421
|
sourceTile.unloadContent();
|
|
485
422
|
await this._addChildrenWithNeighborsAndWriteFile({
|
|
486
423
|
parentNode: nodes[0],
|
|
487
424
|
sourceTiles: sourceTile.children,
|
|
488
|
-
parentId: nodesInPage[0].index,
|
|
489
425
|
level: level + 1
|
|
490
426
|
});
|
|
491
427
|
return nodes;
|
|
492
428
|
}
|
|
493
429
|
|
|
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) {
|
|
430
|
+
async _convertResources(sourceTile, parentId, propertyTable) {
|
|
505
431
|
var _this$layers2;
|
|
506
|
-
|
|
507
432
|
if (!this.isContentSupported(sourceTile)) {
|
|
508
433
|
return null;
|
|
509
434
|
}
|
|
510
|
-
|
|
511
|
-
|
|
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);
|
|
512
444
|
return resourcesData;
|
|
513
445
|
}
|
|
514
446
|
|
|
515
|
-
|
|
447
|
+
async _updateNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentId, resources) {
|
|
516
448
|
const {
|
|
517
449
|
meshMaterial,
|
|
518
450
|
texture,
|
|
519
451
|
vertexCount,
|
|
520
452
|
featureCount,
|
|
521
|
-
geometry
|
|
453
|
+
geometry,
|
|
454
|
+
hasUvRegions
|
|
522
455
|
} = resources;
|
|
523
456
|
const nodeInPage = {
|
|
524
457
|
index: 0,
|
|
@@ -526,11 +459,10 @@ export default class I3SConverter {
|
|
|
526
459
|
obb: boundingVolumes.obb,
|
|
527
460
|
children: []
|
|
528
461
|
};
|
|
529
|
-
|
|
530
462
|
if (geometry && this.isContentSupported(sourceTile)) {
|
|
531
463
|
nodeInPage.mesh = {
|
|
532
464
|
geometry: {
|
|
533
|
-
definition: texture
|
|
465
|
+
definition: this.findOrCreateGeometryDefinition(Boolean(texture), hasUvRegions),
|
|
534
466
|
resource: 0
|
|
535
467
|
},
|
|
536
468
|
attribute: {
|
|
@@ -541,86 +473,30 @@ export default class I3SConverter {
|
|
|
541
473
|
}
|
|
542
474
|
};
|
|
543
475
|
}
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
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);
|
|
547
484
|
if (meshMaterial) {
|
|
548
|
-
|
|
485
|
+
NodePages.updateMaterialByNodeId(node, this._findOrCreateMaterial(meshMaterial));
|
|
549
486
|
}
|
|
550
|
-
|
|
551
487
|
if (texture) {
|
|
552
488
|
const texelCountHint = texture.image.height * texture.image.width;
|
|
553
|
-
|
|
489
|
+
NodePages.updateTexelCountHintByNodeId(node, texelCountHint);
|
|
554
490
|
}
|
|
555
|
-
|
|
556
491
|
if (vertexCount) {
|
|
557
492
|
this.vertexCounter += vertexCount;
|
|
558
|
-
|
|
493
|
+
NodePages.updateVertexCountByNodeId(node, vertexCount);
|
|
559
494
|
}
|
|
560
|
-
|
|
561
|
-
this.nodePages.updateNodeAttributeByNodeId(nodeId);
|
|
562
|
-
|
|
495
|
+
NodePages.updateNodeAttributeByNodeId(node);
|
|
563
496
|
if (featureCount) {
|
|
564
|
-
|
|
497
|
+
NodePages.updateFeatureCountByNodeId(node, featureCount);
|
|
565
498
|
}
|
|
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
|
-
|
|
499
|
+
this.nodePages.saveNode(node);
|
|
624
500
|
return node;
|
|
625
501
|
}
|
|
626
502
|
|
|
@@ -643,28 +519,27 @@ export default class I3SConverter {
|
|
|
643
519
|
async _writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath) {
|
|
644
520
|
if (this.options.slpk) {
|
|
645
521
|
const slpkGeometryPath = join(childPath, 'geometries');
|
|
646
|
-
this.writeQueue.enqueue({
|
|
522
|
+
await this.writeQueue.enqueue({
|
|
647
523
|
archiveKey: "".concat(slpkChildPath, "/geometries/0.bin.gz"),
|
|
648
|
-
writePromise: writeFileForSlpk(slpkGeometryPath, geometryBuffer, '0.bin')
|
|
524
|
+
writePromise: () => writeFileForSlpk(slpkGeometryPath, geometryBuffer, '0.bin')
|
|
649
525
|
});
|
|
650
526
|
} else {
|
|
651
527
|
const geometryPath = join(childPath, 'geometries/0/');
|
|
652
|
-
this.writeQueue.enqueue({
|
|
653
|
-
writePromise: writeFile(geometryPath, geometryBuffer, 'index.bin')
|
|
528
|
+
await this.writeQueue.enqueue({
|
|
529
|
+
writePromise: () => writeFile(geometryPath, geometryBuffer, 'index.bin')
|
|
654
530
|
});
|
|
655
531
|
}
|
|
656
|
-
|
|
657
532
|
if (this.options.draco) {
|
|
658
533
|
if (this.options.slpk) {
|
|
659
534
|
const slpkCompressedGeometryPath = join(childPath, 'geometries');
|
|
660
|
-
this.writeQueue.enqueue({
|
|
535
|
+
await this.writeQueue.enqueue({
|
|
661
536
|
archiveKey: "".concat(slpkChildPath, "/geometries/1.bin.gz"),
|
|
662
|
-
writePromise: writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, '1.bin')
|
|
537
|
+
writePromise: () => writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, '1.bin')
|
|
663
538
|
});
|
|
664
539
|
} else {
|
|
665
540
|
const compressedGeometryPath = join(childPath, 'geometries/1/');
|
|
666
|
-
this.writeQueue.enqueue({
|
|
667
|
-
writePromise: writeFile(compressedGeometryPath, compressedGeometry, 'index.bin')
|
|
541
|
+
await this.writeQueue.enqueue({
|
|
542
|
+
writePromise: () => writeFile(compressedGeometryPath, compressedGeometry, 'index.bin')
|
|
668
543
|
});
|
|
669
544
|
}
|
|
670
545
|
}
|
|
@@ -674,21 +549,19 @@ export default class I3SConverter {
|
|
|
674
549
|
if (!sharedResources) {
|
|
675
550
|
return;
|
|
676
551
|
}
|
|
677
|
-
|
|
678
552
|
sharedResources.nodePath = nodePath;
|
|
679
553
|
const sharedData = transform(sharedResources, sharedResourcesTemplate());
|
|
680
554
|
const sharedDataStr = JSON.stringify(sharedData);
|
|
681
|
-
|
|
682
555
|
if (this.options.slpk) {
|
|
683
556
|
const slpkSharedPath = join(childPath, 'shared');
|
|
684
|
-
this.writeQueue.enqueue({
|
|
557
|
+
await this.writeQueue.enqueue({
|
|
685
558
|
archiveKey: "".concat(slpkChildPath, "/shared/sharedResource.json.gz"),
|
|
686
|
-
writePromise: writeFileForSlpk(slpkSharedPath, sharedDataStr, 'sharedResource.json')
|
|
559
|
+
writePromise: () => writeFileForSlpk(slpkSharedPath, sharedDataStr, 'sharedResource.json')
|
|
687
560
|
});
|
|
688
561
|
} else {
|
|
689
562
|
const sharedPath = join(childPath, 'shared/');
|
|
690
|
-
this.writeQueue.enqueue({
|
|
691
|
-
writePromise: writeFile(sharedPath, sharedDataStr)
|
|
563
|
+
await this.writeQueue.enqueue({
|
|
564
|
+
writePromise: () => writeFile(sharedPath, sharedDataStr)
|
|
692
565
|
});
|
|
693
566
|
}
|
|
694
567
|
}
|
|
@@ -696,10 +569,8 @@ export default class I3SConverter {
|
|
|
696
569
|
async _writeTexture(texture, childPath, slpkChildPath) {
|
|
697
570
|
if (texture) {
|
|
698
571
|
const format = this._getFormatByMimeType(texture === null || texture === void 0 ? void 0 : texture.mimeType);
|
|
699
|
-
|
|
700
572
|
const formats = [];
|
|
701
573
|
const textureData = texture.bufferView.data;
|
|
702
|
-
|
|
703
574
|
switch (format) {
|
|
704
575
|
case 'jpg':
|
|
705
576
|
case 'png':
|
|
@@ -709,7 +580,6 @@ export default class I3SConverter {
|
|
|
709
580
|
format
|
|
710
581
|
});
|
|
711
582
|
await this.writeTextureFile(textureData, '0', format, childPath, slpkChildPath);
|
|
712
|
-
|
|
713
583
|
if (this.generateTextures) {
|
|
714
584
|
formats.push({
|
|
715
585
|
name: '1',
|
|
@@ -717,19 +587,19 @@ export default class I3SConverter {
|
|
|
717
587
|
});
|
|
718
588
|
const copyArrayBuffer = texture.image.data.subarray();
|
|
719
589
|
const arrayToEncode = new Uint8Array(copyArrayBuffer);
|
|
720
|
-
const ktx2TextureData = encode({
|
|
590
|
+
const ktx2TextureData = encode({
|
|
591
|
+
...texture.image,
|
|
721
592
|
data: arrayToEncode
|
|
722
|
-
}, KTX2BasisWriterWorker, {
|
|
593
|
+
}, KTX2BasisWriterWorker, {
|
|
594
|
+
...KTX2BasisWriterWorker.options,
|
|
723
595
|
source: this.workerSource.ktx2,
|
|
724
596
|
reuseWorkers: true,
|
|
725
597
|
_nodeWorkers: true
|
|
726
598
|
});
|
|
727
599
|
await this.writeTextureFile(ktx2TextureData, '1', 'ktx2', childPath, slpkChildPath);
|
|
728
600
|
}
|
|
729
|
-
|
|
730
601
|
break;
|
|
731
602
|
}
|
|
732
|
-
|
|
733
603
|
case 'ktx2':
|
|
734
604
|
{
|
|
735
605
|
formats.push({
|
|
@@ -737,7 +607,6 @@ export default class I3SConverter {
|
|
|
737
607
|
format
|
|
738
608
|
});
|
|
739
609
|
await this.writeTextureFile(textureData, '1', format, childPath, slpkChildPath);
|
|
740
|
-
|
|
741
610
|
if (this.generateTextures) {
|
|
742
611
|
formats.push({
|
|
743
612
|
name: '0',
|
|
@@ -748,11 +617,14 @@ export default class I3SConverter {
|
|
|
748
617
|
}
|
|
749
618
|
}
|
|
750
619
|
}
|
|
751
|
-
|
|
752
620
|
if (!this.layers0.textureSetDefinitions.length) {
|
|
753
621
|
this.layers0.textureSetDefinitions.push({
|
|
754
622
|
formats
|
|
755
623
|
});
|
|
624
|
+
this.layers0.textureSetDefinitions.push({
|
|
625
|
+
formats,
|
|
626
|
+
atlas: true
|
|
627
|
+
});
|
|
756
628
|
}
|
|
757
629
|
}
|
|
758
630
|
}
|
|
@@ -761,36 +633,37 @@ export default class I3SConverter {
|
|
|
761
633
|
if (this.options.slpk) {
|
|
762
634
|
const slpkTexturePath = join(childPath, 'textures');
|
|
763
635
|
const compress = false;
|
|
764
|
-
this.writeQueue.enqueue({
|
|
636
|
+
await this.writeQueue.enqueue({
|
|
765
637
|
archiveKey: "".concat(slpkChildPath, "/textures/").concat(name, ".").concat(format),
|
|
766
|
-
writePromise: writeFileForSlpk(slpkTexturePath, textureData, "".concat(name, ".").concat(format), compress)
|
|
638
|
+
writePromise: () => writeFileForSlpk(slpkTexturePath, textureData, "".concat(name, ".").concat(format), compress)
|
|
767
639
|
});
|
|
768
640
|
} else {
|
|
769
641
|
const texturePath = join(childPath, "textures/".concat(name, "/"));
|
|
770
|
-
this.writeQueue.enqueue({
|
|
771
|
-
writePromise: writeFile(texturePath, textureData, "index.".concat(format))
|
|
642
|
+
await this.writeQueue.enqueue({
|
|
643
|
+
writePromise: () => writeFile(texturePath, textureData, "index.".concat(format))
|
|
772
644
|
});
|
|
773
645
|
}
|
|
774
646
|
}
|
|
775
647
|
|
|
776
|
-
async _writeAttributes(
|
|
777
|
-
var _this$
|
|
778
|
-
|
|
779
|
-
|
|
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) {
|
|
780
654
|
for (let index = 0; index < attributes.length; index++) {
|
|
781
655
|
const folderName = this.layers0.attributeStorageInfo[index].key;
|
|
782
656
|
const fileBuffer = new Uint8Array(attributes[index]);
|
|
783
|
-
|
|
784
657
|
if (this.options.slpk) {
|
|
785
658
|
const slpkAttributesPath = join(childPath, 'attributes', folderName);
|
|
786
|
-
this.writeQueue.enqueue({
|
|
659
|
+
await this.writeQueue.enqueue({
|
|
787
660
|
archiveKey: "".concat(slpkChildPath, "/attributes/").concat(folderName, ".bin.gz"),
|
|
788
|
-
writePromise: writeFileForSlpk(slpkAttributesPath, fileBuffer, '0.bin')
|
|
661
|
+
writePromise: () => writeFileForSlpk(slpkAttributesPath, fileBuffer, '0.bin')
|
|
789
662
|
});
|
|
790
663
|
} else {
|
|
791
664
|
const attributesPath = join(childPath, "attributes/".concat(folderName, "/0"));
|
|
792
|
-
this.writeQueue.enqueue({
|
|
793
|
-
writePromise: writeFile(attributesPath, fileBuffer, 'index.bin')
|
|
665
|
+
await this.writeQueue.enqueue({
|
|
666
|
+
writePromise: () => writeFile(attributesPath, fileBuffer, 'index.bin')
|
|
794
667
|
});
|
|
795
668
|
}
|
|
796
669
|
}
|
|
@@ -801,13 +674,10 @@ export default class I3SConverter {
|
|
|
801
674
|
switch (mimeType) {
|
|
802
675
|
case 'image/jpeg':
|
|
803
676
|
return 'jpg';
|
|
804
|
-
|
|
805
677
|
case 'image/png':
|
|
806
678
|
return 'png';
|
|
807
|
-
|
|
808
679
|
case 'image/ktx2':
|
|
809
680
|
return 'ktx2';
|
|
810
|
-
|
|
811
681
|
default:
|
|
812
682
|
return 'jpg';
|
|
813
683
|
}
|
|
@@ -815,130 +685,41 @@ export default class I3SConverter {
|
|
|
815
685
|
|
|
816
686
|
_findOrCreateMaterial(material) {
|
|
817
687
|
const hash = md5(JSON.stringify(material));
|
|
818
|
-
|
|
819
688
|
if (this.materialMap.has(hash)) {
|
|
820
|
-
return this.materialMap.get(hash);
|
|
689
|
+
return this.materialMap.get(hash) || 0;
|
|
821
690
|
}
|
|
822
|
-
|
|
823
691
|
const newMaterialId = this.materialDefinitions.push(material) - 1;
|
|
824
692
|
this.materialMap.set(hash, newMaterialId);
|
|
825
693
|
return newMaterialId;
|
|
826
694
|
}
|
|
827
695
|
|
|
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
|
-
}
|
|
696
|
+
findOrCreateGeometryDefinition(hasTexture, hasUvRegions) {
|
|
697
|
+
const geometryConfig = {
|
|
698
|
+
hasTexture,
|
|
699
|
+
hasUvRegions
|
|
841
700
|
};
|
|
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;
|
|
701
|
+
const hash = md5(JSON.stringify(geometryConfig));
|
|
702
|
+
if (this.geometryMap.has(hash)) {
|
|
703
|
+
return this.geometryMap.get(hash) || 0;
|
|
879
704
|
}
|
|
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
|
-
};
|
|
705
|
+
const newGeometryId = this.geometryConfigs.push(geometryConfig) - 1;
|
|
706
|
+
this.geometryMap.set(hash, newGeometryId);
|
|
707
|
+
return newGeometryId;
|
|
899
708
|
}
|
|
900
709
|
|
|
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) {
|
|
710
|
+
_convertPropertyTableToNodeAttributes(propertyTable) {
|
|
924
711
|
let attributeIndex = 0;
|
|
925
|
-
const
|
|
712
|
+
const propertyTableWithObjectId = {
|
|
926
713
|
OBJECTID: [0],
|
|
927
|
-
...
|
|
714
|
+
...propertyTable
|
|
928
715
|
};
|
|
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
|
-
|
|
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);
|
|
942
723
|
this.layers0.attributeStorageInfo.push(storageAttribute);
|
|
943
724
|
this.layers0.fields.push(fieldAttribute);
|
|
944
725
|
this.layers0.popupInfo = popupInfo;
|
|
@@ -947,54 +728,6 @@ export default class I3SConverter {
|
|
|
947
728
|
}
|
|
948
729
|
}
|
|
949
730
|
|
|
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
731
|
async _finishConversion(params) {
|
|
999
732
|
const {
|
|
1000
733
|
tilesCount,
|
|
@@ -1017,7 +750,6 @@ export default class I3SConverter {
|
|
|
1017
750
|
if (!this.Loader.preload) {
|
|
1018
751
|
return {};
|
|
1019
752
|
}
|
|
1020
|
-
|
|
1021
753
|
const options = {
|
|
1022
754
|
'cesium-ion': {
|
|
1023
755
|
accessToken: this.options.token || ION_DEFAULT_TOKEN
|
|
@@ -1025,26 +757,26 @@ export default class I3SConverter {
|
|
|
1025
757
|
};
|
|
1026
758
|
const preloadOptions = await this.Loader.preload(this.options.inputUrl, options);
|
|
1027
759
|
this.refreshTokenTime = process.hrtime();
|
|
1028
|
-
return {
|
|
760
|
+
return {
|
|
761
|
+
...options,
|
|
1029
762
|
...preloadOptions
|
|
1030
763
|
};
|
|
1031
764
|
}
|
|
1032
765
|
|
|
1033
766
|
async _updateTilesetOptions() {
|
|
1034
767
|
const diff = process.hrtime(this.refreshTokenTime);
|
|
1035
|
-
|
|
1036
768
|
if (diff[0] < REFRESH_TOKEN_TIMEOUT) {
|
|
1037
769
|
return;
|
|
1038
770
|
}
|
|
1039
|
-
|
|
1040
771
|
this.refreshTokenTime = process.hrtime();
|
|
1041
772
|
const preloadOptions = await this._fetchPreloadOptions();
|
|
1042
|
-
this.sourceTileset.options = {
|
|
773
|
+
this.sourceTileset.options = {
|
|
774
|
+
...this.sourceTileset.options,
|
|
1043
775
|
...preloadOptions
|
|
1044
776
|
};
|
|
1045
|
-
|
|
1046
777
|
if (preloadOptions.headers) {
|
|
1047
|
-
this.sourceTileset.loadOptions.fetch = {
|
|
778
|
+
this.sourceTileset.loadOptions.fetch = {
|
|
779
|
+
...this.sourceTileset.loadOptions.fetch,
|
|
1048
780
|
headers: preloadOptions.headers
|
|
1049
781
|
};
|
|
1050
782
|
console.log('Authorization Bearer token has been updated');
|
|
@@ -1053,7 +785,6 @@ export default class I3SConverter {
|
|
|
1053
785
|
|
|
1054
786
|
_checkAddRefinementTypeForTile(tile) {
|
|
1055
787
|
const ADD_TILE_REFINEMENT = 1;
|
|
1056
|
-
|
|
1057
788
|
if (tile.refine === ADD_TILE_REFINEMENT) {
|
|
1058
789
|
this.refinementCounter.tilesWithAddRefineCount += 1;
|
|
1059
790
|
console.warn('This tile uses "ADD" type of refinement');
|
|
@@ -1061,39 +792,35 @@ export default class I3SConverter {
|
|
|
1061
792
|
|
|
1062
793
|
this.refinementCounter.tilesCount += 1;
|
|
1063
794
|
}
|
|
1064
|
-
|
|
1065
795
|
isContentSupported(sourceRootTile) {
|
|
1066
796
|
var _sourceRootTile$conte;
|
|
1067
|
-
|
|
1068
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);
|
|
1069
798
|
}
|
|
1070
|
-
|
|
1071
799
|
async loadWorkers() {
|
|
1072
800
|
console.log("Loading workers source...");
|
|
1073
|
-
|
|
1074
801
|
if (this.options.draco) {
|
|
1075
|
-
const url = getWorkerURL(DracoWriterWorker, {
|
|
802
|
+
const url = getWorkerURL(DracoWriterWorker, {
|
|
803
|
+
...getLoaderOptions()
|
|
1076
804
|
});
|
|
1077
805
|
const sourceResponse = await fetchFile(url);
|
|
1078
806
|
const source = await sourceResponse.text();
|
|
1079
807
|
this.workerSource.draco = source;
|
|
1080
808
|
}
|
|
1081
|
-
|
|
1082
809
|
if (this.generateTextures) {
|
|
1083
|
-
const url = getWorkerURL(KTX2BasisWriterWorker, {
|
|
810
|
+
const url = getWorkerURL(KTX2BasisWriterWorker, {
|
|
811
|
+
...getLoaderOptions()
|
|
1084
812
|
});
|
|
1085
813
|
const sourceResponse = await fetchFile(url);
|
|
1086
814
|
const source = await sourceResponse.text();
|
|
1087
815
|
this.workerSource.ktx2 = source;
|
|
1088
816
|
}
|
|
1089
|
-
|
|
1090
|
-
|
|
817
|
+
const i3sAttributesWorkerUrl = getWorkerURL(I3SAttributesWorker, {
|
|
818
|
+
...getLoaderOptions()
|
|
1091
819
|
});
|
|
1092
820
|
const sourceResponse = await fetchFile(i3sAttributesWorkerUrl);
|
|
1093
821
|
const source = await sourceResponse.text();
|
|
1094
822
|
this.workerSource.I3SAttributes = source;
|
|
1095
823
|
console.log("Loading workers source completed!");
|
|
1096
824
|
}
|
|
1097
|
-
|
|
1098
825
|
}
|
|
1099
826
|
//# sourceMappingURL=i3s-converter.js.map
|