@loaders.gl/tile-converter 4.0.0-alpha.7 → 4.0.0-alpha.8

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 (148) hide show
  1. package/dist/3d-tiles-attributes-worker.js +2 -2
  2. package/dist/3d-tiles-attributes-worker.js.map +2 -2
  3. package/dist/converter.min.js +67 -67
  4. package/dist/deps-installer/deps-installer.js +1 -1
  5. package/dist/dist.min.js +694 -338
  6. package/dist/es5/3d-tiles-attributes-worker.js +1 -1
  7. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  8. package/dist/es5/deps-installer/deps-installer.js +2 -2
  9. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  10. package/dist/es5/i3s-attributes-worker.js +1 -1
  11. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +2 -2
  12. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  13. package/dist/es5/i3s-converter/helpers/coordinate-converter.js +6 -7
  14. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  15. package/dist/es5/i3s-converter/helpers/geometry-converter.js +25 -14
  16. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  17. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +45 -12
  18. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  19. package/dist/es5/i3s-converter/helpers/load-3d-tiles.js +82 -0
  20. package/dist/es5/i3s-converter/helpers/load-3d-tiles.js.map +1 -0
  21. package/dist/es5/i3s-converter/helpers/node-index-document.js +74 -45
  22. package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -1
  23. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js +111 -0
  24. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -0
  25. package/dist/es5/i3s-converter/helpers/tileset-traversal.js +82 -0
  26. package/dist/es5/i3s-converter/helpers/tileset-traversal.js.map +1 -0
  27. package/dist/es5/i3s-converter/i3s-converter.js +545 -516
  28. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  29. package/dist/es5/i3s-converter/types.js +16 -0
  30. package/dist/es5/i3s-converter/types.js.map +1 -1
  31. package/dist/es5/i3s-server/README.md +19 -0
  32. package/dist/es5/i3s-server/app.js +10 -1
  33. package/dist/es5/i3s-server/app.js.map +1 -1
  34. package/dist/es5/i3s-server/controllers/slpk-controller.js +84 -0
  35. package/dist/es5/i3s-server/controllers/slpk-controller.js.map +1 -0
  36. package/dist/es5/i3s-server/routes/slpk-router.js +71 -0
  37. package/dist/es5/i3s-server/routes/slpk-router.js.map +1 -0
  38. package/dist/es5/i3s-server/utils/create-scene-server.js +17 -0
  39. package/dist/es5/i3s-server/utils/create-scene-server.js.map +1 -0
  40. package/dist/es5/lib/utils/file-utils.js +1 -1
  41. package/dist/es5/lib/utils/file-utils.js.map +1 -1
  42. package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
  43. package/dist/es5/pgm-loader.js +1 -1
  44. package/dist/esm/3d-tiles-attributes-worker.js +1 -1
  45. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  46. package/dist/esm/deps-installer/deps-installer.js +2 -2
  47. package/dist/esm/deps-installer/deps-installer.js.map +1 -1
  48. package/dist/esm/i3s-attributes-worker.js +1 -1
  49. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +2 -2
  50. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  51. package/dist/esm/i3s-converter/helpers/coordinate-converter.js +6 -7
  52. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  53. package/dist/esm/i3s-converter/helpers/geometry-converter.js +19 -8
  54. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  55. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +49 -12
  56. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  57. package/dist/esm/i3s-converter/helpers/load-3d-tiles.js +35 -0
  58. package/dist/esm/i3s-converter/helpers/load-3d-tiles.js.map +1 -0
  59. package/dist/esm/i3s-converter/helpers/node-index-document.js +14 -1
  60. package/dist/esm/i3s-converter/helpers/node-index-document.js.map +1 -1
  61. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js +48 -0
  62. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -0
  63. package/dist/esm/i3s-converter/helpers/tileset-traversal.js +14 -0
  64. package/dist/esm/i3s-converter/helpers/tileset-traversal.js.map +1 -0
  65. package/dist/esm/i3s-converter/i3s-converter.js +134 -120
  66. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  67. package/dist/esm/i3s-converter/types.js +10 -1
  68. package/dist/esm/i3s-converter/types.js.map +1 -1
  69. package/dist/esm/i3s-server/README.md +19 -0
  70. package/dist/esm/i3s-server/app.js +11 -1
  71. package/dist/esm/i3s-server/app.js.map +1 -1
  72. package/dist/esm/i3s-server/controllers/slpk-controller.js +36 -0
  73. package/dist/esm/i3s-server/controllers/slpk-controller.js.map +1 -0
  74. package/dist/esm/i3s-server/routes/slpk-router.js +33 -0
  75. package/dist/esm/i3s-server/routes/slpk-router.js.map +1 -0
  76. package/dist/esm/i3s-server/utils/create-scene-server.js +16 -0
  77. package/dist/esm/i3s-server/utils/create-scene-server.js.map +1 -0
  78. package/dist/esm/lib/utils/file-utils.js +1 -1
  79. package/dist/esm/lib/utils/file-utils.js.map +1 -1
  80. package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
  81. package/dist/esm/pgm-loader.js +1 -1
  82. package/dist/i3s-attributes-worker.js +2 -2
  83. package/dist/i3s-attributes-worker.js.map +2 -2
  84. package/dist/i3s-converter/helpers/batch-ids-extensions.js +2 -5
  85. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +3 -4
  86. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
  87. package/dist/i3s-converter/helpers/coordinate-converter.js +8 -9
  88. package/dist/i3s-converter/helpers/geometry-converter.d.ts +9 -4
  89. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  90. package/dist/i3s-converter/helpers/geometry-converter.js +34 -12
  91. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +22 -3
  92. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  93. package/dist/i3s-converter/helpers/gltf-attributes.js +61 -18
  94. package/dist/i3s-converter/helpers/load-3d-tiles.d.ts +18 -0
  95. package/dist/i3s-converter/helpers/load-3d-tiles.d.ts.map +1 -0
  96. package/dist/i3s-converter/helpers/load-3d-tiles.js +53 -0
  97. package/dist/i3s-converter/helpers/node-index-document.d.ts +8 -0
  98. package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
  99. package/dist/i3s-converter/helpers/node-index-document.js +20 -2
  100. package/dist/i3s-converter/helpers/node-pages.js +1 -1
  101. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +23 -0
  102. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -0
  103. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +76 -0
  104. package/dist/i3s-converter/helpers/tileset-traversal.d.ts +25 -0
  105. package/dist/i3s-converter/helpers/tileset-traversal.d.ts.map +1 -0
  106. package/dist/i3s-converter/helpers/tileset-traversal.js +29 -0
  107. package/dist/i3s-converter/i3s-converter.d.ts +40 -40
  108. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  109. package/dist/i3s-converter/i3s-converter.js +150 -126
  110. package/dist/i3s-converter/types.d.ts +18 -0
  111. package/dist/i3s-converter/types.d.ts.map +1 -1
  112. package/dist/i3s-converter/types.js +15 -0
  113. package/dist/i3s-server/app.d.ts.map +1 -1
  114. package/dist/i3s-server/app.js +9 -1
  115. package/dist/i3s-server/controllers/slpk-controller.d.ts +3 -0
  116. package/dist/i3s-server/controllers/slpk-controller.d.ts.map +1 -0
  117. package/dist/i3s-server/controllers/slpk-controller.js +32 -0
  118. package/dist/i3s-server/routes/slpk-router.d.ts +3 -0
  119. package/dist/i3s-server/routes/slpk-router.d.ts.map +1 -0
  120. package/dist/i3s-server/routes/slpk-router.js +33 -0
  121. package/dist/i3s-server/utils/create-scene-server.d.ts +11 -0
  122. package/dist/i3s-server/utils/create-scene-server.d.ts.map +1 -0
  123. package/dist/i3s-server/utils/create-scene-server.js +14 -0
  124. package/dist/lib/utils/file-utils.d.ts.map +1 -1
  125. package/dist/lib/utils/file-utils.js +2 -1
  126. package/dist/lib/utils/lod-conversion-utils.d.ts +3 -2
  127. package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -1
  128. package/dist/lib/utils/lod-conversion-utils.js +1 -1
  129. package/package.json +14 -14
  130. package/src/3d-tiles-converter/3d-tiles-converter.ts +5 -5
  131. package/src/deps-installer/deps-installer.ts +1 -1
  132. package/src/i3s-converter/helpers/batch-ids-extensions.ts +2 -5
  133. package/src/i3s-converter/helpers/coordinate-converter.ts +11 -10
  134. package/src/i3s-converter/helpers/geometry-converter.ts +51 -19
  135. package/src/i3s-converter/helpers/gltf-attributes.ts +84 -21
  136. package/src/i3s-converter/helpers/load-3d-tiles.ts +68 -0
  137. package/src/i3s-converter/helpers/node-index-document.ts +22 -2
  138. package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +81 -0
  139. package/src/i3s-converter/helpers/tileset-traversal.ts +51 -0
  140. package/src/i3s-converter/i3s-converter.ts +228 -178
  141. package/src/i3s-converter/types.ts +20 -0
  142. package/src/i3s-server/README.md +19 -0
  143. package/src/i3s-server/app.js +8 -1
  144. package/src/i3s-server/controllers/slpk-controller.js +38 -0
  145. package/src/i3s-server/routes/slpk-router.js +33 -0
  146. package/src/i3s-server/utils/create-scene-server.js +15 -0
  147. package/src/lib/utils/file-utils.ts +2 -1
  148. package/src/lib/utils/lod-conversion-utils.ts +6 -2
