@loaders.gl/tile-converter 3.1.8 → 3.2.0-alpha.1

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.
Files changed (112) hide show
  1. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +78 -0
  2. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -0
  3. package/dist/3d-tiles-converter/3d-tiles-converter.js +242 -0
  4. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +83 -0
  5. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -0
  6. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +278 -0
  7. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +13 -0
  8. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts.map +1 -0
  9. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +23 -0
  10. package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +9 -0
  11. package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +1 -0
  12. package/dist/3d-tiles-converter/helpers/texture-atlas.js +52 -0
  13. package/dist/3d-tiles-converter/json-templates/tileset.d.ts +15 -0
  14. package/dist/3d-tiles-converter/json-templates/tileset.d.ts.map +1 -0
  15. package/dist/3d-tiles-converter/json-templates/tileset.js +43 -0
  16. package/dist/bundle.d.ts +2 -0
  17. package/dist/bundle.d.ts.map +1 -0
  18. package/dist/bundle.js +5 -0
  19. package/dist/converter.min.js +19 -19
  20. package/dist/deps-installer/deps-installer.d.ts +4 -0
  21. package/dist/deps-installer/deps-installer.d.ts.map +1 -0
  22. package/dist/deps-installer/deps-installer.js +21 -0
  23. package/dist/dist.min.js +304 -494
  24. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +2 -1
  25. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  26. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +14 -21
  27. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  28. package/dist/es5/i3s-converter/i3s-converter.js +35 -25
  29. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  30. package/dist/es5/pgm-loader.js +1 -1
  31. package/dist/es5/pgm-loader.js.map +1 -1
  32. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +2 -1
  33. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  34. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +7 -5
  35. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  36. package/dist/esm/i3s-converter/i3s-converter.js +10 -0
  37. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  38. package/dist/esm/pgm-loader.js +1 -1
  39. package/dist/esm/pgm-loader.js.map +1 -1
  40. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +41 -0
  41. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -0
  42. package/dist/i3s-converter/helpers/coordinate-converter.js +118 -0
  43. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts +9 -0
  44. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts.map +1 -0
  45. package/dist/i3s-converter/helpers/create-scene-server-path.js +28 -0
  46. package/dist/i3s-converter/helpers/geometry-attributes.d.ts +8 -0
  47. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -0
  48. package/dist/i3s-converter/helpers/geometry-attributes.js +176 -0
  49. package/dist/i3s-converter/helpers/geometry-converter.d.ts +12 -0
  50. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -0
  51. package/dist/i3s-converter/helpers/geometry-converter.js +791 -0
  52. package/dist/i3s-converter/helpers/node-debug.d.ts +8 -0
  53. package/dist/i3s-converter/helpers/node-debug.d.ts.map +1 -0
  54. package/dist/i3s-converter/helpers/node-debug.js +114 -0
  55. package/dist/i3s-converter/helpers/node-pages.d.ts +116 -0
  56. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -0
  57. package/dist/i3s-converter/helpers/node-pages.js +203 -0
  58. package/dist/i3s-converter/i3s-converter.d.ts +321 -0
  59. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -0
  60. package/dist/i3s-converter/i3s-converter.js +994 -0
  61. package/dist/i3s-converter/json-templates/layers.d.ts +95 -0
  62. package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -0
  63. package/dist/i3s-converter/json-templates/layers.js +199 -0
  64. package/dist/i3s-converter/json-templates/metadata.d.ts +22 -0
  65. package/dist/i3s-converter/json-templates/metadata.d.ts.map +1 -0
  66. package/dist/i3s-converter/json-templates/metadata.js +25 -0
  67. package/dist/i3s-converter/json-templates/node.d.ts +61 -0
  68. package/dist/i3s-converter/json-templates/node.d.ts.map +1 -0
  69. package/dist/i3s-converter/json-templates/node.js +89 -0
  70. package/dist/i3s-converter/json-templates/scene-server.d.ts +28 -0
  71. package/dist/i3s-converter/json-templates/scene-server.d.ts.map +1 -0
  72. package/dist/i3s-converter/json-templates/scene-server.js +31 -0
  73. package/dist/i3s-converter/json-templates/shared-resources.d.ts +14 -0
  74. package/dist/i3s-converter/json-templates/shared-resources.d.ts.map +1 -0
  75. package/dist/i3s-converter/json-templates/shared-resources.js +129 -0
  76. package/dist/i3s-converter/json-templates/store.d.ts +95 -0
  77. package/dist/i3s-converter/json-templates/store.d.ts.map +1 -0
  78. package/dist/i3s-converter/json-templates/store.js +103 -0
  79. package/dist/i3s-converter/types.d.ts +39 -0
  80. package/dist/i3s-converter/types.d.ts.map +1 -0
  81. package/dist/i3s-converter/types.js +2 -0
  82. package/dist/i3s-server/app.d.ts +3 -0
  83. package/dist/i3s-server/app.d.ts.map +1 -0
  84. package/dist/i3s-server/app.js +14 -0
  85. package/dist/i3s-server/controllers/index-controller.d.ts +2 -0
  86. package/dist/i3s-server/controllers/index-controller.d.ts.map +1 -0
  87. package/dist/i3s-server/controllers/index-controller.js +23 -0
  88. package/dist/i3s-server/routes/index.d.ts +3 -0
  89. package/dist/i3s-server/routes/index.d.ts.map +1 -0
  90. package/dist/i3s-server/routes/index.js +16 -0
  91. package/dist/index.d.ts +5 -0
  92. package/dist/index.d.ts.map +1 -0
  93. package/dist/index.js +14 -0
  94. package/dist/lib/utils/compress-util.d.ts +6 -0
  95. package/dist/lib/utils/compress-util.d.ts.map +1 -0
  96. package/dist/lib/utils/compress-util.js +190 -0
  97. package/dist/lib/utils/file-utils.d.ts +6 -0
  98. package/dist/lib/utils/file-utils.d.ts.map +1 -0
  99. package/dist/lib/utils/file-utils.js +42 -0
  100. package/dist/lib/utils/lod-conversion-utils.d.ts +20 -0
  101. package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -0
  102. package/dist/lib/utils/lod-conversion-utils.js +57 -0
  103. package/dist/lib/utils/statistic-utills.d.ts +3 -0
  104. package/dist/lib/utils/statistic-utills.d.ts.map +1 -0
  105. package/dist/lib/utils/statistic-utills.js +64 -0
  106. package/dist/pgm-loader.d.ts +6 -0
  107. package/dist/pgm-loader.d.ts.map +1 -0
  108. package/dist/pgm-loader.js +23 -0
  109. package/package.json +16 -17
  110. package/src/3d-tiles-converter/3d-tiles-converter.ts +4 -1
  111. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +6 -5
  112. package/src/i3s-converter/i3s-converter.ts +12 -0
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createObbFromMbs = exports.convertCommonToI3SExtentCoordinate = exports.convertPositionsToVectors = exports.createBoundingVolumesFromGeometry = exports.createBoundingVolumes = void 0;
4
+ const core_1 = require("@math.gl/core");
5
+ const geospatial_1 = require("@math.gl/geospatial");
6
+ const culling_1 = require("@math.gl/culling");
7
+ /**
8
+ * Create bounding volumes object from tile and geoid height model.
9
+ * @param tile
10
+ * @param geoidHeightModel
11
+ * @returns - Bounding volumes object
12
+ */
13
+ function createBoundingVolumes(tile, geoidHeightModel) {
14
+ let radius;
15
+ let halfSize;
16
+ let quaternion;
17
+ const boundingVolume = tile.boundingVolume;
18
+ const cartographicCenter = geospatial_1.Ellipsoid.WGS84.cartesianToCartographic(boundingVolume.center, new core_1.Vector3());
19
+ cartographicCenter[2] =
20
+ cartographicCenter[2] -
21
+ geoidHeightModel.getHeight(cartographicCenter[1], cartographicCenter[0]);
22
+ if (boundingVolume instanceof culling_1.OrientedBoundingBox) {
23
+ halfSize = boundingVolume.halfSize;
24
+ radius = new core_1.Vector3(halfSize[0], halfSize[1], halfSize[2]).len();
25
+ quaternion = boundingVolume.quaternion;
26
+ }
27
+ else {
28
+ radius = tile.boundingVolume.radius;
29
+ halfSize = [radius, radius, radius];
30
+ quaternion = new core_1.Quaternion()
31
+ .fromMatrix3(new core_1.Matrix3([halfSize[0], 0, 0, 0, halfSize[1], 0, 0, 0, halfSize[2]]))
32
+ .normalize();
33
+ }
34
+ return {
35
+ mbs: [cartographicCenter[0], cartographicCenter[1], cartographicCenter[2], radius],
36
+ obb: {
37
+ center: [cartographicCenter[0], cartographicCenter[1], cartographicCenter[2]],
38
+ halfSize,
39
+ quaternion
40
+ }
41
+ };
42
+ }
43
+ exports.createBoundingVolumes = createBoundingVolumes;
44
+ /**
45
+ * Generates bounding volumes from geometry positions
46
+ * @param cartesianPositions
47
+ * @param geoidHeightModel
48
+ */
49
+ function createBoundingVolumesFromGeometry(cartesianPositions, geoidHeightModel) {
50
+ const positionVectors = convertPositionsToVectors(cartesianPositions);
51
+ const geometryObb = (0, culling_1.makeOrientedBoundingBoxFromPoints)(positionVectors);
52
+ const geometryMbs = (0, culling_1.makeBoundingSphereFromPoints)(positionVectors);
53
+ let mbsCenter = geospatial_1.Ellipsoid.WGS84.cartesianToCartographic(geometryMbs.center, new core_1.Vector3());
54
+ let obbCenter = geospatial_1.Ellipsoid.WGS84.cartesianToCartographic(geometryObb.center, new core_1.Vector3());
55
+ mbsCenter[2] = mbsCenter[2] - geoidHeightModel.getHeight(mbsCenter[1], mbsCenter[0]);
56
+ obbCenter[2] = obbCenter[2] - geoidHeightModel.getHeight(obbCenter[1], obbCenter[0]);
57
+ return {
58
+ mbs: [mbsCenter[0], mbsCenter[1], mbsCenter[2], geometryMbs.radius],
59
+ obb: {
60
+ center: obbCenter,
61
+ halfSize: geometryObb.halfSize,
62
+ quaternion: geometryObb.quaternion
63
+ }
64
+ };
65
+ }
66
+ exports.createBoundingVolumesFromGeometry = createBoundingVolumesFromGeometry;
67
+ /**
68
+ * Create array of posisitons where each vertex is vector
69
+ * @param {array} positions
70
+ * @returns {Vector3[]}
71
+ */
72
+ function convertPositionsToVectors(positions) {
73
+ const result = [];
74
+ for (let i = 0; i < positions.length; i += 3) {
75
+ // TODO: (perf) new Vector3 is not optimal but required in `makeOrientedBoundingBoxFromPoints`.
76
+ // modify `makeOrientedBoundingBoxFromPoints` to use scratch vectors
77
+ const positionVector = new core_1.Vector3([positions[i], positions[i + 1], positions[i + 2]]);
78
+ result.push(positionVector);
79
+ }
80
+ return result;
81
+ }
82
+ exports.convertPositionsToVectors = convertPositionsToVectors;
83
+ /**
84
+ * Convert common coordinate to extent coordinate
85
+ * @param tileset
86
+ * @returns - Extent
87
+ * @todo why lodMetricValue is radius? need to check this function
88
+ */
89
+ function convertCommonToI3SExtentCoordinate(tileset) {
90
+ const cartesianCenter = tileset?.cartesianCenter;
91
+ if (!cartesianCenter) {
92
+ return null;
93
+ }
94
+ const radius = tileset?.lodMetricValue;
95
+ const rightTop = geospatial_1.Ellipsoid.WGS84.cartesianToCartographic(new core_1.Vector3(cartesianCenter[0] + radius, cartesianCenter[1] + radius, cartesianCenter[2]), new core_1.Vector3());
96
+ const leftBottom = geospatial_1.Ellipsoid.WGS84.cartesianToCartographic(new core_1.Vector3(cartesianCenter[0] - radius, cartesianCenter[1] - radius, cartesianCenter[2]), new core_1.Vector3());
97
+ const isFirstRight = rightTop[0] < leftBottom[0];
98
+ const isFirstTop = rightTop[1] < leftBottom[1];
99
+ return [
100
+ isFirstRight ? rightTop[0] : leftBottom[0],
101
+ isFirstTop ? rightTop[1] : leftBottom[1],
102
+ isFirstRight ? leftBottom[0] : rightTop[0],
103
+ isFirstTop ? leftBottom[1] : rightTop[1]
104
+ ];
105
+ }
106
+ exports.convertCommonToI3SExtentCoordinate = convertCommonToI3SExtentCoordinate;
107
+ /**
108
+ * Creates oriented boundinb box from mbs.
109
+ * @param mbs - Minimum Bounding Sphere
110
+ * @returns - Oriented BOunding Box
111
+ */
112
+ function createObbFromMbs(mbs) {
113
+ const radius = mbs[3];
114
+ const center = new core_1.Vector3(mbs[0], mbs[1], mbs[2]);
115
+ const halfAxex = new core_1.Matrix3([radius, 0, 0, 0, radius, 0, 0, 0, radius]);
116
+ return new culling_1.OrientedBoundingBox(center, halfAxex);
117
+ }
118
+ exports.createObbFromMbs = createObbFromMbs;
@@ -0,0 +1,9 @@
1
+ import type { SceneLayer3D } from '@loaders.gl/i3s';
2
+ /**
3
+ * Form and save sceneServer meta data into a file
4
+ * @param layerName - layer name to display
5
+ * @param layers0 - layer object embedded into sceneServer meta data
6
+ * @param rootPath - root path of new converted tileset
7
+ */
8
+ export declare function createSceneServerPath(layerName: string, layers0: SceneLayer3D, rootPath: string): 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":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAQlD;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAUf"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createSceneServerPath = void 0;
7
+ const uuid_1 = require("uuid");
8
+ const json_map_transform_1 = __importDefault(require("json-map-transform"));
9
+ const path_1 = require("path");
10
+ const scene_server_1 = require("../json-templates/scene-server");
11
+ const file_utils_1 = require("../../lib/utils/file-utils");
12
+ /**
13
+ * Form and save sceneServer meta data into a file
14
+ * @param layerName - layer name to display
15
+ * @param layers0 - layer object embedded into sceneServer meta data
16
+ * @param rootPath - root path of new converted tileset
17
+ */
18
+ async function createSceneServerPath(layerName, layers0, rootPath) {
19
+ const sceneServerData = {
20
+ serviceItemId: (0, uuid_1.v4)().replace(/-/gi, ''),
21
+ layerName,
22
+ layers0
23
+ };
24
+ const sceneServer = (0, json_map_transform_1.default)(sceneServerData, (0, scene_server_1.SCENE_SERVER)());
25
+ const nodePagePath = (0, path_1.join)(rootPath, 'SceneServer');
26
+ await (0, file_utils_1.writeFile)(nodePagePath, JSON.stringify(sceneServer));
27
+ }
28
+ exports.createSceneServerPath = createSceneServerPath;
@@ -0,0 +1,8 @@
1
+ import type { GeometryAttributes, AttributesData } from '../types';
2
+ /**
3
+ * Generate geometry attributes with faceRange and featureCount
4
+ * @param attributes
5
+ * @returns attirbutes with featureCount, featureIds and changed faceRange.
6
+ */
7
+ export declare function generateAttributes(attributes: AttributesData): GeometryAttributes;
8
+ //# 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":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAE,cAAc,EAA+B,MAAM,UAAU,CAAC;AAM/F;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,cAAc,GAAG,kBAAkB,CAuBjF"}
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateAttributes = void 0;
4
+ const loader_utils_1 = require("@loaders.gl/loader-utils");
5
+ const VALUES_PER_VERTEX = 3;
6
+ const POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;
7
+ /**
8
+ * Generate geometry attributes with faceRange and featureCount
9
+ * @param attributes
10
+ * @returns attirbutes with featureCount, featureIds and changed faceRange.
11
+ */
12
+ function generateAttributes(attributes) {
13
+ const { positions, normals, texCoords, colors, featureIndices, triangleCount } = attributes;
14
+ if (!featureIndices.length) {
15
+ return {
16
+ faceRange: new Uint32Array([0, triangleCount - 1]),
17
+ featureIds: [0],
18
+ featureCount: 1,
19
+ positions,
20
+ normals,
21
+ texCoords,
22
+ colors
23
+ };
24
+ }
25
+ const data = calculateFaceRangesAndFeaturesCount(featureIndices);
26
+ const attributeObjects = makeAttributeObjects({ ...data, ...attributes });
27
+ const unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);
28
+ const groupedAttributes = groupAttributesAndRangesByFeatureId(unifiedAttributeObjectsByFeatureIds, data.featureCount);
29
+ return groupedAttributes;
30
+ }
31
+ exports.generateAttributes = generateAttributes;
32
+ /**
33
+ * Calculates face Ranges and feature count based on featureIndices.
34
+ * @param featureIndices
35
+ * @returns Object with featureCount, reordered attributes and changed faceRange.
36
+ */
37
+ function calculateFaceRangesAndFeaturesCount(featureIndices) {
38
+ let rangeIndex = 1;
39
+ let featureIndex = 1;
40
+ let currentFeatureId = featureIndices[0];
41
+ const faceRangeList = [];
42
+ const featureIds = [];
43
+ const uniqueFeatureIds = [currentFeatureId];
44
+ faceRangeList[0] = 0;
45
+ featureIds[0] = currentFeatureId;
46
+ for (let index = 1; index < featureIndices.length; index++) {
47
+ if (currentFeatureId !== featureIndices[index]) {
48
+ faceRangeList[rangeIndex] = index / VALUES_PER_VERTEX - 1;
49
+ faceRangeList[rangeIndex + 1] = index / VALUES_PER_VERTEX;
50
+ featureIds[featureIndex] = featureIndices[index];
51
+ if (!uniqueFeatureIds.includes(featureIndices[index])) {
52
+ uniqueFeatureIds.push(featureIndices[index]);
53
+ }
54
+ rangeIndex += 2;
55
+ featureIndex += 1;
56
+ }
57
+ currentFeatureId = featureIndices[index];
58
+ }
59
+ faceRangeList[rangeIndex] = featureIndices.length / VALUES_PER_VERTEX - 1;
60
+ const faceRange = new Uint32Array(faceRangeList);
61
+ const featureCount = uniqueFeatureIds.length;
62
+ return { faceRange, featureCount, featureIds };
63
+ }
64
+ /**
65
+ * Generate list of attribute object grouped by feature ids.
66
+ * @param attributes
67
+ * @returns sorted list of attribute objects.
68
+ */
69
+ function makeAttributeObjects(attributes) {
70
+ const { featureIds, positions, normals, colors, texCoords, faceRange = new Uint32Array(0) } = attributes;
71
+ const groupedData = [];
72
+ let positionsList = new Float32Array(positions);
73
+ let normalsList = new Float32Array(normals);
74
+ let colorsList = new Uint8Array(colors);
75
+ let texCoordsList = new Float32Array(texCoords);
76
+ let faceRangeIndex = 0;
77
+ for (let index = 0; index < featureIds.length; index++) {
78
+ const startIndex = faceRange[index + faceRangeIndex];
79
+ const endIndex = faceRange[index + faceRangeIndex + 1];
80
+ const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);
81
+ const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);
82
+ const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);
83
+ const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);
84
+ groupedData.push({
85
+ featureId: featureIds[index],
86
+ positions: positionsList.slice(0, positionsCount),
87
+ normals: normalsList.slice(0, normalsCount),
88
+ colors: colorsList.slice(0, colorsCount),
89
+ texCoords: texCoordsList.slice(0, texCoordsCount)
90
+ });
91
+ positionsList = positionsList.slice(positionsCount);
92
+ normalsList = normalsList.slice(normalsCount);
93
+ colorsList = colorsList.slice(colorsCount);
94
+ texCoordsList = texCoordsList.slice(texCoordsCount);
95
+ faceRangeIndex += 1;
96
+ }
97
+ return groupedData.sort((first, second) => first.featureId - second.featureId);
98
+ }
99
+ /**
100
+ * Generate sliced count for generating attribute objects depends on attribute name and range.
101
+ * @param attributeName
102
+ * @param startIndex
103
+ * @param endIndex
104
+ * @returns sliced count
105
+ */
106
+ function getSliceAttributeCount(attributeName, startIndex, endIndex) {
107
+ const colorsPerVertex = 4;
108
+ const texCoordsPerVertex = 2;
109
+ const trianglesCount = endIndex - startIndex + 1;
110
+ const vertexCount = trianglesCount * 3;
111
+ switch (attributeName) {
112
+ case 'positions':
113
+ case 'normals':
114
+ return trianglesCount * POSITIONS_AND_NORMALS_PER_TRIANGLE;
115
+ case 'colors':
116
+ return vertexCount * colorsPerVertex;
117
+ case 'texCoords':
118
+ return vertexCount * texCoordsPerVertex;
119
+ default:
120
+ return 0;
121
+ }
122
+ }
123
+ /**
124
+ * Generates unique object list depends on feature ids and concantenate their attributes.
125
+ * @param sortedData
126
+ * @returns unique list of objects
127
+ */
128
+ function unifyObjectsByFeatureId(sortedData) {
129
+ const uniqueObjects = [];
130
+ for (let index = 0; index < sortedData.length; index++) {
131
+ const currentObject = sortedData[index];
132
+ const existedObject = uniqueObjects.find((obj) => obj.featureId === currentObject.featureId);
133
+ if (existedObject) {
134
+ existedObject.positions = (0, loader_utils_1.concatenateTypedArrays)(existedObject.positions, currentObject.positions);
135
+ existedObject.normals = (0, loader_utils_1.concatenateTypedArrays)(existedObject.normals, currentObject.normals);
136
+ existedObject.colors = (0, loader_utils_1.concatenateTypedArrays)(existedObject.colors, currentObject.colors);
137
+ existedObject.texCoords = (0, loader_utils_1.concatenateTypedArrays)(existedObject.texCoords, currentObject.texCoords);
138
+ }
139
+ else {
140
+ uniqueObjects.push(currentObject);
141
+ }
142
+ }
143
+ return uniqueObjects;
144
+ }
145
+ /**
146
+ * Generates attribute objects with new faceRange and reordered attributes.
147
+ * @param unifiedObjects
148
+ * @returns generated attributes with new faceRange.
149
+ */
150
+ function groupAttributesAndRangesByFeatureId(unifiedObjects, featureCount) {
151
+ const firstAttributeObject = unifiedObjects[0];
152
+ const featureIds = [firstAttributeObject.featureId || 0];
153
+ let positions = new Float32Array(firstAttributeObject.positions);
154
+ let normals = new Float32Array(firstAttributeObject.normals);
155
+ let colors = new Uint8Array(firstAttributeObject.colors);
156
+ let texCoords = new Float32Array(firstAttributeObject.texCoords);
157
+ const range = [0];
158
+ let objIndex = 0;
159
+ let sum = 0;
160
+ for (let index = 1; index < unifiedObjects.length; index++) {
161
+ const currentAttributesObject = unifiedObjects[index];
162
+ featureIds.push(currentAttributesObject.featureId || 0);
163
+ positions = (0, loader_utils_1.concatenateTypedArrays)(positions, currentAttributesObject.positions);
164
+ normals = (0, loader_utils_1.concatenateTypedArrays)(normals, currentAttributesObject.normals);
165
+ colors = (0, loader_utils_1.concatenateTypedArrays)(colors, currentAttributesObject.colors);
166
+ texCoords = (0, loader_utils_1.concatenateTypedArrays)(texCoords, currentAttributesObject.texCoords);
167
+ const groupedObject = unifiedObjects[objIndex];
168
+ range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);
169
+ range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE + sum);
170
+ sum += groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;
171
+ objIndex += 1;
172
+ }
173
+ range.push(positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);
174
+ const faceRange = new Uint32Array(range);
175
+ return { faceRange, featureIds, positions, normals, colors, texCoords, featureCount };
176
+ }
@@ -0,0 +1,12 @@
1
+ export default function convertB3dmToI3sGeometry(tileContent: any, nodeId: any, featuresHashArray: any, attributeStorageInfo: any, draco: any, generateBoundingVolumes: any, geoidHeightModel: any): Promise<{
2
+ geometry: Uint8Array;
3
+ compressedGeometry: any;
4
+ texture: any;
5
+ sharedResources: any;
6
+ meshMaterial: any;
7
+ vertexCount: number;
8
+ attributes: any[];
9
+ featureCount: number;
10
+ boundingVolumes: any;
11
+ }[] | null>;
12
+ //# sourceMappingURL=geometry-converter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometry-converter.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/geometry-converter.js"],"names":[],"mappings":"AA+BA;;;;;;;;;;YAuDC"}