@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,82 @@
1
+ import type { AttributeStorageInfo } from '@loaders.gl/i3s';
2
+ import { Tileset3D } from '@loaders.gl/tiles';
3
+ import { Geoid } from '@math.gl/geoid';
4
+ /**
5
+ * Converter from i3s to 3d-tiles
6
+ */
7
+ export default class Tiles3DConverter {
8
+ options: any;
9
+ tilesetPath: string;
10
+ vertexCounter: number;
11
+ conversionStartTime: [number, number];
12
+ geoidHeightModel: Geoid | null;
13
+ sourceTileset: Tileset3D | null;
14
+ attributeStorageInfo: AttributeStorageInfo | null;
15
+ workerSource: {
16
+ [key: string]: string;
17
+ };
18
+ constructor();
19
+ /**
20
+ * Convert i3s format data to 3dTiles
21
+ * @param options
22
+ * @param options.inputUrl the url to read the tileset from
23
+ * @param options.outputPath the output filename
24
+ * @param options.tilesetName the output name of the tileset
25
+ * @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format
26
+ * @param options.maxDepth The max tree depth of conversion
27
+ */
28
+ convert(options: {
29
+ inputUrl: string;
30
+ outputPath: string;
31
+ tilesetName: string;
32
+ maxDepth?: number;
33
+ egmFilePath: string;
34
+ }): Promise<any>;
35
+ /**
36
+ * The recursive function of traversal of a nodes tree
37
+ * @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)
38
+ * @param parentNode object in resulting tileset
39
+ * @param level a current level of a tree depth
40
+ */
41
+ private _addChildren;
42
+ /**
43
+ * Load a child node having information from the node header
44
+ * @param parentNode a parent node tile object (@loaders.gl/tiles/Tile3D)
45
+ * @param childNodeInfo child information from 3DNodeIndexDocument
46
+ * (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/nodeReference.cmn.md)
47
+ */
48
+ private _loadChildNode;
49
+ /**
50
+ * Make an url of a resource from its relative url having the base url
51
+ * @param baseUrl the base url. A resulting url will be related from this url
52
+ * @param relativeUrl a realtive url of a resource
53
+ */
54
+ private _relativeUrlToFullUrl;
55
+ /**
56
+ * Do loading all attributes related to particular node.
57
+ * @param sourceChild
58
+ * @param attributeStorageInfo
59
+ * @returns Promise of attributes object.
60
+ */
61
+ private _loadChildAttributes;
62
+ /**
63
+ * Returns attribute type for loading attributes
64
+ * @param attribute
65
+ * Workaround for I3S v1.6. There is no attribute.attributeValues.valueType field in attribute.
66
+ * There is an 'Oid32' type if attribute has objectIds property.
67
+ * Doc: https://github.com/Esri/i3s-spec/blob/master/docs/1.6/attributeStorageInfo.cmn.md
68
+ */
69
+ private _getAttributeType;
70
+ /**
71
+ * Make simple arrays from attribute typed arrays.
72
+ * @param attributesList
73
+ */
74
+ private _replaceNestedArrays;
75
+ /**
76
+ * Print statistics in the end of conversion
77
+ * @param params - output files data
78
+ */
79
+ private _finishConversion;
80
+ private loadWorkers;
81
+ }
82
+ //# sourceMappingURL=3d-tiles-converter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"3d-tiles-converter.d.ts","sourceRoot":"","sources":["../../src/3d-tiles-converter/3d-tiles-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,oBAAoB,EAAkC,MAAM,iBAAiB,CAAC;AAQ3F,OAAO,EAAC,SAAS,EAAS,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAmBrC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,OAAO,EAAE,GAAG,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,gBAAgB,EAAE,KAAK,GAAG,IAAI,CAAC;IAC/B,aAAa,EAAE,SAAS,GAAG,IAAI,CAAC;IAChC,oBAAoB,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAClD,YAAY,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAC,CAAM;;IAa3C;;;;;;;;OAQG;IACU,OAAO,CAAC,OAAO,EAAE;QAC5B,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC,GAAG,CAAC;IAsDhB;;;;;OAKG;YACW,YAAY;IAgE1B;;;;;OAKG;YACW,cAAc;IAyB5B;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAiB7B;;;;;OAKG;YACW,oBAAoB;IAsBlC;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IASzB;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAU5B;;;OAGG;YACW,iBAAiB;YAiBjB,WAAW;CAS1B"}
@@ -0,0 +1,268 @@
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
+ const path_1 = require("path");
7
+ const process_1 = __importDefault(require("process"));
8
+ const json_map_transform_1 = __importDefault(require("json-map-transform"));
9
+ const core_1 = require("@loaders.gl/core");
10
+ const i3s_1 = require("@loaders.gl/i3s");
11
+ const tiles_1 = require("@loaders.gl/tiles");
12
+ const pgm_loader_1 = require("../pgm-loader");
13
+ const i3s_obb_to_3d_tiles_obb_1 = require("./helpers/i3s-obb-to-3d-tiles-obb");
14
+ const lod_conversion_utils_1 = require("../lib/utils/lod-conversion-utils");
15
+ const file_utils_1 = require("../lib/utils/file-utils");
16
+ const statistic_utills_1 = require("../lib/utils/statistic-utills");
17
+ const tileset_1 = require("./json-templates/tileset");
18
+ const b3dm_converter_1 = __importDefault(require("./helpers/b3dm-converter"));
19
+ const coordinate_converter_1 = require("../i3s-converter/helpers/coordinate-converter");
20
+ const _3d_tiles_attributes_worker_1 = require("../3d-tiles-attributes-worker");
21
+ const worker_utils_1 = require("@loaders.gl/worker-utils");
22
+ const I3S = 'I3S';
23
+ /**
24
+ * Converter from i3s to 3d-tiles
25
+ */
26
+ class Tiles3DConverter {
27
+ constructor() {
28
+ this.workerSource = {};
29
+ this.options = {};
30
+ this.tilesetPath = '';
31
+ this.vertexCounter = 0;
32
+ this.conversionStartTime = [0, 0];
33
+ this.geoidHeightModel = null;
34
+ this.sourceTileset = null;
35
+ this.attributeStorageInfo = null;
36
+ this.workerSource = {};
37
+ }
38
+ /**
39
+ * Convert i3s format data to 3dTiles
40
+ * @param options
41
+ * @param options.inputUrl the url to read the tileset from
42
+ * @param options.outputPath the output filename
43
+ * @param options.tilesetName the output name of the tileset
44
+ * @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format
45
+ * @param options.maxDepth The max tree depth of conversion
46
+ */
47
+ async convert(options) {
48
+ const { inputUrl, outputPath, tilesetName, maxDepth, egmFilePath } = options;
49
+ this.conversionStartTime = process_1.default.hrtime();
50
+ this.options = { maxDepth };
51
+ console.log('Loading egm file...'); // eslint-disable-line
52
+ this.geoidHeightModel = await (0, core_1.load)(egmFilePath, pgm_loader_1.PGMLoader);
53
+ console.log('Loading egm file completed!'); // eslint-disable-line
54
+ await this.loadWorkers();
55
+ const sourceTilesetJson = await (0, core_1.load)(inputUrl, i3s_1.I3SLoader, {});
56
+ this.sourceTileset = new tiles_1.Tileset3D(sourceTilesetJson, {
57
+ loadOptions: {
58
+ i3s: { coordinateSystem: i3s_1.COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false }
59
+ }
60
+ });
61
+ await this.sourceTileset.tilesetInitializationPromise;
62
+ const rootNode = this.sourceTileset.root;
63
+ if (!rootNode.header.obb) {
64
+ rootNode.header.obb = (0, coordinate_converter_1.createObbFromMbs)(rootNode.header.mbs);
65
+ }
66
+ this.tilesetPath = (0, path_1.join)(`${outputPath}`, `${tilesetName}`);
67
+ this.attributeStorageInfo = sourceTilesetJson.attributeStorageInfo;
68
+ // Removing the tilesetPath needed to exclude erroneous files after conversion
69
+ try {
70
+ await (0, file_utils_1.removeDir)(this.tilesetPath);
71
+ }
72
+ catch (e) {
73
+ // do nothing
74
+ }
75
+ const rootTile = {
76
+ boundingVolume: {
77
+ box: (0, i3s_obb_to_3d_tiles_obb_1.i3sObbTo3dTilesObb)(rootNode.header.obb, this.geoidHeightModel)
78
+ },
79
+ geometricError: (0, lod_conversion_utils_1.convertScreenThresholdToGeometricError)(rootNode),
80
+ children: []
81
+ };
82
+ await this._addChildren(rootNode, rootTile, 1);
83
+ const tileset = (0, json_map_transform_1.default)({ root: rootTile }, (0, tileset_1.TILESET)());
84
+ await (0, file_utils_1.writeFile)(this.tilesetPath, JSON.stringify(tileset), 'tileset.json');
85
+ this._finishConversion({ slpk: false, outputPath, tilesetName });
86
+ // Clean up worker pools
87
+ const workerFarm = worker_utils_1.WorkerFarm.getWorkerFarm({});
88
+ workerFarm.destroy();
89
+ }
90
+ /**
91
+ * The recursive function of traversal of a nodes tree
92
+ * @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)
93
+ * @param parentNode object in resulting tileset
94
+ * @param level a current level of a tree depth
95
+ */
96
+ async _addChildren(parentSourceNode, parentNode, level) {
97
+ if (this.options.maxDepth && level > this.options.maxDepth) {
98
+ return;
99
+ }
100
+ for (const childNodeInfo of parentSourceNode.header.children || []) {
101
+ const sourceChild = await this._loadChildNode(parentSourceNode, childNodeInfo);
102
+ parentSourceNode.children.push(sourceChild);
103
+ if (sourceChild.contentUrl) {
104
+ await this.sourceTileset._loadTile(sourceChild);
105
+ this.vertexCounter += sourceChild.content.vertexCount;
106
+ let featureAttributes = null;
107
+ if (this.attributeStorageInfo) {
108
+ featureAttributes = await this._loadChildAttributes(sourceChild, this.attributeStorageInfo);
109
+ }
110
+ if (!sourceChild.header.obb) {
111
+ sourceChild.header.obb = (0, coordinate_converter_1.createObbFromMbs)(sourceChild.header.mbs);
112
+ }
113
+ const boundingVolume = {
114
+ box: (0, i3s_obb_to_3d_tiles_obb_1.i3sObbTo3dTilesObb)(sourceChild.header.obb, this.geoidHeightModel)
115
+ };
116
+ const child = {
117
+ boundingVolume,
118
+ geometricError: (0, lod_conversion_utils_1.convertScreenThresholdToGeometricError)(sourceChild),
119
+ children: []
120
+ };
121
+ const i3sAttributesData = {
122
+ tileContent: sourceChild.content,
123
+ textureFormat: sourceChild?.header?.textureFormat
124
+ };
125
+ // TODO Uncomment when 3d-tiles-attributes-worker will be published on CDN.
126
+ // const b3dm = await transform3DTilesAttributesOnWorker(i3sAttributesData, {
127
+ // source: this.workerSource.tile3dWorkerSource,
128
+ // featureAttributes
129
+ // });
130
+ const b3dm = await new b3dm_converter_1.default().convert(i3sAttributesData, featureAttributes);
131
+ child.content = {
132
+ uri: `${sourceChild.id}.b3dm`,
133
+ boundingVolume
134
+ };
135
+ await (0, file_utils_1.writeFile)(this.tilesetPath, new Uint8Array(b3dm), `${sourceChild.id}.b3dm`);
136
+ parentNode.children.push(child);
137
+ sourceChild.unloadContent();
138
+ await this._addChildren(sourceChild, child, level + 1);
139
+ }
140
+ else {
141
+ await this._addChildren(sourceChild, parentNode, level + 1);
142
+ }
143
+ }
144
+ }
145
+ /**
146
+ * Load a child node having information from the node header
147
+ * @param parentNode a parent node tile object (@loaders.gl/tiles/Tile3D)
148
+ * @param childNodeInfo child information from 3DNodeIndexDocument
149
+ * (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/nodeReference.cmn.md)
150
+ */
151
+ async _loadChildNode(parentNode, childNodeInfo) {
152
+ let header;
153
+ if (this.sourceTileset.tileset.nodePages) {
154
+ console.log(`Node conversion: ${childNodeInfo.id}`); // eslint-disable-line no-console,no-undef
155
+ header = await this.sourceTileset.tileset.nodePagesTile.formTileFromNodePages(childNodeInfo.id);
156
+ }
157
+ else {
158
+ const { loader } = this.sourceTileset;
159
+ const nodeUrl = this._relativeUrlToFullUrl(parentNode.url, childNodeInfo.href);
160
+ // load metadata
161
+ const options = {
162
+ i3s: {
163
+ ...this.sourceTileset.loadOptions,
164
+ isTileHeader: true,
165
+ loadContent: false
166
+ }
167
+ };
168
+ console.log(`Node conversion: ${nodeUrl}`); // eslint-disable-line no-console,no-undef
169
+ header = await (0, core_1.load)(nodeUrl, loader, options);
170
+ }
171
+ return new tiles_1.Tile3D(this.sourceTileset, header, parentNode);
172
+ }
173
+ /**
174
+ * Make an url of a resource from its relative url having the base url
175
+ * @param baseUrl the base url. A resulting url will be related from this url
176
+ * @param relativeUrl a realtive url of a resource
177
+ */
178
+ _relativeUrlToFullUrl(baseUrl, relativeUrl) {
179
+ let resultArray = baseUrl.split('/');
180
+ const relativeUrlArray = relativeUrl.split('/');
181
+ for (const folder of relativeUrlArray) {
182
+ switch (folder) {
183
+ case '.':
184
+ continue; // eslint-disable-line no-continue
185
+ case '..':
186
+ resultArray = resultArray.slice(0, -1);
187
+ break;
188
+ default:
189
+ resultArray.push(folder);
190
+ }
191
+ }
192
+ return resultArray.join('/');
193
+ }
194
+ /**
195
+ * Do loading all attributes related to particular node.
196
+ * @param sourceChild
197
+ * @param attributeStorageInfo
198
+ * @returns Promise of attributes object.
199
+ */
200
+ async _loadChildAttributes(sourceChild, attributeStorageInfo) {
201
+ const promises = [];
202
+ const { attributeUrls } = sourceChild.header;
203
+ for (let index = 0; index < attributeUrls.length; index++) {
204
+ const inputUrl = attributeUrls[index];
205
+ const attribute = attributeStorageInfo[index];
206
+ const options = {
207
+ attributeName: attribute.name,
208
+ attributeType: this._getAttributeType(attribute)
209
+ };
210
+ promises.push((0, core_1.load)(inputUrl, i3s_1.I3SAttributeLoader, options));
211
+ }
212
+ const attributesList = await Promise.all(promises);
213
+ this._replaceNestedArrays(attributesList);
214
+ return Object.assign({}, ...attributesList);
215
+ }
216
+ /**
217
+ * Returns attribute type for loading attributes
218
+ * @param attribute
219
+ * Workaround for I3S v1.6. There is no attribute.attributeValues.valueType field in attribute.
220
+ * There is an 'Oid32' type if attribute has objectIds property.
221
+ * Doc: https://github.com/Esri/i3s-spec/blob/master/docs/1.6/attributeStorageInfo.cmn.md
222
+ */
223
+ _getAttributeType(attribute) {
224
+ if (attribute.attributeValues) {
225
+ return attribute.attributeValues.valueType;
226
+ }
227
+ else if (attribute.objectIds) {
228
+ return 'Oid32';
229
+ }
230
+ return '';
231
+ }
232
+ /**
233
+ * Make simple arrays from attribute typed arrays.
234
+ * @param attributesList
235
+ */
236
+ _replaceNestedArrays(attributesList) {
237
+ for (let index = 0; index < attributesList.length; index++) {
238
+ const attributeObject = attributesList[index];
239
+ for (const key in attributeObject) {
240
+ attributeObject[key] = Array.from(attributeObject[key]);
241
+ }
242
+ }
243
+ }
244
+ /**
245
+ * Print statistics in the end of conversion
246
+ * @param params - output files data
247
+ */
248
+ async _finishConversion(params) {
249
+ const filesSize = await (0, statistic_utills_1.calculateFilesSize)(params);
250
+ const diff = process_1.default.hrtime(this.conversionStartTime);
251
+ const conversionTime = (0, statistic_utills_1.timeConverter)(diff);
252
+ console.log(`------------------------------------------------`); // eslint-disable-line
253
+ console.log(`Finish conversion of ${I3S}`); // eslint-disable-line
254
+ console.log(`Total conversion time: ${conversionTime}`); // eslint-disable-line
255
+ console.log(`Vertex count: `, this.vertexCounter); // eslint-disable-line
256
+ console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line
257
+ console.log(`------------------------------------------------`); // eslint-disable-line
258
+ }
259
+ async loadWorkers() {
260
+ console.log(`Loading workers source...`); // eslint-disable-line no-undef, no-console
261
+ const tile3dAttributesWorkerUrl = (0, worker_utils_1.getWorkerURL)(_3d_tiles_attributes_worker_1.Tile3dAttributesWorker, { ...(0, core_1.getLoaderOptions)() });
262
+ const sourceResponse = await (0, core_1.fetchFile)(tile3dAttributesWorkerUrl);
263
+ const source = await sourceResponse.text();
264
+ this.workerSource.tile3dWorkerSource = source;
265
+ console.log(`Loading workers source completed!`); // eslint-disable-line no-undef, no-console
266
+ }
267
+ }
268
+ exports.default = Tiles3DConverter;
@@ -0,0 +1,84 @@
1
+ import type { I3SAttributesData } from '../../3d-tiles-attributes-worker';
2
+ import { Matrix4 } from '@math.gl/core';
3
+ /**
4
+ * Converts content of an I3S node to *.b3dm's file content
5
+ */
6
+ export default class B3dmConverter {
7
+ rtcCenter: Float32Array;
8
+ i3sTile: any;
9
+ /**
10
+ * The starter of content conversion
11
+ * @param i3sTile - Tile3D instance for I3S node
12
+ * @returns - encoded content
13
+ */
14
+ convert(i3sAttributesData: I3SAttributesData, featureAttributes?: any): Promise<ArrayBuffer>;
15
+ /**
16
+ * Build and encode gltf
17
+ * @param i3sTile - Tile3D instance for I3S node
18
+ * @returns - encoded glb content
19
+ */
20
+ buildGltf(i3sAttributesData: I3SAttributesData): Promise<ArrayBuffer>;
21
+ /**
22
+ * Update gltfBuilder with texture from I3S tile
23
+ * @param {object} i3sTile - Tile3D object
24
+ * @param {GLTFScenegraph} gltfBuilder - gltfScenegraph instance to construct GLTF
25
+ * @returns {Promise<number | null>} - GLTF texture index
26
+ */
27
+ _addI3sTextureToGltf(tileContent: any, textureFormat: any, gltfBuilder: any): Promise<null>;
28
+ /**
29
+ * Generate a positions array which is correct for 3DTiles/GLTF format
30
+ * @param {Float64Array} positionsValue - the input geometry positions array
31
+ * @param {number[]} cartesianOrigin - the tile center in the cartesian coordinate system
32
+ * @param {number[]} cartographicOrigin - the tile center in the cartographic coordinate system
33
+ * @param {number[]} modelMatrix - the model matrix of geometry
34
+ * @returns {Float32Array} - the output geometry positions array
35
+ */
36
+ _normalizePositions(positionsValue: any, cartesianOrigin: any, cartographicOrigin: any, modelMatrix: any): Float32Array;
37
+ /**
38
+ * Generate the transformation matrix for GLTF node:
39
+ * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-node
40
+ * 1. Create the translate transformation from cartesianOrigin (the positions array stores offsets from this cartesianOrigin)
41
+ * 2. Create the rotation transformation to rotate model from z-up coordinates (I3S specific) to y-up coordinates (GLTF specific)
42
+ * @param {number[]} cartesianOrigin - the tile center in the cartesian coordinate system
43
+ * @returns {Matrix4} - an array of 16 numbers (4x4 matrix)
44
+ */
45
+ _generateTransformMatrix(cartesianOrigin: any): Matrix4;
46
+ /**
47
+ * Generate batchId attribute from faceRanges.
48
+ * @param {Uint32Array} faceRanges - the source array
49
+ * @returns {Float32Array} batchId list.
50
+ */
51
+ _generateBatchId(faceRanges: any): Float32Array;
52
+ /**
53
+ * luma.gl can not work without indices now:
54
+ * https://github.com/visgl/luma.gl/blob/d8cad75b9f8ca3e578cf078ed9d19e619c2ddbc9/modules/experimental/src/gltf/gltf-instantiator.js#L115
55
+ * This method generates syntetic indices array: [0, 1, 2, 3, .... , vertexCount-1]
56
+ * @param {number} vertexCount - vertex count in the geometry
57
+ * @returns {Uint32Array} indices array.
58
+ */
59
+ _generateSynteticIndices(vertexCount: any): Uint32Array;
60
+ /**
61
+ * Deduce mime type by format from `textureSetDefinition.formats[0].format`
62
+ * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/textureSetDefinitionFormat.cmn.md
63
+ * @param {string} format - format name
64
+ * @returns {string} mime type.
65
+ */
66
+ _deduceMimeTypeFromFormat(format: any): "image/jpeg" | "image/png" | "image/ktx2";
67
+ /**
68
+ * Convert i3s material to GLTF compatible material
69
+ * @param {object} material - i3s material definition
70
+ * @param {number | null} textureIndex - texture index in GLTF
71
+ * @returns {object} GLTF material
72
+ */
73
+ _convertI3sMaterialToGltfMaterial(material: any, textureIndex: any): any;
74
+ /**
75
+ * Set texture properties in material with GLTF textureIndex
76
+ * @param {object} materialDefinition - i3s material definition
77
+ * @param {number} textureIndex - texture index in GLTF
78
+ * @returns {void}
79
+ */
80
+ _setGltfTexture(materialDefinition: any, textureIndex: any): any;
81
+ _getFeaturesLength(attributes: any): any;
82
+ _checkNormals(normals: any): any;
83
+ }
84
+ //# sourceMappingURL=b3dm-converter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"b3dm-converter.d.ts","sourceRoot":"","sources":["../../../src/3d-tiles-converter/helpers/b3dm-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,kCAAkC,CAAC;AAKxE,OAAO,EAAC,OAAO,EAAU,MAAM,eAAe,CAAC;AAO/C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAEhC,SAAS,EAAE,YAAY,CAAC;IACxB,OAAO,EAAE,GAAG,CAAC;IAEb;;;;OAIG;IACG,OAAO,CACX,iBAAiB,EAAE,iBAAiB,EACpC,iBAAiB,GAAE,GAAU,GAC5B,OAAO,CAAC,WAAW,CAAC;IAcvB;;;;OAIG;IACG,SAAS,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;IAuD3E;;;;;OAKG;IACG,oBAAoB,CAAC,WAAW,KAAA,EAAE,aAAa,KAAA,EAAE,WAAW,KAAA;IAmBlE;;;;;;;OAOG;IACH,mBAAmB,CAAC,cAAc,KAAA,EAAE,eAAe,KAAA,EAAE,kBAAkB,KAAA,EAAE,WAAW,KAAA;IAepF;;;;;;;OAOG;IACH,wBAAwB,CAAC,eAAe,KAAA;IAMxC;;;;OAIG;IACH,gBAAgB,CAAC,UAAU,KAAA;IAiB3B;;;;;;OAMG;IACH,wBAAwB,CAAC,WAAW,KAAA;IAQpC;;;;;OAKG;IACH,yBAAyB,CAAC,MAAM,KAAA;IAchC;;;;;OAKG;IACH,iCAAiC,CAAC,QAAQ,KAAA,EAAE,YAAY,KAAA;IAgCxD;;;;;OAKG;IACH,eAAe,CAAC,kBAAkB,KAAA,EAAE,YAAY,KAAA;IA+ChD,kBAAkB,CAAC,UAAU,KAAA;IAY7B,aAAa,CAAC,OAAO,KAAA;CAItB"}