@@ -57,12 +57,9 @@ function handleExtFeatureMetadataExtension(attributes, extFeatureMetadata, image
57
57
  }
58
58
  // Take only first extension texture to get batchIds from the root EXT_feature_metadata object.
59
59
  const featureTexture = extFeatureMetadata?.featureTextures && extFeatureMetadata?.featureTextures[0];
60
- /**
61
- * TODO need to get batchIds from root extension
62
- */
63
60
  if (featureTexture) {
64
- console.warn("EXT_feature_metadata doesn't yet support featureTextures in primitive");
65
- return [];
61
+ const batchIdsAttribute = attributes[featureTexture];
62
+ return batchIdsAttribute.value;
66
63
  }
67
64
  return [];
68
65
  }
@@ -1,15 +1,14 @@
1
1
  import type { BoundingVolumes, FullExtent, Mbs, Obb } from '@loaders.gl/i3s';
2
2
  import { Vector3 } from '@math.gl/core';
3
3
  import { OrientedBoundingBox, BoundingSphere } from '@math.gl/culling';
4
- import { Tile3D } from '@loaders.gl/tiles';
5
4
  import { Geoid } from '@math.gl/geoid';
6
5
  /**
7
6
  * Create bounding volumes object from tile and geoid height model.
8
- * @param tile
9
- * @param geoidHeightModel
7
+ * @param sourceBoundingVolume - initialized bounding volume of the source tile
8
+ * @param geoidHeightModel - instance of Geoid class that converts elevation from geoidal to ellipsoidal and back
10
9
  * @returns - Bounding volumes object
11
10
  */
12
- export declare function createBoundingVolumes(tile: Tile3D, geoidHeightModel: Geoid): BoundingVolumes;
11
+ export declare function createBoundingVolumes(sourceBoundingVolume: OrientedBoundingBox | BoundingSphere, geoidHeightModel: Geoid): BoundingVolumes;
13
12
  /**
14
13
  * Generates bounding volumes from geometry positions
15
14
  * @param cartesianPositions
@@ -1 +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,UAAU,EAAE,GAAG,EAAE,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAE3E,OAAO,EAAsB,OAAO,EAAC,MAAM,eAAe,CAAC;AAE3D,OAAO,EACL,mBAAmB,EAGnB,cAAc,EACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAErC;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,KAAK,GAAG,eAAe,CAiC5F;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,oCAAoC,CAClD,cAAc,EAAE,mBAAmB,GAAG,cAAc,GACnD,UAAU,CA4BZ;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAK9C"}
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,UAAU,EAAE,GAAG,EAAE,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAE3E,OAAO,EAAsB,OAAO,EAAC,MAAM,eAAe,CAAC;AAE3D,OAAO,EACL,mBAAmB,EAGnB,cAAc,EACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAErC;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,oBAAoB,EAAE,mBAAmB,GAAG,cAAc,EAC1D,gBAAgB,EAAE,KAAK,GACtB,eAAe,CAgCjB;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,oCAAoC,CAClD,cAAc,EAAE,mBAAmB,GAAG,cAAc,GACnD,UAAU,CA4BZ;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAK9C"}
@@ -6,26 +6,25 @@ const geospatial_1 = require("@math.gl/geospatial");
6
6
  const culling_1 = require("@math.gl/culling");
7
7
  /**
8
8
  * Create bounding volumes object from tile and geoid height model.
9
- * @param tile
10
- * @param geoidHeightModel
9
+ * @param sourceBoundingVolume - initialized bounding volume of the source tile
10
+ * @param geoidHeightModel - instance of Geoid class that converts elevation from geoidal to ellipsoidal and back
11
11
  * @returns - Bounding volumes object
12
12
  */
