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

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 (238) hide show
  1. package/dist/3d-tiles-attributes-worker.d.ts +28 -0
  2. package/dist/3d-tiles-attributes-worker.d.ts.map +1 -0
  3. package/dist/3d-tiles-attributes-worker.js +4 -0
  4. package/dist/3d-tiles-attributes-worker.js.map +7 -0
  5. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +82 -0
  6. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -0
  7. package/dist/3d-tiles-converter/3d-tiles-converter.js +268 -0
  8. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +84 -0
  9. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -0
  10. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +278 -0
  11. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +13 -0
  12. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts.map +1 -0
  13. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +23 -0
  14. package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +9 -0
  15. package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +1 -0
  16. package/dist/3d-tiles-converter/helpers/texture-atlas.js +52 -0
  17. package/dist/3d-tiles-converter/json-templates/tileset.d.ts +15 -0
  18. package/dist/3d-tiles-converter/json-templates/tileset.d.ts.map +1 -0
  19. package/dist/3d-tiles-converter/json-templates/tileset.js +43 -0
  20. package/dist/bundle.d.ts +2 -0
  21. package/dist/bundle.d.ts.map +1 -0
  22. package/dist/bundle.js +5 -0
  23. package/dist/converter-cli.d.ts +2 -0
  24. package/dist/converter-cli.d.ts.map +1 -0
  25. package/dist/converter-cli.js +232 -0
  26. package/dist/converter.min.js +68 -68
  27. package/dist/deps-installer/deps-installer.d.ts +14 -0
  28. package/dist/deps-installer/deps-installer.d.ts.map +1 -0
  29. package/dist/deps-installer/deps-installer.js +31 -0
  30. package/dist/dist.min.js +1151 -1264
  31. package/dist/es5/3d-tiles-attributes-worker.js +29 -0
  32. package/dist/es5/3d-tiles-attributes-worker.js.map +1 -0
  33. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +104 -44
  34. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  35. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +34 -43
  36. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  37. package/dist/es5/converter-cli.js +306 -0
  38. package/dist/es5/converter-cli.js.map +1 -0
  39. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  40. package/dist/es5/i3s-attributes-worker.js +29 -0
  41. package/dist/es5/i3s-attributes-worker.js.map +1 -0
  42. package/dist/es5/i3s-converter/helpers/coordinate-converter.js +19 -11
  43. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  44. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +2 -2
  45. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  46. package/dist/es5/i3s-converter/helpers/geometry-converter.js +271 -182
  47. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  48. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +71 -0
  49. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -0
  50. package/dist/es5/i3s-converter/helpers/node-pages.js +47 -99
  51. package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
  52. package/dist/es5/i3s-converter/i3s-converter.js +311 -245
  53. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  54. package/dist/es5/index.js +0 -16
  55. package/dist/es5/index.js.map +1 -1
  56. package/dist/es5/lib/utils/compress-util.js +14 -17
  57. package/dist/es5/lib/utils/compress-util.js.map +1 -1
  58. package/dist/es5/lib/utils/file-utils.js +39 -14
  59. package/dist/es5/lib/utils/file-utils.js.map +1 -1
  60. package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
  61. package/dist/es5/lib/utils/queue.js +61 -0
  62. package/dist/es5/lib/utils/queue.js.map +1 -0
  63. package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
  64. package/dist/es5/lib/utils/write-queue.js +225 -0
  65. package/dist/es5/lib/utils/write-queue.js.map +1 -0
  66. package/dist/es5/pgm-loader.js +1 -1
  67. package/dist/es5/pgm-loader.js.map +1 -1
  68. package/dist/es5/workers/3d-tiles-attributes-worker.js +37 -0
  69. package/dist/es5/workers/3d-tiles-attributes-worker.js.map +1 -0
  70. package/dist/es5/workers/i3s-attributes-worker.js +40 -0
  71. package/dist/es5/workers/i3s-attributes-worker.js.map +1 -0
  72. package/dist/esm/3d-tiles-attributes-worker.js +16 -0
  73. package/dist/esm/3d-tiles-attributes-worker.js.map +1 -0
  74. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +32 -5
  75. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  76. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +23 -23
  77. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  78. package/dist/esm/converter-cli.js +230 -0
  79. package/dist/esm/converter-cli.js.map +1 -0
  80. package/dist/esm/deps-installer/deps-installer.js.map +1 -1
  81. package/dist/esm/i3s-attributes-worker.js +16 -0
  82. package/dist/esm/i3s-attributes-worker.js.map +1 -0
  83. package/dist/esm/i3s-converter/helpers/coordinate-converter.js +19 -11
  84. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  85. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +2 -2
  86. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  87. package/dist/esm/i3s-converter/helpers/geometry-converter.js +121 -62
  88. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  89. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +54 -0
  90. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -0
  91. package/dist/esm/i3s-converter/helpers/node-pages.js +12 -4
  92. package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
  93. package/dist/esm/i3s-converter/i3s-converter.js +155 -50
  94. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  95. package/dist/esm/index.js +0 -2
  96. package/dist/esm/index.js.map +1 -1
  97. package/dist/esm/lib/utils/compress-util.js +6 -8
  98. package/dist/esm/lib/utils/compress-util.js.map +1 -1
  99. package/dist/esm/lib/utils/file-utils.js +11 -1
  100. package/dist/esm/lib/utils/file-utils.js.map +1 -1
  101. package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
  102. package/dist/esm/lib/utils/queue.js +19 -0
  103. package/dist/esm/lib/utils/queue.js.map +1 -0
  104. package/dist/esm/lib/utils/statistic-utills.js.map +1 -1
  105. package/dist/esm/lib/utils/write-queue.js +88 -0
  106. package/dist/esm/lib/utils/write-queue.js.map +1 -0
  107. package/dist/esm/pgm-loader.js +1 -1
  108. package/dist/esm/pgm-loader.js.map +1 -1
  109. package/dist/esm/workers/3d-tiles-attributes-worker.js +5 -0
  110. package/dist/esm/workers/3d-tiles-attributes-worker.js.map +1 -0
  111. package/dist/esm/workers/i3s-attributes-worker.js +4 -0
  112. package/dist/esm/workers/i3s-attributes-worker.js.map +1 -0
  113. package/dist/i3s-attributes-worker.d.ts +33 -0
  114. package/dist/i3s-attributes-worker.d.ts.map +1 -0
  115. package/dist/i3s-attributes-worker.js +10 -0
  116. package/dist/i3s-attributes-worker.js.map +7 -0
  117. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +41 -0
  118. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -0
  119. package/dist/i3s-converter/helpers/coordinate-converter.js +122 -0
  120. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts +9 -0
  121. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts.map +1 -0
  122. package/dist/i3s-converter/helpers/create-scene-server-path.js +28 -0
  123. package/dist/i3s-converter/helpers/geometry-attributes.d.ts +8 -0
  124. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -0
  125. package/dist/i3s-converter/helpers/geometry-attributes.js +177 -0
  126. package/dist/i3s-converter/helpers/geometry-converter.d.ts +29 -0
  127. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -0
  128. package/dist/i3s-converter/helpers/geometry-converter.js +901 -0
  129. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +9 -0
  130. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -0
  131. package/dist/i3s-converter/helpers/gltf-attributes.js +56 -0
  132. package/dist/i3s-converter/helpers/node-debug.d.ts +8 -0
  133. package/dist/i3s-converter/helpers/node-debug.d.ts.map +1 -0
  134. package/dist/i3s-converter/helpers/node-debug.js +114 -0
  135. package/dist/i3s-converter/helpers/node-pages.d.ts +117 -0
  136. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -0
  137. package/dist/i3s-converter/helpers/node-pages.js +208 -0
  138. package/dist/i3s-converter/i3s-converter.d.ts +323 -0
  139. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -0
  140. package/dist/i3s-converter/i3s-converter.js +1074 -0
  141. package/dist/i3s-converter/json-templates/layers.d.ts +95 -0
  142. package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -0
  143. package/dist/i3s-converter/json-templates/layers.js +199 -0
  144. package/dist/i3s-converter/json-templates/metadata.d.ts +22 -0
  145. package/dist/i3s-converter/json-templates/metadata.d.ts.map +1 -0
  146. package/dist/i3s-converter/json-templates/metadata.js +25 -0
  147. package/dist/i3s-converter/json-templates/node.d.ts +61 -0
  148. package/dist/i3s-converter/json-templates/node.d.ts.map +1 -0
  149. package/dist/i3s-converter/json-templates/node.js +89 -0
  150. package/dist/i3s-converter/json-templates/scene-server.d.ts +28 -0
  151. package/dist/i3s-converter/json-templates/scene-server.d.ts.map +1 -0
  152. package/dist/i3s-converter/json-templates/scene-server.js +31 -0
  153. package/dist/i3s-converter/json-templates/shared-resources.d.ts +14 -0
  154. package/dist/i3s-converter/json-templates/shared-resources.d.ts.map +1 -0
  155. package/dist/i3s-converter/json-templates/shared-resources.js +129 -0
  156. package/dist/i3s-converter/json-templates/store.d.ts +95 -0
  157. package/dist/i3s-converter/json-templates/store.d.ts.map +1 -0
  158. package/dist/i3s-converter/json-templates/store.js +103 -0
  159. package/dist/i3s-converter/types.d.ts +114 -0
  160. package/dist/i3s-converter/types.d.ts.map +1 -0
  161. package/dist/i3s-converter/types.js +2 -0
  162. package/dist/i3s-server/app.d.ts +3 -0
  163. package/dist/i3s-server/app.d.ts.map +1 -0
  164. package/dist/i3s-server/app.js +14 -0
  165. package/dist/i3s-server/controllers/index-controller.d.ts +2 -0
  166. package/dist/i3s-server/controllers/index-controller.d.ts.map +1 -0
  167. package/dist/i3s-server/controllers/index-controller.js +23 -0
  168. package/dist/i3s-server/routes/index.d.ts +3 -0
  169. package/dist/i3s-server/routes/index.d.ts.map +1 -0
  170. package/dist/i3s-server/routes/index.js +16 -0
  171. package/dist/index.d.ts +3 -0
  172. package/dist/index.d.ts.map +1 -0
  173. package/dist/index.js +10 -0
  174. package/dist/lib/utils/compress-util.d.ts +45 -0
  175. package/dist/lib/utils/compress-util.d.ts.map +1 -0
  176. package/dist/lib/utils/compress-util.js +257 -0
  177. package/dist/{esm/lib → lib}/utils/file-utils.d.ts +6 -14
  178. package/dist/lib/utils/file-utils.d.ts.map +1 -0
  179. package/dist/lib/utils/file-utils.js +81 -0
  180. package/dist/lib/utils/lod-conversion-utils.d.ts +41 -0
  181. package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -0
  182. package/dist/lib/utils/lod-conversion-utils.js +76 -0
  183. package/dist/lib/utils/queue.d.ts +7 -0
  184. package/dist/lib/utils/queue.d.ts.map +1 -0
  185. package/dist/lib/utils/queue.js +18 -0
  186. package/dist/lib/utils/statistic-utills.d.ts +3 -0
  187. package/dist/lib/utils/statistic-utills.d.ts.map +1 -0
  188. package/dist/lib/utils/statistic-utills.js +64 -0
  189. package/dist/lib/utils/write-queue.d.ts +22 -0
  190. package/dist/lib/utils/write-queue.d.ts.map +1 -0
  191. package/dist/lib/utils/write-queue.js +62 -0
  192. package/dist/pgm-loader.d.ts +6 -0
  193. package/dist/pgm-loader.d.ts.map +1 -0
  194. package/dist/pgm-loader.js +23 -0
  195. package/dist/workers/3d-tiles-attributes-worker.d.ts +2 -0
  196. package/dist/workers/3d-tiles-attributes-worker.d.ts.map +1 -0
  197. package/dist/workers/3d-tiles-attributes-worker.js +9 -0
  198. package/dist/workers/i3s-attributes-worker.d.ts +2 -0
  199. package/dist/workers/i3s-attributes-worker.d.ts.map +1 -0
  200. package/dist/workers/i3s-attributes-worker.js +5 -0
  201. package/package.json +19 -18
  202. package/src/3d-tiles-attributes-worker.ts +43 -0
  203. package/src/3d-tiles-converter/3d-tiles-converter.ts +49 -6
  204. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +21 -18
  205. package/src/converter-cli.ts +310 -0
  206. package/src/deps-installer/{deps-installer.js → deps-installer.ts} +11 -1
  207. package/src/i3s-attributes-worker.ts +46 -0
  208. package/src/i3s-converter/helpers/coordinate-converter.ts +29 -24
  209. package/src/i3s-converter/helpers/geometry-attributes.ts +4 -3
  210. package/src/i3s-converter/helpers/{geometry-converter.js → geometry-converter.ts} +425 -179
  211. package/src/i3s-converter/helpers/gltf-attributes.ts +68 -0
  212. package/src/i3s-converter/helpers/node-pages.ts +25 -17
  213. package/src/i3s-converter/i3s-converter.ts +154 -87
  214. package/src/i3s-converter/types.ts +90 -8
  215. package/src/index.ts +0 -4
  216. package/src/lib/utils/{compress-util.js → compress-util.ts} +105 -18
  217. package/src/lib/utils/file-utils.ts +84 -0
  218. package/src/lib/utils/{lod-conversion-utils.js → lod-conversion-utils.ts} +27 -5
  219. package/src/lib/utils/queue.ts +17 -0
  220. package/src/lib/utils/{statistic-utills.js → statistic-utills.ts} +0 -0
  221. package/src/lib/utils/write-queue.ts +75 -0
  222. package/src/workers/3d-tiles-attributes-worker.ts +6 -0
  223. package/src/workers/i3s-attributes-worker.ts +6 -0
  224. package/dist/es5/deps-installer/deps-installer.d.ts +0 -10
  225. package/dist/es5/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  226. package/dist/es5/lib/utils/compress-util.d.ts +0 -53
  227. package/dist/es5/lib/utils/file-utils.d.ts +0 -43
  228. package/dist/es5/lib/utils/lod-conversion-utils.d.ts +0 -32
  229. package/dist/esm/deps-installer/deps-installer.d.ts +0 -10
  230. package/dist/esm/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  231. package/dist/esm/lib/utils/compress-util.d.ts +0 -53
  232. package/dist/esm/lib/utils/lod-conversion-utils.d.ts +0 -32
  233. package/src/deps-installer/deps-installer.d.ts +0 -10
  234. package/src/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  235. package/src/lib/utils/compress-util.d.ts +0 -53
  236. package/src/lib/utils/file-utils.d.ts +0 -43
  237. package/src/lib/utils/file-utils.js +0 -38
  238. package/src/lib/utils/lod-conversion-utils.d.ts +0 -32
