@loaders.gl/tile-converter 4.0.0-alpha.4 → 4.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +78 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.js +9 -7
- package/dist/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +78 -18
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -0
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +19 -9
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +4 -7
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts.map +1 -0
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +9 -0
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +1 -0
- package/dist/3d-tiles-converter/helpers/texture-atlas.js +1 -1
- package/dist/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
- package/dist/3d-tiles-converter/json-templates/tileset.d.ts +15 -0
- package/dist/3d-tiles-converter/json-templates/tileset.d.ts.map +1 -0
- package/dist/3d-tiles-converter/json-templates/tileset.js +12 -9
- package/dist/3d-tiles-converter/json-templates/tileset.js.map +1 -1
- package/dist/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/converter.min.js +22 -22
- package/dist/deps-installer/deps-installer.d.ts.map +1 -0
- package/dist/deps-installer/deps-installer.js +2 -6
- package/dist/deps-installer/deps-installer.js.map +1 -1
- package/dist/dist.min.js +86527 -0
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts +41 -0
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/coordinate-converter.js +35 -3
- package/dist/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/i3s-converter/helpers/create-scene-server-path.d.ts +9 -0
- package/dist/i3s-converter/helpers/create-scene-server-path.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/create-scene-server-path.js +2 -2
- package/dist/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts +23 -0
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +5 -1
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/geometry-converter.js +88 -42
- package/dist/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/i3s-converter/helpers/node-debug.d.ts +2 -0
- package/dist/i3s-converter/helpers/node-debug.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/node-debug.js +2 -4
- package/dist/i3s-converter/helpers/node-debug.js.map +1 -1
- package/dist/i3s-converter/helpers/node-pages.d.ts +83 -111
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/node-pages.js +15 -4
- package/dist/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/i3s-converter/i3s-converter.d.ts +320 -0
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -0
- package/dist/i3s-converter/i3s-converter.js +158 -65
- package/dist/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/i3s-converter/json-templates/layers.d.ts +95 -0
- package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/layers.js +37 -27
- package/dist/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/i3s-converter/json-templates/metadata.d.ts +22 -0
- package/dist/i3s-converter/json-templates/metadata.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/metadata.js +2 -2
- package/dist/i3s-converter/json-templates/metadata.js.map +1 -1
- package/dist/i3s-converter/json-templates/node.d.ts +61 -0
- package/dist/i3s-converter/json-templates/node.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/node.js +16 -12
- package/dist/i3s-converter/json-templates/node.js.map +1 -1
- package/dist/i3s-converter/json-templates/scene-server.d.ts +28 -0
- package/dist/i3s-converter/json-templates/scene-server.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/scene-server.js +2 -2
- package/dist/i3s-converter/json-templates/scene-server.js.map +1 -1
- package/dist/i3s-converter/json-templates/shared-resources.d.ts +14 -0
- package/dist/i3s-converter/json-templates/shared-resources.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/shared-resources.js +19 -14
- package/dist/i3s-converter/json-templates/shared-resources.js.map +1 -1
- package/dist/i3s-converter/json-templates/store.d.ts +95 -0
- package/dist/i3s-converter/json-templates/store.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/store.js.map +1 -1
- package/dist/i3s-converter/types.d.ts +14 -0
- package/dist/i3s-converter/types.d.ts.map +1 -0
- package/dist/i3s-converter/types.js +2 -0
- package/dist/i3s-converter/types.js.map +1 -0
- package/dist/i3s-server/app.d.ts +3 -0
- package/dist/i3s-server/app.d.ts.map +1 -0
- package/dist/i3s-server/controllers/index-controller.d.ts +2 -0
- package/dist/i3s-server/controllers/index-controller.d.ts.map +1 -0
- package/dist/i3s-server/routes/index.d.ts +3 -0
- package/dist/i3s-server/routes/index.d.ts.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/lib/utils/{compress-utils.d.ts → compress-util.d.ts} +0 -0
- package/dist/lib/utils/compress-util.d.ts.map +1 -0
- package/dist/lib/utils/file-utils.d.ts.map +1 -0
- package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -0
- package/dist/lib/utils/statistic-utills.d.ts.map +1 -0
- package/dist/pgm-loader.d.ts +6 -0
- package/dist/pgm-loader.d.ts.map +1 -0
- package/dist/pgm-loader.js +3 -3
- package/dist/pgm-loader.js.map +1 -1
- package/package.json +21 -19
- package/src/3d-tiles-converter/3d-tiles-converter.ts +25 -21
- package/src/3d-tiles-converter/helpers/{b3dm-converter.js → b3dm-converter.ts} +35 -11
- package/src/3d-tiles-converter/helpers/{i3s-obb-to-3d-tiles-obb.js → i3s-obb-to-3d-tiles-obb.ts} +16 -1
- package/src/3d-tiles-converter/helpers/texture-atlas.ts +4 -4
- package/src/3d-tiles-converter/json-templates/{tileset.js → tileset.ts} +9 -9
- package/src/deps-installer/deps-installer.js +2 -2
- package/src/i3s-converter/helpers/coordinate-converter.ts +62 -9
- package/src/i3s-converter/helpers/{create-scene-server-path.js → create-scene-server-path.ts} +2 -2
- package/src/i3s-converter/helpers/{geometry-attributes.js → geometry-attributes.ts} +4 -4
- package/src/i3s-converter/helpers/geometry-converter.d.ts +5 -1
- package/src/i3s-converter/helpers/geometry-converter.js +110 -33
- package/src/i3s-converter/helpers/{node-debug.js → node-debug.ts} +3 -2
- package/src/i3s-converter/helpers/{node-pages.js → node-pages.ts} +41 -26
- package/src/i3s-converter/i3s-converter.ts +214 -136
- package/src/i3s-converter/json-templates/{layers.js → layers.ts} +29 -27
- package/src/i3s-converter/json-templates/{metadata.js → metadata.ts} +2 -2
- package/src/i3s-converter/json-templates/{node.js → node.ts} +12 -12
- package/src/i3s-converter/json-templates/{scene-server.js → scene-server.ts} +2 -2
- package/src/i3s-converter/json-templates/{shared-resources.js → shared-resources.ts} +14 -14
- package/src/i3s-converter/json-templates/{store.js → store.ts} +0 -0
- package/src/i3s-converter/types.ts +14 -0
- package/src/lib/utils/{compress-utils.d.ts → compress-util.d.ts} +0 -0
- package/src/pgm-loader.ts +2 -2
- package/dist/lib/geoid-height-model.d.ts +0 -41
- package/dist/lib/geoid-height-model.js +0 -140
- package/dist/lib/geoid-height-model.js.map +0 -1
- package/dist/lib/pgm-parser.d.ts +0 -14
- package/dist/lib/pgm-parser.js +0 -183
- package/dist/lib/pgm-parser.js.map +0 -1
- package/src/3d-tiles-converter/helpers/b3dm-converter.d.ts +0 -23
- package/src/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +0 -16
- package/src/i3s-converter/helpers/node-pages.d.ts +0 -144
- package/src/lib/geoid-height-model.d.ts +0 -41
- package/src/lib/geoid-height-model.js +0 -239
- package/src/lib/pgm-parser.d.ts +0 -14
- package/src/lib/pgm-parser.js +0 -179
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/i3s-server/routes/index.js"],"names":[],"mappings":";AACA,0BAAgC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as I3SConverter } from './i3s-converter/i3s-converter';
|
|
2
|
+
export { default as NodePages } from './i3s-converter/helpers/node-pages';
|
|
3
|
+
export { default as Tiles3DConverter } from './3d-tiles-converter/3d-tiles-converter';
|
|
4
|
+
export { DepsInstaller } from './deps-installer/deps-installer';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,oCAAoC,CAAC;AAExE,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,yCAAyC,CAAC;AAEpF,OAAO,EAAC,aAAa,EAAC,MAAM,iCAAiC,CAAC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compress-util.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/compress-util.js"],"names":[],"mappings":"AAWA,kEAiBC;AAED,kGAoDC;AAED,wEAOC;AA0CD,yFA6CC;AASD,6GAGC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/file-utils.js"],"names":[],"mappings":"AAIA,oFAUC;AAED,+GASC;AAED,oDAEC;AAED,qDAEC;AAED,wDAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lod-conversion-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/lod-conversion-utils.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH;;;IAsBC;AAED,0EAeC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statistic-utills.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/statistic-utills.js"],"names":[],"mappings":"AAIA,iDA4BC;AAED,wEAkBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pgm-loader.d.ts","sourceRoot":"","sources":["../src/pgm-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAQ/D;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,gBAYvB,CAAC"}
|
package/dist/pgm-loader.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
const VERSION = typeof "4.0.0-alpha.
|
|
2
|
-
import {
|
|
1
|
+
const VERSION = typeof "4.0.0-alpha.5" !== 'undefined' ? "4.0.0-alpha.5" : 'latest';
|
|
2
|
+
import { parsePGM } from '@math.gl/geoid';
|
|
3
3
|
export const PGMLoader = {
|
|
4
4
|
name: 'PGM - Netpbm grayscale image format',
|
|
5
5
|
id: 'pgm',
|
|
6
6
|
module: 'tile-converter',
|
|
7
7
|
version: VERSION,
|
|
8
8
|
mimeTypes: ['image/x-portable-graymap'],
|
|
9
|
-
parse: (arrayBuffer, options) =>
|
|
9
|
+
parse: async (arrayBuffer, options) => parsePGM(new Uint8Array(arrayBuffer), options),
|
|
10
10
|
extensions: ['pgm'],
|
|
11
11
|
options: {
|
|
12
12
|
cubic: false
|
package/dist/pgm-loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/pgm-loader.ts"],"names":["VERSION","
|
|
1
|
+
{"version":3,"sources":["../src/pgm-loader.ts"],"names":["VERSION","parsePGM","PGMLoader","name","id","module","version","mimeTypes","parse","arrayBuffer","options","Uint8Array","extensions","cubic"],"mappings":"AAIA,MAAMA,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,QAAnE;AAEA,SAAQC,QAAR,QAAuB,gBAAvB;AAKA,OAAO,MAAMC,SAA2B,GAAG;AACzCC,EAAAA,IAAI,EAAE,qCADmC;AAEzCC,EAAAA,EAAE,EAAE,KAFqC;AAGzCC,EAAAA,MAAM,EAAE,gBAHiC;AAIzCC,EAAAA,OAAO,EAAEN,OAJgC;AAKzCO,EAAAA,SAAS,EAAE,CAAC,0BAAD,CAL8B;AAMzCC,EAAAA,KAAK,EAAE,OAAOC,WAAP,EAAoBC,OAApB,KAAgCT,QAAQ,CAAC,IAAIU,UAAJ,CAAeF,WAAf,CAAD,EAA8BC,OAA9B,CANN;AAOzCE,EAAAA,UAAU,EAAE,CAAC,KAAD,CAP6B;AAQzCF,EAAAA,OAAO,EAAE;AAEPG,IAAAA,KAAK,EAAE;AAFA;AARgC,CAApC","sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nimport {parsePGM} from '@math.gl/geoid';\n\n/**\n * Loader for PGM - Netpbm grayscale image format\n */\nexport const PGMLoader: LoaderWithParser = {\n name: 'PGM - Netpbm grayscale image format',\n id: 'pgm',\n module: 'tile-converter',\n version: VERSION,\n mimeTypes: ['image/x-portable-graymap'],\n parse: async (arrayBuffer, options) => parsePGM(new Uint8Array(arrayBuffer), options),\n extensions: ['pgm'],\n options: {\n // TODO - use pgm namespace\n cubic: false\n }\n};\n"],"file":"pgm-loader.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/tile-converter",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.5",
|
|
4
4
|
"description": "Converter",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"3dTiles",
|
|
16
16
|
"i3s"
|
|
17
17
|
],
|
|
18
|
-
"types": "
|
|
18
|
+
"types": "dist/index.d.ts",
|
|
19
19
|
"main": "dist/index.js",
|
|
20
20
|
"module": "dist/index.js",
|
|
21
21
|
"sideEffects": false,
|
|
@@ -33,26 +33,28 @@
|
|
|
33
33
|
"fs": false
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
|
-
"pre-build": "npm run build-bundle",
|
|
37
|
-
"
|
|
38
|
-
"build-bundle": "
|
|
39
|
-
"build-
|
|
36
|
+
"pre-build": "npm run build-bundle && npm run build-converter-bundle",
|
|
37
|
+
"build-bundle": "esbuild ./src/index.ts --bundle --outfile=dist/dist.min.js --platform=node",
|
|
38
|
+
"build-converter-bundle": "webpack --display errors-only --config ./converter-webpack/bundle.js",
|
|
39
|
+
"build-bin": "BABEL_ENV=es5 babel scripts --config-file ../../babel.config.js --out-dir dist/scripts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@loaders.gl/3d-tiles": "4.0.0-alpha.
|
|
43
|
-
"@loaders.gl/crypto": "4.0.0-alpha.
|
|
44
|
-
"@loaders.gl/draco": "4.0.0-alpha.
|
|
45
|
-
"@loaders.gl/gltf": "4.0.0-alpha.
|
|
46
|
-
"@loaders.gl/i3s": "4.0.0-alpha.
|
|
47
|
-
"@loaders.gl/images": "4.0.0-alpha.
|
|
48
|
-
"@loaders.gl/loader-utils": "4.0.0-alpha.
|
|
49
|
-
"@loaders.gl/polyfills": "4.0.0-alpha.
|
|
50
|
-
"@loaders.gl/
|
|
51
|
-
"@loaders.gl/
|
|
52
|
-
"@loaders.gl/
|
|
42
|
+
"@loaders.gl/3d-tiles": "4.0.0-alpha.5",
|
|
43
|
+
"@loaders.gl/crypto": "4.0.0-alpha.5",
|
|
44
|
+
"@loaders.gl/draco": "4.0.0-alpha.5",
|
|
45
|
+
"@loaders.gl/gltf": "4.0.0-alpha.5",
|
|
46
|
+
"@loaders.gl/i3s": "4.0.0-alpha.5",
|
|
47
|
+
"@loaders.gl/images": "4.0.0-alpha.5",
|
|
48
|
+
"@loaders.gl/loader-utils": "4.0.0-alpha.5",
|
|
49
|
+
"@loaders.gl/polyfills": "4.0.0-alpha.5",
|
|
50
|
+
"@loaders.gl/textures": "4.0.0-alpha.5",
|
|
51
|
+
"@loaders.gl/tiles": "4.0.0-alpha.5",
|
|
52
|
+
"@loaders.gl/worker-utils": "4.0.0-alpha.5",
|
|
53
|
+
"@loaders.gl/zip": "4.0.0-alpha.5",
|
|
53
54
|
"@luma.gl/engine": "^8.5.4",
|
|
54
55
|
"@math.gl/core": "^3.5.1",
|
|
55
56
|
"@math.gl/culling": "^3.5.1",
|
|
57
|
+
"@math.gl/geoid": "^3.5.1",
|
|
56
58
|
"@math.gl/geospatial": "^3.5.1",
|
|
57
59
|
"archiver": "^5.0.0",
|
|
58
60
|
"cors": "^2.8.5",
|
|
@@ -66,7 +68,7 @@
|
|
|
66
68
|
"uuid": "^8.1.0"
|
|
67
69
|
},
|
|
68
70
|
"peerDependencies": {
|
|
69
|
-
"@loaders.gl/core": "
|
|
71
|
+
"@loaders.gl/core": "4.0.0-alpha.4"
|
|
70
72
|
},
|
|
71
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "7a71a54bdf1ddf985cc3af3db90b82e7fa97d025"
|
|
72
74
|
}
|
|
@@ -7,6 +7,7 @@ import transform from 'json-map-transform';
|
|
|
7
7
|
import {load} from '@loaders.gl/core';
|
|
8
8
|
import {I3SLoader, I3SAttributeLoader, COORDINATE_SYSTEM} from '@loaders.gl/i3s';
|
|
9
9
|
import {Tileset3D, Tile3D} from '@loaders.gl/tiles';
|
|
10
|
+
import {Geoid} from '@math.gl/geoid';
|
|
10
11
|
|
|
11
12
|
import {PGMLoader} from '../pgm-loader';
|
|
12
13
|
import {i3sObbTo3dTilesObb} from './helpers/i3s-obb-to-3d-tiles-obb';
|
|
@@ -16,7 +17,6 @@ import {calculateFilesSize, timeConverter} from '../lib/utils/statistic-utills';
|
|
|
16
17
|
import {TILESET as tilesetTemplate} from './json-templates/tileset';
|
|
17
18
|
import B3dmConverter from './helpers/b3dm-converter';
|
|
18
19
|
import {createObbFromMbs} from '../i3s-converter/helpers/coordinate-converter';
|
|
19
|
-
import {GeoidHeightModel} from '../lib/geoid-height-model';
|
|
20
20
|
|
|
21
21
|
const I3S = 'I3S';
|
|
22
22
|
|
|
@@ -28,9 +28,9 @@ export default class Tiles3DConverter {
|
|
|
28
28
|
tilesetPath: string;
|
|
29
29
|
vertexCounter: number;
|
|
30
30
|
conversionStartTime: [number, number];
|
|
31
|
-
geoidHeightModel:
|
|
32
|
-
sourceTileset: Tileset3D;
|
|
33
|
-
attributeStorageInfo: AttributeStorageInfo;
|
|
31
|
+
geoidHeightModel: Geoid | null;
|
|
32
|
+
sourceTileset: Tileset3D | null;
|
|
33
|
+
attributeStorageInfo: AttributeStorageInfo | null;
|
|
34
34
|
|
|
35
35
|
constructor() {
|
|
36
36
|
this.options = {};
|
|
@@ -51,7 +51,7 @@ export default class Tiles3DConverter {
|
|
|
51
51
|
* @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format
|
|
52
52
|
* @param options.maxDepth The max tree depth of conversion
|
|
53
53
|
*/
|
|
54
|
-
|
|
54
|
+
public async convert(options: {
|
|
55
55
|
inputUrl: string;
|
|
56
56
|
outputPath: string;
|
|
57
57
|
tilesetName: string;
|
|
@@ -67,12 +67,16 @@ export default class Tiles3DConverter {
|
|
|
67
67
|
console.log('Loading egm file completed!'); // eslint-disable-line
|
|
68
68
|
|
|
69
69
|
const sourceTilesetJson = await load(inputUrl, I3SLoader, {});
|
|
70
|
+
|
|
70
71
|
this.sourceTileset = new Tileset3D(sourceTilesetJson, {
|
|
71
|
-
loadOptions: {
|
|
72
|
+
loadOptions: {
|
|
73
|
+
i3s: {coordinateSystem: COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false}
|
|
74
|
+
}
|
|
72
75
|
});
|
|
73
76
|
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
const rootNode = this.sourceTileset.root!;
|
|
78
|
+
if (!rootNode.header.obb) {
|
|
79
|
+
rootNode.header.obb = createObbFromMbs(rootNode.header.mbs);
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
this.tilesetPath = join(`${outputPath}`, `${tilesetName}`);
|
|
@@ -86,15 +90,15 @@ export default class Tiles3DConverter {
|
|
|
86
90
|
|
|
87
91
|
const rootTile: Node3D = {
|
|
88
92
|
boundingVolume: {
|
|
89
|
-
box: i3sObbTo3dTilesObb(
|
|
93
|
+
box: i3sObbTo3dTilesObb(rootNode.header.obb, this.geoidHeightModel)
|
|
90
94
|
},
|
|
91
|
-
geometricError: convertScreenThresholdToGeometricError(
|
|
95
|
+
geometricError: convertScreenThresholdToGeometricError(rootNode),
|
|
92
96
|
children: []
|
|
93
97
|
};
|
|
94
98
|
|
|
95
|
-
await this._addChildren(
|
|
99
|
+
await this._addChildren(rootNode, rootTile, 1);
|
|
96
100
|
|
|
97
|
-
const tileset = transform({root: rootTile}, tilesetTemplate);
|
|
101
|
+
const tileset = transform({root: rootTile}, tilesetTemplate());
|
|
98
102
|
await writeFile(this.tilesetPath, JSON.stringify(tileset), 'tileset.json');
|
|
99
103
|
|
|
100
104
|
this._finishConversion({slpk: false, outputPath, tilesetName});
|
|
@@ -118,10 +122,10 @@ export default class Tiles3DConverter {
|
|
|
118
122
|
const sourceChild = await this._loadChildNode(parentSourceNode, childNodeInfo);
|
|
119
123
|
parentSourceNode.children.push(sourceChild);
|
|
120
124
|
if (sourceChild.contentUrl) {
|
|
121
|
-
await this.sourceTileset
|
|
125
|
+
await this.sourceTileset!._loadTile(sourceChild);
|
|
122
126
|
this.vertexCounter += sourceChild.content.vertexCount;
|
|
123
127
|
|
|
124
|
-
let attributes = null;
|
|
128
|
+
let attributes: FeatureAttribute | null = null;
|
|
125
129
|
if (this.attributeStorageInfo) {
|
|
126
130
|
attributes = await this._loadChildAttributes(sourceChild, this.attributeStorageInfo);
|
|
127
131
|
}
|
|
@@ -163,18 +167,18 @@ export default class Tiles3DConverter {
|
|
|
163
167
|
*/
|
|
164
168
|
private async _loadChildNode(parentNode: Tile3D, childNodeInfo: NodeReference): Promise<Tile3D> {
|
|
165
169
|
let header;
|
|
166
|
-
if (this.sourceTileset
|
|
170
|
+
if (this.sourceTileset!.tileset.nodePages) {
|
|
167
171
|
console.log(`Node conversion: ${childNodeInfo.id}`); // eslint-disable-line no-console,no-undef
|
|
168
|
-
header = await this.sourceTileset
|
|
172
|
+
header = await this.sourceTileset!.tileset.nodePagesTile.formTileFromNodePages(
|
|
169
173
|
childNodeInfo.id
|
|
170
174
|
);
|
|
171
175
|
} else {
|
|
172
|
-
const {loader} = this.sourceTileset
|
|
173
|
-
const nodeUrl = this._relativeUrlToFullUrl(parentNode.url, childNodeInfo.href);
|
|
176
|
+
const {loader} = this.sourceTileset!;
|
|
177
|
+
const nodeUrl = this._relativeUrlToFullUrl(parentNode.url, childNodeInfo.href!);
|
|
174
178
|
// load metadata
|
|
175
179
|
const options = {
|
|
176
180
|
i3s: {
|
|
177
|
-
...this.sourceTileset
|
|
181
|
+
...this.sourceTileset!.loadOptions,
|
|
178
182
|
isTileHeader: true,
|
|
179
183
|
loadContent: false
|
|
180
184
|
}
|
|
@@ -183,7 +187,7 @@ export default class Tiles3DConverter {
|
|
|
183
187
|
console.log(`Node conversion: ${nodeUrl}`); // eslint-disable-line no-console,no-undef
|
|
184
188
|
header = await load(nodeUrl, loader, options);
|
|
185
189
|
}
|
|
186
|
-
return new Tile3D(this.sourceTileset
|
|
190
|
+
return new Tile3D(this.sourceTileset!, header, parentNode);
|
|
187
191
|
}
|
|
188
192
|
|
|
189
193
|
/**
|
|
@@ -218,7 +222,7 @@ export default class Tiles3DConverter {
|
|
|
218
222
|
sourceChild: Tile3D,
|
|
219
223
|
attributeStorageInfo: AttributeStorageInfo
|
|
220
224
|
): Promise<FeatureAttribute> {
|
|
221
|
-
const promises = [];
|
|
225
|
+
const promises: any[] = [];
|
|
222
226
|
const {attributeUrls} = sourceChild.header;
|
|
223
227
|
|
|
224
228
|
for (let index = 0; index < attributeUrls.length; index++) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {encodeSync} from '@loaders.gl/core';
|
|
2
2
|
import {GLTFScenegraph, GLTFWriter} from '@loaders.gl/gltf';
|
|
3
3
|
import {Tile3DWriter} from '@loaders.gl/3d-tiles';
|
|
4
|
-
import {ImageWriter} from '@loaders.gl/images';
|
|
5
4
|
import {Matrix4, Vector3} from '@math.gl/core';
|
|
6
5
|
import {Ellipsoid} from '@math.gl/geospatial';
|
|
7
6
|
import {convertTextureAtlas} from './texture-atlas';
|
|
@@ -9,8 +8,20 @@ import {convertTextureAtlas} from './texture-atlas';
|
|
|
9
8
|
const Z_UP_TO_Y_UP_MATRIX = new Matrix4([1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
|
|
10
9
|
const scratchVector = new Vector3();
|
|
11
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Converts content of an I3S node to *.b3dm's file content
|
|
13
|
+
*/
|
|
12
14
|
export default class B3dmConverter {
|
|
13
|
-
|
|
15
|
+
// @ts-expect-error
|
|
16
|
+
rtcCenter: Float32Array;
|
|
17
|
+
i3sTile: any;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The starter of content conversion
|
|
21
|
+
* @param i3sTile - Tile3D instance for I3S node
|
|
22
|
+
* @returns - encoded content
|
|
23
|
+
*/
|
|
24
|
+
async convert(i3sTile: Object, attributes: any = null): Promise<ArrayBuffer> {
|
|
14
25
|
this.i3sTile = i3sTile;
|
|
15
26
|
const gltf = await this.buildGltf(i3sTile);
|
|
16
27
|
const b3dm = encodeSync(
|
|
@@ -25,13 +36,19 @@ export default class B3dmConverter {
|
|
|
25
36
|
return b3dm;
|
|
26
37
|
}
|
|
27
38
|
|
|
28
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Build and encode gltf
|
|
41
|
+
* @param i3sTile - Tile3D instance for I3S node
|
|
42
|
+
* @returns - encoded glb content
|
|
43
|
+
*/
|
|
44
|
+
async buildGltf(i3sTile): Promise<ArrayBuffer> {
|
|
29
45
|
const {
|
|
30
46
|
material,
|
|
31
47
|
attributes,
|
|
32
48
|
indices: originalIndices,
|
|
33
49
|
cartesianOrigin,
|
|
34
|
-
cartographicOrigin
|
|
50
|
+
cartographicOrigin,
|
|
51
|
+
modelMatrix
|
|
35
52
|
} = i3sTile.content;
|
|
36
53
|
const gltfBuilder = new GLTFScenegraph();
|
|
37
54
|
|
|
@@ -52,7 +69,8 @@ export default class B3dmConverter {
|
|
|
52
69
|
attributes.positions.value = this._normalizePositions(
|
|
53
70
|
positionsValue,
|
|
54
71
|
cartesianOrigin,
|
|
55
|
-
cartographicOrigin
|
|
72
|
+
cartographicOrigin,
|
|
73
|
+
modelMatrix
|
|
56
74
|
);
|
|
57
75
|
if (attributes.normals && !this._checkNormals(attributes.normals.value)) {
|
|
58
76
|
delete attributes.normals;
|
|
@@ -62,7 +80,8 @@ export default class B3dmConverter {
|
|
|
62
80
|
const meshIndex = gltfBuilder.addMesh({
|
|
63
81
|
attributes,
|
|
64
82
|
indices,
|
|
65
|
-
material: materialIndex
|
|
83
|
+
material: materialIndex,
|
|
84
|
+
mode: 4
|
|
66
85
|
});
|
|
67
86
|
const transformMatrix = this._generateTransformMatrix(cartesianOrigin);
|
|
68
87
|
const nodeIndex = gltfBuilder.addNode({meshIndex, matrix: transformMatrix});
|
|
@@ -97,8 +116,7 @@ export default class B3dmConverter {
|
|
|
97
116
|
}
|
|
98
117
|
if (selectedTexture) {
|
|
99
118
|
const mimeType = this._deduceMimeTypeFromFormat(textureFormat);
|
|
100
|
-
const
|
|
101
|
-
const imageIndex = gltfBuilder.addImage(imageBuffer, mimeType);
|
|
119
|
+
const imageIndex = gltfBuilder.addImage(selectedTexture, mimeType);
|
|
102
120
|
textureIndex = gltfBuilder.addTexture({imageIndex});
|
|
103
121
|
delete attributes.colors;
|
|
104
122
|
}
|
|
@@ -109,14 +127,18 @@ export default class B3dmConverter {
|
|
|
109
127
|
* Generate a positions array which is correct for 3DTiles/GLTF format
|
|
110
128
|
* @param {Float64Array} positionsValue - the input geometry positions array
|
|
111
129
|
* @param {number[]} cartesianOrigin - the tile center in the cartesian coordinate system
|
|
130
|
+
* @param {number[]} cartographicOrigin - the tile center in the cartographic coordinate system
|
|
131
|
+
* @param {number[]} modelMatrix - the model matrix of geometry
|
|
112
132
|
* @returns {Float32Array} - the output geometry positions array
|
|
113
133
|
*/
|
|
114
|
-
_normalizePositions(positionsValue, cartesianOrigin, cartographicOrigin) {
|
|
134
|
+
_normalizePositions(positionsValue, cartesianOrigin, cartographicOrigin, modelMatrix) {
|
|
115
135
|
const newPositionsValue = new Float32Array(positionsValue.length);
|
|
116
136
|
for (let index = 0; index < positionsValue.length; index += 3) {
|
|
117
137
|
const vertex = positionsValue.subarray(index, index + 3);
|
|
118
138
|
const cartesianOriginVector = new Vector3(cartesianOrigin);
|
|
119
|
-
let vertexVector = new Vector3(Array.from(vertex))
|
|
139
|
+
let vertexVector = new Vector3(Array.from(vertex))
|
|
140
|
+
.transform(modelMatrix)
|
|
141
|
+
.add(cartographicOrigin);
|
|
120
142
|
Ellipsoid.WGS84.cartographicToCartesian(vertexVector, scratchVector);
|
|
121
143
|
vertexVector = scratchVector.subtract(cartesianOriginVector);
|
|
122
144
|
newPositionsValue.set(vertexVector, index);
|
|
@@ -187,6 +209,8 @@ export default class B3dmConverter {
|
|
|
187
209
|
return 'image/jpeg';
|
|
188
210
|
case 'png':
|
|
189
211
|
return 'image/png';
|
|
212
|
+
case 'ktx2':
|
|
213
|
+
return 'image/ktx2';
|
|
190
214
|
default:
|
|
191
215
|
console.warn(`Unexpected texture format in I3S: ${format}`); // eslint-disable-line no-console, no-undef
|
|
192
216
|
return 'image/jpeg';
|
package/src/3d-tiles-converter/helpers/{i3s-obb-to-3d-tiles-obb.js → i3s-obb-to-3d-tiles-obb.ts}
RENAMED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import {Vector3} from '@math.gl/core';
|
|
2
2
|
import {Ellipsoid} from '@math.gl/geospatial';
|
|
3
3
|
import {OrientedBoundingBox} from '@math.gl/culling';
|
|
4
|
+
// @ts-expect-error
|
|
5
|
+
import {GeoidHeightModel} from '@loaders.gl/tile-converter/lib/geoid-height-model';
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Convert quaternion-based OBB to half-axes-based OBB
|
|
9
|
+
* @param i3SObb quaternion based OBB
|
|
10
|
+
* @param geoidHeightModel the Earth Gravity Model instance
|
|
11
|
+
* @returns number[12] 3DTiles OBB https://github.com/CesiumGS/3d-tiles/tree/master/specification#box
|
|
12
|
+
*/
|
|
13
|
+
export function i3sObbTo3dTilesObb(
|
|
14
|
+
i3SObb: {
|
|
15
|
+
center: number[];
|
|
16
|
+
halfSize: number[];
|
|
17
|
+
quaternion: number[];
|
|
18
|
+
},
|
|
19
|
+
geoidHeightModel: GeoidHeightModel
|
|
20
|
+
): number[] {
|
|
6
21
|
const tiles3DCenter = [
|
|
7
22
|
i3SObb.center[0],
|
|
8
23
|
i3SObb.center[1],
|
|
@@ -13,7 +13,7 @@ export function convertTextureAtlas(texCoords: Float32Array, uvRegions: Uint16Ar
|
|
|
13
13
|
const uv = texCoords.subarray(index, index + 2);
|
|
14
14
|
const regions = normalisedRegions.slice(index * 2, index * 2 + 4);
|
|
15
15
|
// fract(texCoords)
|
|
16
|
-
const fractatedUV = fract(uv);
|
|
16
|
+
const fractatedUV = fract([uv[0], uv[1]]);
|
|
17
17
|
// (uvRegions.zw - uvRegions.xy)
|
|
18
18
|
const subtracted = [regions[2] - regions[0], regions[3] - regions[1]];
|
|
19
19
|
// fract(texCoords) * (uvRegions.zw - uvRegions.xy)
|
|
@@ -35,7 +35,7 @@ export function convertTextureAtlas(texCoords: Float32Array, uvRegions: Uint16Ar
|
|
|
35
35
|
* Do fractation of UV array.
|
|
36
36
|
* @param uv
|
|
37
37
|
*/
|
|
38
|
-
function fract(uv: number
|
|
38
|
+
function fract(uv: [number, number]): [number, number] {
|
|
39
39
|
return [uv[0] - Math.floor(uv[0]), uv[1] - Math.floor(uv[1])];
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -43,9 +43,9 @@ function fract(uv: number[2]): number[2] {
|
|
|
43
43
|
* Normalize uvRegions by dividing by the maximum Uint16 value
|
|
44
44
|
* @param regions
|
|
45
45
|
*/
|
|
46
|
-
function normalizeRegions(regions: Uint16Array): number[
|
|
46
|
+
function normalizeRegions(regions: Uint16Array): number[] {
|
|
47
47
|
const MAX_UINT_16_VALUE = 65535;
|
|
48
|
-
const normalizedRegions = [];
|
|
48
|
+
const normalizedRegions: number[] = [];
|
|
49
49
|
|
|
50
50
|
for (let index = 0; index < regions.length; index++) {
|
|
51
51
|
normalizedRegions[index] = regions[index] / MAX_UINT_16_VALUE;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import transform from 'json-map-transform';
|
|
2
2
|
|
|
3
|
-
const ASSET = {
|
|
3
|
+
const ASSET = () => ({
|
|
4
4
|
version: {
|
|
5
5
|
path: 'version',
|
|
6
6
|
default: '1.0'
|
|
7
7
|
}
|
|
8
|
-
};
|
|
8
|
+
});
|
|
9
9
|
|
|
10
|
-
const TILE = {
|
|
10
|
+
const TILE = () => ({
|
|
11
11
|
boundingVolume: {
|
|
12
12
|
path: 'boundingVolume'
|
|
13
13
|
},
|
|
@@ -19,14 +19,14 @@ const TILE = {
|
|
|
19
19
|
},
|
|
20
20
|
children: {
|
|
21
21
|
path: 'children',
|
|
22
|
-
transform: (val) => val.map((tile) => transform(tile, TILE))
|
|
22
|
+
transform: (val) => val.map((tile) => transform(tile, TILE()))
|
|
23
23
|
}
|
|
24
|
-
};
|
|
24
|
+
});
|
|
25
25
|
|
|
26
|
-
export const TILESET = {
|
|
26
|
+
export const TILESET = () => ({
|
|
27
27
|
asset: {
|
|
28
28
|
path: 'asset',
|
|
29
|
-
transform: (val) => transform(val, ASSET)
|
|
29
|
+
transform: (val) => transform(val, ASSET())
|
|
30
30
|
},
|
|
31
31
|
geometricError: {
|
|
32
32
|
path: 'root',
|
|
@@ -34,6 +34,6 @@ export const TILESET = {
|
|
|
34
34
|
},
|
|
35
35
|
root: {
|
|
36
36
|
path: 'root',
|
|
37
|
-
transform: (val) => transform(val, TILE)
|
|
37
|
+
transform: (val) => transform(val, TILE())
|
|
38
38
|
}
|
|
39
|
-
};
|
|
39
|
+
});
|
|
@@ -3,12 +3,12 @@ import {ZipLoader} from '@loaders.gl/zip';
|
|
|
3
3
|
import {writeFile} from '../lib/utils/file-utils';
|
|
4
4
|
import {join} from 'path';
|
|
5
5
|
|
|
6
|
-
const PGM_LINK = 'https://
|
|
6
|
+
const PGM_LINK = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip';
|
|
7
7
|
|
|
8
8
|
export class DepsInstaller {
|
|
9
9
|
async install(path = '') {
|
|
10
10
|
console.log('Installing "EGM2008-5" model...'); // eslint-disable-line no-console
|
|
11
|
-
const fileMap = await load(PGM_LINK, ZipLoader, {
|
|
11
|
+
const fileMap = await load(PGM_LINK, ZipLoader, {});
|
|
12
12
|
|
|
13
13
|
let depsPath = process.cwd();
|
|
14
14
|
if (path) {
|
|
@@ -2,9 +2,13 @@ import type {BoundingVolumes, Extent, Mbs, Obb} from '@loaders.gl/i3s';
|
|
|
2
2
|
|
|
3
3
|
import {Matrix3, Quaternion, Vector3} from '@math.gl/core';
|
|
4
4
|
import {Ellipsoid} from '@math.gl/geospatial';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
OrientedBoundingBox,
|
|
7
|
+
makeOrientedBoundingBoxFromPoints,
|
|
8
|
+
makeBoundingSphereFromPoints
|
|
9
|
+
} from '@math.gl/culling';
|
|
6
10
|
import TileHeader from '@loaders.gl/tiles/src/tileset/tile-3d';
|
|
7
|
-
import {
|
|
11
|
+
import {Geoid} from '@math.gl/geoid';
|
|
8
12
|
import {Tileset3D} from '@loaders.gl/tiles';
|
|
9
13
|
|
|
10
14
|
/**
|
|
@@ -13,10 +17,7 @@ import {Tileset3D} from '@loaders.gl/tiles';
|
|
|
13
17
|
* @param geoidHeightModel
|
|
14
18
|
* @returns - Bounding volumes object
|
|
15
19
|
*/
|
|
16
|
-
export function createBoundingVolumes(
|
|
17
|
-
tile: TileHeader,
|
|
18
|
-
geoidHeightModel: GeoidHeightModel
|
|
19
|
-
): BoundingVolumes {
|
|
20
|
+
export function createBoundingVolumes(tile: TileHeader, geoidHeightModel: Geoid): BoundingVolumes {
|
|
20
21
|
let radius;
|
|
21
22
|
let halfSize;
|
|
22
23
|
let quaternion;
|
|
@@ -51,14 +52,66 @@ export function createBoundingVolumes(
|
|
|
51
52
|
};
|
|
52
53
|
}
|
|
53
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Generates bounding volumes from geometry positions
|
|
57
|
+
* @param cartesianPositions
|
|
58
|
+
* @param geoidHeightModel
|
|
59
|
+
*/
|
|
60
|
+
export function createBoundingVolumesFromGeometry(
|
|
61
|
+
cartesianPositions: Float32Array,
|
|
62
|
+
geoidHeightModel: Geoid
|
|
63
|
+
): {mbs: Mbs; obb: Obb} {
|
|
64
|
+
const positionVectors = convertPositionsToVectors(cartesianPositions);
|
|
65
|
+
|
|
66
|
+
const geometryObb = makeOrientedBoundingBoxFromPoints(positionVectors);
|
|
67
|
+
const geometryMbs = makeBoundingSphereFromPoints(positionVectors);
|
|
68
|
+
|
|
69
|
+
let mbsCenter = Ellipsoid.WGS84.cartesianToCartographic(geometryMbs.center, new Vector3());
|
|
70
|
+
let obbCenter = Ellipsoid.WGS84.cartesianToCartographic(geometryObb.center, new Vector3());
|
|
71
|
+
|
|
72
|
+
mbsCenter[2] = mbsCenter[2] - geoidHeightModel.getHeight(mbsCenter[1], mbsCenter[0]);
|
|
73
|
+
obbCenter[2] = obbCenter[2] - geoidHeightModel.getHeight(obbCenter[1], obbCenter[0]);
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
mbs: [mbsCenter[0], mbsCenter[1], mbsCenter[2], geometryMbs.radius],
|
|
77
|
+
obb: {
|
|
78
|
+
center: obbCenter,
|
|
79
|
+
halfSize: geometryObb.halfSize,
|
|
80
|
+
quaternion: geometryObb.quaternion
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Create array of posisitons where each vertex is vector
|
|
87
|
+
* @param {array} positions
|
|
88
|
+
* @returns {Vector3[]}
|
|
89
|
+
*/
|
|
90
|
+
export function convertPositionsToVectors(positions: Float32Array): Vector3[] {
|
|
91
|
+
const result: Vector3[] = [];
|
|
92
|
+
|
|
93
|
+
for (let i = 0; i < positions.length; i += 3) {
|
|
94
|
+
// TODO: (perf) new Vector3 is not optimal but required in `makeOrientedBoundingBoxFromPoints`.
|
|
95
|
+
// modify `makeOrientedBoundingBoxFromPoints` to use scratch vectors
|
|
96
|
+
const positionVector = new Vector3([positions[i], positions[i + 1], positions[i + 2]]);
|
|
97
|
+
result.push(positionVector);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
|
|
54
103
|
/**
|
|
55
104
|
* Convert common coordinate to extent coordinate
|
|
56
105
|
* @param tileset
|
|
57
106
|
* @returns - Extent
|
|
107
|
+
* @todo why lodMetricValue is radius? need to check this function
|
|
58
108
|
*/
|
|
59
|
-
export function convertCommonToI3SExtentCoordinate(tileset: Tileset3D): Extent {
|
|
60
|
-
const cartesianCenter = tileset
|
|
61
|
-
|
|
109
|
+
export function convertCommonToI3SExtentCoordinate(tileset: Tileset3D | null): Extent | null {
|
|
110
|
+
const cartesianCenter = tileset?.cartesianCenter;
|
|
111
|
+
if (!cartesianCenter) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const radius = tileset?.lodMetricValue;
|
|
62
115
|
const rightTop = Ellipsoid.WGS84.cartesianToCartographic(
|
|
63
116
|
new Vector3(cartesianCenter[0] + radius, cartesianCenter[1] + radius, cartesianCenter[2]),
|
|
64
117
|
new Vector3()
|
package/src/i3s-converter/helpers/{create-scene-server-path.js → create-scene-server-path.ts}
RENAMED
|
@@ -2,7 +2,7 @@ import {v4 as uuidv4} from 'uuid';
|
|
|
2
2
|
import transform from 'json-map-transform';
|
|
3
3
|
import {join} from 'path';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {SCENE_SERVER as sceneServerTemplate} from '../json-templates/scene-server';
|
|
6
6
|
import {writeFile} from '../../lib/utils/file-utils';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -19,7 +19,7 @@ export async function createSceneServerPath(layerName, layers0, rootPath) {
|
|
|
19
19
|
layers0
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
const sceneServer = transform(sceneServerData,
|
|
22
|
+
const sceneServer = transform(sceneServerData, sceneServerTemplate());
|
|
23
23
|
const nodePagePath = join(rootPath, 'SceneServer');
|
|
24
24
|
await writeFile(nodePagePath, JSON.stringify(sceneServer));
|
|
25
25
|
}
|
|
@@ -41,8 +41,8 @@ function calculateFaceRangesAndFeaturesCount(featureIndices) {
|
|
|
41
41
|
let rangeIndex = 1;
|
|
42
42
|
let featureIndex = 1;
|
|
43
43
|
let currentFeatureId = featureIndices[0];
|
|
44
|
-
const faceRangeList = [];
|
|
45
|
-
const featureIds = [];
|
|
44
|
+
const faceRangeList: any[] = [];
|
|
45
|
+
const featureIds: any[] = [];
|
|
46
46
|
const uniqueFeatureIds = [currentFeatureId];
|
|
47
47
|
|
|
48
48
|
faceRangeList[0] = 0;
|
|
@@ -79,7 +79,7 @@ function calculateFaceRangesAndFeaturesCount(featureIndices) {
|
|
|
79
79
|
*/
|
|
80
80
|
function makeAttributeObjects(attributes) {
|
|
81
81
|
const {featureIds, positions, normals, colors, texCoords, faceRange} = attributes;
|
|
82
|
-
const groupedData = [];
|
|
82
|
+
const groupedData: any[] = [];
|
|
83
83
|
|
|
84
84
|
let positionsList = new Float32Array(positions);
|
|
85
85
|
let normalsList = new Float32Array(normals);
|
|
@@ -149,7 +149,7 @@ function getSliceAttributeCount(attributeName, startIndex, endIndex) {
|
|
|
149
149
|
* @returns {Array} - unique list of objects
|
|
150
150
|
*/
|
|
151
151
|
function unifyObjectsByFeatureId(sortedData) {
|
|
152
|
-
const uniqueObjects = [];
|
|
152
|
+
const uniqueObjects: any[] = [];
|
|
153
153
|
|
|
154
154
|
for (let index = 0; index < sortedData.length; index++) {
|
|
155
155
|
const currentObject = sortedData[index];
|