@loaders.gl/tile-converter 3.1.3 → 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/{esm/3d-tiles-converter → 3d-tiles-converter}/3d-tiles-converter.js +2 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js.map +1 -0
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +83 -0
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -0
- package/dist/{esm/3d-tiles-converter → 3d-tiles-converter}/helpers/b3dm-converter.js +7 -5
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -0
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +13 -0
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts.map +1 -0
- package/dist/{esm/3d-tiles-converter → 3d-tiles-converter}/helpers/i3s-obb-to-3d-tiles-obb.js +0 -0
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -0
- 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/{esm/3d-tiles-converter → 3d-tiles-converter}/helpers/texture-atlas.js +0 -0
- package/dist/3d-tiles-converter/helpers/texture-atlas.js.map +1 -0
- 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/{esm/3d-tiles-converter → 3d-tiles-converter}/json-templates/tileset.js +0 -0
- package/dist/3d-tiles-converter/json-templates/tileset.js.map +1 -0
- package/dist/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/{esm/bundle.js → bundle.js} +0 -0
- package/dist/bundle.js.map +1 -0
- package/dist/converter.min.js +21 -21
- package/dist/{es5/deps-installer → deps-installer}/deps-installer.d.ts +0 -0
- package/dist/deps-installer/deps-installer.d.ts.map +1 -0
- package/dist/{esm/deps-installer → deps-installer}/deps-installer.js +0 -0
- package/dist/deps-installer/deps-installer.js.map +1 -0
- package/dist/dist.min.js +201 -445
- 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/{esm/i3s-converter → i3s-converter}/helpers/coordinate-converter.js +0 -0
- package/dist/i3s-converter/helpers/coordinate-converter.js.map +1 -0
- 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/{esm/i3s-converter → i3s-converter}/helpers/create-scene-server-path.js +0 -0
- package/dist/i3s-converter/helpers/create-scene-server-path.js.map +1 -0
- 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/{esm/i3s-converter → i3s-converter}/helpers/geometry-attributes.js +0 -0
- package/dist/i3s-converter/helpers/geometry-attributes.js.map +1 -0
- package/dist/{es5/i3s-converter → i3s-converter}/helpers/geometry-converter.d.ts +0 -0
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -0
- package/dist/{esm/i3s-converter → i3s-converter}/helpers/geometry-converter.js +31 -4
- package/dist/i3s-converter/helpers/geometry-converter.js.map +1 -0
- 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/{esm/i3s-converter → i3s-converter}/helpers/node-debug.js +0 -0
- package/dist/i3s-converter/helpers/node-debug.js.map +1 -0
- package/dist/i3s-converter/helpers/node-pages.d.ts +116 -0
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -0
- package/dist/{esm/i3s-converter → i3s-converter}/helpers/node-pages.js +0 -0
- package/dist/i3s-converter/helpers/node-pages.js.map +1 -0
- package/dist/i3s-converter/i3s-converter.d.ts +320 -0
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -0
- package/dist/{esm/i3s-converter → i3s-converter}/i3s-converter.js +0 -0
- package/dist/i3s-converter/i3s-converter.js.map +1 -0
- 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/{esm/i3s-converter → i3s-converter}/json-templates/layers.js +0 -0
- package/dist/i3s-converter/json-templates/layers.js.map +1 -0
- 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/{esm/i3s-converter → i3s-converter}/json-templates/metadata.js +0 -0
- package/dist/i3s-converter/json-templates/metadata.js.map +1 -0
- 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/{esm/i3s-converter → i3s-converter}/json-templates/node.js +0 -0
- package/dist/i3s-converter/json-templates/node.js.map +1 -0
- 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/{esm/i3s-converter → i3s-converter}/json-templates/scene-server.js +0 -0
- package/dist/i3s-converter/json-templates/scene-server.js.map +1 -0
- 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/{esm/i3s-converter → i3s-converter}/json-templates/shared-resources.js +0 -0
- package/dist/i3s-converter/json-templates/shared-resources.js.map +1 -0
- 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/{esm/i3s-converter → i3s-converter}/json-templates/store.js +0 -0
- package/dist/i3s-converter/json-templates/store.js.map +1 -0
- package/dist/i3s-converter/types.d.ts +14 -0
- package/dist/i3s-converter/types.d.ts.map +1 -0
- package/dist/{esm/i3s-converter → i3s-converter}/types.js +0 -0
- package/dist/{es5/i3s-converter → i3s-converter}/types.js.map +0 -0
- package/dist/i3s-server/app.d.ts +3 -0
- package/dist/i3s-server/app.d.ts.map +1 -0
- package/dist/{esm/i3s-server → i3s-server}/app.js +0 -0
- package/dist/i3s-server/app.js.map +1 -0
- package/dist/{es5/i3s-server → i3s-server}/bin/www +0 -0
- package/dist/{es5/i3s-server → i3s-server}/certs/cert.pem +0 -0
- package/dist/{es5/i3s-server → i3s-server}/certs/key.pem +0 -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/{esm/i3s-server → i3s-server}/controllers/index-controller.js +0 -0
- package/dist/i3s-server/controllers/index-controller.js.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/{esm/i3s-server → i3s-server}/routes/index.js +0 -0
- package/dist/i3s-server/routes/index.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/{esm/index.js → index.js} +0 -0
- package/dist/index.js.map +1 -0
- package/dist/{es5/lib → lib}/utils/compress-util.d.ts +0 -0
- package/dist/lib/utils/compress-util.d.ts.map +1 -0
- package/dist/{esm/lib → lib}/utils/compress-util.js +0 -0
- package/dist/lib/utils/compress-util.js.map +1 -0
- package/dist/{es5/lib → lib}/utils/file-utils.d.ts +0 -0
- package/dist/lib/utils/file-utils.d.ts.map +1 -0
- package/dist/{esm/lib → lib}/utils/file-utils.js +0 -0
- package/dist/lib/utils/file-utils.js.map +1 -0
- package/dist/{es5/lib → lib}/utils/lod-conversion-utils.d.ts +0 -0
- package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -0
- package/dist/{esm/lib → lib}/utils/lod-conversion-utils.js +0 -0
- package/dist/lib/utils/lod-conversion-utils.js.map +1 -0
- package/dist/{es5/lib → lib}/utils/statistic-utills.d.ts +0 -0
- package/dist/lib/utils/statistic-utills.d.ts.map +1 -0
- package/dist/{esm/lib → lib}/utils/statistic-utills.js +0 -0
- package/dist/lib/utils/statistic-utills.js.map +1 -0
- package/dist/pgm-loader.d.ts +6 -0
- package/dist/pgm-loader.d.ts.map +1 -0
- package/dist/{esm/pgm-loader.js → pgm-loader.js} +1 -1
- package/dist/pgm-loader.js.map +1 -0
- package/package.json +18 -19
- package/src/3d-tiles-converter/3d-tiles-converter.ts +4 -1
- package/src/3d-tiles-converter/helpers/b3dm-converter.ts +6 -5
- package/src/i3s-converter/helpers/geometry-converter.js +39 -4
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +0 -507
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +0 -1
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +0 -366
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +0 -1
- package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -26
- package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +0 -1
- package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js +0 -40
- package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +0 -1
- package/dist/es5/3d-tiles-converter/json-templates/tileset.js +0 -67
- package/dist/es5/3d-tiles-converter/json-templates/tileset.js.map +0 -1
- package/dist/es5/bundle.js +0 -7
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/deps-installer/deps-installer.js +0 -83
- package/dist/es5/deps-installer/deps-installer.js.map +0 -1
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js +0 -104
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +0 -1
- package/dist/es5/i3s-converter/helpers/create-scene-server-path.js +0 -54
- package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +0 -1
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js +0 -218
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +0 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +0 -911
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +0 -1
- package/dist/es5/i3s-converter/helpers/node-debug.js +0 -99
- package/dist/es5/i3s-converter/helpers/node-debug.js.map +0 -1
- package/dist/es5/i3s-converter/helpers/node-pages.js +0 -258
- package/dist/es5/i3s-converter/helpers/node-pages.js.map +0 -1
- package/dist/es5/i3s-converter/i3s-converter.js +0 -1860
- package/dist/es5/i3s-converter/i3s-converter.js.map +0 -1
- package/dist/es5/i3s-converter/json-templates/layers.js +0 -239
- package/dist/es5/i3s-converter/json-templates/layers.js.map +0 -1
- package/dist/es5/i3s-converter/json-templates/metadata.js +0 -33
- package/dist/es5/i3s-converter/json-templates/metadata.js.map +0 -1
- package/dist/es5/i3s-converter/json-templates/node.js +0 -109
- package/dist/es5/i3s-converter/json-templates/node.js.map +0 -1
- package/dist/es5/i3s-converter/json-templates/scene-server.js +0 -41
- package/dist/es5/i3s-converter/json-templates/scene-server.js.map +0 -1
- package/dist/es5/i3s-converter/json-templates/shared-resources.js +0 -196
- package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +0 -1
- package/dist/es5/i3s-converter/json-templates/store.js +0 -107
- package/dist/es5/i3s-converter/json-templates/store.js.map +0 -1
- package/dist/es5/i3s-converter/types.js +0 -2
- package/dist/es5/i3s-server/app.js +0 -23
- package/dist/es5/i3s-server/app.js.map +0 -1
- package/dist/es5/i3s-server/controllers/index-controller.js +0 -73
- package/dist/es5/i3s-server/controllers/index-controller.js.map +0 -1
- package/dist/es5/i3s-server/routes/index.js +0 -49
- package/dist/es5/i3s-server/routes/index.js.map +0 -1
- package/dist/es5/index.js +0 -40
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/lib/utils/compress-util.js +0 -424
- package/dist/es5/lib/utils/compress-util.js.map +0 -1
- package/dist/es5/lib/utils/file-utils.js +0 -137
- package/dist/es5/lib/utils/file-utils.js.map +0 -1
- package/dist/es5/lib/utils/lod-conversion-utils.js +0 -52
- package/dist/es5/lib/utils/lod-conversion-utils.js.map +0 -1
- package/dist/es5/lib/utils/statistic-utills.js +0 -196
- package/dist/es5/lib/utils/statistic-utills.js.map +0 -1
- package/dist/es5/pgm-loader.js +0 -51
- package/dist/es5/pgm-loader.js.map +0 -1
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +0 -1
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +0 -1
- package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +0 -1
- package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +0 -1
- package/dist/esm/3d-tiles-converter/json-templates/tileset.js.map +0 -1
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/deps-installer/deps-installer.d.ts +0 -10
- package/dist/esm/deps-installer/deps-installer.js.map +0 -1
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +0 -1
- package/dist/esm/i3s-converter/helpers/create-scene-server-path.js.map +0 -1
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +0 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.d.ts +0 -44
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +0 -1
- package/dist/esm/i3s-converter/helpers/node-debug.js.map +0 -1
- package/dist/esm/i3s-converter/helpers/node-pages.js.map +0 -1
- package/dist/esm/i3s-converter/i3s-converter.js.map +0 -1
- package/dist/esm/i3s-converter/json-templates/layers.js.map +0 -1
- package/dist/esm/i3s-converter/json-templates/metadata.js.map +0 -1
- package/dist/esm/i3s-converter/json-templates/node.js.map +0 -1
- package/dist/esm/i3s-converter/json-templates/scene-server.js.map +0 -1
- package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +0 -1
- package/dist/esm/i3s-converter/json-templates/store.js.map +0 -1
- package/dist/esm/i3s-converter/types.js.map +0 -1
- package/dist/esm/i3s-server/app.js.map +0 -1
- package/dist/esm/i3s-server/bin/www +0 -102
- package/dist/esm/i3s-server/certs/cert.pem +0 -19
- package/dist/esm/i3s-server/certs/key.pem +0 -27
- package/dist/esm/i3s-server/controllers/index-controller.js.map +0 -1
- package/dist/esm/i3s-server/routes/index.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lib/utils/compress-util.d.ts +0 -53
- package/dist/esm/lib/utils/compress-util.js.map +0 -1
- package/dist/esm/lib/utils/file-utils.d.ts +0 -43
- package/dist/esm/lib/utils/file-utils.js.map +0 -1
- package/dist/esm/lib/utils/lod-conversion-utils.d.ts +0 -32
- package/dist/esm/lib/utils/lod-conversion-utils.js.map +0 -1
- package/dist/esm/lib/utils/statistic-utills.d.ts +0 -25
- package/dist/esm/lib/utils/statistic-utills.js.map +0 -1
- package/dist/esm/pgm-loader.js.map +0 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { BoundingVolumes, Extent, Mbs, Obb } from '@loaders.gl/i3s';
|
|
2
|
+
import { Vector3 } from '@math.gl/core';
|
|
3
|
+
import TileHeader from '@loaders.gl/tiles/src/tileset/tile-3d';
|
|
4
|
+
import { Geoid } from '@math.gl/geoid';
|
|
5
|
+
import { Tileset3D } from '@loaders.gl/tiles';
|
|
6
|
+
/**
|
|
7
|
+
* Create bounding volumes object from tile and geoid height model.
|
|
8
|
+
* @param tile
|
|
9
|
+
* @param geoidHeightModel
|
|
10
|
+
* @returns - Bounding volumes object
|
|
11
|
+
*/
|
|
12
|
+
export declare function createBoundingVolumes(tile: TileHeader, geoidHeightModel: Geoid): BoundingVolumes;
|
|
13
|
+
/**
|
|
14
|
+
* Generates bounding volumes from geometry positions
|
|
15
|
+
* @param cartesianPositions
|
|
16
|
+
* @param geoidHeightModel
|
|
17
|
+
*/
|
|
18
|
+
export declare function createBoundingVolumesFromGeometry(cartesianPositions: Float32Array, geoidHeightModel: Geoid): {
|
|
19
|
+
mbs: Mbs;
|
|
20
|
+
obb: Obb;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Create array of posisitons where each vertex is vector
|
|
24
|
+
* @param {array} positions
|
|
25
|
+
* @returns {Vector3[]}
|
|
26
|
+
*/
|
|
27
|
+
export declare function convertPositionsToVectors(positions: Float32Array): Vector3[];
|
|
28
|
+
/**
|
|
29
|
+
* Convert common coordinate to extent coordinate
|
|
30
|
+
* @param tileset
|
|
31
|
+
* @returns - Extent
|
|
32
|
+
* @todo why lodMetricValue is radius? need to check this function
|
|
33
|
+
*/
|
|
34
|
+
export declare function convertCommonToI3SExtentCoordinate(tileset: Tileset3D | null): Extent | null;
|
|
35
|
+
/**
|
|
36
|
+
* Creates oriented boundinb box from mbs.
|
|
37
|
+
* @param mbs - Minimum Bounding Sphere
|
|
38
|
+
* @returns - Oriented BOunding Box
|
|
39
|
+
*/
|
|
40
|
+
export declare function createObbFromMbs(mbs: Mbs): Obb;
|
|
41
|
+
//# sourceMappingURL=coordinate-converter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinate-converter.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/coordinate-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,eAAe,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAEvE,OAAO,EAAsB,OAAO,EAAC,MAAM,eAAe,CAAC;AAO3D,OAAO,UAAU,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAE5C;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,UAAU,EAAE,gBAAgB,EAAE,KAAK,GAAG,eAAe,CAiChG;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAC/C,kBAAkB,EAAE,YAAY,EAChC,gBAAgB,EAAE,KAAK,GACtB;IAAC,GAAG,EAAE,GAAG,CAAC;IAAC,GAAG,EAAE,GAAG,CAAA;CAAC,CAoBtB;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,YAAY,GAAG,OAAO,EAAE,CAW5E;AAED;;;;;GAKG;AACH,wBAAgB,kCAAkC,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAuB3F;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAK9C"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/i3s-converter/helpers/coordinate-converter.ts"],"names":["Matrix3","Quaternion","Vector3","Ellipsoid","OrientedBoundingBox","makeOrientedBoundingBoxFromPoints","makeBoundingSphereFromPoints","createBoundingVolumes","tile","geoidHeightModel","radius","halfSize","quaternion","boundingVolume","cartographicCenter","WGS84","cartesianToCartographic","center","getHeight","len","fromMatrix3","normalize","mbs","obb","createBoundingVolumesFromGeometry","cartesianPositions","positionVectors","convertPositionsToVectors","geometryObb","geometryMbs","mbsCenter","obbCenter","positions","result","i","length","positionVector","push","convertCommonToI3SExtentCoordinate","tileset","cartesianCenter","lodMetricValue","rightTop","leftBottom","isFirstRight","isFirstTop","createObbFromMbs","halfAxex"],"mappings":"AAEA,SAAQA,OAAR,EAAiBC,UAAjB,EAA6BC,OAA7B,QAA2C,eAA3C;AACA,SAAQC,SAAR,QAAwB,qBAAxB;AACA,SACEC,mBADF,EAEEC,iCAFF,EAGEC,4BAHF,QAIO,kBAJP;AAeA,OAAO,SAASC,qBAAT,CAA+BC,IAA/B,EAAiDC,gBAAjD,EAA2F;AAChG,MAAIC,MAAJ;AACA,MAAIC,QAAJ;AACA,MAAIC,UAAJ;AAEA,QAAMC,cAAc,GAAGL,IAAI,CAACK,cAA5B;AACA,QAAMC,kBAAkB,GAAGX,SAAS,CAACY,KAAV,CAAgBC,uBAAhB,CACzBH,cAAc,CAACI,MADU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,CADiB,EAEjB,IAAItC,OAAJ,EAFiB,CAAnB;AAIA,QAAM0C,YAAY,GAAGF,QAAQ,CAAC,CAAD,CAAR,GAAcC,UAAU,CAAC,CAAD,CAA7C;AACA,QAAME,UAAU,GAAGH,QAAQ,CAAC,CAAD,CAAR,GAAcC,UAAU,CAAC,CAAD,CAA3C;AAEA,SAAO,CACLC,YAAY,GAAGF,QAAQ,CAAC,CAAD,CAAX,GAAiBC,UAAU,CAAC,CAAD,CADlC,EAELE,UAAU,GAAGH,QAAQ,CAAC,CAAD,CAAX,GAAiBC,UAAU,CAAC,CAAD,CAFhC,EAGLC,YAAY,GAAGD,UAAU,CAAC,CAAD,CAAb,GAAmBD,QAAQ,CAAC,CAAD,CAHlC,EAILG,UAAU,GAAGF,UAAU,CAAC,CAAD,CAAb,GAAmBD,QAAQ,CAAC,CAAD,CAJhC,CAAP;AAMD;AAOD,OAAO,SAASI,gBAAT,CAA0BxB,GAA1B,EAAyC;AAC9C,QAAMZ,MAAM,GAAGY,GAAG,CAAC,CAAD,CAAlB;AACA,QAAML,MAAM,GAAG,IAAIf,OAAJ,CAAYoB,GAAG,CAAC,CAAD,CAAf,EAAoBA,GAAG,CAAC,CAAD,CAAvB,EAA4BA,GAAG,CAAC,CAAD,CAA/B,CAAf;AACA,QAAMyB,QAAQ,GAAG,IAAI/C,OAAJ,CAAY,CAACU,MAAD,EAAS,CAAT,EAAY,CAAZ,EAAe,CAAf,EAAkBA,MAAlB,EAA0B,CAA1B,EAA6B,CAA7B,EAAgC,CAAhC,EAAmCA,MAAnC,CAAZ,CAAjB;AACA,SAAO,IAAIN,mBAAJ,CAAwBa,MAAxB,EAAgC8B,QAAhC,CAAP;AACD","sourcesContent":["import type {BoundingVolumes, Extent, Mbs, Obb} from '@loaders.gl/i3s';\n\nimport {Matrix3, Quaternion, Vector3} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {\n OrientedBoundingBox,\n makeOrientedBoundingBoxFromPoints,\n makeBoundingSphereFromPoints\n} from '@math.gl/culling';\nimport TileHeader from '@loaders.gl/tiles/src/tileset/tile-3d';\nimport {Geoid} from '@math.gl/geoid';\nimport {Tileset3D} from '@loaders.gl/tiles';\n\n/**\n * Create bounding volumes object from tile and geoid height model.\n * @param tile\n * @param geoidHeightModel\n * @returns - Bounding volumes object\n */\nexport function createBoundingVolumes(tile: TileHeader, geoidHeightModel: Geoid): BoundingVolumes {\n let radius;\n let halfSize;\n let quaternion;\n\n const boundingVolume = tile.boundingVolume;\n const cartographicCenter = Ellipsoid.WGS84.cartesianToCartographic(\n boundingVolume.center,\n new Vector3()\n );\n cartographicCenter[2] =\n cartographicCenter[2] -\n geoidHeightModel.getHeight(cartographicCenter[1], cartographicCenter[0]);\n if (boundingVolume instanceof OrientedBoundingBox) {\n halfSize = boundingVolume.halfSize;\n radius = new Vector3(halfSize[0], halfSize[1], halfSize[2]).len();\n quaternion = boundingVolume.quaternion;\n } else {\n radius = tile.boundingVolume.radius;\n halfSize = [radius, radius, radius];\n quaternion = new Quaternion()\n .fromMatrix3(new Matrix3([halfSize[0], 0, 0, 0, halfSize[1], 0, 0, 0, halfSize[2]]))\n .normalize();\n }\n\n return {\n mbs: [cartographicCenter[0], cartographicCenter[1], cartographicCenter[2], radius],\n obb: {\n center: [cartographicCenter[0], cartographicCenter[1], cartographicCenter[2]],\n halfSize,\n quaternion\n }\n };\n}\n\n/**\n * Generates bounding volumes from geometry positions\n * @param cartesianPositions\n * @param geoidHeightModel\n */\nexport function createBoundingVolumesFromGeometry(\n cartesianPositions: Float32Array,\n geoidHeightModel: Geoid\n): {mbs: Mbs; obb: Obb} {\n const positionVectors = convertPositionsToVectors(cartesianPositions);\n\n const geometryObb = makeOrientedBoundingBoxFromPoints(positionVectors);\n const geometryMbs = makeBoundingSphereFromPoints(positionVectors);\n\n let mbsCenter = Ellipsoid.WGS84.cartesianToCartographic(geometryMbs.center, new Vector3());\n let obbCenter = Ellipsoid.WGS84.cartesianToCartographic(geometryObb.center, new Vector3());\n\n mbsCenter[2] = mbsCenter[2] - geoidHeightModel.getHeight(mbsCenter[1], mbsCenter[0]);\n obbCenter[2] = obbCenter[2] - geoidHeightModel.getHeight(obbCenter[1], obbCenter[0]);\n\n return {\n mbs: [mbsCenter[0], mbsCenter[1], mbsCenter[2], geometryMbs.radius],\n obb: {\n center: obbCenter,\n halfSize: geometryObb.halfSize,\n quaternion: geometryObb.quaternion\n }\n };\n}\n\n/**\n * Create array of posisitons where each vertex is vector\n * @param {array} positions\n * @returns {Vector3[]}\n */\nexport function convertPositionsToVectors(positions: Float32Array): Vector3[] {\n const result: Vector3[] = [];\n\n for (let i = 0; i < positions.length; i += 3) {\n // TODO: (perf) new Vector3 is not optimal but required in `makeOrientedBoundingBoxFromPoints`.\n // modify `makeOrientedBoundingBoxFromPoints` to use scratch vectors\n const positionVector = new Vector3([positions[i], positions[i + 1], positions[i + 2]]);\n result.push(positionVector);\n }\n\n return result;\n}\n\n/**\n * Convert common coordinate to extent coordinate\n * @param tileset\n * @returns - Extent\n * @todo why lodMetricValue is radius? need to check this function\n */\nexport function convertCommonToI3SExtentCoordinate(tileset: Tileset3D | null): Extent | null {\n const cartesianCenter = tileset?.cartesianCenter;\n if (!cartesianCenter) {\n return null;\n }\n const radius = tileset?.lodMetricValue;\n const rightTop = Ellipsoid.WGS84.cartesianToCartographic(\n new Vector3(cartesianCenter[0] + radius, cartesianCenter[1] + radius, cartesianCenter[2]),\n new Vector3()\n );\n const leftBottom = Ellipsoid.WGS84.cartesianToCartographic(\n new Vector3(cartesianCenter[0] - radius, cartesianCenter[1] - radius, cartesianCenter[2]),\n new Vector3()\n );\n const isFirstRight = rightTop[0] < leftBottom[0];\n const isFirstTop = rightTop[1] < leftBottom[1];\n\n return [\n isFirstRight ? rightTop[0] : leftBottom[0],\n isFirstTop ? rightTop[1] : leftBottom[1],\n isFirstRight ? leftBottom[0] : rightTop[0],\n isFirstTop ? leftBottom[1] : rightTop[1]\n ];\n}\n\n/**\n * Creates oriented boundinb box from mbs.\n * @param mbs - Minimum Bounding Sphere\n * @returns - Oriented BOunding Box\n */\nexport function createObbFromMbs(mbs: Mbs): Obb {\n const radius = mbs[3];\n const center = new Vector3(mbs[0], mbs[1], mbs[2]);\n const halfAxex = new Matrix3([radius, 0, 0, 0, radius, 0, 0, 0, radius]);\n return new OrientedBoundingBox(center, halfAxex);\n}\n"],"file":"coordinate-converter.js"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Form and save sceneServer meta data into a file
|
|
3
|
+
* @param {string} layerName - layer name to display
|
|
4
|
+
* @param {object} layers0 - layer object embedded into sceneServer meta data
|
|
5
|
+
* @param {string} rootPath - root path of new converted tileset
|
|
6
|
+
* @return {promise}
|
|
7
|
+
*/
|
|
8
|
+
export declare function createSceneServerPath(layerName: any, layers0: any, rootPath: any): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=create-scene-server-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-scene-server-path.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/create-scene-server-path.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CAAC,SAAS,KAAA,EAAE,OAAO,KAAA,EAAE,QAAQ,KAAA,iBAUvE"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/i3s-converter/helpers/create-scene-server-path.ts"],"names":["v4","uuidv4","transform","join","SCENE_SERVER","sceneServerTemplate","writeFile","createSceneServerPath","layerName","layers0","rootPath","sceneServerData","serviceItemId","replace","sceneServer","nodePagePath","JSON","stringify"],"mappings":"AAAA,SAAQA,EAAE,IAAIC,MAAd,QAA2B,MAA3B;AACA,OAAOC,SAAP,MAAsB,oBAAtB;AACA,SAAQC,IAAR,QAAmB,MAAnB;AAEA,SAAQC,YAAY,IAAIC,mBAAxB,QAAkD,gCAAlD;AACA,SAAQC,SAAR,QAAwB,4BAAxB;AASA,OAAO,eAAeC,qBAAf,CAAqCC,SAArC,EAAgDC,OAAhD,EAAyDC,QAAzD,EAAmE;AACxE,QAAMC,eAAe,GAAG;AACtBC,IAAAA,aAAa,EAAEX,MAAM,GAAGY,OAAT,CAAiB,KAAjB,EAAwB,EAAxB,CADO;AAEtBL,IAAAA,SAFsB;AAGtBC,IAAAA;AAHsB,GAAxB;AAMA,QAAMK,WAAW,GAAGZ,SAAS,CAACS,eAAD,EAAkBN,mBAAmB,EAArC,CAA7B;AACA,QAAMU,YAAY,GAAGZ,IAAI,CAACO,QAAD,EAAW,aAAX,CAAzB;AACA,QAAMJ,SAAS,CAACS,YAAD,EAAeC,IAAI,CAACC,SAAL,CAAeH,WAAf,CAAf,CAAf;AACD","sourcesContent":["import {v4 as uuidv4} from 'uuid';\nimport transform from 'json-map-transform';\nimport {join} from 'path';\n\nimport {SCENE_SERVER as sceneServerTemplate} from '../json-templates/scene-server';\nimport {writeFile} from '../../lib/utils/file-utils';\n\n/**\n * Form and save sceneServer meta data into a file\n * @param {string} layerName - layer name to display\n * @param {object} layers0 - layer object embedded into sceneServer meta data\n * @param {string} rootPath - root path of new converted tileset\n * @return {promise}\n */\nexport async function createSceneServerPath(layerName, layers0, rootPath) {\n const sceneServerData = {\n serviceItemId: uuidv4().replace(/-/gi, ''),\n layerName,\n layers0\n };\n\n const sceneServer = transform(sceneServerData, sceneServerTemplate());\n const nodePagePath = join(rootPath, 'SceneServer');\n await writeFile(nodePagePath, JSON.stringify(sceneServer));\n}\n"],"file":"create-scene-server-path.js"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate geometry attributes with faceRange and featureCount
|
|
3
|
+
* @param {Object} attributes
|
|
4
|
+
* @returns {Object} Object with featureCount, reordered attributes and changed faceRange.
|
|
5
|
+
*/
|
|
6
|
+
export declare function generateAttributes(attributes: any): {
|
|
7
|
+
faceRange: Uint32Array;
|
|
8
|
+
featureIds: number[];
|
|
9
|
+
featureCount: number;
|
|
10
|
+
positions: any;
|
|
11
|
+
normals: any;
|
|
12
|
+
texCoords: any;
|
|
13
|
+
colors: any;
|
|
14
|
+
} | {
|
|
15
|
+
faceRange: Uint32Array;
|
|
16
|
+
featureIds: any[];
|
|
17
|
+
positions: Float32Array;
|
|
18
|
+
normals: Float32Array;
|
|
19
|
+
colors: Uint8Array;
|
|
20
|
+
texCoords: Float32Array;
|
|
21
|
+
featureCount: number;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=geometry-attributes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry-attributes.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/geometry-attributes.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,KAAA;;;;;;;;;;;;;;;;EAsB5C"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/i3s-converter/helpers/geometry-attributes.ts"],"names":["concatenateTypedArrays","VALUES_PER_VERTEX","POSITIONS_AND_NORMALS_PER_TRIANGLE","generateAttributes","attributes","positions","normals","texCoords","colors","featureIndices","triangleCount","length","faceRange","Uint32Array","featureIds","featureCount","calculateFaceRangesAndFeaturesCount","attributeObjects","makeAttributeObjects","unifiedAttributeObjectsByFeatureIds","unifyObjectsByFeatureId","groupedAttributes","groupAttributesAndRangesByFeatureId","rangeIndex","featureIndex","currentFeatureId","faceRangeList","uniqueFeatureIds","index","includes","push","groupedData","positionsList","Float32Array","normalsList","colorsList","Uint8Array","texCoordsList","faceRangeIndex","startIndex","endIndex","positionsCount","getSliceAttributeCount","normalsCount","colorsCount","texCoordsCount","featureId","slice","sort","first","second","attributeName","colorsPerVertex","texCoordsPerVertex","trianglesCount","vertexCount","sortedData","uniqueObjects","currentObject","existedObject","find","obj","unifiedObjects","firstAttributeObject","range","objIndex","sum","currentAttributesObject","groupedObject"],"mappings":"A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D,IAAAA,QAAQ,IAAI,CAAZ;AACD;;AAEDD,EAAAA,KAAK,CAAClC,IAAN,CAAWzB,SAAS,CAACM,MAAV,GAAmBT,kCAAnB,GAAwD,CAAnE;AAEA,QAAMU,SAAS,GAAG,IAAIC,WAAJ,CAAgBmD,KAAhB,CAAlB;AACA,SAAO;AAACpD,IAAAA,SAAD;AAAYE,IAAAA,UAAZ;AAAwBT,IAAAA,SAAxB;AAAmCC,IAAAA,OAAnC;AAA4CE,IAAAA,MAA5C;AAAoDD,IAAAA;AAApD,GAAP;AACD","sourcesContent":["import {concatenateTypedArrays} from '@loaders.gl/loader-utils';\n\nconst VALUES_PER_VERTEX = 3;\nconst POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;\n\n/**\n * Generate geometry attributes with faceRange and featureCount\n * @param {Object} attributes\n * @returns {Object} Object with featureCount, reordered attributes and changed faceRange.\n */\nexport function generateAttributes(attributes) {\n const {positions, normals, texCoords, colors, featureIndices, triangleCount} = attributes;\n\n if (!featureIndices.length) {\n return {\n faceRange: new Uint32Array([0, triangleCount - 1]),\n featureIds: [0],\n featureCount: 1,\n positions,\n normals,\n texCoords,\n colors\n };\n }\n\n const {faceRange, featureCount, featureIds} = calculateFaceRangesAndFeaturesCount(featureIndices);\n const attributeObjects = makeAttributeObjects({faceRange, featureIds, ...attributes});\n const unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);\n const groupedAttributes = groupAttributesAndRangesByFeatureId(\n unifiedAttributeObjectsByFeatureIds\n );\n return {featureCount, ...groupedAttributes};\n}\n\n/**\n * Calculates face Ranges and feature count based on featureIndices.\n * @param {Object} featureIndices\n * @returns {Object} Object with featureCount, reordered attributes and changed faceRange.\n */\nfunction calculateFaceRangesAndFeaturesCount(featureIndices) {\n let rangeIndex = 1;\n let featureIndex = 1;\n let currentFeatureId = featureIndices[0];\n const faceRangeList: any[] = [];\n const featureIds: any[] = [];\n const uniqueFeatureIds = [currentFeatureId];\n\n faceRangeList[0] = 0;\n featureIds[0] = currentFeatureId;\n\n for (let index = 1; index < featureIndices.length; index++) {\n if (currentFeatureId !== featureIndices[index]) {\n faceRangeList[rangeIndex] = index / VALUES_PER_VERTEX - 1;\n faceRangeList[rangeIndex + 1] = index / VALUES_PER_VERTEX;\n featureIds[featureIndex] = featureIndices[index];\n\n if (!uniqueFeatureIds.includes(featureIndices[index])) {\n uniqueFeatureIds.push(featureIndices[index]);\n }\n\n rangeIndex += 2;\n featureIndex += 1;\n }\n currentFeatureId = featureIndices[index];\n }\n\n faceRangeList[rangeIndex] = featureIndices.length / VALUES_PER_VERTEX - 1;\n\n const faceRange = new Uint32Array(faceRangeList);\n const featureCount = uniqueFeatureIds.length;\n\n return {faceRange, featureCount, featureIds};\n}\n\n/**\n * Generate list of attribute object grouped by feature ids.\n * @param {Object} attributes\n * @returns {Array} sorted list of attribute objects.\n */\nfunction makeAttributeObjects(attributes) {\n const {featureIds, positions, normals, colors, texCoords, faceRange} = attributes;\n const groupedData: any[] = [];\n\n let positionsList = new Float32Array(positions);\n let normalsList = new Float32Array(normals);\n let colorsList = new Uint8Array(colors);\n let texCoordsList = new Float32Array(texCoords);\n\n let faceRangeIndex = 0;\n\n for (let index = 0; index < featureIds.length; index++) {\n const startIndex = faceRange[index + faceRangeIndex];\n const endIndex = faceRange[index + faceRangeIndex + 1];\n\n const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);\n const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);\n const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);\n const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);\n\n groupedData.push({\n featureId: featureIds[index],\n positions: positionsList.slice(0, positionsCount),\n normals: normalsList.slice(0, normalsCount),\n colors: colorsList.slice(0, colorsCount),\n texCoords: texCoordsList.slice(0, texCoordsCount)\n });\n\n positionsList = positionsList.slice(positionsCount);\n normalsList = normalsList.slice(normalsCount);\n colorsList = colorsList.slice(colorsCount);\n texCoordsList = texCoordsList.slice(texCoordsCount);\n\n faceRangeIndex += 1;\n }\n\n return groupedData.sort((first, second) => first.featureId - second.featureId);\n}\n\n/**\n * Generate sliced count for generating attribute objects depends on attribute name and range.\n * @param {String} attributeName\n * @param {Number} startIndex\n * @param {Number} endIndex\n * @returns {Number} - sliced count\n */\nfunction getSliceAttributeCount(attributeName, startIndex, endIndex) {\n const colorsPerVertex = 4;\n const texCoordsPerVertex = 2;\n\n const trianglesCount = endIndex - startIndex + 1;\n const vertexCount = trianglesCount * 3;\n\n switch (attributeName) {\n case 'positions':\n case 'normals':\n return trianglesCount * POSITIONS_AND_NORMALS_PER_TRIANGLE;\n case 'colors':\n return vertexCount * colorsPerVertex;\n case 'texCoords':\n return vertexCount * texCoordsPerVertex;\n default:\n return 0;\n }\n}\n\n/**\n * Generates unique object list depends on feature ids and concantenate their attributes.\n * @param {Array} sortedData\n * @returns {Array} - unique list of objects\n */\nfunction unifyObjectsByFeatureId(sortedData) {\n const uniqueObjects: any[] = [];\n\n for (let index = 0; index < sortedData.length; index++) {\n const currentObject = sortedData[index];\n const existedObject = uniqueObjects.find((obj) => obj.featureId === currentObject.featureId);\n\n if (existedObject) {\n existedObject.positions = concatenateTypedArrays(\n existedObject.positions,\n currentObject.positions\n );\n existedObject.normals = concatenateTypedArrays(existedObject.normals, currentObject.normals);\n existedObject.colors = concatenateTypedArrays(existedObject.colors, currentObject.colors);\n existedObject.texCoords = concatenateTypedArrays(\n existedObject.texCoords,\n currentObject.texCoords\n );\n } else {\n uniqueObjects.push(currentObject);\n }\n }\n\n return uniqueObjects;\n}\n\n/**\n * Generates attribute objects with new faceRange and reordered attributes.\n * @param {Array} unifiedObjects\n * @returns {Object} - ugenerated attributes with new faceRange.\n */\nfunction groupAttributesAndRangesByFeatureId(unifiedObjects) {\n const firstAttributeObject = unifiedObjects[0];\n const featureIds = [firstAttributeObject.featureId];\n\n let positions = new Float32Array(firstAttributeObject.positions);\n let normals = new Float32Array(firstAttributeObject.normals);\n let colors = new Uint8Array(firstAttributeObject.colors);\n let texCoords = new Float32Array(firstAttributeObject.texCoords);\n const range = [0];\n\n let objIndex = 0;\n let sum = 0;\n\n for (let index = 1; index < unifiedObjects.length; index++) {\n const currentAttributesObject = unifiedObjects[index];\n featureIds.push(currentAttributesObject.featureId);\n\n positions = concatenateTypedArrays(positions, currentAttributesObject.positions);\n normals = concatenateTypedArrays(normals, currentAttributesObject.normals);\n colors = concatenateTypedArrays(colors, currentAttributesObject.colors);\n texCoords = concatenateTypedArrays(texCoords, currentAttributesObject.texCoords);\n\n const groupedObject = unifiedObjects[objIndex];\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE + sum);\n\n sum += groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;\n objIndex += 1;\n }\n\n range.push(positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);\n\n const faceRange = new Uint32Array(range);\n return {faceRange, featureIds, positions, normals, colors, texCoords};\n}\n"],"file":"geometry-attributes.js"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry-converter.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/geometry-converter.js"],"names":[],"mappings":"AA2BA;;;;;;;;;;YAuDC"}
|
|
@@ -189,16 +189,43 @@ function convertNodes(nodes, tileContent, attributesMap, useCartesianPositions,
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
+
function getCompositeTransformationMatrix(node, matrix) {
|
|
193
|
+
let transformationMatrix = matrix;
|
|
194
|
+
const {
|
|
195
|
+
matrix: nodeMatrix,
|
|
196
|
+
rotation,
|
|
197
|
+
scale,
|
|
198
|
+
translation
|
|
199
|
+
} = node;
|
|
200
|
+
|
|
201
|
+
if (nodeMatrix) {
|
|
202
|
+
transformationMatrix = matrix.multiplyRight(nodeMatrix);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (rotation) {
|
|
206
|
+
transformationMatrix = transformationMatrix.rotateXYZ(rotation);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (scale) {
|
|
210
|
+
transformationMatrix = transformationMatrix.scale(scale);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (translation) {
|
|
214
|
+
transformationMatrix = transformationMatrix.translate(translation);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return transformationMatrix;
|
|
218
|
+
}
|
|
219
|
+
|
|
192
220
|
function convertNode(node, tileContent, attributesMap, useCartesianPositions, matrix = new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
|
|
193
|
-
const
|
|
194
|
-
const compositeMatrix = nodeMatrix ? matrix.multiplyRight(nodeMatrix) : matrix;
|
|
221
|
+
const transformationMatrix = getCompositeTransformationMatrix(node, matrix);
|
|
195
222
|
const mesh = node.mesh;
|
|
196
223
|
|
|
197
224
|
if (mesh) {
|
|
198
|
-
convertMesh(mesh, tileContent, attributesMap, useCartesianPositions,
|
|
225
|
+
convertMesh(mesh, tileContent, attributesMap, useCartesianPositions, transformationMatrix);
|
|
199
226
|
}
|
|
200
227
|
|
|
201
|
-
convertNodes(node.children, tileContent, attributesMap, useCartesianPositions,
|
|
228
|
+
convertNodes(node.children, tileContent, attributesMap, useCartesianPositions, transformationMatrix);
|
|
202
229
|
}
|
|
203
230
|
|
|
204
231
|
function convertMesh(mesh, content, attributesMap, useCartesianPositions = false, matrix = new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/i3s-converter/helpers/geometry-converter.js"],"names":["Vector3","Matrix4","Vector4","Ellipsoid","DracoWriter","encode","assert","concatenateArrayBuffers","concatenateTypedArrays","md5","generateAttributes","createBoundingVolumesFromGeometry","VALUES_PER_VERTEX","VALUES_PER_TEX_COORD","VALUES_PER_COLOR_ELEMENT","STRING_TYPE","SHORT_INT_TYPE","DOUBLE_TYPE","OBJECT_ID_TYPE","BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES","scratchVector","convertB3dmToI3sGeometry","tileContent","nodeId","featuresHashArray","attributeStorageInfo","draco","generateBoundingVolumes","geoidHeightModel","useCartesianPositions","materialAndTextureList","convertMaterials","convertedAttributesMap","convertAttributes","_generateBoundingVolumesFromGeometry","has","push","material","getDefaultMaterial","result","nodesCounter","materials","gltf","length","id","i","sourceMaterial","convertedAttributes","get","texture","_makeNodeResources","attributes","values","boundingVolumes","positions","cartographicOrigin","obb","center","index","vertex","subarray","WGS84","cartesianToCartographic","Array","from","getHeight","subtract","set","vertexCount","triangleCount","faceRange","featureIds","normals","colors","texCoords","featureCount","batchTableJson","makeFeatureIdsUnique","featureIndices","header","Uint32Array","typedFeatureIds","generateBigUint64Array","fileBuffer","Uint8Array","buffer","ArrayBuffer","compressedGeometry","generateCompressedGeometry","Float32Array","convertBatchTableToAttributeBuffers","geometry","sharedResources","getSharedResources","meshMaterial","attributesMap","Map","nodes","scene","scenes","convertNodes","attrKey","keys","delete","reduce","acc","value","concat","matrix","node","convertNode","getCompositeTransformationMatrix","transformationMatrix","nodeMatrix","rotation","scale","translation","multiplyRight","rotateXYZ","translate","mesh","convertMesh","children","content","primitive","primitives","outputAttributes","transformVertexArray","vertices","POSITION","cartesianModelMatrix","indices","attributeSpecificTransformation","transformVertexPositions","NORMAL","transformVertexNormals","flattenTexCoords","TEXCOORD_0","flattenColors","COLOR_0","flattenBatchIds","getBatchIdsByAttributeName","args","newVertices","coordIndex","vertexVector","x","y","z","calleeArgs","transform","transformAsVector","newTexCoords","fill","texCoord","colorsAttribute","components","newColors","colorIndex","color","colorUint8","j","batchedIds","newBatchIds","batchIds","possibleBatchIdAttributeName","sourceMaterials","convertMaterial","doubleSided","emissiveFactor","map","c","Math","round","alphaMode","toLowerCase","pbrMetallicRoughness","roughnessFactor","metallicFactor","baseColorTexture","source","textureSetDefinitionId","emissiveTexture","baseColorFactor","undefined","gltfMaterials","i3sResources","materialDefinitionInfos","gltfMaterial","materialDefinitionInfo","textureDefinitionInfo","convertGLTFMaterialToI3sSharedResources","textureDefinitionInfos","extractSharedResourcesTextureInfo","colorFactor","extractSharedResourcesMaterialInfo","matDielectricColorComponent","black","unitVector","dielectricSpecular","baseColorVector","firstOperand","multiply","diffuse","lerp","specular","toArray","encoding","mimeType","images","generateImageId","size","image","width","data","height","levelCountOfTexture","indexOfLevel","indexOfTextureInStore","zerosCount","toString","rightHalf","repeat","shiftedLevelCountOfTexture","shiftedIndexOfLevel","shiftedWidth","shiftedHeight","leftHalf","imageId","BigInt","batchTable","replaceMap","getFeaturesReplaceMap","replaceIndicesByUnique","featureMap","oldFeatureId","uniqueFeatureId","getOrCreateUniqueFeatureId","generateStringFromBatchTableByIndex","str","key","batchTableStr","hash","includes","indexOf","indicesArray","attributeBuffers","batchTableWithFeatureIds","OBJECTID","type","getAttributeType","attributeBuffer","generateShortIntegerAttributeBuffer","generateDoubleAttributeBuffer","generateStringAttributeBuffer","attribute","find","attr","name","attributeValues","valueType","count","valuesArray","padding","Float64Array","batchAttributes","stringCountArray","totalNumberOfBytes","stringSizesArray","stringBufferArray","currentString","String","currentStringBuffer","Buffer","currentStringSize","totalBytes","BigUint64Array","featureIndex","generateFeatureIndexAttribute","compressedAttributes","attributesMetadata","Int32Array","method","orderedFeatureIndices","fillIndex","startIndex","endIndex"],"mappings":"AAAA,SAAQA,OAAR,EAAiBC,OAAjB,EAA0BC,OAA1B,QAAwC,eAAxC;AACA,SAAQC,SAAR,QAAwB,qBAAxB;AAEA,SAAQC,WAAR,QAA0B,mBAA1B;AACA,SAAQC,MAAR,EAAgBC,MAAhB,QAA6B,kBAA7B;AACA,SAAQC,uBAAR,EAAiCC,sBAAjC,QAA8D,0BAA9D;AACA,OAAOC,GAAP,MAAgB,KAAhB;AACA,SAAQC,kBAAR,QAA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co';\nimport {encode, assert} from '@loaders.gl/core';\nimport {concatenateArrayBuffers, concatenateTypedArrays} from '@loaders.gl/loader-utils';\nimport md5 from 'md5';\nimport {generateAttributes} from './geometry-attributes';\nimport {createBoundingVolumesFromGeometry} from './coordinate-converter';\n\nconst VALUES_PER_VERTEX = 3;\nconst VALUES_PER_TEX_COORD = 2;\nconst VALUES_PER_COLOR_ELEMENT = 4;\n\nconst STRING_TYPE = 'string';\nconst SHORT_INT_TYPE = 'Int32';\nconst DOUBLE_TYPE = 'Float64';\nconst OBJECT_ID_TYPE = 'Oid32';\n/*\n * 'CUSTOM_ATTRIBUTE_2' - Attribute name which includes batch info and used by New York map.\n * _BATCHID - Default attribute name which includes batch info.\n * BATCHID - Legacy attribute name which includes batch info.\n */\nconst BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ['CUSTOM_ATTRIBUTE_2', '_BATCHID', 'BATCHID'];\n\nlet scratchVector = new Vector3();\n\nexport default async function convertB3dmToI3sGeometry(\n tileContent,\n nodeId,\n featuresHashArray,\n attributeStorageInfo,\n draco,\n generateBoundingVolumes,\n geoidHeightModel\n) {\n const useCartesianPositions = generateBoundingVolumes;\n const materialAndTextureList = convertMaterials(tileContent);\n const convertedAttributesMap = convertAttributes(tileContent, useCartesianPositions);\n\n if (generateBoundingVolumes) {\n _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel);\n }\n\n if (convertedAttributesMap.has('default')) {\n materialAndTextureList.push({\n material: getDefaultMaterial()\n });\n }\n\n const result = [];\n let nodesCounter = nodeId;\n let {materials = []} = tileContent.gltf;\n if (!materials?.length) {\n materials.push({id: 'default'});\n }\n for (let i = 0; i < materials.length; i++) {\n const sourceMaterial = materials[i];\n if (!convertedAttributesMap.has(sourceMaterial.id)) {\n continue; // eslint-disable-line no-continue\n }\n const convertedAttributes = convertedAttributesMap.get(sourceMaterial.id);\n const {material, texture} = materialAndTextureList[i];\n result.push(\n await _makeNodeResources({\n convertedAttributes,\n material,\n texture,\n tileContent,\n nodeId: nodesCounter,\n featuresHashArray,\n attributeStorageInfo,\n draco\n })\n );\n nodesCounter++;\n }\n\n if (!result.length) {\n return null;\n }\n return result;\n}\n\n/**\n * Create bounding volumes based on positions\n * @param convertedAttributesMap\n * @param geoidHeightModel\n */\nfunction _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel) {\n for (const attributes of convertedAttributesMap.values()) {\n const boundingVolumes = createBoundingVolumesFromGeometry(\n attributes.positions,\n geoidHeightModel\n );\n\n attributes.boundingVolumes = boundingVolumes;\n const cartographicOrigin = boundingVolumes.obb.center;\n\n for (let index = 0; index < attributes.positions.length; index += VALUES_PER_VERTEX) {\n const vertex = attributes.positions.subarray(index, index + VALUES_PER_VERTEX);\n Ellipsoid.WGS84.cartesianToCartographic(Array.from(vertex), scratchVector);\n scratchVector[2] =\n scratchVector[2] - geoidHeightModel.getHeight(scratchVector[1], scratchVector[0]);\n scratchVector = scratchVector.subtract(cartographicOrigin);\n attributes.positions.set(scratchVector, index);\n }\n }\n}\n\nasync function _makeNodeResources({\n convertedAttributes,\n material,\n texture,\n tileContent,\n nodeId,\n featuresHashArray,\n attributeStorageInfo,\n draco\n}) {\n const boundingVolumes = convertedAttributes.boundingVolumes;\n const vertexCount = convertedAttributes.positions.length / VALUES_PER_VERTEX;\n const triangleCount = vertexCount / 3;\n const {faceRange, featureIds, positions, normals, colors, texCoords, featureCount} =\n generateAttributes({triangleCount, ...convertedAttributes});\n\n if (tileContent.batchTableJson) {\n makeFeatureIdsUnique(\n featureIds,\n convertedAttributes.featureIndices,\n featuresHashArray,\n tileContent.batchTableJson\n );\n }\n\n const header = new Uint32Array(2);\n const typedFeatureIds = generateBigUint64Array(featureIds);\n\n header.set([vertexCount, featureCount], 0);\n const fileBuffer = new Uint8Array(\n concatenateArrayBuffers(\n header.buffer,\n positions.buffer,\n normals.buffer,\n texture ? texCoords.buffer : new ArrayBuffer(0),\n colors.buffer,\n typedFeatureIds.buffer,\n faceRange.buffer\n )\n );\n const compressedGeometry = draco\n ? await generateCompressedGeometry(vertexCount, convertedAttributes, {\n positions,\n normals,\n texCoords: texture ? texCoords : new Float32Array(0),\n colors,\n featureIds,\n faceRange\n })\n : null;\n\n const attributes = convertBatchTableToAttributeBuffers(\n tileContent.batchTableJson,\n featureIds,\n attributeStorageInfo\n );\n\n return {\n geometry: fileBuffer,\n compressedGeometry,\n texture,\n sharedResources: getSharedResources(tileContent, nodeId),\n meshMaterial: material,\n vertexCount,\n attributes,\n featureCount,\n boundingVolumes\n };\n}\n\n/**\n * Convert attributes from the gltf nodes tree to i3s plain geometry\n * @param {Object} tileContent - 3d tile content\n * @returns {Map}\n * Map<{\n * positions: Float32Array,\n * normals: Float32Array,\n * colors: Uint8Array,\n * texCoords: Float32Array\n * }>\n * @todo implement colors support (if applicable for gltf format)\n */\nfunction convertAttributes(tileContent, useCartesianPositions) {\n const attributesMap = new Map();\n\n for (const material of tileContent.gltf.materials || [{id: 'default'}]) {\n attributesMap.set(material.id, {\n positions: new Float32Array(0),\n normals: new Float32Array(0),\n texCoords: new Float32Array(0),\n colors: new Uint8Array(0),\n featureIndices: [],\n boundingVolumes: null\n });\n }\n\n const nodes = (tileContent.gltf.scene || tileContent.gltf.scenes?.[0] || tileContent.gltf).nodes;\n convertNodes(nodes, tileContent, attributesMap, useCartesianPositions);\n\n for (const attrKey of attributesMap.keys()) {\n const attributes = attributesMap.get(attrKey);\n if (attributes.positions.length === 0) {\n attributesMap.delete(attrKey);\n continue; // eslint-disable-line no-continue\n }\n attributes.featureIndices = attributes.featureIndices.reduce((acc, value) => acc.concat(value));\n }\n\n return attributesMap;\n}\n\n/**\n * Gltf has hierarchical structure of nodes. This function converts nodes starting from those which are in gltf scene object.\n * The goal is applying tranformation matrix for all children. Functions \"convertNodes\" and \"convertNode\" work together recursively.\n * @param {Object[]} nodes - gltf nodes array\n * @param {Object} tileContent - 3d tile content\n * @param {Map} attributesMap Map<{positions: Float32Array, normals: Float32Array, texCoords: Float32Array, colors: UInt8Array, featureIndices: Array}> - for recursive concatenation of\n * attributes\n * @param {Matrix4} matrix - transformation matrix - cumulative transformation matrix formed from all parent node matrices\n * @returns {void}\n */\nfunction convertNodes(\n nodes,\n tileContent,\n attributesMap,\n useCartesianPositions,\n matrix = new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])\n) {\n if (nodes) {\n for (const node of nodes) {\n convertNode(node, tileContent, attributesMap, useCartesianPositions, matrix);\n }\n }\n}\n\n/**\n * Generate transformation matrix for node\n * Aapply all gltf transformations to initial transformation matrix.\n * @param node\n * @param matrix\n */\nfunction getCompositeTransformationMatrix(node, matrix) {\n let transformationMatrix = matrix;\n\n const {matrix: nodeMatrix, rotation, scale, translation} = node;\n\n if (nodeMatrix) {\n transformationMatrix = matrix.multiplyRight(nodeMatrix);\n }\n\n if (rotation) {\n transformationMatrix = transformationMatrix.rotateXYZ(rotation);\n }\n\n if (scale) {\n transformationMatrix = transformationMatrix.scale(scale);\n }\n\n if (translation) {\n transformationMatrix = transformationMatrix.translate(translation);\n }\n\n return transformationMatrix;\n}\n\n/**\n * Convert all primitives of node and all children nodes\n * @param {Object} node - gltf node\n * @param {Object} tileContent - 3d tile content\n * @param {Map} attributesMap Map<{positions: Float32Array, normals: Float32Array, texCoords: Float32Array, colors: Uint8Array, featureIndices: Array}> - for recursive concatenation of\n * attributes\n * @param {Matrix4} matrix - transformation matrix - cumulative transformation matrix formed from all parent node matrices\n * @todo: optimize arrays concatenation\n */\nfunction convertNode(\n node,\n tileContent,\n attributesMap,\n useCartesianPositions,\n matrix = new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])\n) {\n const transformationMatrix = getCompositeTransformationMatrix(node, matrix);\n\n const mesh = node.mesh;\n if (mesh) {\n convertMesh(mesh, tileContent, attributesMap, useCartesianPositions, transformationMatrix);\n }\n\n convertNodes(\n node.children,\n tileContent,\n attributesMap,\n useCartesianPositions,\n transformationMatrix\n );\n}\n\n/**\n * Convert all primitives of node and all children nodes\n * @param {Object} mesh - gltf node\n * @param {Object} content - 3d tile content\n * @param {Map} attributesMap Map<{positions: Float32Array, normals: Float32Array, texCoords: Float32Array, colors: Uint8Array, featureIndices: Array}> - for recursive concatenation of\n * attributes\n * @param {Matrix4} matrix - transformation matrix - cumulative transformation matrix formed from all parent node matrices\n * @todo: optimize arrays concatenation\n */\nfunction convertMesh(\n mesh,\n content,\n attributesMap,\n useCartesianPositions = false,\n matrix = new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])\n) {\n for (const primitive of mesh.primitives) {\n let outputAttributes = null;\n if (primitive.material) {\n outputAttributes = attributesMap.get(primitive.material.id);\n } else if (attributesMap.has('default')) {\n outputAttributes = attributesMap.get('default');\n }\n assert(outputAttributes !== null, 'Primitive - material mapping failed');\n const attributes = primitive.attributes;\n\n outputAttributes.positions = concatenateTypedArrays(\n outputAttributes.positions,\n transformVertexArray({\n vertices: attributes.POSITION.value,\n cartographicOrigin: content.cartographicOrigin,\n cartesianModelMatrix: content.cartesianModelMatrix,\n nodeMatrix: matrix,\n indices: primitive.indices.value,\n attributeSpecificTransformation: transformVertexPositions,\n useCartesianPositions\n })\n );\n outputAttributes.normals = concatenateTypedArrays(\n outputAttributes.normals,\n transformVertexArray({\n vertices: attributes.NORMAL && attributes.NORMAL.value,\n cartographicOrigin: content.cartographicOrigin,\n cartesianModelMatrix: content.cartesianModelMatrix,\n nodeMatrix: matrix,\n indices: primitive.indices.value,\n attributeSpecificTransformation: transformVertexNormals,\n useCartesianPositions: false\n })\n );\n outputAttributes.texCoords = concatenateTypedArrays(\n outputAttributes.texCoords,\n flattenTexCoords(\n attributes.TEXCOORD_0 && attributes.TEXCOORD_0.value,\n primitive.indices.value\n )\n );\n\n outputAttributes.colors = concatenateTypedArrays(\n outputAttributes.colors,\n flattenColors(attributes.COLOR_0, primitive.indices.value)\n );\n\n outputAttributes.featureIndices.push(\n flattenBatchIds(getBatchIdsByAttributeName(attributes), primitive.indices.value)\n );\n }\n}\n\n/**\n * Convert vertices attributes (POSITIONS or NORMALS) to i3s compatible format\n * @param {object} args - source tile (3DTile)\n * @param {Float32Array} args.vertices - gltf primitive POSITION or NORMAL attribute\n * @param {Object} args.cartographicOrigin - cartographic origin coordinates\n * @param {Object} args.cartesianModelMatrix - a cartesian model matrix to transform coordnates from cartesian to cartographic format\n * @param {Matrix4} args.nodeMatrix - a gltf node transformation matrix - cumulative transformation matrix formed from all parent node matrices\n * @param {Uint8Array} args.indices - gltf primitive indices\n * @param {Function} args.attributeSpecificTransformation - function to do attribute - specific transformations\n * @param {Boolean} args.useCartesianPositions - use coordinates as it is.\n * @returns {Float32Array}\n */\nfunction transformVertexArray(args) {\n const {vertices, indices, attributeSpecificTransformation} = args;\n const newVertices = new Float32Array(indices.length * VALUES_PER_VERTEX);\n if (!vertices) {\n return newVertices;\n }\n for (let i = 0; i < indices.length; i++) {\n const coordIndex = indices[i] * VALUES_PER_VERTEX;\n const vertex = vertices.subarray(coordIndex, coordIndex + VALUES_PER_VERTEX);\n let vertexVector = new Vector3(Array.from(vertex));\n\n vertexVector = attributeSpecificTransformation(vertexVector, args);\n\n newVertices[i * VALUES_PER_VERTEX] = vertexVector.x;\n newVertices[i * VALUES_PER_VERTEX + 1] = vertexVector.y;\n newVertices[i * VALUES_PER_VERTEX + 2] = vertexVector.z;\n }\n return newVertices;\n}\n\nfunction transformVertexPositions(vertexVector, calleeArgs) {\n const {cartesianModelMatrix, cartographicOrigin, nodeMatrix, useCartesianPositions} = calleeArgs;\n\n if (nodeMatrix) {\n vertexVector = vertexVector.transform(nodeMatrix);\n }\n\n vertexVector = vertexVector.transform(cartesianModelMatrix);\n\n if (useCartesianPositions) {\n return vertexVector;\n }\n\n Ellipsoid.WGS84.cartesianToCartographic(\n [vertexVector[0], vertexVector[1], vertexVector[2]],\n vertexVector\n );\n vertexVector = vertexVector.subtract(cartographicOrigin);\n return vertexVector;\n}\n\nfunction transformVertexNormals(vertexVector, calleeArgs) {\n const {cartesianModelMatrix, nodeMatrix} = calleeArgs;\n\n if (nodeMatrix) {\n vertexVector = vertexVector.transformAsVector(nodeMatrix);\n }\n\n vertexVector = vertexVector.transformAsVector(cartesianModelMatrix);\n return vertexVector;\n}\n\n/**\n * Convert uv0 (texture coordinates) from coords based on indices to plain arrays, compatible with i3s\n * @param {Float32Array} texCoords - gltf primitive TEXCOORD_0 attribute\n * @param {Uint8Array} indices - gltf primitive indices\n * @returns {Float32Array}\n */\nfunction flattenTexCoords(texCoords, indices) {\n const newTexCoords = new Float32Array(indices.length * VALUES_PER_TEX_COORD);\n if (!texCoords) {\n // We need dummy UV0s because it is required in 1.6\n // https://github.com/Esri/i3s-spec/blob/master/docs/1.6/vertexAttribute.cmn.md\n newTexCoords.fill(1);\n return newTexCoords;\n }\n for (let i = 0; i < indices.length; i++) {\n const coordIndex = indices[i] * VALUES_PER_TEX_COORD;\n const texCoord = texCoords.subarray(coordIndex, coordIndex + VALUES_PER_TEX_COORD);\n newTexCoords[i * VALUES_PER_TEX_COORD] = texCoord[0];\n newTexCoords[i * VALUES_PER_TEX_COORD + 1] = texCoord[1];\n }\n return newTexCoords;\n}\n\n/**\n * Convert color from COLOR_0 based on indices to plain arrays, compatible with i3s\n * @param {object} colorsAttribute - gltf primitive COLOR_0 attribute\n * @param {Uint8Array} indices - gltf primitive indices\n * @returns {Uint8Array}\n */\nfunction flattenColors(colorsAttribute, indices) {\n const components = colorsAttribute?.components || VALUES_PER_COLOR_ELEMENT;\n const newColors = new Uint8Array(indices.length * components);\n if (!colorsAttribute) {\n // Vertex color multiplies by material color so it must be normalized 1 by default\n newColors.fill(255);\n return newColors;\n }\n const colors = colorsAttribute.value;\n for (let i = 0; i < indices.length; i++) {\n const colorIndex = indices[i] * components;\n const color = colors.subarray(colorIndex, colorIndex + components);\n const colorUint8 = new Uint8Array(components);\n for (let j = 0; j < color.length; j++) {\n colorUint8[j] = color[j] * 255;\n }\n newColors.set(colorUint8, i * components);\n }\n return newColors;\n}\n\n/**\n * Flatten batchedIds list based on indices to right ordered array, compatible with i3s\n * @param {Array} batchedIds - gltf primitive\n * @param {Uint8Array} indices - gltf primitive indices\n * @returns {Array}\n */\nfunction flattenBatchIds(batchedIds, indices) {\n if (!batchedIds.length || !indices.length) {\n return [];\n }\n const newBatchIds = [];\n for (let i = 0; i < indices.length; i++) {\n const coordIndex = indices[i];\n newBatchIds.push(batchedIds[coordIndex]);\n }\n return newBatchIds;\n}\n/**\n * Return batchIds based on possible attribute names for different kind of maps.\n * @param {Object} attributes {attributeName: Float32Array}\n * @returns {Array}\n */\nfunction getBatchIdsByAttributeName(attributes) {\n let batchIds = [];\n\n for (let index = 0; index < BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES.length; index++) {\n const possibleBatchIdAttributeName = BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES[index];\n if (\n attributes[possibleBatchIdAttributeName] &&\n attributes[possibleBatchIdAttributeName].value\n ) {\n batchIds = attributes[possibleBatchIdAttributeName].value;\n break;\n }\n }\n\n return batchIds;\n}\n\nfunction convertMaterials(tileContent) {\n const result = [];\n const sourceMaterials = tileContent.gltf.materials || [];\n for (const sourceMaterial of sourceMaterials) {\n result.push(convertMaterial(sourceMaterial));\n }\n return result;\n}\n\n/**\n * Convert texture and material from gltf 2.0 material object\n * @param {Object} sourceMaterial - material object\n * @returns {Object}\n */\nfunction convertMaterial(sourceMaterial) {\n const material = {\n doubleSided: sourceMaterial.doubleSided,\n emissiveFactor: sourceMaterial.emissiveFactor.map((c) => Math.round(c * 255)),\n // It is in upper case in GLTF: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#alpha-coverage\n // But it is in lower case in I3S: https://github.com/Esri/i3s-spec/blob/master/docs/1.7/materialDefinitions.cmn.md\n alphaMode: (sourceMaterial.alphaMode || 'OPAQUE').toLowerCase(),\n pbrMetallicRoughness: {\n roughnessFactor: sourceMaterial.pbrMetallicRoughness.roughnessFactor,\n metallicFactor: sourceMaterial.pbrMetallicRoughness.metallicFactor\n }\n };\n\n let texture;\n if (sourceMaterial.pbrMetallicRoughness.baseColorTexture) {\n texture = sourceMaterial.pbrMetallicRoughness.baseColorTexture.texture.source;\n material.pbrMetallicRoughness.baseColorTexture = {\n textureSetDefinitionId: 0\n };\n } else if (sourceMaterial.emissiveTexture) {\n texture = sourceMaterial.emissiveTexture.texture.source;\n // ArcGIS webscene doesn't show emissiveTexture but shows baseColorTexture\n material.pbrMetallicRoughness.baseColorTexture = {\n textureSetDefinitionId: 0\n };\n }\n\n if (!texture) {\n // Should use default baseColorFactor if it is not present in source material\n // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-pbrmetallicroughness\n const baseColorFactor = sourceMaterial.pbrMetallicRoughness.baseColorFactor;\n material.pbrMetallicRoughness.baseColorFactor =\n (baseColorFactor && baseColorFactor.map((c) => Math.round(c * 255))) || undefined;\n }\n\n return {material, texture};\n}\n\nfunction getDefaultMaterial() {\n return {\n alphaMode: 'opaque',\n pbrMetallicRoughness: {}\n };\n}\n\n/**\n * Form \"sharedResources\" from gltf materials array\n * @param {Object} tileContent - 3d tile content\n * @returns {Object} {materialDefinitionInfos: Object[], textureDefinitionInfos: Object[]} -\n * 2 arrays in format of i3s sharedResources data https://github.com/Esri/i3s-spec/blob/master/docs/1.7/sharedResource.cmn.md\n */\nfunction getSharedResources(tileContent, nodeId) {\n const gltfMaterials = tileContent.gltf.materials;\n const i3sResources = {};\n\n if (!gltfMaterials || !gltfMaterials.length) {\n return i3sResources;\n }\n\n i3sResources.materialDefinitionInfos = [];\n for (const gltfMaterial of gltfMaterials) {\n const {materialDefinitionInfo, textureDefinitionInfo} = convertGLTFMaterialToI3sSharedResources(\n gltfMaterial,\n nodeId\n );\n i3sResources.materialDefinitionInfos.push(materialDefinitionInfo);\n if (textureDefinitionInfo) {\n i3sResources.textureDefinitionInfos = i3sResources.textureDefinitionInfos || [];\n i3sResources.textureDefinitionInfos.push(textureDefinitionInfo);\n }\n }\n return i3sResources;\n}\n\n/**\n * Convert gltf material into I3S sharedResources data\n * @param {Object} gltfMaterial - gltf material data\n * @returns {Object} - Couple {materialDefinitionInfo, textureDefinitionInfo} extracted from gltf material data\n */\nfunction convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {\n const texture =\n gltfMaterial.pbrMetallicRoughness.baseColorTexture || gltfMaterial.emissiveTexture;\n let textureDefinitionInfo = null;\n if (texture) {\n textureDefinitionInfo = extractSharedResourcesTextureInfo(texture.texture, nodeId);\n }\n const {baseColorFactor, metallicFactor} = gltfMaterial.pbrMetallicRoughness;\n let colorFactor = baseColorFactor;\n // If alpha channel is 0 try to get emissive factor from gltf material.\n if ((!baseColorFactor || baseColorFactor[3] === 0) && gltfMaterial.emissiveFactor) {\n colorFactor = gltfMaterial.emissiveFactor;\n colorFactor[3] = colorFactor[3] || 1;\n }\n\n return {\n materialDefinitionInfo: extractSharedResourcesMaterialInfo(colorFactor, metallicFactor),\n textureDefinitionInfo\n };\n}\n\n/**\n * Form \"materialDefinition\" which is part of \"sharedResouces\"\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#materials\n * See formulas in appendix \"Appendix B: BRDF Implementation\":\n * const dielectricSpecular = rgb(0.04, 0.04, 0.04)\n * const black = rgb(0, 0, 0)\n * cdiff = lerp(baseColor.rgb * (1 - dielectricSpecular.r), black, metallic)\n * F0 = lerp(dieletricSpecular, baseColor.rgb, metallic)\n *\n * Assumption: F0 - specular in i3s (\"specular reflection\" <-> \"reflectance value at normal incidence\")\n * cdiff - diffuse in i3s (\"Diffuse color\" <-> \"'c' diffuse\" (c means color?))\n * @param {number[]} baseColorFactor - RGBA color in 0..1 format\n * @param {number} metallicFactor - \"metallicFactor\" attribute of gltf material object\n * @returns {Object}\n */\nfunction extractSharedResourcesMaterialInfo(baseColorFactor, metallicFactor = 0) {\n const matDielectricColorComponent = 0.04 / 255; // Color from rgb (255) to 0..1 resolution\n // All color resolutions are 0..1\n const black = new Vector4(0, 0, 0, 1);\n const unitVector = new Vector4(1, 1, 1, 1);\n const dielectricSpecular = new Vector4(\n matDielectricColorComponent,\n matDielectricColorComponent,\n matDielectricColorComponent,\n 0\n );\n const baseColorVector = new Vector4(baseColorFactor);\n // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#metallic-roughness-material\n // Formulas for Cdiff & F0\n const firstOperand = unitVector.subtract(dielectricSpecular).multiply(baseColorVector);\n const diffuse = firstOperand.lerp(firstOperand, black, metallicFactor);\n dielectricSpecular[3] = 1;\n const specular = dielectricSpecular.lerp(dielectricSpecular, baseColorVector, metallicFactor);\n return {\n diffuse: diffuse.toArray(),\n specular: specular.toArray()\n };\n}\n\n/**\n * Form \"textureDefinition\" which is part of \"sharedResouces\"\n * @param {Object} texture - texture image info\n * @returns {Object}\n */\nfunction extractSharedResourcesTextureInfo(texture, nodeId) {\n return {\n encoding: [texture.source.mimeType],\n images: [\n {\n // 'i3s' has just size which is width of the image. Images are supposed to be square.\n // https://github.com/Esri/i3s-spec/blob/master/docs/1.7/image.cmn.md\n id: generateImageId(texture, nodeId),\n size: texture.source.image.width,\n length: [texture.source.image.data.length]\n }\n ]\n };\n}\n/*\n * Formula for counting imageId:\n * https://github.com/Esri/i3s-spec/blob/0a6366a9249b831db8436c322f8d27521e86cf07/format/Indexed%203d%20Scene%20Layer%20Format%20Specification.md#generating-image-ids\n * @param {Object} texture - texture image info\n * @returns {string}\n */\nfunction generateImageId(texture, nodeId) {\n const {width, height} = texture.source.image;\n const levelCountOfTexture = 1;\n const indexOfLevel = 0;\n const indexOfTextureInStore = nodeId + 1;\n\n const zerosCount = 32 - indexOfTextureInStore.toString(2).length;\n const rightHalf = '0'.repeat(zerosCount).concat(indexOfTextureInStore.toString(2));\n\n const shiftedLevelCountOfTexture = levelCountOfTexture << 28;\n const shiftedIndexOfLevel = indexOfLevel << 24;\n const shiftedWidth = (width - 1) << 12;\n const shiftedHeight = (height - 1) << 0;\n\n const leftHalf = shiftedLevelCountOfTexture + shiftedIndexOfLevel + shiftedWidth + shiftedHeight;\n const imageId = BigInt(`0b${leftHalf.toString(2)}${rightHalf}`);\n return imageId.toString();\n}\n\n/**\n * Make all feature ids unique through all nodes in layout.\n * @param {Array} featureIds\n * @param {Array} featureIndices\n * @param {Array} featuresHashArray\n * @param {Object} batchTable\n * @returns {void}\n */\nfunction makeFeatureIdsUnique(featureIds, featureIndices, featuresHashArray, batchTable) {\n const replaceMap = getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray);\n replaceIndicesByUnique(featureIndices, replaceMap);\n replaceIndicesByUnique(featureIds, replaceMap);\n}\n\n/**\n * Generate replace map to make featureIds unique.\n * @param {Array} featureIds\n * @param {Object} batchTable\n * @param {Array} featuresHashArray\n * @returns {Object}\n */\nfunction getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray) {\n const featureMap = {};\n\n for (let index = 0; index < featureIds.length; index++) {\n const oldFeatureId = featureIds[index];\n const uniqueFeatureId = getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray);\n featureMap[oldFeatureId.toString()] = uniqueFeatureId;\n }\n\n return featureMap;\n}\n\n/**\n * Generates string for unique batch id creation.\n * @param {Object} batchTable\n * @param {Number} index\n * @returns {String}\n */\nfunction generateStringFromBatchTableByIndex(batchTable, index) {\n let str = '';\n for (const key in batchTable) {\n str += batchTable[key][index];\n }\n return str;\n}\n\n/**\n * Return already exited featureId or creates and returns new to support unique feature ids throw nodes.\n * @param {Number} index\n * @param {Object} batchTable\n * @param {Array} featuresHashArray\n * @returns {Number}\n */\nfunction getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray) {\n const batchTableStr = generateStringFromBatchTableByIndex(batchTable, index);\n const hash = md5(batchTableStr);\n\n if (featuresHashArray.includes(hash)) {\n return featuresHashArray.indexOf(hash);\n }\n return featuresHashArray.push(hash) - 1;\n}\n\n/**\n * Do replacement of indices for making them unique through all nodes.\n * @param {Array} indicesArray\n * @param {Object} featureMap\n * @returns {void}\n */\nfunction replaceIndicesByUnique(indicesArray, featureMap) {\n for (let index = 0; index < indicesArray.length; index++) {\n indicesArray[index] = featureMap[indicesArray[index]];\n }\n}\n\n/**\n * Convert batch table data to attribute buffers.\n * @param {Object} batchTable - table with metadata for particular feature.\n * @param {Array} featureIds\n * @param {Array} attributeStorageInfo\n * @returns {Array} - Array of file buffers.\n */\nfunction convertBatchTableToAttributeBuffers(batchTable, featureIds, attributeStorageInfo) {\n const attributeBuffers = [];\n\n if (batchTable) {\n const batchTableWithFeatureIds = {\n OBJECTID: featureIds,\n ...batchTable\n };\n\n for (const key in batchTableWithFeatureIds) {\n const type = getAttributeType(key, attributeStorageInfo);\n\n let attributeBuffer = null;\n\n switch (type) {\n case OBJECT_ID_TYPE:\n case SHORT_INT_TYPE:\n attributeBuffer = generateShortIntegerAttributeBuffer(batchTableWithFeatureIds[key]);\n break;\n case DOUBLE_TYPE:\n attributeBuffer = generateDoubleAttributeBuffer(batchTableWithFeatureIds[key]);\n break;\n case STRING_TYPE:\n attributeBuffer = generateStringAttributeBuffer(batchTableWithFeatureIds[key]);\n break;\n default:\n attributeBuffer = generateStringAttributeBuffer(batchTableWithFeatureIds[key]);\n }\n\n attributeBuffers.push(attributeBuffer);\n }\n }\n\n return attributeBuffers;\n}\n/**\n * Return attribute type.\n * @param {String} key\n * @param {Array} attributeStorageInfo\n * @returns {String} attribute type.\n */\nfunction getAttributeType(key, attributeStorageInfo) {\n const attribute = attributeStorageInfo.find((attr) => attr.name === key);\n return attribute.attributeValues.valueType;\n}\n\n/**\n * Convert short integer to attribute arrayBuffer.\n * @param {Array} featureIds\n * @returns {ArrayBuffer} - Buffer with objectId data.\n */\nfunction generateShortIntegerAttributeBuffer(featureIds) {\n const count = new Uint32Array([featureIds.length]);\n const valuesArray = new Uint32Array(featureIds);\n return concatenateArrayBuffers(count.buffer, valuesArray.buffer);\n}\n\n/**\n * Convert double to attribute arrayBuffer.\n * @param {Array} featureIds\n * @returns {ArrayBuffer} - Buffer with objectId data.\n */\nfunction generateDoubleAttributeBuffer(featureIds) {\n const count = new Uint32Array([featureIds.length]);\n const padding = new Uint8Array(4);\n const valuesArray = new Float64Array(featureIds);\n\n return concatenateArrayBuffers(count.buffer, padding.buffer, valuesArray.buffer);\n}\n\n/**\n * Convert batch table attributes to array buffer with batch table data.\n * @param {Array} batchAttributes\n * @returns {ArrayBuffer} - Buffer with batch table data.\n */\nfunction generateStringAttributeBuffer(batchAttributes) {\n const stringCountArray = new Uint32Array([batchAttributes.length]);\n let totalNumberOfBytes = 0;\n const stringSizesArray = new Uint32Array(batchAttributes.length);\n const stringBufferArray = [];\n\n for (let index = 0; index < batchAttributes.length; index++) {\n const currentString = `${String(batchAttributes[index])}\\0`;\n const currentStringBuffer = Buffer.from(currentString);\n const currentStringSize = currentStringBuffer.length;\n totalNumberOfBytes += currentStringSize;\n stringSizesArray[index] = currentStringSize;\n stringBufferArray.push(currentStringBuffer);\n }\n\n const totalBytes = new Uint32Array([totalNumberOfBytes]);\n\n return concatenateArrayBuffers(\n stringCountArray.buffer,\n totalBytes.buffer,\n stringSizesArray.buffer,\n ...stringBufferArray\n );\n}\n\n/**\n * Convert featureIds to BigUint64Array.\n * @param {Array} featureIds\n * @returns {BigUint64Array} - Array of feature ids in BigUint64 format.\n */\nfunction generateBigUint64Array(featureIds) {\n const typedFeatureIds = new BigUint64Array(featureIds.length);\n for (let index = 0; index < featureIds.length; index++) {\n typedFeatureIds[index] = BigInt(featureIds[index]);\n }\n return typedFeatureIds;\n}\n\n/**\n * Generates draco compressed geometry\n * @param {Number} vertexCount\n * @param {Object} convertedAttributes\n * @returns {Promise<object>} - COmpressed geometry.\n */\nasync function generateCompressedGeometry(vertexCount, convertedAttributes, attributes) {\n const {positions, normals, texCoords, colors, featureIds, faceRange} = attributes;\n const indices = new Uint32Array(vertexCount);\n\n for (let index = 0; index < indices.length; index++) {\n indices.set([index], index);\n }\n\n const featureIndices = new Uint32Array(\n convertedAttributes.featureIndices.length ? convertedAttributes.featureIndices : vertexCount\n );\n\n const featureIndex = generateFeatureIndexAttribute(featureIndices, faceRange);\n\n const compressedAttributes = {\n positions,\n normals,\n colors,\n 'feature-index': featureIndex\n };\n\n if (texCoords.length) {\n compressedAttributes.texCoords = texCoords;\n }\n\n const attributesMetadata = {\n 'feature-index': {\n 'i3s-attribute-type': 'feature-index',\n 'i3s-feature-ids': new Int32Array(featureIds)\n }\n };\n\n return new Uint8Array(\n await encode({attributes: compressedAttributes, indices}, DracoWriter, {\n draco: {\n method: 'MESH_SEQUENTIAL_ENCODING',\n attributesMetadata\n }\n })\n );\n}\n\n/**\n * Generates ordered feature indices based on face range\n * @param {Uint32Array} featureIndex\n * @param {Uint32Array} faceRange\n * @returns {Uint32Array}\n */\nfunction generateFeatureIndexAttribute(featureIndex, faceRange) {\n const orderedFeatureIndices = new Uint32Array(featureIndex.length);\n let fillIndex = 0;\n let startIndex = 0;\n\n for (let index = 1; index < faceRange.length; index += 2) {\n const endIndex = (faceRange[index] + 1) * VALUES_PER_VERTEX;\n\n orderedFeatureIndices.fill(fillIndex, startIndex, endIndex);\n\n fillIndex++;\n startIndex = endIndex + 1;\n }\n\n return orderedFeatureIndices;\n}\n"],"file":"geometry-converter.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-debug.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/node-debug.ts"],"names":[],"mappings":"AAMA,wBAAgB,2BAA2B,CAAC,IAAI,KAAA,WAU/C"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/i3s-converter/helpers/node-debug.ts"],"names":["OrientedBoundingBox","BoundingSphere","CubeGeometry","Vector3","Ellipsoid","validateNodeBoundingVolumes","node","parentNode","obb","mbs","tileWarnings","validateObb","validateMbs","parentObb","createBoundingBoxFromTileObb","tileVertices","getTileObbVertices","isTileObbInsideParentObb","isAllVerticesInsideBoundingVolume","title","id","push","tileMbs","createBoundingSphereFromTileMbs","parentMbs","distanceBetweenCenters","center","distanceTo","radius","halfSize","quaternion","fromCenterHalfSizeQuaternion","geometry","attributes","getAttributes","positions","Float32Array","POSITION","value","obbCenterCartesian","WGS84","cartographicToCartesian","vertices","i","length","positionsVector","rotatedPositions","transformByQuaternion","add","concat","boundingVolume","isVerticesInsideObb","index","point","cartographicPoint","cartesianToCartographic","distance"],"mappings":"AAAA,SAAQA,mBAAR,EAA6BC,cAA7B,QAAkD,kBAAlD;AACA,SAAQC,YAAR,QAA2B,iBAA3B;AACA,SAAQC,OAAR,QAAsB,eAAtB;AACA,SAAQC,SAAR,QAAwB,qBAAxB;AAGA,OAAO,SAASC,2BAAT,CAAqCC,IAArC,EAA2C;AAChD,MAAI,CAACA,IAAI,CAACC,UAAL,CAAgBC,GAAjB,IAAwB,CAACF,IAAI,CAACC,UAAL,CAAgBE,GAA7C,EAAkD;AAChD,WAAO,EAAP;AACD;;AACD,QAAMC,YAAY,GAAG,EAArB;AAEAC,EAAAA,WAAW,CAACD,YAAD,EAAeJ,IAAf,CAAX;AACAM,EAAAA,WAAW,CAACF,YAAD,EAAeJ,IAAf,CAAX;AAEA,SAAOI,YAAP;AACD;;AAED,SAASC,WAAT,CAAqBD,YAArB,EAAmCJ,IAAnC,EAAyC;AACvC,QAAMO,SAAS,GAAGC,4BAA4B,CAACR,IAAI,CAACC,UAAL,CAAgBC,GAAjB,CAA9C;AACA,QAAMO,YAAY,GAAGC,kBAAkB,CAACV,IAAD,CAAvC;AACA,QAAMW,wBAAwB,GAAGC,iCAAiC,CAACL,SAAD,EAAYE,YAAZ,CAAlE;;AAEA,MAAIE,wBAAJ,EAA8B;AAC5B;AACD;;AAED,QAAME,KAAK,0BAAmBb,IAAI,CAACc,EAAxB,wCAAwDd,IAAI,CAACC,UAAL,CAAgBa,EAAxE,eAAX;AACAV,EAAAA,YAAY,CAACW,IAAb,CAAkBF,KAAlB;AACD;;AAED,SAASP,WAAT,CAAqBF,YAArB,EAAmCJ,IAAn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AAwCF,KAAxC,CAA1B;AAEA,UAAMG,QAAQ,GAAGN,cAAc,CAACvB,UAAf,CAA0B2B,iBAA1B,CAAjB;;AAEA,QAAIE,QAAQ,GAAG,CAAf,EAAkB;AAChBL,MAAAA,mBAAmB,GAAG,KAAtB;AACA;AACD;AACF;;AAED,SAAOA,mBAAP;AACD","sourcesContent":["import {OrientedBoundingBox, BoundingSphere} from '@math.gl/culling';\nimport {CubeGeometry} from '@luma.gl/engine';\nimport {Vector3} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\n\n// TODO Unite Tile validation logic in i3s-17-and-debug with this code.\nexport function validateNodeBoundingVolumes(node) {\n if (!node.parentNode.obb || !node.parentNode.mbs) {\n return [];\n }\n const tileWarnings = [];\n\n validateObb(tileWarnings, node);\n validateMbs(tileWarnings, node);\n\n return tileWarnings;\n}\n\nfunction validateObb(tileWarnings, node) {\n const parentObb = createBoundingBoxFromTileObb(node.parentNode.obb);\n const tileVertices = getTileObbVertices(node);\n const isTileObbInsideParentObb = isAllVerticesInsideBoundingVolume(parentObb, tileVertices);\n\n if (isTileObbInsideParentObb) {\n return;\n }\n\n const title = `OBB of Tile (${node.id}) doesn't fit into Parent (${node.parentNode.id}) tile OBB`;\n tileWarnings.push(title);\n}\n\nfunction validateMbs(tileWarnings, node) {\n const tileMbs = createBoundingSphereFromTileMbs(node.mbs);\n const parentMbs = createBoundingSphereFromTileMbs(node.parentNode.mbs);\n const distanceBetweenCenters = tileMbs.center.distanceTo(parentMbs.center);\n\n if (distanceBetweenCenters + tileMbs.radius > parentMbs.radius) {\n const title = `MBS of Tile (${node.id}) doesn't fit into Parent (${node.parentNode.id}) tile MBS`;\n tileWarnings.push(title);\n }\n}\n\nfunction createBoundingSphereFromTileMbs(mbs) {\n return new BoundingSphere([mbs[0], mbs[1], mbs[2]], mbs[3]);\n}\n\nfunction createBoundingBoxFromTileObb(obb) {\n const {center, halfSize, quaternion} = obb;\n return new OrientedBoundingBox().fromCenterHalfSizeQuaternion(center, halfSize, quaternion);\n}\n\n// TODO check if Obb generates properly\nfunction getTileObbVertices(node) {\n const geometry = new CubeGeometry();\n const halfSize = node.obb.halfSize;\n const attributes = geometry.getAttributes();\n const positions = new Float32Array(attributes.POSITION.value);\n const obbCenterCartesian = Ellipsoid.WGS84.cartographicToCartesian(node.obb.center);\n\n let vertices = [];\n\n for (let i = 0; i < positions.length; i += 3) {\n const positionsVector = new Vector3(\n (positions[i] *= halfSize[0]),\n (positions[i + 1] *= halfSize[1]),\n (positions[i + 2] *= halfSize[2])\n );\n const rotatedPositions = positionsVector\n .transformByQuaternion(node.obb.quaternion)\n .add(obbCenterCartesian);\n // @ts-expect-error\n vertices = vertices.concat(rotatedPositions);\n }\n\n return vertices;\n}\n\nfunction isAllVerticesInsideBoundingVolume(boundingVolume, positions) {\n let isVerticesInsideObb = true;\n\n for (let index = 0; index < positions.length / 3; index += 3) {\n const point = [positions[index], positions[index + 1], positions[index + 2]];\n const cartographicPoint = Ellipsoid.WGS84.cartesianToCartographic(point);\n\n const distance = boundingVolume.distanceTo(cartographicPoint);\n\n if (distance > 0) {\n isVerticesInsideObb = false;\n break;\n }\n }\n\n return isVerticesInsideObb;\n}\n"],"file":"node-debug.js"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { NodeInPage } from '@loaders.gl/i3s';
|
|
2
|
+
/**
|
|
3
|
+
* class NodePages - wrapper of nodePages array
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* import {writeFile} from './helpers/write-file';
|
|
7
|
+
*
|
|
8
|
+
* // create an instance of the class
|
|
9
|
+
* const nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);
|
|
10
|
+
* ...
|
|
11
|
+
* // push root node
|
|
12
|
+
* const parentId = nodePages.push({
|
|
13
|
+
lodThreshold: HARDCODED_MAX_SCREEN_THRESHOLD_SQ,
|
|
14
|
+
obb: coordinates.obb,
|
|
15
|
+
children: []
|
|
16
|
+
});
|
|
17
|
+
* ...
|
|
18
|
+
* // push node with parent relation
|
|
19
|
+
* const nodeInPage = {
|
|
20
|
+
lodThreshold: HARDCODED_MAX_SCREEN_THRESHOLD_SQ,
|
|
21
|
+
obb: coordinates.obb,
|
|
22
|
+
children: [],
|
|
23
|
+
mesh: {
|
|
24
|
+
geometry: {
|
|
25
|
+
definition: 0
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
* const nodeId = this.nodePages.push(nodeInPage, parentId);
|
|
30
|
+
* ...
|
|
31
|
+
* // save all the nodePages in the end of pushing all the nodes
|
|
32
|
+
* await this.nodePages.save(layers0path);
|
|
33
|
+
*/
|
|
34
|
+
export default class NodePages {
|
|
35
|
+
readonly nodesPerPage: number;
|
|
36
|
+
nodesCounter: number;
|
|
37
|
+
writeFile: Function;
|
|
38
|
+
readonly nodePages: {
|
|
39
|
+
nodes: NodeInPage[];
|
|
40
|
+
}[];
|
|
41
|
+
/**
|
|
42
|
+
* @constructs
|
|
43
|
+
* Create a nodePages instance.
|
|
44
|
+
* @param writeFileFunc - function to save one nodePage into a file
|
|
45
|
+
* @param nodesPerPage - length limit for one nodePage. An additional nodePage is created when this limit is met
|
|
46
|
+
*/
|
|
47
|
+
constructor(writeFileFunc: any, nodesPerPage: any);
|
|
48
|
+
/**
|
|
49
|
+
* Setup function to save node pages
|
|
50
|
+
* @param func - function which should be used to save node pages
|
|
51
|
+
*/
|
|
52
|
+
useWriteFunction(func: Function): void;
|
|
53
|
+
/**
|
|
54
|
+
* Get the node by its end-to-end index
|
|
55
|
+
* @param id - end-to-end index of the node
|
|
56
|
+
* @return the node object
|
|
57
|
+
*/
|
|
58
|
+
getNodeById(id: number): NodeInPage;
|
|
59
|
+
/**
|
|
60
|
+
* Update material in node.mesh object by node id
|
|
61
|
+
* @param id - end-to-end index of the node
|
|
62
|
+
* @param materialId - id from scene layer materialDefinitions
|
|
63
|
+
*/
|
|
64
|
+
updateMaterialByNodeId(id: number, materialId: number): void;
|
|
65
|
+
/**
|
|
66
|
+
* Update vertexCount in node.mesh.geometry object by node id
|
|
67
|
+
* @param id - end-to-end index of the node
|
|
68
|
+
* @param vertexCount - vertex count for particular node
|
|
69
|
+
*/
|
|
70
|
+
updateVertexCountByNodeId(id: number, vertexCount: number): void;
|
|
71
|
+
/**
|
|
72
|
+
* Update resource in node.mesh.attribute object by node id
|
|
73
|
+
* @param id - end-to-end index of the node
|
|
74
|
+
*/
|
|
75
|
+
updateNodeAttributeByNodeId(id: number): void;
|
|
76
|
+
/**
|
|
77
|
+
* Update featureCount in node.mesh.geometry object by node id
|
|
78
|
+
* @param id - end-to-end index of the node
|
|
79
|
+
* @param featureCount - features count of the node
|
|
80
|
+
*/
|
|
81
|
+
updateFeatureCountByNodeId(id: number, featureCount: number): void;
|
|
82
|
+
/**
|
|
83
|
+
* Update texelCountHint in node.mesh.material object by node id
|
|
84
|
+
* @param id - end-to-end index of the node
|
|
85
|
+
* @param texelCountHint - texelCountHint of particular node
|
|
86
|
+
*/
|
|
87
|
+
updateTexelCountHintByNodeId(id: number, texelCountHint: number): void;
|
|
88
|
+
/**
|
|
89
|
+
* Add a child id into the parent node.children array
|
|
90
|
+
* @param parentId - end-to-end parent node index
|
|
91
|
+
* @param childId - end-to-end child node index
|
|
92
|
+
*/
|
|
93
|
+
addChildRelation(parentId: number | undefined, childId: number): void;
|
|
94
|
+
/**
|
|
95
|
+
* Update resource index in node.mesh object
|
|
96
|
+
* @param node - node object
|
|
97
|
+
*/
|
|
98
|
+
updateResourceInMesh(node: NodeInPage): void;
|
|
99
|
+
/**
|
|
100
|
+
* Put new node in nodePages array
|
|
101
|
+
* @param node - node object
|
|
102
|
+
* @param parentId - index of parent node
|
|
103
|
+
* @return
|
|
104
|
+
*/
|
|
105
|
+
push(node: NodeInPage, parentId?: number): number;
|
|
106
|
+
/**
|
|
107
|
+
* Save all the node pages
|
|
108
|
+
* Run this method when all nodes is pushed in nodePages
|
|
109
|
+
* @param {string} layers0Path - path of layer
|
|
110
|
+
* @param {Object} fileMap - fileMap which keep info for slpk archive
|
|
111
|
+
* @param {boolean} slpk
|
|
112
|
+
* @return {promise}
|
|
113
|
+
*/
|
|
114
|
+
save(layers0Path: string, fileMap: Object, slpk?: boolean): Promise<void>;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=node-pages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-pages.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/node-pages.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAG3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,QAAQ,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE;QAAC,KAAK,EAAE,UAAU,EAAE,CAAA;KAAC,EAAE,CAAC;IAE5C;;;;;OAKG;gBACS,aAAa,KAAA,EAAE,YAAY,KAAA;IASvC;;;OAGG;IACH,gBAAgB,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAItC;;;;OAIG;IACH,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU;IAMnC;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IAW5D;;;;OAIG;IACH,yBAAyB,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;IAQhE;;;OAGG;IACH,2BAA2B,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAQ7C;;;;OAIG;IACH,0BAA0B,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAQlE;;;;OAIG;IACH,4BAA4B,CAAC,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI;IAQtE;;;;OAIG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAQrE;;;OAGG;IACH,oBAAoB,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAM5C;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM;IAajD;;;;;;;OAOG;IACG,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CA2BvF"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/i3s-converter/helpers/node-pages.ts"],"names":["join","transform","METADATA","metadataTemplate","NodePages","constructor","writeFileFunc","nodesPerPage","nodesCounter","nodePages","nodes","writeFile","useWriteFunction","func","getNodeById","id","pageIndex","Math","floor","nodeIndex","updateMaterialByNodeId","materialId","node","mesh","material","definition","resource","index","updateVertexCountByNodeId","vertexCount","geometry","updateNodeAttributeByNodeId","attribute","updateFeatureCountByNodeId","featureCount","updateTexelCountHintByNodeId","texelCountHint","addChildRelation","parentId","childId","undefined","parentNode","children","push","updateResourceInMesh","currentNodePage","length","save","layers0Path","fileMap","slpk","promises","nodePage","entries","nodePageStr","JSON","stringify","slpkPath","toString","metadata","nodeCount","compress","nodePagePath","Promise","all"],"mappings":";AAAA,SAAQA,IAAR,QAAmB,MAAnB;AACA,OAAOC,SAAP,MAAsB,oBAAtB;AACA,SAAQC,QAAQ,IAAIC,gBAApB,QAA2C,4BAA3C;AAoCA,eAAe,MAAMC,SAAN,CAAgB;AAY7BC,EAAAA,WAAW,CAACC,aAAD,EAAgBC,YAAhB,EAA8B;AAAA;;AAAA;;AAAA;;AAAA;;AACvC,SAAKA,YAAL,GAAoBA,YAApB;AACA,SAAKC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,OAAO,CAAC,eAAD,CAAP,GAA2B,MAAM,KAAKtC,SAAL,CAC/BqC,WAD+B,EAE/BO,IAAI,CAACC,SAAL,CAAeG,QAAf,CAF+B,EAG/B,eAH+B,EAI/BE,QAJ+B,CAAjC;AAMD,KAfD,MAeO;AACL,WAAK,MAAM,CAAClC,KAAD,EAAQyB,QAAR,CAAX,IAAgC,KAAK3C,SAAL,CAAe4C,OAAf,EAAhC,EAA0D;AACxD,cAAMC,WAAW,GAAGC,IAAI,CAACC,SAAL,CAAeJ,QAAf,CAApB;AACA,cAAMU,YAAY,GAAG9D,IAAI,CAACgD,WAAD,EAAc,WAAd,EAA2BrB,KAAK,CAAC+B,QAAN,EAA3B,CAAzB;AACAP,QAAAA,QAAQ,CAACR,IAAT,CAAc,KAAKhC,SAAL,CAAemD,YAAf,EAA6BR,WAA7B,CAAd;AACD;AACF;;AAED,UAAMS,OAAO,CAACC,GAAR,CAAYb,QAAZ,CAAN;AACD;;AAvL4B","sourcesContent":["import {join} from 'path';\nimport transform from 'json-map-transform';\nimport {METADATA as metadataTemplate} from '../json-templates/metadata';\nimport {NodeInPage} from '@loaders.gl/i3s';\n\n// @ts-nocheck\n/**\n * class NodePages - wrapper of nodePages array\n *\n * @example\n * import {writeFile} from './helpers/write-file';\n *\n * // create an instance of the class\n * const nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);\n * ...\n * // push root node\n * const parentId = nodePages.push({\n lodThreshold: HARDCODED_MAX_SCREEN_THRESHOLD_SQ,\n obb: coordinates.obb,\n children: []\n });\n * ...\n * // push node with parent relation\n * const nodeInPage = {\n lodThreshold: HARDCODED_MAX_SCREEN_THRESHOLD_SQ,\n obb: coordinates.obb,\n children: [],\n mesh: {\n geometry: {\n definition: 0\n }\n }\n };\n * const nodeId = this.nodePages.push(nodeInPage, parentId);\n * ...\n * // save all the nodePages in the end of pushing all the nodes\n * await this.nodePages.save(layers0path);\n */\nexport default class NodePages {\n readonly nodesPerPage: number;\n nodesCounter: number;\n writeFile: Function;\n readonly nodePages: {nodes: NodeInPage[]}[];\n\n /**\n * @constructs\n * Create a nodePages instance.\n * @param writeFileFunc - function to save one nodePage into a file\n * @param nodesPerPage - length limit for one nodePage. An additional nodePage is created when this limit is met\n */\n constructor(writeFileFunc, nodesPerPage) {\n this.nodesPerPage = nodesPerPage;\n this.nodesCounter = 0;\n // @ts-expect-error\n this.nodePages = [{}];\n this.nodePages[0].nodes = [];\n this.writeFile = writeFileFunc;\n }\n\n /**\n * Setup function to save node pages\n * @param func - function which should be used to save node pages\n */\n useWriteFunction(func: Function): void {\n this.writeFile = func;\n }\n\n /**\n * Get the node by its end-to-end index\n * @param id - end-to-end index of the node\n * @return the node object\n */\n getNodeById(id: number): NodeInPage {\n const pageIndex = Math.floor(id / this.nodesPerPage);\n const nodeIndex = id % this.nodesPerPage;\n return this.nodePages[pageIndex].nodes[nodeIndex];\n }\n\n /**\n * Update material in node.mesh object by node id\n * @param id - end-to-end index of the node\n * @param materialId - id from scene layer materialDefinitions\n */\n updateMaterialByNodeId(id: number, materialId: number): void {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.material = {\n definition: materialId,\n resource: node.index\n };\n }\n\n /**\n * Update vertexCount in node.mesh.geometry object by node id\n * @param id - end-to-end index of the node\n * @param vertexCount - vertex count for particular node\n */\n updateVertexCountByNodeId(id: number, vertexCount: number): void {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.geometry.vertexCount = vertexCount;\n }\n\n /**\n * Update resource in node.mesh.attribute object by node id\n * @param id - end-to-end index of the node\n */\n updateNodeAttributeByNodeId(id: number): void {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.attribute.resource = node.index;\n }\n\n /**\n * Update featureCount in node.mesh.geometry object by node id\n * @param id - end-to-end index of the node\n * @param featureCount - features count of the node\n */\n updateFeatureCountByNodeId(id: number, featureCount: number): void {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.geometry.featureCount = featureCount;\n }\n\n /**\n * Update texelCountHint in node.mesh.material object by node id\n * @param id - end-to-end index of the node\n * @param texelCountHint - texelCountHint of particular node\n */\n updateTexelCountHintByNodeId(id: number, texelCountHint: number): void {\n const node = this.getNodeById(id);\n if (!node.mesh || !node.mesh.material) {\n return;\n }\n node.mesh.material.texelCountHint = texelCountHint;\n }\n\n /**\n * Add a child id into the parent node.children array\n * @param parentId - end-to-end parent node index\n * @param childId - end-to-end child node index\n */\n addChildRelation(parentId: number | undefined, childId: number): void {\n if (parentId === null || parentId === undefined) {\n return;\n }\n const parentNode = this.getNodeById(parentId);\n parentNode.children?.push(childId);\n }\n\n /**\n * Update resource index in node.mesh object\n * @param node - node object\n */\n updateResourceInMesh(node: NodeInPage): void {\n if (node.mesh) {\n node.mesh.geometry.resource = node.index;\n }\n }\n\n /**\n * Put new node in nodePages array\n * @param node - node object\n * @param parentId - index of parent node\n * @return\n */\n push(node: NodeInPage, parentId?: number): number {\n let currentNodePage = this.nodePages[this.nodePages.length - 1];\n if (currentNodePage.nodes.length === this.nodesPerPage) {\n currentNodePage = {nodes: []};\n this.nodePages.push(currentNodePage);\n }\n node.index = this.nodesCounter++;\n currentNodePage.nodes.push(node);\n this.addChildRelation(parentId, node.index);\n this.updateResourceInMesh(node);\n return node.index;\n }\n\n /**\n * Save all the node pages\n * Run this method when all nodes is pushed in nodePages\n * @param {string} layers0Path - path of layer\n * @param {Object} fileMap - fileMap which keep info for slpk archive\n * @param {boolean} slpk\n * @return {promise}\n */\n async save(layers0Path: string, fileMap: Object, slpk: boolean = false): Promise<void> {\n const promises: Promise<any>[] = [];\n if (slpk) {\n for (const [index, nodePage] of this.nodePages.entries()) {\n const nodePageStr = JSON.stringify(nodePage);\n const slpkPath = join(layers0Path, 'nodepages');\n promises.push(this.writeFile(slpkPath, nodePageStr, `${index.toString()}.json`));\n fileMap[`nodePages/${index.toString()}.json.gz`] = `${slpkPath}.json.gz`;\n }\n const metadata = transform({nodeCount: this.nodesCounter}, metadataTemplate());\n const compress = false;\n fileMap['metadata.json'] = await this.writeFile(\n layers0Path,\n JSON.stringify(metadata),\n 'metadata.json',\n compress\n );\n } else {\n for (const [index, nodePage] of this.nodePages.entries()) {\n const nodePageStr = JSON.stringify(nodePage);\n const nodePagePath = join(layers0Path, 'nodepages', index.toString());\n promises.push(this.writeFile(nodePagePath, nodePageStr));\n }\n }\n\n await Promise.all(promises);\n }\n}\n"],"file":"node-pages.js"}
|