13
- function createBoundingVolumes(tile, geoidHeightModel) {
13
+ function createBoundingVolumes(sourceBoundingVolume, geoidHeightModel) {
14
14
  let radius;
15
15
  let halfSize;
16
16
  let quaternion;
17
- const boundingVolume = tile.boundingVolume;
18
- const cartographicCenter = geospatial_1.Ellipsoid.WGS84.cartesianToCartographic(boundingVolume.center, new core_1.Vector3());
17
+ const cartographicCenter = geospatial_1.Ellipsoid.WGS84.cartesianToCartographic(sourceBoundingVolume.center, new core_1.Vector3());
19
18
  cartographicCenter[2] =
20
19
  cartographicCenter[2] -
21
20
  geoidHeightModel.getHeight(cartographicCenter[1], cartographicCenter[0]);
22
- if (boundingVolume instanceof culling_1.OrientedBoundingBox) {
23
- halfSize = boundingVolume.halfSize;
21
+ if (sourceBoundingVolume instanceof culling_1.OrientedBoundingBox) {
22
+ halfSize = sourceBoundingVolume.halfSize;
24
23
  radius = new core_1.Vector3(halfSize[0], halfSize[1], halfSize[2]).len();
25
- quaternion = boundingVolume.quaternion;
24
+ quaternion = sourceBoundingVolume.quaternion;
26
25
  }
27
26
  else {
28
- radius = tile.boundingVolume.radius;
27
+ radius = sourceBoundingVolume.radius;
29
28
  halfSize = [radius, radius, radius];
30
29
  quaternion = new core_1.Quaternion()
31
30
  .fromMatrix3(new core_1.Matrix3([halfSize[0], 0, 0, 0, halfSize[1], 0, 0, 0, halfSize[2]]))
@@ -1,13 +1,18 @@
1
- import type { B3DMContent, FeatureTableJson } from '@loaders.gl/3d-tiles';
1
+ import type { FeatureTableJson, Tiles3DTileContent } from '@loaders.gl/3d-tiles';
2
+ import { Matrix4 } from '@math.gl/core';
2
3
  import { ConvertedAttributes, I3SConvertedResources, I3SMaterialWithTexture } from '../types';
3
4
  import { AttributeStorageInfo } from '@loaders.gl/i3s';
4
5
  import { Geoid } from '@math.gl/geoid';
5
6
  /** Usage of worker here brings more overhead than advantage */
6
7
  import { B3DMAttributesData } from '../../i3s-attributes-worker';
8
+ import { BoundingSphere, OrientedBoundingBox } from '@math.gl/culling';
7
9
  /**
8
10
  * Convert binary data from b3dm file to i3s resources
9
11
  *
10
12
  * @param tileContent - 3d tile content
13
+ * @param tileTransform - transformation matrix of the tile, calculated recursively multiplying
14
+ * transform of all parent tiles and transform of the current tile
15
+ * @param tileBoundingVolume - initialized bounding volume of the source tile
11
16
  * @param addNodeToNodePage - function to add new node to node pages
12
17
  * @param propertyTable - batch table (corresponding to feature attributes data)
13
18
  * @param featuresHashArray - hash array of features that is needed to not to mix up same features in parent and child nodes
@@ -19,7 +24,7 @@ import { B3DMAttributesData } from '../../i3s-attributes-worker';
19
24
  * @param workerSource - source code of used workers
20
25
  * @returns Array of node resources to create one or more i3s nodes
21
26
  */
22
- export default function convertB3dmToI3sGeometry(tileContent: B3DMContent, addNodeToNodePage: () => Promise<number>, propertyTable: FeatureTableJson | null, featuresHashArray: string[], attributeStorageInfo: AttributeStorageInfo[] | undefined, draco: boolean, generateBoundingVolumes: boolean, shouldMergeMaterials: boolean, geoidHeightModel: Geoid, workerSource: {
27
+ export default function convertB3dmToI3sGeometry(tileContent: Tiles3DTileContent, tileTransform: Matrix4, tileBoundingVolume: OrientedBoundingBox | BoundingSphere, addNodeToNodePage: () => Promise<number>, propertyTable: FeatureTableJson | null, featuresHashArray: string[], attributeStorageInfo: AttributeStorageInfo[] | undefined, draco: boolean, generateBoundingVolumes: boolean, shouldMergeMaterials: boolean, geoidHeightModel: Geoid, workerSource: {
23
28
  [key: string]: string;
24
29
  }): Promise<I3SConvertedResources[] | null>;
25
30
  /**
@@ -34,8 +39,8 @@ export declare function convertAttributes(attributesData: B3DMAttributesData, ma
34
39
  /**
35
40
  * Find property table in tile
36
41
  * For example it can be batchTable for b3dm files or property table in gLTF extension.
37
- * @param sourceTile
42
+ * @param tileContent - 3DTiles tile content
38
43
  * @return batch table from b3dm / feature properties from EXT_FEATURE_METADATA
39
44
  */
40
- export declare function getPropertyTable(tileContent: B3DMContent): FeatureTableJson | null;
45
+ export declare function getPropertyTable(tileContent: Tiles3DTileContent | null): FeatureTableJson | null;
41
46
  //# sourceMappingURL=geometry-converter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"geometry-converter.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/geometry-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAE,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAsBxE,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EAGvB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,oBAAoB,EAIrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AACrC,+DAA+D;AAC/D,OAAO,EACL,kBAAkB,EAEnB,MAAM,6BAA6B,CAAC;AAsCrC;;;;;;;;;;;;;;GAcG;AACH,wBAA8B,wBAAwB,CACpD,WAAW,EAAE,WAAW,EACxB,iBAAiB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EACxC,aAAa,EAAE,gBAAgB,GAAG,IAAI,EACtC,iBAAiB,EAAE,MAAM,EAAE,EAC3B,oBAAoB,EAAE,oBAAoB,EAAE,GAAG,SAAS,EACxD,KAAK,EAAE,OAAO,EACd,uBAAuB,EAAE,OAAO,EAChC,oBAAoB,EAAE,OAAO,EAC7B,gBAAgB,EAAE,KAAK,EACvB,YAAY,EAAE;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAC,GACpC,OAAO,CAAC,qBAAqB,EAAE,GAAG,IAAI,CAAC,CA0DzC;AA6ID;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,cAAc,EAAE,kBAAkB,EAClC,sBAAsB,EAAE,sBAAsB,EAAE,EAChD,qBAAqB,EAAE,OAAO,GAC7B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAgD3C;AAwpCD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,gBAAgB,GAAG,IAAI,CAoBlF"}
1
+ {"version":3,"file":"geometry-converter.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/geometry-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAY/E,OAAO,EAAU,OAAO,EAAU,MAAM,eAAe,CAAC;AAUxD,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EAGvB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,oBAAoB,EAIrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AACrC,+DAA+D;AAC/D,OAAO,EACL,kBAAkB,EAEnB,MAAM,6BAA6B,CAAC;AAarC,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AA0BrE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAA8B,wBAAwB,CACpD,WAAW,EAAE,kBAAkB,EAC/B,aAAa,EAAE,OAAO,EACtB,kBAAkB,EAAE,mBAAmB,GAAG,cAAc,EACxD,iBAAiB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EACxC,aAAa,EAAE,gBAAgB,GAAG,IAAI,EACtC,iBAAiB,EAAE,MAAM,EAAE,EAC3B,oBAAoB,EAAE,oBAAoB,EAAE,GAAG,SAAS,EACxD,KAAK,EAAE,OAAO,EACd,uBAAuB,EAAE,OAAO,EAChC,oBAAoB,EAAE,OAAO,EAC7B,gBAAgB,EAAE,KAAK,EACvB,YAAY,EAAE;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAC,GACpC,OAAO,CAAC,qBAAqB,EAAE,GAAG,IAAI,CAAC,CA8DzC;AA6ID;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,cAAc,EAAE,kBAAkB,EAClC,sBAAsB,EAAE,sBAAsB,EAAE,EAChD,qBAAqB,EAAE,OAAO,GAC7B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAgD3C;AA4pCD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,kBAAkB,GAAG,IAAI,GAAG,gBAAgB,GAAG,IAAI,CAwBhG"}
@@ -64,6 +64,9 @@ let scratchVector = new core_1.Vector3();
64
64
  * Convert binary data from b3dm file to i3s resources
65
65
  *
66
66
  * @param tileContent - 3d tile content
67
+ * @param tileTransform - transformation matrix of the tile, calculated recursively multiplying
68
+ * transform of all parent tiles and transform of the current tile
69
+ * @param tileBoundingVolume - initialized bounding volume of the source tile
67
70
  * @param addNodeToNodePage - function to add new node to node pages
68
71
  * @param propertyTable - batch table (corresponding to feature attributes data)
69
72
  * @param featuresHashArray - hash array of features that is needed to not to mix up same features in parent and child nodes
@@ -75,10 +78,10 @@ let scratchVector = new core_1.Vector3();
75
78
  * @param workerSource - source code of used workers
76
79
  * @returns Array of node resources to create one or more i3s nodes
77
80
  */
78
- async function convertB3dmToI3sGeometry(tileContent, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, workerSource) {
81
+ async function convertB3dmToI3sGeometry(tileContent, tileTransform, tileBoundingVolume, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, workerSource) {
79
82
  const useCartesianPositions = generateBoundingVolumes;
80
83
  const materialAndTextureList = await convertMaterials(tileContent.gltf?.materials, shouldMergeMaterials);
81
- const dataForAttributesConversion = (0, gltf_attributes_1.prepareDataForAttributesConversion)(tileContent);
84
+ const dataForAttributesConversion = (0, gltf_attributes_1.prepareDataForAttributesConversion)(tileContent, tileTransform, tileBoundingVolume);
82
85
  const convertedAttributesMap = await convertAttributes(dataForAttributesConversion, materialAndTextureList, useCartesianPositions);
83
86
  /** Usage of worker here brings more overhead than advantage */
84
87
  // const convertedAttributesMap: Map<string, ConvertedAttributes> =
@@ -148,7 +151,7 @@ function _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeigh
148
151
  * @param params.convertedAttributes - Converted geometry attributes
149
152
  * @param params.material - I3S PBR-like material definition
150
153
  * @param params.texture - texture content
151
- * @param params.tileContent - B3DM decoded content
154
+ * @param params.tileContent - 3DTiles decoded content
152
155
  * @param params.nodeId - new node ID
153
156
  * @param params.featuresHashArray - hash array of features that is needed to not to mix up same features in parent and child nodes
154
157
  * @param params.propertyTable - batch table (corresponding to feature attributes data)
@@ -332,7 +335,11 @@ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, att
332
335
  outputAttributes = attributesMap.get('default');
333
336
  }
334
337
  (0, core_2.assert)(outputAttributes !== null, 'Primitive - material mapping failed');
335
- (0, core_2.assert)(primitive.mode === math_1.GL.TRIANGLES || primitive.mode === math_1.GL.TRIANGLE_STRIP, `Primitive - unsupported mode ${primitive.mode}`);
338
+ // Per the spec https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#_mesh_primitive_mode
339
+ // GL.TRIANGLES is default. So in case `mode` is `undefined`, it is 'TRIANGLES'
340
+ (0, core_2.assert)(primitive.mode === undefined ||
341
+ primitive.mode === math_1.GL.TRIANGLES ||
342
+ primitive.mode === math_1.GL.TRIANGLE_STRIP, `Primitive - unsupported mode ${primitive.mode}`);
336
343
  const attributes = primitive.attributes;
337
344
  if (!outputAttributes) {
338
345
  continue;
@@ -1129,10 +1136,13 @@ function generateFeatureIndexAttribute(featureIndex, faceRange) {
1129
1136
  /**
1130
1137
  * Find property table in tile
1131
1138
  * For example it can be batchTable for b3dm files or property table in gLTF extension.
1132
- * @param sourceTile
1139
+ * @param tileContent - 3DTiles tile content
1133
1140
  * @return batch table from b3dm / feature properties from EXT_FEATURE_METADATA
1134
1141
  */
1135
1142
  function getPropertyTable(tileContent) {
1143
+ if (!tileContent) {
1144
+ return null;
1145
+ }
1136
1146
  const batchTableJson = tileContent?.batchTableJson;
1137
1147
  if (batchTableJson) {
1138
1148
  return batchTableJson;
@@ -1153,7 +1163,7 @@ function getPropertyTable(tileContent) {
1153
1163
  exports.getPropertyTable = getPropertyTable;
1154
1164
  /**
1155
1165
  * Check extensions which can be with property table inside.
1156
- * @param sourceTile
1166
+ * @param tileContent - 3DTiles tile content
1157
1167
  */
1158
1168
  function getPropertyTableExtension(tileContent) {
1159
1169
  const extensionsWithPropertyTables = [EXT_FEATURE_METADATA, EXT_MESH_FEATURES];
@@ -1174,13 +1184,8 @@ function getPropertyTableExtension(tileContent) {
1174
1184
  /**
1175
1185
  * Handle EXT_feature_metadata to get property table
1176
1186
  * @param extension
1177
- * TODO add EXT_feature_metadata feature textures support.
1178
1187
  */
1179
1188
  function getPropertyTableFromExtFeatureMetadata(extension) {
1180
- if (extension?.featureTextures) {
1181
- console.warn('The I3S converter does not yet support the EXT_feature_metadata feature textures');
1182
- return null;
1183
- }
1184
1189
  if (extension?.featureTables) {
1185
1190
  /**
1186
1191
  * Take only first feature table to generate attributes storage info object.
@@ -1198,6 +1203,23 @@ function getPropertyTableFromExtFeatureMetadata(extension) {
1198
1203
  return propertyTable;
1199
1204
  }
1200
1205
  }
1201
- console.warn("The I3S converter couldn't handle EXT_feature_metadata extension");
1206
+ if (extension?.featureTextures) {
1207
+ /**
1208
+ * Take only first feature texture to generate attributes storage info object.
1209
+ * TODO: Think about getting data from all feature textures?
1210
+ * It can be tricky just because 3dTiles is able to have multiple featureTextures.
1211
+ * In I3S we should decide which featureTextures will be passed to geometry data.
1212
+ */
1213
+ const firstTextureName = Object.keys(extension.featureTextures)?.[0];
1214
+ if (firstTextureName) {
1215
+ const featureTable = extension?.featureTextures[firstTextureName];
1216
+ const propertyTable = {};
1217
+ for (const propertyName in featureTable.properties) {
1218
+ propertyTable[propertyName] = featureTable.properties[propertyName].data;
1219
+ }
1220
+ return propertyTable;
1221
+ }
1222
+ }
1223
+ console.warn("The I3S converter couldn't handle EXT_feature_metadata extension: There is neither featureTables, no featureTextures in the extension.");
1202
1224
  return null;
1203
1225
  }
@@ -1,9 +1,28 @@
1
- import type { B3DMContent } from '@loaders.gl/3d-tiles';
1
+ import type { Tiles3DTileContent } from '@loaders.gl/3d-tiles';
2
2
  import type { B3DMAttributesData } from '../../i3s-attributes-worker';
3
+ import { Matrix4, Vector3 } from '@math.gl/core';
4
+ import { BoundingSphere, OrientedBoundingBox } from '@math.gl/culling';
3
5
  /**
4
6
  * Prepare attributes for conversion to avoid binary data breaking in worker thread.
5
- * @param tileContent
7
+ * @param tileContent - 3DTiles tile content
8
+ * @param tileTransform - transformation matrix of the tile, calculated recursively multiplying
9
+ * transform of all parent tiles and transform of the current tile
10
+ * @param boundingVolume - initialized bounding volume of the source tile
6
11
  * @returns
7
12
  */
8
- export declare function prepareDataForAttributesConversion(tileContent: B3DMContent): B3DMAttributesData;
13
+ export declare function prepareDataForAttributesConversion(tileContent: Tiles3DTileContent, tileTransform: Matrix4, boundingVolume: OrientedBoundingBox | BoundingSphere): B3DMAttributesData;
14
+ /**
15
+ * Calculate transformation properties to transform vertex attributes (POSITION, NORMAL, etc.)
16
+ * from METER_OFFSET coorditantes to LNGLAT_OFFSET coordinates
17
+ * @param tileContent - 3DTiles tile content
18
+ * @param tileTransform - transformation matrix of the tile, calculated recursively multiplying
19
+ * transform of all parent tiles and transform of the current tile
20
+ * @param boundingVolume - initialized bounding volume of the source tile
21
+ * @returns modelMatrix - transformation matrix to transform coordinates to cartographic coordinates
22
+ * cartographicOrigin - tile origin coordinates to calculate offsets
23
+ */
24
+ export declare function calculateTransformProps(tileContent: Tiles3DTileContent, tileTransform: Matrix4, boundingVolume: OrientedBoundingBox | BoundingSphere): {
25
+ modelMatrix: Matrix4;
26
+ cartographicOrigin: Vector3;
27
+ };
9
28
  //# sourceMappingURL=gltf-attributes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gltf-attributes.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/gltf-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AAsBpE;;;;GAIG;AACH,wBAAgB,kCAAkC,CAAC,WAAW,EAAE,WAAW,GAAG,kBAAkB,CAsC/F"}
1
+ {"version":3,"file":"gltf-attributes.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/gltf-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAE7D,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AAOrE;;;;;;;GAOG;AACH,wBAAgB,kCAAkC,CAChD,WAAW,EAAE,kBAAkB,EAC/B,aAAa,EAAE,OAAO,EACtB,cAAc,EAAE,mBAAmB,GAAG,cAAc,GACnD,kBAAkB,CAyCpB;AAkBD;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,kBAAkB,EAC/B,aAAa,EAAE,OAAO,EACtB,cAAc,EAAE,mBAAmB,GAAG,cAAc,GACnD;IAAC,WAAW,EAAE,OAAO,CAAC;IAAC,kBAAkB,EAAE,OAAO,CAAA;CAAC,CAkCrD"}
@@ -1,25 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prepareDataForAttributesConversion = void 0;
4
- /**
5
- * Keep only values for B3DM attributes to pass data to worker thread.
6
- * @param attributes
7
- */
8
- function getB3DMAttributesWithoutBufferView(attributes) {
9
- const attributesWithoutBufferView = {};
10
- for (const attributeName in attributes) {
11
- attributesWithoutBufferView[attributeName] = {
12
- value: attributes[attributeName].value
13
- };
14
- }
15
- return attributesWithoutBufferView;
16
- }
3
+ exports.calculateTransformProps = exports.prepareDataForAttributesConversion = void 0;
4
+ const core_1 = require("@math.gl/core");
5
+ const geospatial_1 = require("@math.gl/geospatial");
17
6
  /**
18
7
  * Prepare attributes for conversion to avoid binary data breaking in worker thread.
19
- * @param tileContent
8
+ * @param tileContent - 3DTiles tile content
9
+ * @param tileTransform - transformation matrix of the tile, calculated recursively multiplying
10
+ * transform of all parent tiles and transform of the current tile
11
+ * @param boundingVolume - initialized bounding volume of the source tile
20
12
  * @returns
21
13
  */
22
- function prepareDataForAttributesConversion(tileContent) {
14
+ function prepareDataForAttributesConversion(tileContent, tileTransform, boundingVolume) {
23
15
  let nodes = tileContent.gltf?.scene?.nodes ||
24
16
  tileContent.gltf?.scenes?.[0]?.nodes ||
25
17
  tileContent.gltf?.nodes ||
@@ -44,8 +36,7 @@ function prepareDataForAttributesConversion(tileContent) {
44
36
  }
45
37
  }) || [];
46
38
  prepareNodes(nodes);
47
- const cartographicOrigin = tileContent.cartographicOrigin;
48
- const cartesianModelMatrix = tileContent.cartesianModelMatrix;
39
+ const { cartographicOrigin, modelMatrix: cartesianModelMatrix } = calculateTransformProps(tileContent, tileTransform, boundingVolume);
49
40
  return {
50
41
  nodes,
51
42
  images,
@@ -54,6 +45,58 @@ function prepareDataForAttributesConversion(tileContent) {
54
45
  };
55
46
  }
56
47
  exports.prepareDataForAttributesConversion = prepareDataForAttributesConversion;
48
+ /**
49
+ * Keep only values for glTF attributes to pass data to worker thread.
50
+ * @param attributes - geometry attributes
51
+ */
52
+ function getB3DMAttributesWithoutBufferView(attributes) {
53
+ const attributesWithoutBufferView = {};
54
+ for (const attributeName in attributes) {
55
+ attributesWithoutBufferView[attributeName] = {
56
+ value: attributes[attributeName].value
57
+ };
58
+ }
59
+ return attributesWithoutBufferView;
60
+ }
61
+ /**
62
+ * Calculate transformation properties to transform vertex attributes (POSITION, NORMAL, etc.)
63
+ * from METER_OFFSET coorditantes to LNGLAT_OFFSET coordinates
64
+ * @param tileContent - 3DTiles tile content
65
+ * @param tileTransform - transformation matrix of the tile, calculated recursively multiplying
66
+ * transform of all parent tiles and transform of the current tile
67
+ * @param boundingVolume - initialized bounding volume of the source tile
68
+ * @returns modelMatrix - transformation matrix to transform coordinates to cartographic coordinates
69
+ * cartographicOrigin - tile origin coordinates to calculate offsets
70
+ */
71
+ function calculateTransformProps(tileContent, tileTransform, boundingVolume) {
72
+ const { rtcCenter, gltfUpAxis } = tileContent;
73
+ const { center } = boundingVolume;
74
+ let modelMatrix = new core_1.Matrix4(tileTransform);
75
+ // Translate if appropriate
76
+ if (rtcCenter) {
77
+ modelMatrix.translate(rtcCenter);
78
+ }
79
+ // glTF models need to be rotated from Y to Z up
80
+ // https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#y-up-to-z-up
81
+ switch (gltfUpAxis) {
82
+ case 'Z':
83
+ break;
84
+ case 'Y':
85
+ const rotationY = new core_1.Matrix4().rotateX(Math.PI / 2);
86
+ modelMatrix = modelMatrix.multiplyRight(rotationY);
87
+ break;
88
+ case 'X':
89
+ const rotationX = new core_1.Matrix4().rotateY(-Math.PI / 2);
90
+ modelMatrix = modelMatrix.multiplyRight(rotationX);
91
+ break;
92
+ default:
93
+ break;
94
+ }
95
+ const cartesianOrigin = new core_1.Vector3(center);
96
+ const cartographicOrigin = geospatial_1.Ellipsoid.WGS84.cartesianToCartographic(cartesianOrigin, new core_1.Vector3());
97
+ return { modelMatrix, cartographicOrigin };
98
+ }
99
+ exports.calculateTransformProps = calculateTransformProps;
57
100
  /**
58
101
  * Traverse all nodes to replace all sensible data with copy to avoid data corruption in worker.
59
102
  * @param nodes
@@ -0,0 +1,18 @@
1
+ import type { Tiles3DLoaderOptions, Tiles3DTileContent, Tiles3DTileJSONPostprocessed, Tiles3DTilesetJSONPostprocessed } from '@loaders.gl/3d-tiles';
2
+ /**
3
+ * Load nested 3DTiles tileset. If the sourceTile is not nested tileset - do nothing
4
+ * @param sourceTileset - source root tileset JSON
5
+ * @param sourceTile - source tile JSON that is supposed to has link to nested tileset
6
+ * @param tilesetLoadOptions - load options for Tiles3DLoader
7
+ * @returns nothing
8
+ */
9
+ export declare const loadNestedTileset: (sourceTileset: Tiles3DTilesetJSONPostprocessed | null, sourceTile: Tiles3DTileJSONPostprocessed, tilesetLoadOptions: Tiles3DLoaderOptions) => Promise<void>;
10
+ /**
11
+ * Load 3DTiles tile content, that includes glTF object
12
+ * @param sourceTileset - source root tileset JSON
13
+ * @param sourceTile - source tile JSON that has link to content data
14
+ * @param tilesetLoadOptions - load options for Tiles3DLoader
15
+ * @returns - 3DTiles tile content or null
16
+ */
17
+ export declare const loadTile3DContent: (sourceTileset: Tiles3DTilesetJSONPostprocessed | null, sourceTile: Tiles3DTileJSONPostprocessed, tilesetLoadOptions: Tiles3DLoaderOptions) => Promise<Tiles3DTileContent | null>;
18
+ //# sourceMappingURL=load-3d-tiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-3d-tiles.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/load-3d-tiles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,4BAA4B,EAC5B,+BAA+B,EAChC,MAAM,sBAAsB,CAAC;AAG9B;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,kBACb,+BAA+B,GAAG,IAAI,cACzC,4BAA4B,sBACpB,oBAAoB,KACvC,QAAQ,IAAI,CAkBd,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,kBACb,+BAA+B,GAAG,IAAI,cACzC,4BAA4B,sBACpB,oBAAoB,KACvC,QAAQ,kBAAkB,GAAG,IAAI,CAiBnC,CAAC"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadTile3DContent = exports.loadNestedTileset = void 0;
4
+ const core_1 = require("@loaders.gl/core");
5
+ /**
6
+ * Load nested 3DTiles tileset. If the sourceTile is not nested tileset - do nothing
7
+ * @param sourceTileset - source root tileset JSON
8
+ * @param sourceTile - source tile JSON that is supposed to has link to nested tileset
9
+ * @param tilesetLoadOptions - load options for Tiles3DLoader
10
+ * @returns nothing
11
+ */
12
+ const loadNestedTileset = async (sourceTileset, sourceTile, tilesetLoadOptions) => {
13
+ const isTileset = sourceTile.type === 'json';
14
+ if (!sourceTileset || !sourceTile.contentUrl || !isTileset) {
15
+ return;
16
+ }
17
+ const loadOptions = {
18
+ ...tilesetLoadOptions,
19
+ [sourceTileset.loader.id]: {
20
+ isTileset,
21
+ assetGltfUpAxis: (sourceTileset.asset && sourceTileset.asset.gltfUpAxis) || 'Y'
22
+ }
23
+ };
24
+ const tileContent = await (0, core_1.load)(sourceTile.contentUrl, sourceTileset.loader, loadOptions);
25
+ if (tileContent.root) {
26
+ sourceTile.children = [tileContent.root];
27
+ }
28
+ };
29
+ exports.loadNestedTileset = loadNestedTileset;
30
+ /**
31
+ * Load 3DTiles tile content, that includes glTF object
32
+ * @param sourceTileset - source root tileset JSON
33
+ * @param sourceTile - source tile JSON that has link to content data
34
+ * @param tilesetLoadOptions - load options for Tiles3DLoader
35
+ * @returns - 3DTiles tile content or null
36
+ */
37
+ const loadTile3DContent = async (sourceTileset, sourceTile, tilesetLoadOptions) => {
38
+ const isTileset = sourceTile.type === 'json';
39
+ if (!sourceTileset || !sourceTile.contentUrl || isTileset) {
40
+ return null;
41
+ }
42
+ const loadOptions = {
43
+ ...tilesetLoadOptions,
44
+ [sourceTileset.loader.id]: {
45
+ ...(tilesetLoadOptions[sourceTileset.loader.id] || {}),
46
+ isTileset,
47
+ assetGltfUpAxis: (sourceTileset.asset && sourceTileset.asset.gltfUpAxis) || 'Y'
48
+ }
49
+ };
50
+ const tileContent = await (0, core_1.load)(sourceTile.contentUrl, sourceTileset.loader, loadOptions);
51
+ return tileContent;
52
+ };
53
+ exports.loadTile3DContent = loadTile3DContent;
@@ -18,6 +18,12 @@ export declare class NodeIndexDocument {
18
18
  children: NodeIndexDocument[];
19
19
  /** converter instance */
20
20
  private converter;
21
+ /**
22
+ * Finalized property. It means that all child nodes are saved and their data
23
+ * is unloaded
24
+ */
25
+ private _finalized;
26
+ get finalized(): boolean;
21
27
  /**
22
28
  * Constructor
23
29
  * @param id - id of the node in node pages
@@ -41,6 +47,8 @@ export declare class NodeIndexDocument {
41
47
  addNeighbors(): Promise<void>;
42
48
  /** Save 3DNodeIndexDocument in file on disk */
43
49
  save(): Promise<void>;
50
+ /** Finalize the node */
51
+ private finalize;
44
52
  /**
45
53
  * Write 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md
46
54
  * @param node - Node3DIndexDocument object
@@ -1 +1 @@
1
- {"version":3,"file":"node-index-document.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/node-index-document.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,UAAU,EAEX,MAAM,iBAAiB,CAAC;AAIzB,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAC,qBAAqB,EAAC,MAAM,UAAU,CAAC;AAE/C;;;;;GAKG;AACH,qBAAa,iBAAiB;IAC5B,cAAc;IACP,EAAE,EAAE,MAAM,CAAC;IAClB,uBAAuB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACxB,+BAA+B;IACxB,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAAQ;IAC/C,eAAe;IACR,QAAQ,EAAE,iBAAiB,EAAE,CAAM;IAC1C,yBAAyB;IACzB,OAAO,CAAC,SAAS,CAAe;IAEhC;;;;OAIG;gBACS,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY;IAM/C;;;;OAIG;IACU,OAAO,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAS3E;;;OAGG;IACU,WAAW,CAAC,UAAU,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BxE;;OAEG;IACU,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAgC1C,+CAA+C;IAClC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAMlC;;;OAGG;YACW,KAAK;IAyBnB;;;OAGG;YACW,IAAI;IAalB;;OAEG;IACH,OAAO,CAAC,KAAK;IAIb;;;;;OAKG;WACU,cAAc,CACzB,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,iBAAiB,CAAC;IAM7B;;;;;;;;;OASG;WACU,UAAU,CACrB,UAAU,EAAE,iBAAiB,EAC7B,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,EAAE,EAC5B,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,qBAAqB,EAChC,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,iBAAiB,CAAC;IAY7B;;;;OAIG;IACH,MAAM,CAAC,2BAA2B,CAAC,eAAe,EAAE,eAAe,GAAG,mBAAmB;IAqBzF;;;;;;;;;;OAUG;WACU,uBAAuB,CAClC,UAAU,EAAE,iBAAiB,EAC7B,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,EAAE,EAC5B,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,qBAAqB,GAC/B,OAAO,CAAC,mBAAmB,CAAC;CA4ChC"}
1
+ {"version":3,"file":"node-index-document.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/node-index-document.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,UAAU,EAEX,MAAM,iBAAiB,CAAC;AAIzB,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAC,qBAAqB,EAAC,MAAM,UAAU,CAAC;AAE/C;;;;;GAKG;AACH,qBAAa,iBAAiB;IAC5B,cAAc;IACP,EAAE,EAAE,MAAM,CAAC;IAClB,uBAAuB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACxB,+BAA+B;IACxB,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAAQ;IAC/C,eAAe;IACR,QAAQ,EAAE,iBAAiB,EAAE,CAAM;IAC1C,yBAAyB;IACzB,OAAO,CAAC,SAAS,CAAe;IAEhC;;;OAGG;IACH,OAAO,CAAC,UAAU,CAAkB;IACpC,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED;;;;OAIG;gBACS,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY;IAM/C;;;;OAIG;IACU,OAAO,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAS3E;;;OAGG;IACU,WAAW,CAAC,UAAU,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BxE;;OAEG;IACU,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAmC1C,+CAA+C;IAClC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAMlC,wBAAwB;IACxB,OAAO,CAAC,QAAQ;IAOhB;;;OAGG;YACW,KAAK;IAyBnB;;;OAGG;YACW,IAAI;IAalB;;OAEG;IACH,OAAO,CAAC,KAAK;IAIb;;;;;OAKG;WACU,cAAc,CACzB,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,iBAAiB,CAAC;IAM7B;;;;;;;;;OASG;WACU,UAAU,CACrB,UAAU,EAAE,iBAAiB,EAC7B,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,EAAE,EAC5B,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,qBAAqB,EAChC,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,iBAAiB,CAAC;IAY7B;;;;OAIG;IACH,MAAM,CAAC,2BAA2B,CAAC,eAAe,EAAE,eAAe,GAAG,mBAAmB;IAqBzF;;;;;;;;;;OAUG;WACU,uBAAuB,CAClC,UAAU,EAAE,iBAAiB,EAC7B,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,EAAE,EAC5B,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,qBAAqB,GAC/B,OAAO,CAAC,mBAAmB,CAAC;CA4ChC"}
@@ -16,6 +16,9 @@ const node_1 = require("../json-templates/node");
16
16
  * on disk: the data is written on disk in a file. The file can be rewritten when new childrend or neighbors have to be added
17
17
  */
18
18
  class NodeIndexDocument {
19
+ get finalized() {
20
+ return this._finalized;
21
+ }
19
22
  /**
20
23
  * Constructor
21
24
  * @param id - id of the node in node pages
@@ -26,6 +29,11 @@ class NodeIndexDocument {
26
29
  this.data = null;
27
30
  /** children */
28
31
  this.children = [];
32
+ /**
33
+ * Finalized property. It means that all child nodes are saved and their data
34
+ * is unloaded
35
+ */
36
+ this._finalized = false;
29
37
  this.inPageId = id;
30
38
  this.id = id === 0 ? 'root' : id.toString();
31
39
  this.converter = converter;
@@ -76,6 +84,9 @@ class NodeIndexDocument {
76
84
  * Add neighbors to child nodes of this node
77
85
  */
78
86
  async addNeighbors() {
87
+ if (this.finalized) {
88
+ return;
89
+ }
79
90
  const nodeData = await this.load();
80
91
  for (const childNode of this.children) {
81
92
  const childNodeData = await childNode.load();
@@ -98,9 +109,9 @@ class NodeIndexDocument {
98
109
  await childNode.write(childNodeData);
99
110
  }
100
111
  await childNode.save();
101
- // The save after adding neighbors is the last one. Flush the the node
102
- childNode.flush();
103
112
  }
113
+ // The save after adding neighbors is the last one. Finalize the the node
114
+ this.finalize();
104
115
  }
105
116
  /** Save 3DNodeIndexDocument in file on disk */
106
117
  async save() {
@@ -108,6 +119,13 @@ class NodeIndexDocument {
108
119
  await this.write(this.data);
109
120
  }
110
121
  }
122
+ /** Finalize the node */
123
+ finalize() {
124
+ this._finalized = true;
125
+ for (const child of this.children) {
126
+ child.flush();
127
+ }
128
+ }
111
129
  /**
112
130
  * Write 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md
113
131
  * @param node - Node3DIndexDocument object
@@ -11,7 +11,7 @@ const file_utils_1 = require("../../lib/utils/file-utils");
11
11
  * class NodePages - wrapper of nodePages array
12
12
  *
13
13
  * @example
14
- * import {writeFile} from './helpers/write-file.js';
14
+ * import {writeFile} from './helpers/write-file';
15
15
  *
16
16
  * // create an instance of the class
17
17
  * const nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);
@@ -0,0 +1,23 @@
1
+ import { Tiles3DTileContent, Tiles3DTileJSONPostprocessed } from '@loaders.gl/3d-tiles';
2
+ import { GltfPrimitiveModeString, PreprocessData } from '../types';
3
+ /**
4
+ * glTF primitive modes
5
+ * @see https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#_mesh_primitive_mode
6
+ */
7
+ export declare const GLTF_PRIMITIVE_MODES: GltfPrimitiveModeString[];
8
+ /**
9
+ * Analyze tile content. This function is used during preprocess stage of
10
+ * conversion
11
+ * @param tile - 3DTiles tile JSON metadata
12
+ * @param tileContent - 3DTiles tile content ArrayBuffer
13
+ * @returns
14
+ */
15
+ export declare const analyzeTileContent: (tile: Tiles3DTileJSONPostprocessed, tileContent: Tiles3DTileContent | null) => Promise<PreprocessData>;
16
+ /**
17
+ * Merge object2 into object1
18
+ * @param object1
19
+ * @param object2
20
+ * @returns nothing
21
+ */
22
+ export declare const mergePreprocessData: (object1: PreprocessData, object2: PreprocessData) => void;
23
+ //# sourceMappingURL=preprocess-3d-tiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preprocess-3d-tiles.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/preprocess-3d-tiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAE,4BAA4B,EAAC,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAC,uBAAuB,EAAE,cAAc,EAAC,MAAM,UAAU,CAAC;AAIjE;;;GAGG;AACH,eAAO,MAAM,oBAAoB,2BAQhC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,SACvB,4BAA4B,eACrB,kBAAkB,GAAG,IAAI,KACrC,QAAQ,cAAc,CAmBxB,CAAC;AAqBF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,YAAa,cAAc,WAAW,cAAc,KAAG,IAKtF,CAAC"}