@@ -0,0 +1,41 @@
1
+ import type { BoundingVolumes, FullExtent, Mbs, Obb } from '@loaders.gl/i3s';
2
+ import { Vector3 } from '@math.gl/core';
3
+ import { OrientedBoundingBox, BoundingSphere } from '@math.gl/culling';
4
+ import TileHeader from '@loaders.gl/tiles/src/tileset/tile-3d';
5
+ import { Geoid } from '@math.gl/geoid';
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 fullExtent https://github.com/Esri/i3s-spec/blob/master/docs/1.8/fullExtent.cmn.md
30
+ * @param
31
+ * @param boundingVolume
32
+ * @returns - fullExtent object
33
+ */
34
+ export declare function convertBoundingVolumeToI3SFullExtent(boundingVolume: OrientedBoundingBox | BoundingSphere): FullExtent;
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,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,UAAU,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAErC;;;;;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,oCAAoC,CAClD,cAAc,EAAE,mBAAmB,GAAG,cAAc,GACnD,UAAU,CA0BZ;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAK9C"}
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createObbFromMbs = exports.convertBoundingVolumeToI3SFullExtent = 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 fullExtent https://github.com/Esri/i3s-spec/blob/master/docs/1.8/fullExtent.cmn.md
85
+ * @param
86
+ * @param boundingVolume
87
+ * @returns - fullExtent object
88
+ */
89
+ function convertBoundingVolumeToI3SFullExtent(boundingVolume) {
90
+ let sphere;
91
+ if (boundingVolume instanceof culling_1.BoundingSphere) {
92
+ sphere = boundingVolume;
93
+ }
94
+ else {
95
+ sphere = boundingVolume.getBoundingSphere();
96
+ }
97
+ const center = sphere.center;
98
+ const radius = sphere.radius;
99
+ const vertexMax = geospatial_1.Ellipsoid.WGS84.cartesianToCartographic(new core_1.Vector3(center[0] + radius, center[1] + radius, center[2] + radius), new core_1.Vector3());
100
+ const vertexMin = geospatial_1.Ellipsoid.WGS84.cartesianToCartographic(new core_1.Vector3(center[0] - radius, center[1] - radius, center[2] - radius), new core_1.Vector3());
101
+ return {
102
+ xmin: vertexMin[0],
103
+ xmax: vertexMax[0],
104
+ ymin: vertexMin[1],
105
+ ymax: vertexMax[1],
106
+ zmin: vertexMin[2],
107
+ zmax: vertexMax[2]
108
+ };
109
+ }
110
+ exports.convertBoundingVolumeToI3SFullExtent = convertBoundingVolumeToI3SFullExtent;
111
+ /**
112
+ * Creates oriented boundinb box from mbs.
113
+ * @param mbs - Minimum Bounding Sphere
114
+ * @returns - Oriented BOunding Box
115
+ */
116
+ function createObbFromMbs(mbs) {
117
+ const radius = mbs[3];
118
+ const center = new core_1.Vector3(mbs[0], mbs[1], mbs[2]);
119
+ const halfAxex = new core_1.Matrix3([radius, 0, 0, 0, radius, 0, 0, 0, radius]);
120
+ return new culling_1.OrientedBoundingBox(center, halfAxex);
121
+ }
122
+ 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, ConvertedAttributes } 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: ConvertedAttributes): 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,mBAAmB,EAA+B,MAAM,UAAU,CAAC;AAMpG;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,mBAAmB,GAAG,kBAAkB,CAwBtF"}
@@ -0,0 +1,177 @@
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 } = attributes;
14
+ const triangleCount = positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;
15
+ if (!featureIndices.length) {
16
+ return {
17
+ faceRange: new Uint32Array([0, triangleCount - 1]),
18
+ featureIds: [0],
19
+ featureCount: 1,
20
+ positions,
21
+ normals,
22
+ texCoords,
23
+ colors
24
+ };
25
+ }
26
+ const data = calculateFaceRangesAndFeaturesCount(featureIndices);
27
+ const attributeObjects = makeAttributeObjects({ ...data, ...attributes });
28
+ const unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);
29
+ const groupedAttributes = groupAttributesAndRangesByFeatureId(unifiedAttributeObjectsByFeatureIds, data.featureCount);
30
+ return groupedAttributes;
31
+ }
32
+ exports.generateAttributes = generateAttributes;
33
+ /**
34
+ * Calculates face Ranges and feature count based on featureIndices.
35
+ * @param featureIndices
36
+ * @returns Object with featureCount, reordered attributes and changed faceRange.
37
+ */
38
+ function calculateFaceRangesAndFeaturesCount(featureIndices) {
39
+ let rangeIndex = 1;
40
+ let featureIndex = 1;
41
+ let currentFeatureId = featureIndices[0];
42
+ const faceRangeList = [];
43
+ const featureIds = [];
44
+ const uniqueFeatureIds = [currentFeatureId];
45
+ faceRangeList[0] = 0;
46
+ featureIds[0] = currentFeatureId;
47
+ for (let index = 1; index < featureIndices.length; index++) {
48
+ if (currentFeatureId !== featureIndices[index]) {
49
+ faceRangeList[rangeIndex] = index / VALUES_PER_VERTEX - 1;
50
+ faceRangeList[rangeIndex + 1] = index / VALUES_PER_VERTEX;
51
+ featureIds[featureIndex] = featureIndices[index];
52
+ if (!uniqueFeatureIds.includes(featureIndices[index])) {
53
+ uniqueFeatureIds.push(featureIndices[index]);
54
+ }
55
+ rangeIndex += 2;
56
+ featureIndex += 1;
57
+ }
58
+ currentFeatureId = featureIndices[index];
59
+ }
60
+ faceRangeList[rangeIndex] = featureIndices.length / VALUES_PER_VERTEX - 1;
61
+ const faceRange = new Uint32Array(faceRangeList);
62
+ const featureCount = uniqueFeatureIds.length;
63
+ return { faceRange, featureCount, featureIds };
64
+ }
65
+ /**
66
+ * Generate list of attribute object grouped by feature ids.
67
+ * @param attributes
68
+ * @returns sorted list of attribute objects.
69
+ */
70
+ function makeAttributeObjects(attributes) {
71
+ const { featureIds, positions, normals, colors, texCoords, faceRange = new Uint32Array(0) } = attributes;
72
+ const groupedData = [];
73
+ let positionsList = new Float32Array(positions);
74
+ let normalsList = new Float32Array(normals);
75
+ let colorsList = new Uint8Array(colors);
76
+ let texCoordsList = new Float32Array(texCoords);
77
+ let faceRangeIndex = 0;
78
+ for (let index = 0; index < featureIds.length; index++) {
79
+ const startIndex = faceRange[index + faceRangeIndex];
80
+ const endIndex = faceRange[index + faceRangeIndex + 1];
81
+ const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);
82
+ const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);
83
+ const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);
84
+ const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);
85
+ groupedData.push({
86
+ featureId: featureIds[index],
87
+ positions: positionsList.slice(0, positionsCount),
88
+ normals: normalsList.slice(0, normalsCount),
89
+ colors: colorsList.slice(0, colorsCount),
90
+ texCoords: texCoordsList.slice(0, texCoordsCount)
91
+ });
92
+ positionsList = positionsList.slice(positionsCount);
93
+ normalsList = normalsList.slice(normalsCount);
94
+ colorsList = colorsList.slice(colorsCount);
95
+ texCoordsList = texCoordsList.slice(texCoordsCount);
96
+ faceRangeIndex += 1;
97
+ }
98
+ return groupedData.sort((first, second) => first.featureId - second.featureId);
99
+ }
100
+ /**
101
+ * Generate sliced count for generating attribute objects depends on attribute name and range.
102
+ * @param attributeName
103
+ * @param startIndex
104
+ * @param endIndex
105
+ * @returns sliced count
106
+ */
107
+ function getSliceAttributeCount(attributeName, startIndex, endIndex) {
108
+ const colorsPerVertex = 4;
109
+ const texCoordsPerVertex = 2;
110
+ const trianglesCount = endIndex - startIndex + 1;
111
+ const vertexCount = trianglesCount * 3;
112
+ switch (attributeName) {
113
+ case 'positions':
114
+ case 'normals':
115
+ return trianglesCount * POSITIONS_AND_NORMALS_PER_TRIANGLE;
116
+ case 'colors':
117
+ return vertexCount * colorsPerVertex;
118
+ case 'texCoords':
119
+ return vertexCount * texCoordsPerVertex;
120
+ default:
121
+ return 0;
122
+ }
123
+ }
124
+ /**
125
+ * Generates unique object list depends on feature ids and concantenate their attributes.
126
+ * @param sortedData
127
+ * @returns unique list of objects
128
+ */
129
+ function unifyObjectsByFeatureId(sortedData) {
130
+ const uniqueObjects = [];
131
+ for (let index = 0; index < sortedData.length; index++) {
132
+ const currentObject = sortedData[index];
133
+ const existedObject = uniqueObjects.find((obj) => obj.featureId === currentObject.featureId);
134
+ if (existedObject) {
135
+ existedObject.positions = (0, loader_utils_1.concatenateTypedArrays)(existedObject.positions, currentObject.positions);
136
+ existedObject.normals = (0, loader_utils_1.concatenateTypedArrays)(existedObject.normals, currentObject.normals);
137
+ existedObject.colors = (0, loader_utils_1.concatenateTypedArrays)(existedObject.colors, currentObject.colors);
138
+ existedObject.texCoords = (0, loader_utils_1.concatenateTypedArrays)(existedObject.texCoords, currentObject.texCoords);
139
+ }
140
+ else {
141
+ uniqueObjects.push(currentObject);
142
+ }
143
+ }
144
+ return uniqueObjects;
145
+ }
146
+ /**
147
+ * Generates attribute objects with new faceRange and reordered attributes.
148
+ * @param unifiedObjects
149
+ * @returns generated attributes with new faceRange.
150
+ */
151
+ function groupAttributesAndRangesByFeatureId(unifiedObjects, featureCount) {
152
+ const firstAttributeObject = unifiedObjects[0];
153
+ const featureIds = [firstAttributeObject.featureId || 0];
154
+ let positions = new Float32Array(firstAttributeObject.positions);
155
+ let normals = new Float32Array(firstAttributeObject.normals);
156
+ let colors = new Uint8Array(firstAttributeObject.colors);
157
+ let texCoords = new Float32Array(firstAttributeObject.texCoords);
158
+ const range = [0];
159
+ let objIndex = 0;
160
+ let sum = 0;
161
+ for (let index = 1; index < unifiedObjects.length; index++) {
162
+ const currentAttributesObject = unifiedObjects[index];
163
+ featureIds.push(currentAttributesObject.featureId || 0);
164
+ positions = (0, loader_utils_1.concatenateTypedArrays)(positions, currentAttributesObject.positions);
165
+ normals = (0, loader_utils_1.concatenateTypedArrays)(normals, currentAttributesObject.normals);
166
+ colors = (0, loader_utils_1.concatenateTypedArrays)(colors, currentAttributesObject.colors);
167
+ texCoords = (0, loader_utils_1.concatenateTypedArrays)(texCoords, currentAttributesObject.texCoords);
168
+ const groupedObject = unifiedObjects[objIndex];
169
+ range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);
170
+ range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE + sum);
171
+ sum += groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;
172
+ objIndex += 1;
173
+ }
174
+ range.push(positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);
175
+ const faceRange = new Uint32Array(range);
176
+ return { faceRange, featureIds, positions, normals, colors, texCoords, featureCount };
177
+ }
@@ -0,0 +1,29 @@
1
+ import { ConvertedAttributes, I3SConvertedResources } from '../types';
2
+ import { B3DMContent } from '@loaders.gl/3d-tiles';
3
+ import { AttributeStorageInfo } from '@loaders.gl/i3s';
4
+ import { Geoid } from '@math.gl/geoid';
5
+ import { B3DMAttributesData } from '../../i3s-attributes-worker';
6
+ /**
7
+ * Convert binary data from b3dm file to i3s resources
8
+ *
9
+ * @param tileContent - 3d tile content
10
+ * @param nodeId - target nodeId. If a few nodes will be created - ids will be nodeId+n where n - index in the resulting array
11
+ * @param featuresHashArray - hash array of features that is needed to not to mix up same features in parent and child nodes
12
+ * @param attributeStorageInfo - attributes metadata from 3DSceneLayer json
13
+ * @param draco - is converter should create draco compressed geometry
14
+ * @param generateBoundingVolumes - is converter should create accurate bounding voulmes from geometry attributes
15
+ * @param geoidHeightModel - model to convert elevation from elipsoidal to geoid
16
+ * @returns Array of node resources to create one or more i3s nodes
17
+ */
18
+ export default function convertB3dmToI3sGeometry(tileContent: B3DMContent, nodeId: number, featuresHashArray: string[], attributeStorageInfo: AttributeStorageInfo[] | undefined, draco: boolean, generateBoundingVolumes: boolean, geoidHeightModel: Geoid, workerSource: {
19
+ [key: string]: string;
20
+ }): Promise<I3SConvertedResources[] | null>;
21
+ /**
22
+ * Convert attributes from the gltf nodes tree to i3s plain geometry
23
+ * @param tileContent - 3d tile content
24
+ * @param useCartesianPositions - convert positions to absolute cartesian coordinates instead of cartographic offsets.
25
+ * Cartesian coordinates will be required for creating bounding voulmest from geometry positions
26
+ * @returns map of converted geometry attributes
27
+ */
28
+ export declare function convertAttributes(attributesData: B3DMAttributesData, useCartesianPositions: boolean): Promise<Map<string, ConvertedAttributes>>;
29
+ //# 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.ts"],"names":[],"mappings":"AASA,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EAGtB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EACL,oBAAoB,EAIrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAMrC,OAAO,EAAC,kBAAkB,EAAqC,MAAM,6BAA6B,CAAC;AAwBnG;;;;;;;;;;;GAWG;AACH,wBAA8B,wBAAwB,CACpD,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,MAAM,EAAE,EAC3B,oBAAoB,EAAE,oBAAoB,EAAE,GAAG,SAAS,EACxD,KAAK,EAAE,OAAO,EACd,uBAAuB,EAAE,OAAO,EAChC,gBAAgB,EAAE,KAAK,EACvB,YAAY,EAAE;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAC,2CAoEtC;AAiID;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,cAAc,EAAE,kBAAkB,EAClC,qBAAqB,EAAE,OAAO,GAC7B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CA0C3C"}