@loaders.gl/tile-converter 3.1.3 → 4.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +78 -0
  2. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -0
  3. package/dist/{esm/3d-tiles-converter → 3d-tiles-converter}/3d-tiles-converter.js +2 -1
  4. package/dist/3d-tiles-converter/3d-tiles-converter.js.map +1 -0
  5. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +83 -0
  6. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -0
  7. package/dist/{esm/3d-tiles-converter → 3d-tiles-converter}/helpers/b3dm-converter.js +7 -5
  8. package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -0
  9. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +13 -0
  10. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts.map +1 -0
  11. package/dist/{esm/3d-tiles-converter → 3d-tiles-converter}/helpers/i3s-obb-to-3d-tiles-obb.js +0 -0
  12. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -0
  13. package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +9 -0
  14. package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +1 -0
  15. package/dist/{esm/3d-tiles-converter → 3d-tiles-converter}/helpers/texture-atlas.js +0 -0
  16. package/dist/3d-tiles-converter/helpers/texture-atlas.js.map +1 -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/{esm/3d-tiles-converter → 3d-tiles-converter}/json-templates/tileset.js +0 -0
  20. package/dist/3d-tiles-converter/json-templates/tileset.js.map +1 -0
  21. package/dist/bundle.d.ts +2 -0
  22. package/dist/bundle.d.ts.map +1 -0
  23. package/dist/{esm/bundle.js → bundle.js} +0 -0
  24. package/dist/bundle.js.map +1 -0
  25. package/dist/converter.min.js +21 -21
  26. package/dist/{es5/deps-installer → deps-installer}/deps-installer.d.ts +0 -0
  27. package/dist/deps-installer/deps-installer.d.ts.map +1 -0
  28. package/dist/{esm/deps-installer → deps-installer}/deps-installer.js +0 -0
  29. package/dist/deps-installer/deps-installer.js.map +1 -0
  30. package/dist/dist.min.js +201 -445
  31. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +41 -0
  32. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -0
  33. package/dist/{esm/i3s-converter → i3s-converter}/helpers/coordinate-converter.js +0 -0
  34. package/dist/i3s-converter/helpers/coordinate-converter.js.map +1 -0
  35. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts +9 -0
  36. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts.map +1 -0
  37. package/dist/{esm/i3s-converter → i3s-converter}/helpers/create-scene-server-path.js +0 -0
  38. package/dist/i3s-converter/helpers/create-scene-server-path.js.map +1 -0
  39. package/dist/i3s-converter/helpers/geometry-attributes.d.ts +23 -0
  40. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -0
  41. package/dist/{esm/i3s-converter → i3s-converter}/helpers/geometry-attributes.js +0 -0
  42. package/dist/i3s-converter/helpers/geometry-attributes.js.map +1 -0
  43. package/dist/{es5/i3s-converter → i3s-converter}/helpers/geometry-converter.d.ts +0 -0
  44. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -0
  45. package/dist/{esm/i3s-converter → i3s-converter}/helpers/geometry-converter.js +31 -4
  46. package/dist/i3s-converter/helpers/geometry-converter.js.map +1 -0
  47. package/dist/i3s-converter/helpers/node-debug.d.ts +2 -0
  48. package/dist/i3s-converter/helpers/node-debug.d.ts.map +1 -0
  49. package/dist/{esm/i3s-converter → i3s-converter}/helpers/node-debug.js +0 -0
  50. package/dist/i3s-converter/helpers/node-debug.js.map +1 -0
  51. package/dist/i3s-converter/helpers/node-pages.d.ts +116 -0
  52. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -0
  53. package/dist/{esm/i3s-converter → i3s-converter}/helpers/node-pages.js +0 -0
  54. package/dist/i3s-converter/helpers/node-pages.js.map +1 -0
  55. package/dist/i3s-converter/i3s-converter.d.ts +320 -0
  56. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -0
  57. package/dist/{esm/i3s-converter → i3s-converter}/i3s-converter.js +0 -0
  58. package/dist/i3s-converter/i3s-converter.js.map +1 -0
  59. package/dist/i3s-converter/json-templates/layers.d.ts +95 -0
  60. package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -0
  61. package/dist/{esm/i3s-converter → i3s-converter}/json-templates/layers.js +0 -0
  62. package/dist/i3s-converter/json-templates/layers.js.map +1 -0
  63. package/dist/i3s-converter/json-templates/metadata.d.ts +22 -0
  64. package/dist/i3s-converter/json-templates/metadata.d.ts.map +1 -0
  65. package/dist/{esm/i3s-converter → i3s-converter}/json-templates/metadata.js +0 -0
  66. package/dist/i3s-converter/json-templates/metadata.js.map +1 -0
  67. package/dist/i3s-converter/json-templates/node.d.ts +61 -0
  68. package/dist/i3s-converter/json-templates/node.d.ts.map +1 -0
  69. package/dist/{esm/i3s-converter → i3s-converter}/json-templates/node.js +0 -0
  70. package/dist/i3s-converter/json-templates/node.js.map +1 -0
  71. package/dist/i3s-converter/json-templates/scene-server.d.ts +28 -0
  72. package/dist/i3s-converter/json-templates/scene-server.d.ts.map +1 -0
  73. package/dist/{esm/i3s-converter → i3s-converter}/json-templates/scene-server.js +0 -0
  74. package/dist/i3s-converter/json-templates/scene-server.js.map +1 -0
  75. package/dist/i3s-converter/json-templates/shared-resources.d.ts +14 -0
  76. package/dist/i3s-converter/json-templates/shared-resources.d.ts.map +1 -0
  77. package/dist/{esm/i3s-converter → i3s-converter}/json-templates/shared-resources.js +0 -0
  78. package/dist/i3s-converter/json-templates/shared-resources.js.map +1 -0
  79. package/dist/i3s-converter/json-templates/store.d.ts +95 -0
  80. package/dist/i3s-converter/json-templates/store.d.ts.map +1 -0
  81. package/dist/{esm/i3s-converter → i3s-converter}/json-templates/store.js +0 -0
  82. package/dist/i3s-converter/json-templates/store.js.map +1 -0
  83. package/dist/i3s-converter/types.d.ts +14 -0
  84. package/dist/i3s-converter/types.d.ts.map +1 -0
  85. package/dist/{esm/i3s-converter → i3s-converter}/types.js +0 -0
  86. package/dist/{es5/i3s-converter → i3s-converter}/types.js.map +0 -0
  87. package/dist/i3s-server/app.d.ts +3 -0
  88. package/dist/i3s-server/app.d.ts.map +1 -0
  89. package/dist/{esm/i3s-server → i3s-server}/app.js +0 -0
  90. package/dist/i3s-server/app.js.map +1 -0
  91. package/dist/{es5/i3s-server → i3s-server}/bin/www +0 -0
  92. package/dist/{es5/i3s-server → i3s-server}/certs/cert.pem +0 -0
  93. package/dist/{es5/i3s-server → i3s-server}/certs/key.pem +0 -0
  94. package/dist/i3s-server/controllers/index-controller.d.ts +2 -0
  95. package/dist/i3s-server/controllers/index-controller.d.ts.map +1 -0
  96. package/dist/{esm/i3s-server → i3s-server}/controllers/index-controller.js +0 -0
  97. package/dist/i3s-server/controllers/index-controller.js.map +1 -0
  98. package/dist/i3s-server/routes/index.d.ts +3 -0
  99. package/dist/i3s-server/routes/index.d.ts.map +1 -0
  100. package/dist/{esm/i3s-server → i3s-server}/routes/index.js +0 -0
  101. package/dist/i3s-server/routes/index.js.map +1 -0
  102. package/dist/index.d.ts +5 -0
  103. package/dist/index.d.ts.map +1 -0
  104. package/dist/{esm/index.js → index.js} +0 -0
  105. package/dist/index.js.map +1 -0
  106. package/dist/{es5/lib → lib}/utils/compress-util.d.ts +0 -0
  107. package/dist/lib/utils/compress-util.d.ts.map +1 -0
  108. package/dist/{esm/lib → lib}/utils/compress-util.js +0 -0
  109. package/dist/lib/utils/compress-util.js.map +1 -0
  110. package/dist/{es5/lib → lib}/utils/file-utils.d.ts +0 -0
  111. package/dist/lib/utils/file-utils.d.ts.map +1 -0
  112. package/dist/{esm/lib → lib}/utils/file-utils.js +0 -0
  113. package/dist/lib/utils/file-utils.js.map +1 -0
  114. package/dist/{es5/lib → lib}/utils/lod-conversion-utils.d.ts +0 -0
  115. package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -0
  116. package/dist/{esm/lib → lib}/utils/lod-conversion-utils.js +0 -0
  117. package/dist/lib/utils/lod-conversion-utils.js.map +1 -0
  118. package/dist/{es5/lib → lib}/utils/statistic-utills.d.ts +0 -0
  119. package/dist/lib/utils/statistic-utills.d.ts.map +1 -0
  120. package/dist/{esm/lib → lib}/utils/statistic-utills.js +0 -0
  121. package/dist/lib/utils/statistic-utills.js.map +1 -0
  122. package/dist/pgm-loader.d.ts +6 -0
  123. package/dist/pgm-loader.d.ts.map +1 -0
  124. package/dist/{esm/pgm-loader.js → pgm-loader.js} +1 -1
  125. package/dist/pgm-loader.js.map +1 -0
  126. package/package.json +18 -19
  127. package/src/3d-tiles-converter/3d-tiles-converter.ts +4 -1
  128. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +6 -5
  129. package/src/i3s-converter/helpers/geometry-converter.js +39 -4
  130. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +0 -507
  131. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +0 -1
  132. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +0 -366
  133. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +0 -1
  134. package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -26
  135. package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +0 -1
  136. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js +0 -40
  137. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +0 -1
  138. package/dist/es5/3d-tiles-converter/json-templates/tileset.js +0 -67
  139. package/dist/es5/3d-tiles-converter/json-templates/tileset.js.map +0 -1
  140. package/dist/es5/bundle.js +0 -7
  141. package/dist/es5/bundle.js.map +0 -1
  142. package/dist/es5/deps-installer/deps-installer.js +0 -83
  143. package/dist/es5/deps-installer/deps-installer.js.map +0 -1
  144. package/dist/es5/i3s-converter/helpers/coordinate-converter.js +0 -104
  145. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +0 -1
  146. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js +0 -54
  147. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +0 -1
  148. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +0 -218
  149. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +0 -1
  150. package/dist/es5/i3s-converter/helpers/geometry-converter.js +0 -911
  151. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +0 -1
  152. package/dist/es5/i3s-converter/helpers/node-debug.js +0 -99
  153. package/dist/es5/i3s-converter/helpers/node-debug.js.map +0 -1
  154. package/dist/es5/i3s-converter/helpers/node-pages.js +0 -258
  155. package/dist/es5/i3s-converter/helpers/node-pages.js.map +0 -1
  156. package/dist/es5/i3s-converter/i3s-converter.js +0 -1860
  157. package/dist/es5/i3s-converter/i3s-converter.js.map +0 -1
  158. package/dist/es5/i3s-converter/json-templates/layers.js +0 -239
  159. package/dist/es5/i3s-converter/json-templates/layers.js.map +0 -1
  160. package/dist/es5/i3s-converter/json-templates/metadata.js +0 -33
  161. package/dist/es5/i3s-converter/json-templates/metadata.js.map +0 -1
  162. package/dist/es5/i3s-converter/json-templates/node.js +0 -109
  163. package/dist/es5/i3s-converter/json-templates/node.js.map +0 -1
  164. package/dist/es5/i3s-converter/json-templates/scene-server.js +0 -41
  165. package/dist/es5/i3s-converter/json-templates/scene-server.js.map +0 -1
  166. package/dist/es5/i3s-converter/json-templates/shared-resources.js +0 -196
  167. package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +0 -1
  168. package/dist/es5/i3s-converter/json-templates/store.js +0 -107
  169. package/dist/es5/i3s-converter/json-templates/store.js.map +0 -1
  170. package/dist/es5/i3s-converter/types.js +0 -2
  171. package/dist/es5/i3s-server/app.js +0 -23
  172. package/dist/es5/i3s-server/app.js.map +0 -1
  173. package/dist/es5/i3s-server/controllers/index-controller.js +0 -73
  174. package/dist/es5/i3s-server/controllers/index-controller.js.map +0 -1
  175. package/dist/es5/i3s-server/routes/index.js +0 -49
  176. package/dist/es5/i3s-server/routes/index.js.map +0 -1
  177. package/dist/es5/index.js +0 -40
  178. package/dist/es5/index.js.map +0 -1
  179. package/dist/es5/lib/utils/compress-util.js +0 -424
  180. package/dist/es5/lib/utils/compress-util.js.map +0 -1
  181. package/dist/es5/lib/utils/file-utils.js +0 -137
  182. package/dist/es5/lib/utils/file-utils.js.map +0 -1
  183. package/dist/es5/lib/utils/lod-conversion-utils.js +0 -52
  184. package/dist/es5/lib/utils/lod-conversion-utils.js.map +0 -1
  185. package/dist/es5/lib/utils/statistic-utills.js +0 -196
  186. package/dist/es5/lib/utils/statistic-utills.js.map +0 -1
  187. package/dist/es5/pgm-loader.js +0 -51
  188. package/dist/es5/pgm-loader.js.map +0 -1
  189. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +0 -1
  190. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +0 -1
  191. package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +0 -1
  192. package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +0 -1
  193. package/dist/esm/3d-tiles-converter/json-templates/tileset.js.map +0 -1
  194. package/dist/esm/bundle.js.map +0 -1
  195. package/dist/esm/deps-installer/deps-installer.d.ts +0 -10
  196. package/dist/esm/deps-installer/deps-installer.js.map +0 -1
  197. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +0 -1
  198. package/dist/esm/i3s-converter/helpers/create-scene-server-path.js.map +0 -1
  199. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +0 -1
  200. package/dist/esm/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  201. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +0 -1
  202. package/dist/esm/i3s-converter/helpers/node-debug.js.map +0 -1
  203. package/dist/esm/i3s-converter/helpers/node-pages.js.map +0 -1
  204. package/dist/esm/i3s-converter/i3s-converter.js.map +0 -1
  205. package/dist/esm/i3s-converter/json-templates/layers.js.map +0 -1
  206. package/dist/esm/i3s-converter/json-templates/metadata.js.map +0 -1
  207. package/dist/esm/i3s-converter/json-templates/node.js.map +0 -1
  208. package/dist/esm/i3s-converter/json-templates/scene-server.js.map +0 -1
  209. package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +0 -1
  210. package/dist/esm/i3s-converter/json-templates/store.js.map +0 -1
  211. package/dist/esm/i3s-converter/types.js.map +0 -1
  212. package/dist/esm/i3s-server/app.js.map +0 -1
  213. package/dist/esm/i3s-server/bin/www +0 -102
  214. package/dist/esm/i3s-server/certs/cert.pem +0 -19
  215. package/dist/esm/i3s-server/certs/key.pem +0 -27
  216. package/dist/esm/i3s-server/controllers/index-controller.js.map +0 -1
  217. package/dist/esm/i3s-server/routes/index.js.map +0 -1
  218. package/dist/esm/index.js.map +0 -1
  219. package/dist/esm/lib/utils/compress-util.d.ts +0 -53
  220. package/dist/esm/lib/utils/compress-util.js.map +0 -1
  221. package/dist/esm/lib/utils/file-utils.d.ts +0 -43
  222. package/dist/esm/lib/utils/file-utils.js.map +0 -1
  223. package/dist/esm/lib/utils/lod-conversion-utils.d.ts +0 -32
  224. package/dist/esm/lib/utils/lod-conversion-utils.js.map +0 -1
  225. package/dist/esm/lib/utils/statistic-utills.d.ts +0 -25
  226. package/dist/esm/lib/utils/statistic-utills.js.map +0 -1
  227. package/dist/esm/pgm-loader.js.map +0 -1
@@ -0,0 +1,320 @@
1
+ import type { SceneLayer3D } from '@loaders.gl/i3s';
2
+ import { Tileset3D } from '@loaders.gl/tiles';
3
+ import { Geoid } from '@math.gl/geoid';
4
+ import NodePages from './helpers/node-pages';
5
+ import { LoaderWithParser } from '@loaders.gl/loader-utils';
6
+ import { I3SMaterialDefinition } from '@loaders.gl/i3s/src/types';
7
+ /**
8
+ * Converter from 3d-tiles tileset to i3s layer
9
+ */
10
+ export default class I3SConverter {
11
+ nodePages: NodePages;
12
+ fileMap: {
13
+ [key: string]: string;
14
+ };
15
+ options: any;
16
+ layers0Path: string;
17
+ materialMap: Map<any, any>;
18
+ materialDefinitions: I3SMaterialDefinition[];
19
+ vertexCounter: number;
20
+ layers0: SceneLayer3D | null;
21
+ featuresHashArray: string[];
22
+ refinementCounter: {
23
+ tilesCount: number;
24
+ tilesWithAddRefineCount: number;
25
+ };
26
+ validate: boolean;
27
+ boundingVolumeWarnings?: string[];
28
+ conversionStartTime: [number, number];
29
+ refreshTokenTime: [number, number];
30
+ sourceTileset: Tileset3D | null;
31
+ geoidHeightModel: Geoid | null;
32
+ Loader: LoaderWithParser;
33
+ generateTextures: boolean;
34
+ generateBoundingVolumes: boolean;
35
+ constructor();
36
+ /**
37
+ * Convert a 3d tileset
38
+ * @param options
39
+ * @param options.inputUrl the url to read the tileset from
40
+ * @param options.outputPath the output filename
41
+ * @param options.tilesetName the output name of the tileset
42
+ * @param options.maxDepth The max tree depth of conversion
43
+ * @param options.slpk Generate slpk (Scene Layer Packages) output file
44
+ * @param options.sevenZipExe Location of 7z.exe archiver to create slpk on Windows
45
+ * @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format
46
+ * @param options.token Token for Cesium ION tilesets authentication
47
+ * @param options.draco Generate I3S 1.7 draco compressed geometries
48
+ * @param options.validate -enable validation
49
+ */
50
+ convert(options: {
51
+ inputUrl: string;
52
+ outputPath: string;
53
+ tilesetName: string;
54
+ sevenZipExe: string;
55
+ egmFilePath: string;
56
+ maxDepth?: number;
57
+ slpk?: boolean;
58
+ token?: string;
59
+ draco?: boolean;
60
+ validate?: boolean;
61
+ generateTextures?: boolean;
62
+ generateBoundingVolumes?: boolean;
63
+ /** @deprecated */
64
+ inputType?: string;
65
+ }): Promise<any>;
66
+ /**
67
+ * Convert and save the layer and embedded tiles
68
+ * @param outputPath - path to save output data
69
+ * @param tilesetName - new tileset path
70
+ */
71
+ private _createAndSaveTileset;
72
+ /**
73
+ * Form object of 3DSceneLayer https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DSceneLayer.cmn.md
74
+ * @param tilesetName - Name of layer
75
+ */
76
+ private _formLayers0;
77
+ /**
78
+ * Convert and save the layer and embedded tiles
79
+ * @param boundingVolumes - mbs and obb data about node's bounding volume
80
+ * @return 3DNodeIndexDocument data https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md
81
+ */
82
+ private _formRootNodeIndexDocument;
83
+ /**
84
+ * Form object of 3DSceneLayer https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DSceneLayer.cmn.md
85
+ * @param root0 - 3DNodeIndexDocument of root node https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md
86
+ * @param sourceRootTile - Source (3DTile) tile data
87
+ * @param parentId - node id in node pages
88
+ * @param boundingVolumes - mbs and obb data about node's bounding volume
89
+ */
90
+ private _convertNodesTree;
91
+ /**
92
+ * Write 3DSceneLayer https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DSceneLayer.cmn.md in file
93
+ */
94
+ private _writeLayers0;
95
+ /**
96
+ * Write 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md in file
97
+ */
98
+ private _writeNodeIndexDocument;
99
+ /**
100
+ * Pack files into *.slpk archive
101
+ * @param tilesetPath - Path to save file
102
+ */
103
+ private _createSlpk;
104
+ /**
105
+ * Add child nodes recursively and write them to files
106
+ * @param data - arguments
107
+ * @param data.sourceTiles - array of source child nodes
108
+ * @param data.parentNode - 3DNodeIndexDocument of parent node for processing child nodes
109
+ * @param data.parentId - id of parent node in node pages
110
+ * @param data.level - level of node (distanse to root node in the tree)
111
+ */
112
+ private _addChildrenWithNeighborsAndWriteFile;
113
+ /**
114
+ * Add child nodes recursively and write them to files
115
+ * @param data - arguments
116
+ * @param data.childNodes - array of target child nodes
117
+ * @param data.sourceTiles - array of source child nodes
118
+ * @param data.parentNode - 3DNodeIndexDocument of parent node for processing child nodes
119
+ * @param data.parentId - id of parent node in node pages
120
+ * @param data.level - level of node (distanse to root node in the tree)
121
+ */
122
+ private _addChildren;
123
+ /**
124
+ * Add neightbors to 3DNodeIndexDocument and write it in a file
125
+ * @param parentNode - arguments
126
+ * @param childNodes - array of target child nodes
127
+ */
128
+ private _addNeighborsAndWriteFile;
129
+ /**
130
+ * Convert tile to one or more I3S nodes
131
+ * @param parentTile - parent 3DNodeIndexDocument
132
+ * @param sourceTile - source tile (3DTile)
133
+ * @param parentId - id of parent node in node pages
134
+ * @param level - level of node (distanse to root node in the tree)
135
+ */
136
+ private _createNode;
137
+ /**
138
+ * Convert attributesStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md
139
+ * from B3DM batch table
140
+ * @param sourceTileContent - tile content of 3DTile
141
+ * @return {void}
142
+ */
143
+ private _convertAttributeStorageInfo;
144
+ /**
145
+ * Convert tile to one or more I3S nodes
146
+ * @param sourceTile - source tile (3DTile)
147
+ * result.geometry - ArrayBuffer with geometry attributes
148
+ * result.compressedGeometry - ArrayBuffer with compressed (draco) geometry
149
+ * result.texture - texture image
150
+ * result.sharedResources - shared resource data object
151
+ * result.meshMaterial - PBR-like material object
152
+ * result.vertexCount - number of vertices in geometry
153
+ * result.attributes - feature attributes
154
+ * result.featureCount - number of features
155
+ */
156
+ private _convertResources;
157
+ /**
158
+ * Create a new node object (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/node.cmn.md)
159
+ * in node pages (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/nodePage.cmn.md)
160
+ * @param maxScreenThresholdSQ - Level of Details (LOD) metric
161
+ * @param boundingVolumes - Bounding volumes
162
+ * @param sourceTile - source tile (3DTile)
163
+ * @param parentId - id of parent node in node pages
164
+ * @param resources - the node resources data
165
+ * @param resources.meshMaterial - PBR-like material object
166
+ * @param resources.texture - texture image
167
+ * @param resources.vertexCount - number of vertices in geometry
168
+ * @param resources.featureCount - number of features
169
+ * @return the node object in node pages
170
+ */
171
+ private _createNodeInNodePages;
172
+ /**
173
+ * Create a new node page object in node pages
174
+ * @param parentNode - 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md object of the parent node
175
+ * @param boundingVolumes - Bounding volumes
176
+ * @param lodSelection - Level of Details (LOD) metrics
177
+ * @param nodeInPage - corresponding node object in a node page
178
+ * @param resources - the node resources data
179
+ * @param resources.texture - texture image
180
+ * @param resources.attributes - feature attributes
181
+ * @return 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md object
182
+ */
183
+ private _createNodeIndexDocument;
184
+ /**
185
+ * Write node resources in files
186
+ * @param resources - source tile (3DTile)
187
+ * @param resources.geometry - Uint8Array with geometry attributes
188
+ * @param resources.compressedGeometry - Uint8Array with compressed (draco) geometry
189
+ * @param resources.texture - texture image
190
+ * @param resources.sharedResources - shared resource data object
191
+ * @param resources.attributes - feature attributes
192
+ * @return {Promise<void>}
193
+ */
194
+ private _writeResources;
195
+ /**
196
+ * Write non-compressed and compressed geometries in files
197
+ * @param geometryBuffer - Uint8Array with geometry attributes
198
+ * @param compressedGeometry - Uint8Array with compressed (draco) geometry
199
+ * @param childPath - a child path to write resources
200
+ * @param slpkChildPath - resource path inside *slpk file
201
+ */
202
+ private _writeGeometries;
203
+ /**
204
+ * Write shared resources in a file
205
+ * @param sharedResources - shared resource data object
206
+ * @param childPath - a child path to write resources
207
+ * @param slpkChildPath - resource path inside *slpk file
208
+ * @param nodePath - a node path
209
+ */
210
+ private _writeShared;
211
+ /**
212
+ * Generates textures based on texture mime type and fill in textureSetDefinitions data.
213
+ * @param texture - the texture image
214
+ * @param childPath - a child path to write resources
215
+ * @param slpkChildPath - the resource path inside *slpk file
216
+ */
217
+ private _writeTexture;
218
+ /**
219
+ * Write the texture image in a file
220
+ * @param textureData
221
+ * @param name
222
+ * @param format
223
+ * @param childPath
224
+ * @param slpkChildPath
225
+ */
226
+ private writeTextureFile;
227
+ /**
228
+ * Write feature attributes in files
229
+ * @param attributes - feature attributes
230
+ * @param childPath - a child path to write resources
231
+ * @param slpkChildPath - the resource path inside *slpk file
232
+ */
233
+ private _writeAttributes;
234
+ /**
235
+ * Return file format by its MIME type
236
+ * @param mimeType - feature attributes
237
+ */
238
+ private _getFormatByMimeType;
239
+ /**
240
+ * Find or create material in materialDefinitions array
241
+ * @param material - end-to-end index of the node
242
+ * @return material id
243
+ */
244
+ private _findOrCreateMaterial;
245
+ /**
246
+ * Generate storage attribute for map segmentation.
247
+ * @param attributeIndex - order index of attribute (f_0, f_1 ...).
248
+ * @param key - attribute key from batch table.\
249
+ * @param attributeType - attribute type.
250
+ * @return Updated storageAttribute.
251
+ */
252
+ private _createdStorageAttribute;
253
+ /**
254
+ * Get the attribute type for attributeStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md
255
+ * @param key - attribute's key
256
+ * @param attribute - attribute's type in batchTable
257
+ */
258
+ private getAttributeType;
259
+ /**
260
+ * Setup storage attribute as string.
261
+ * @param storageAttribute - attribute for map segmentation.
262
+ */
263
+ private _setupStringAttribute;
264
+ /**
265
+ * Setup Id attribute for map segmentation.
266
+ * @param storageAttribute - attribute for map segmentation .
267
+ */
268
+ private _setupIdAttribute;
269
+ /**
270
+ * Setup double attribute for map segmentation.
271
+ * @param storageAttribute - attribute for map segmentation .
272
+ */
273
+ private _setupDoubleAttribute;
274
+ /**
275
+ * Setup field attribute for map segmentation.
276
+ * @param key - attribute for map segmentation.
277
+ * @param fieldAttributeType - esri attribute type ('esriFieldTypeString' or 'esriFieldTypeOID').
278
+ */
279
+ private _createFieldAttribute;
280
+ /**
281
+ * Do conversion of 3DTiles batch table to I3s node attributes.
282
+ * @param batchTable - Table with layer meta data.
283
+ */
284
+ private _convertBatchTableInfoToNodeAttributes;
285
+ /**
286
+ * Find and return attribute type based on key form Batch table.
287
+ * @param attributeType
288
+ */
289
+ private _getFieldAttributeType;
290
+ /**
291
+ * Generate popup info to show metadata on the map.
292
+ * @param batchTable - Batch table data with OBJECTID.
293
+ * @return data for correct rendering of popup.
294
+ */
295
+ private _createPopupInfo;
296
+ /**
297
+ * Print statistics in the end of conversion
298
+ * @param params - output files data
299
+ */
300
+ private _finishConversion;
301
+ /**
302
+ * Fetch preload options for ION tileset
303
+ */
304
+ private _fetchPreloadOptions;
305
+ /**
306
+ * Update options of source tileset
307
+ */
308
+ private _updateTilesetOptions;
309
+ /** Do calculations of all tiles and tiles with "ADD" type of refinement.
310
+ * @param tile
311
+ */
312
+ private _checkAddRefinementTypeForTile;
313
+ /**
314
+ * Check if the tile's content format is supported by the converter
315
+ * @param sourceRootTile
316
+ * @returns
317
+ */
318
+ private isContentSupported;
319
+ }
320
+ //# sourceMappingURL=i3s-converter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i3s-converter.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/i3s-converter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,YAAY,EAab,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAOrC,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAuB7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,qBAAqB,EAA8B,MAAM,2BAA2B,CAAC;AAmB7F;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM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ACH,OAAO,CAAC,sBAAsB;IAe9B;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAgCxB;;;OAGG;YACW,iBAAiB;IAqB/B;;OAEG;YACW,oBAAoB;IAYlC;;OAEG;YACW,qBAAqB;IAkBnC;;OAEG;IACH,OAAO,CAAC,8BAA8B;IAUtC;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;CAG3B"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/i3s-converter/i3s-converter.ts"],"names":["load","encode","Tileset3D","CesiumIonLoader","Tiles3DLoader","join","v4","uuidv4","process","transform","md5","NodePages","writeFile","removeDir","writeFileForSlpk","compressWithChildProcess","calculateFilesSize","timeConverter","convertB3dmToI3sGeometry","createBoundingVolumes","convertCommonToI3SExtentCoordinate","createSceneServerPath","convertGeometricErrorToScreenThreshold","PGMLoader","LAYERS","layersTemplate","NODE","nodeTemplate","SHARED_RESOURCES","sharedResourcesTemplate","validateNodeBoundingVolumes","KTX2BasisUniversalTextureWriter","ImageWriter","ION_DEFAULT_TOKEN","env","IonToken","HARDCODED_NODES_PER_PAGE","_3D_TILES","_3D_OBJECT_LAYER_TYPE","STRING_TYPE","SHORT_INT_TYPE","DOUBLE_TYPE","OBJECT_ID_TYPE","REFRESH_TOKEN_TIMEOUT","CESIUM_DATASET_PREFIX","I3SConverter","constructor","nodePages","fileMap","options","layers0Path","materialMap","Map","materialDefinitions","vertexCounter","layers0","featuresHashArray","refinementCounter","tilesCount","tilesWithAddRefineCount","validate","generateTextures","generateBoundingVolumes","convert","conversionStartTime","hrtime","tilesetName","slpk","egmFilePath","inputUrl","outputPath","draco","sevenZipExe","maxDepth","token","Boolean","Loader","indexOf","console","log","geoidHeightModel","useWriteFunction","preloadOptions","_fetchPreloadOptions","tilesetOptions","loadOptions","basis","format","headers","fetch","Object","assign","sourceTilesetJson","sourceTileset","_createAndSaveTileset","_finishConversion","tilesetPath","e","_formLayers0","sourceRootTile","root","boundingVolumes","parentId","push","index","lodThreshold","obb","children","isCreateSlpk","root0","_formRootNodeIndexDocument","_convertNodesTree","_writeLayers0","_writeNodeIndexDocument","save","_createSlpk","extent","layers0data","version","toUpperCase","id","name","href","store","nodesPerPage","compressGeometry","root0data","level","lodSelection","metricType","maxError","_loadTile","isContentSupported","child","_createNode","childPath","path","JSON","stringify","_addChildrenWithNeighborsAndWriteFile","parentNode","sourceTiles","unloadContent","nodePath","rootPath","slpkTilesetPath","slpkFileName","data","childNodes","_addChildren","_addNeighborsAndWriteFile","sourceTile","type","mbs","node","Number","length","neighbor","neighbors","warn","parentTile","_checkAddRefinementTypeForTile","_updateTilesetOptions","batchTable","content","batchTableJson","_convertAttributeStorageInfo","resourcesData","_convertResources","nodes","nodesInPage","emptyResources","geometry","compressedGeometry","texture","sharedResources","meshMaterial","vertexCount","attributes","featureCount","resources","maxScreenThresholdSQ","find","val","nodeInPage","_createNodeInNodePages","_createNodeIndexDocument","mesh","_writeResources","boundingVolumeWarnings","sourceTileContent","attributeStorageInfo","_convertBatchTableInfoToNodeAttributes","nodesCounter","definition","resource","attribute","material","nodeId","updateMaterialByNodeId","_findOrCreateMaterial","texelCountHint","image","height","width","updateTexelCountHintByNodeId","updateVertexCountByNodeId","updateNodeAttributeByNodeId","updateFeatureCountByNodeId","nodeData","toString","geometryData","sharedResource","textureData","attributeData","folderName","key","geometryBuffer","slpkChildPath","_writeGeometries","_writeShared","_writeTexture","_writeAttributes","slpkGeometryPath","geometryPath","slpkCompressedGeometryPath","compressedGeometryPath","sharedData","sharedDataStr","slpkSharedPath","sharedPath","_getFormatByMimeType","mimeType","formats","bufferView","writeTextureFile","ktx2TextureData","Uint8Array","decodedFromKTX2TextureData","textureSetDefinitions","texturePath","slpkTexturePath","compress","fileBuffer","slpkAttributesPath","attributesPath","hash","has","get","newMaterialId","set","_createdStorageAttribute","attributeIndex","attributeType","storageAttribute","ordering","header","property","valueType","attributeValues","valuesPerElement","_setupIdAttribute","_setupStringAttribute","_setupDoubleAttribute","getAttributeType","isInteger","unshift","encoding","attributeByteCounts","_createFieldAttribute","fieldAttributeType","alias","batchTableWithObjectId","OBJECTID","firstAttribute","_getFieldAttributeType","fieldAttribute","popupInfo","_createPopupInfo","fields","layerType","title","mediaInfos","fieldInfos","popupElements","expressionInfos","fieldName","visible","isEditable","label","params","addRefinementPercentage","filesSize","diff","conversionTime","preload","accessToken","refreshTokenTime","tile","ADD_TILE_REFINEMENT","refine","includes"],"mappings":";AAmBA,SAAQA,IAAR,EAAcC,MAAd,QAA2B,kBAA3B;AACA,SAAQC,SAAR,QAAwB,mBAAxB;AACA,SAAQC,eAAR,EAAyBC,aAAzB,QAA6C,sBAA7C;AAEA,SAAQC,IAAR,QAAmB,MAAnB;AACA,SAAQC,EAAE,IAAIC,MAAd,QAA2B,MAA3B;AACA,OAAOC,OAAP,MAAoB,SAApB;AACA,OAAOC,SAAP,MAAsB,oBAAtB;AACA,OAAOC,GAAP,MAAgB,KAAhB;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;AACA,SAAQC,SAAR,EAAmBC,SAAnB,EAA8BC,gBAA9B,QAAqD,yBAArD;AACA,SACEC,wBADF,QAIO,4BAJP;AAKA,SAAQC,kBAAR,EAA4BC,aAA5B,QAAgD,+BAAhD;AACA,OAAOC,wBAAP,MAAqC,8BAArC;AACA,SACEC,qBADF,EAEEC,kCAFF,QAGO,gCAHP;AAIA,SAAQC,qBAAR,QAAoC,oCAApC;AACA,SAAQC,sCAAR,QAAqD,mCAArD;AACA,SAAQC,SAAR,QAAwB,eAAxB;AAEA,SAAQC,MAAM,IAAIC,cAAlB,QAAuC,yBAAvC;AACA,SAAQC,IAAI,IAAIC,YAAhB,QAAmC,uBAAnC;AACA,SAAQC,gBAAgB,IAAIC,uBAA5B,QAA0D,mCAA1D;AACA,SAAQC,2BAAR,QAA0C,sBAA1C;AAEA,SAAQC,+BAAR,QAA8C,sBAA9C;AAGA,SAAQC,WAAR,QAA0B,oBAA1B;AAIA,MAAMC,iBAAiB,GACrBzB,OAAO,CA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AiC,SAAGiC;AAApC,KAA9B;;AACA,QAAIA,cAAc,CAACM,OAAnB,EAA4B;AAC1B,WAAKK,aAAL,CAAoBR,WAApB,CAAgCI,KAAhC,GAAwC,EACtC,GAAG,KAAKI,aAAL,CAAoBR,WAApB,CAAgCI,KADG;AAEtCD,QAAAA,OAAO,EAAEN,cAAc,CAACM;AAFc,OAAxC;AAIAV,MAAAA,OAAO,CAACC,GAAR,CAAY,6CAAZ;AACD;AACF;;AAKOkF,EAAAA,8BAA8B,CAACyI,IAAD,EAAyB;AAC7D,UAAMC,mBAAmB,GAAG,CAA5B;;AAEA,QAAID,IAAI,CAACE,MAAL,KAAgBD,mBAApB,EAAyC;AACvC,WAAKlP,iBAAL,CAAuBE,uBAAvB,IAAkD,CAAlD;AACAmB,MAAAA,OAAO,CAACiF,IAAR,CAAa,yCAAb;AACD;;AAED,SAAKtG,iBAAL,CAAuBC,UAAvB,IAAqC,CAArC;AACD;;AAMO0E,EAAAA,kBAAkB,CAACjC,cAAD,EAAkC;AAAA;;AAC1D,WAAO,CAAC,MAAD,EAAS,MAAT,EAAiB0M,QAAjB,CAA0B1M,cAA1B,aAA0BA,cAA1B,gDAA0BA,cAAc,CAAEiE,OAA1C,0DAA0B,sBAAyBZ,IAAnD,CAAP;AACD;;AAvsC+B","sourcesContent":["import type {Tile3D, Tileset3DProps} from '@loaders.gl/tiles';\nimport type {BatchTableJson, B3DMContent} from '@loaders.gl/3d-tiles';\n\nimport type {\n AttributeStorageInfo,\n SceneLayer3D,\n BoundingVolumes,\n Node3DIndexDocument,\n NodeReference,\n MaxScreenThresholdSQ,\n NodeInPage,\n LodSelection,\n SharedResources,\n Attribute,\n ESRIField,\n Field,\n PopupInfo,\n FieldInfo\n} from '@loaders.gl/i3s';\nimport {load, encode} from '@loaders.gl/core';\nimport {Tileset3D} from '@loaders.gl/tiles';\nimport {CesiumIonLoader, Tiles3DLoader} from '@loaders.gl/3d-tiles';\nimport {Geoid} from '@math.gl/geoid';\nimport {join} from 'path';\nimport {v4 as uuidv4} from 'uuid';\nimport process from 'process';\nimport transform from 'json-map-transform';\nimport md5 from 'md5';\n\nimport NodePages from './helpers/node-pages';\nimport {writeFile, removeDir, writeFileForSlpk} from '../lib/utils/file-utils';\nimport {\n compressWithChildProcess\n // generateHash128FromZip,\n // addFileToZip\n} from '../lib/utils/compress-util';\nimport {calculateFilesSize, timeConverter} from '../lib/utils/statistic-utills';\nimport convertB3dmToI3sGeometry from './helpers/geometry-converter';\nimport {\n createBoundingVolumes,\n convertCommonToI3SExtentCoordinate\n} from './helpers/coordinate-converter';\nimport {createSceneServerPath} from './helpers/create-scene-server-path';\nimport {convertGeometricErrorToScreenThreshold} from '../lib/utils/lod-conversion-utils';\nimport {PGMLoader} from '../pgm-loader';\n\nimport {LAYERS as layersTemplate} from './json-templates/layers';\nimport {NODE as nodeTemplate} from './json-templates/node';\nimport {SHARED_RESOURCES as sharedResourcesTemplate} from './json-templates/shared-resources';\nimport {validateNodeBoundingVolumes} from './helpers/node-debug';\nimport TileHeader from '@loaders.gl/tiles/src/tileset/tile-3d';\nimport {KTX2BasisUniversalTextureWriter} from '@loaders.gl/textures';\nimport {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {I3SMaterialDefinition, TextureSetDefinitionFormats} from '@loaders.gl/i3s/src/types';\nimport {ImageWriter} from '@loaders.gl/images';\nimport {GLTFImagePostprocessed} from '@loaders.gl/gltf';\nimport {I3SConvertedResources} from './types';\n\nconst ION_DEFAULT_TOKEN =\n process.env.IonToken || // eslint-disable-line\n 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWMxMzcyYy0zZjJkLTQwODctODNlNi01MDRkZmMzMjIxOWIiLCJpZCI6OTYyMCwic2NvcGVzIjpbImFzbCIsImFzciIsImdjIl0sImlhdCI6MTU2Mjg2NjI3M30.1FNiClUyk00YH_nWfSGpiQAjR5V2OvREDq1PJ5QMjWQ'; // eslint-disable-line\nconst HARDCODED_NODES_PER_PAGE = 64;\nconst _3D_TILES = '3DTILES';\nconst _3D_OBJECT_LAYER_TYPE = '3DObject';\nconst STRING_TYPE = 'string';\nconst SHORT_INT_TYPE = 'Int32';\nconst DOUBLE_TYPE = 'double';\nconst OBJECT_ID_TYPE = 'OBJECTID';\nconst REFRESH_TOKEN_TIMEOUT = 1800; // 30 minutes in seconds\nconst CESIUM_DATASET_PREFIX = 'https://';\n// const FS_FILE_TOO_LARGE = 'ERR_FS_FILE_TOO_LARGE';\n\n/**\n * Converter from 3d-tiles tileset to i3s layer\n */\nexport default class I3SConverter {\n nodePages: NodePages;\n fileMap: {[key: string]: string};\n options: any;\n layers0Path: string;\n materialMap: Map<any, any>;\n materialDefinitions: I3SMaterialDefinition[];\n vertexCounter: number;\n layers0: SceneLayer3D | null;\n featuresHashArray: string[];\n refinementCounter: {\n tilesCount: number;\n tilesWithAddRefineCount: number;\n };\n validate: boolean;\n boundingVolumeWarnings?: string[] = [];\n conversionStartTime: [number, number] = [0, 0];\n refreshTokenTime: [number, number] = [0, 0];\n sourceTileset: Tileset3D | null = null;\n geoidHeightModel: Geoid | null = null;\n Loader: LoaderWithParser = Tiles3DLoader;\n generateTextures: boolean;\n generateBoundingVolumes: boolean;\n\n constructor() {\n this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);\n this.fileMap = {};\n this.options = {};\n this.layers0Path = '';\n this.materialMap = new Map();\n this.materialDefinitions = [];\n this.vertexCounter = 0;\n this.layers0 = null;\n this.featuresHashArray = [];\n this.refinementCounter = {\n tilesCount: 0,\n tilesWithAddRefineCount: 0\n };\n this.validate = false;\n this.generateTextures = false;\n this.generateBoundingVolumes = false;\n }\n\n /**\n * Convert a 3d tileset\n * @param options\n * @param options.inputUrl the url to read the tileset from\n * @param options.outputPath the output filename\n * @param options.tilesetName the output name of the tileset\n * @param options.maxDepth The max tree depth of conversion\n * @param options.slpk Generate slpk (Scene Layer Packages) output file\n * @param options.sevenZipExe Location of 7z.exe archiver to create slpk on Windows\n * @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format\n * @param options.token Token for Cesium ION tilesets authentication\n * @param options.draco Generate I3S 1.7 draco compressed geometries\n * @param options.validate -enable validation\n */\n async convert(options: {\n inputUrl: string;\n outputPath: string;\n tilesetName: string;\n sevenZipExe: string;\n egmFilePath: string;\n maxDepth?: number;\n slpk?: boolean;\n token?: string;\n draco?: boolean;\n validate?: boolean;\n generateTextures?: boolean;\n generateBoundingVolumes?: boolean;\n /** @deprecated */\n inputType?: string;\n }): Promise<any> {\n this.conversionStartTime = process.hrtime();\n const {\n tilesetName,\n slpk,\n egmFilePath,\n inputUrl,\n validate,\n outputPath,\n draco,\n sevenZipExe,\n maxDepth,\n token,\n generateTextures,\n generateBoundingVolumes\n } = options;\n this.options = {maxDepth, slpk, sevenZipExe, egmFilePath, draco, token, inputUrl};\n this.validate = Boolean(validate);\n this.Loader = inputUrl.indexOf(CESIUM_DATASET_PREFIX) !== -1 ? CesiumIonLoader : Tiles3DLoader;\n this.generateTextures = Boolean(generateTextures);\n this.generateBoundingVolumes = Boolean(generateBoundingVolumes);\n\n console.log('Loading egm file...'); // eslint-disable-line\n this.geoidHeightModel = await load(egmFilePath, PGMLoader);\n console.log('Loading egm file completed!'); // eslint-disable-line\n\n if (slpk) {\n this.nodePages.useWriteFunction(writeFileForSlpk);\n }\n\n const preloadOptions = await this._fetchPreloadOptions();\n const tilesetOptions: Tileset3DProps = {loadOptions: {basis: {format: 'rgba32'}}};\n if (preloadOptions.headers) {\n tilesetOptions.loadOptions!.fetch = {headers: preloadOptions.headers};\n }\n Object.assign(tilesetOptions, preloadOptions);\n const sourceTilesetJson = await load(inputUrl, this.Loader, tilesetOptions.loadOptions);\n // console.log(tilesetJson); // eslint-disable-line\n this.sourceTileset = new Tileset3D(sourceTilesetJson, tilesetOptions);\n\n await this._createAndSaveTileset(outputPath, tilesetName);\n await this._finishConversion({slpk: Boolean(slpk), outputPath, tilesetName});\n return sourceTilesetJson;\n }\n\n /**\n * Convert and save the layer and embedded tiles\n * @param outputPath - path to save output data\n * @param tilesetName - new tileset path\n */\n private async _createAndSaveTileset(outputPath: string, tilesetName: string): Promise<void> {\n const tilesetPath = join(`${outputPath}`, `${tilesetName}`);\n // Removing the tilesetPath needed to exclude erroneous files after conversion\n try {\n await removeDir(tilesetPath);\n } catch (e) {\n // do nothing\n }\n\n this.layers0Path = join(tilesetPath, 'SceneServer', 'layers', '0');\n\n this._formLayers0(tilesetName);\n\n this.materialDefinitions = [];\n this.materialMap = new Map();\n\n const sourceRootTile: TileHeader = this.sourceTileset!.root!;\n const boundingVolumes = createBoundingVolumes(sourceRootTile, this.geoidHeightModel!);\n const parentId = this.nodePages.push({\n index: 0,\n lodThreshold: 0,\n obb: boundingVolumes.obb,\n children: []\n });\n\n const isCreateSlpk = this.options.slpk;\n const root0 = this._formRootNodeIndexDocument(boundingVolumes);\n\n await this._convertNodesTree(root0, sourceRootTile, parentId, boundingVolumes);\n\n this.layers0!.materialDefinitions = this.materialDefinitions;\n await this._writeLayers0();\n createSceneServerPath(tilesetName, this.layers0, tilesetPath);\n await this._writeNodeIndexDocument(root0, 'root', join(this.layers0Path, 'nodes', 'root'));\n await this.nodePages.save(this.layers0Path, this.fileMap, isCreateSlpk);\n await this._createSlpk(tilesetPath);\n }\n\n /**\n * Form object of 3DSceneLayer https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DSceneLayer.cmn.md\n * @param tilesetName - Name of layer\n */\n private _formLayers0(tilesetName: string): void {\n const extent = convertCommonToI3SExtentCoordinate(this.sourceTileset);\n const layers0data = {\n version: `{${uuidv4().toUpperCase()}}`,\n id: 0,\n name: tilesetName,\n href: './layers/0',\n store: {\n id: `{${uuidv4().toUpperCase()}}`,\n extent\n },\n nodePages: {\n nodesPerPage: HARDCODED_NODES_PER_PAGE\n },\n compressGeometry: this.options.draco\n };\n\n this.layers0 = transform(layers0data, layersTemplate());\n }\n\n /**\n * Convert and save the layer and embedded tiles\n * @param boundingVolumes - mbs and obb data about node's bounding volume\n * @return 3DNodeIndexDocument data https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md\n */\n private _formRootNodeIndexDocument(boundingVolumes: BoundingVolumes): Node3DIndexDocument {\n const root0data = {\n version: `{${uuidv4().toUpperCase()}}`,\n id: 'root',\n level: 0,\n lodSelection: [\n {\n metricType: 'maxScreenThresholdSQ',\n maxError: 0\n },\n {\n metricType: 'maxScreenThreshold',\n maxError: 0\n }\n ],\n ...boundingVolumes,\n children: []\n };\n return transform(root0data, nodeTemplate());\n }\n\n /**\n * Form object of 3DSceneLayer https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DSceneLayer.cmn.md\n * @param root0 - 3DNodeIndexDocument of root node https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md\n * @param sourceRootTile - Source (3DTile) tile data\n * @param parentId - node id in node pages\n * @param boundingVolumes - mbs and obb data about node's bounding volume\n */\n private async _convertNodesTree(\n root0: Node3DIndexDocument,\n sourceRootTile: TileHeader,\n parentId: number,\n boundingVolumes: BoundingVolumes\n ): Promise<void> {\n await this.sourceTileset!._loadTile(sourceRootTile);\n if (this.isContentSupported(sourceRootTile)) {\n root0.children = root0.children || [];\n root0.children.push({\n id: '1',\n href: './1',\n ...boundingVolumes\n });\n const [child] = await this._createNode(root0, sourceRootTile, parentId, 0);\n const childPath = join(this.layers0Path, 'nodes', child.path!);\n\n if (this.options.slpk) {\n this.fileMap['nodes/1/3dNodeIndexDocument.json.gz'] = await writeFileForSlpk(\n childPath,\n JSON.stringify(child),\n '3dNodeIndexDocument.json'\n );\n } else {\n await writeFile(childPath, JSON.stringify(child));\n }\n } else {\n await this._addChildrenWithNeighborsAndWriteFile({\n parentNode: root0,\n sourceTiles: sourceRootTile.children,\n parentId,\n level: 1\n });\n }\n await sourceRootTile.unloadContent();\n }\n\n /**\n * Write 3DSceneLayer https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DSceneLayer.cmn.md in file\n */\n private async _writeLayers0(): Promise<void> {\n if (this.options.slpk) {\n this.fileMap['3dSceneLayer.json.gz'] = await writeFileForSlpk(\n this.layers0Path,\n JSON.stringify(this.layers0),\n '3dSceneLayer.json'\n );\n } else {\n await writeFile(this.layers0Path, JSON.stringify(this.layers0));\n }\n }\n\n /**\n * Write 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md in file\n */\n private async _writeNodeIndexDocument(\n root0: Node3DIndexDocument,\n nodePath: string,\n rootPath: string\n ): Promise<void> {\n if (this.options.slpk) {\n this.fileMap[`nodes/${nodePath}/3dNodeIndexDocument.json.gz`] = await writeFileForSlpk(\n rootPath,\n JSON.stringify(root0),\n '3dNodeIndexDocument.json'\n );\n } else {\n await writeFile(rootPath, JSON.stringify(root0));\n }\n }\n\n /**\n * Pack files into *.slpk archive\n * @param tilesetPath - Path to save file\n */\n private async _createSlpk(tilesetPath: string): Promise<void> {\n if (this.options.slpk) {\n const slpkTilesetPath = join(tilesetPath, 'SceneServer', 'layers', '0');\n const slpkFileName = `${tilesetPath}.slpk`;\n await compressWithChildProcess(\n slpkTilesetPath,\n slpkFileName,\n 0,\n '.',\n // @ts-expect-error\n this.options.sevenZipExe\n );\n\n // TODO: `addFileToZip` corrupts archive so it can't be validated with windows i3s_converter.exe\n // const fileHash128Path = `${tilesetPath}/@specialIndexFileHASH128@`;\n // try {\n // await generateHash128FromZip(slpkFileName, fileHash128Path);\n // await addFileToZip(\n // tilesetPath,\n // '@specialIndexFileHASH128@',\n // slpkFileName,\n // this.options.sevenZipExe\n // );\n // } catch (error) {\n // if (error.code === FS_FILE_TOO_LARGE) {\n // console.warn(`${slpkFileName} file is too big to generate a hash`); // eslint-disable-line\n // } else {\n // console.error(error); // eslint-disable-line\n // }\n // }\n // All converted files are contained in slpk now they can be deleted\n try {\n await removeDir(tilesetPath);\n } catch (e) {\n // do nothing\n }\n }\n }\n\n /**\n * Add child nodes recursively and write them to files\n * @param data - arguments\n * @param data.sourceTiles - array of source child nodes\n * @param data.parentNode - 3DNodeIndexDocument of parent node for processing child nodes\n * @param data.parentId - id of parent node in node pages\n * @param data.level - level of node (distanse to root node in the tree)\n */\n private async _addChildrenWithNeighborsAndWriteFile(data: {\n parentNode: Node3DIndexDocument;\n sourceTiles: TileHeader[];\n parentId: number;\n level: number;\n }): Promise<void> {\n const childNodes = [];\n await this._addChildren({...data, childNodes});\n await this._addNeighborsAndWriteFile(data.parentNode, childNodes);\n }\n\n /**\n * Add child nodes recursively and write them to files\n * @param data - arguments\n * @param data.childNodes - array of target child nodes\n * @param data.sourceTiles - array of source child nodes\n * @param data.parentNode - 3DNodeIndexDocument of parent node for processing child nodes\n * @param data.parentId - id of parent node in node pages\n * @param data.level - level of node (distanse to root node in the tree)\n */\n private async _addChildren(data: {\n childNodes: NodeReference[];\n sourceTiles: TileHeader[];\n parentNode: Node3DIndexDocument;\n parentId: number;\n level: number;\n }): Promise<void> {\n const {childNodes, sourceTiles, parentNode, parentId, level} = data;\n if (this.options.maxDepth && level > this.options.maxDepth) {\n return;\n }\n for (const sourceTile of sourceTiles) {\n if (sourceTile.type === 'json') {\n await this.sourceTileset!._loadTile(sourceTile);\n await this._addChildren({\n parentNode,\n sourceTiles: sourceTile.children,\n childNodes,\n parentId,\n level: level + 1\n });\n await sourceTile.unloadContent();\n } else {\n const children = await this._createNode(parentNode, sourceTile, parentId, level);\n parentNode.children = parentNode.children || [];\n for (const child of children) {\n parentNode.children.push({\n id: child.id,\n href: `../${child.path}`,\n obb: child.obb,\n mbs: child.mbs\n });\n childNodes.push(child);\n }\n }\n if (sourceTile.id) {\n console.log(sourceTile.id); // eslint-disable-line\n }\n }\n }\n\n /**\n * Add neightbors to 3DNodeIndexDocument and write it in a file\n * @param parentNode - arguments\n * @param childNodes - array of target child nodes\n */\n private async _addNeighborsAndWriteFile(\n parentNode: Node3DIndexDocument,\n childNodes: Node3DIndexDocument[]\n ): Promise<void> {\n for (const node of childNodes) {\n const childPath = join(this.layers0Path, 'nodes', node.path!);\n const nodePath = node.path;\n delete node.path;\n\n // Don't do large amount of \"neightbors\" to avoid big memory consumption\n if (Number(parentNode?.children?.length) < 1000) {\n for (const neighbor of parentNode.children || []) {\n // eslint-disable-next-line max-depth\n if (node.id === neighbor.id) {\n continue; // eslint-disable-line\n }\n\n if (node.neighbors) {\n node.neighbors.push({...neighbor});\n }\n }\n } else {\n // eslint-disable-next-line no-console, no-undef\n console.warn(\n `Node ${node.id}: neighbors attribute is omited because of large number of neigbors`\n );\n delete node.neighbors;\n }\n await this._writeNodeIndexDocument(node, nodePath!, childPath);\n node.neighbors = [];\n }\n }\n\n /**\n * Convert tile to one or more I3S nodes\n * @param parentTile - parent 3DNodeIndexDocument\n * @param sourceTile - source tile (3DTile)\n * @param parentId - id of parent node in node pages\n * @param level - level of node (distanse to root node in the tree)\n */\n private async _createNode(\n parentTile: Node3DIndexDocument,\n sourceTile: TileHeader,\n parentId: number,\n level: number\n ): Promise<Node3DIndexDocument[]> {\n if (this.validate) {\n this._checkAddRefinementTypeForTile(sourceTile);\n }\n\n await this._updateTilesetOptions();\n await this.sourceTileset!._loadTile(sourceTile);\n\n let boundingVolumes = createBoundingVolumes(sourceTile, this.geoidHeightModel!);\n\n const batchTable = sourceTile?.content?.batchTableJson;\n\n if (batchTable) {\n this._convertAttributeStorageInfo(sourceTile.content);\n }\n\n const resourcesData = await this._convertResources(sourceTile);\n\n const nodes: Node3DIndexDocument[] = [];\n const nodesInPage: NodeInPage[] = [];\n const emptyResources = {\n geometry: null,\n compressedGeometry: null,\n texture: null,\n sharedResources: null,\n meshMaterial: null,\n vertexCount: null,\n attributes: null,\n featureCount: null,\n boundingVolumes: null\n };\n\n for (const resources of resourcesData || [emptyResources]) {\n if (this.generateBoundingVolumes && resources.boundingVolumes) {\n boundingVolumes = resources.boundingVolumes;\n }\n\n const lodSelection = convertGeometricErrorToScreenThreshold(sourceTile, boundingVolumes);\n const maxScreenThresholdSQ = lodSelection.find(\n (val) => val.metricType === 'maxScreenThresholdSQ'\n ) || {maxError: 0};\n\n const nodeInPage = this._createNodeInNodePages(\n maxScreenThresholdSQ,\n boundingVolumes,\n sourceTile,\n parentId,\n resources\n );\n const node = this._createNodeIndexDocument(\n parentTile,\n boundingVolumes,\n lodSelection,\n nodeInPage,\n resources\n );\n\n if (nodeInPage.mesh) {\n await this._writeResources(resources, node.path!);\n }\n\n if (this.validate) {\n this.boundingVolumeWarnings = validateNodeBoundingVolumes(node);\n\n if (this.boundingVolumeWarnings && this.boundingVolumeWarnings.length) {\n console.warn('Bounding Volume Warnings: ', ...this.boundingVolumeWarnings); //eslint-disable-line\n }\n }\n\n nodes.push(node);\n nodesInPage.push(nodeInPage);\n }\n\n sourceTile.unloadContent();\n\n await this._addChildrenWithNeighborsAndWriteFile({\n parentNode: nodes[0],\n sourceTiles: sourceTile.children,\n parentId: nodesInPage[0].index!,\n level: level + 1\n });\n return nodes;\n }\n\n /**\n * Convert attributesStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md\n * from B3DM batch table\n * @param sourceTileContent - tile content of 3DTile\n * @return {void}\n */\n private _convertAttributeStorageInfo(sourceTileContent: B3DMContent): void {\n // In legacy b3dm files sometimes sourceTileContent is null.\n const batchTable = sourceTileContent && sourceTileContent.batchTableJson;\n if (batchTable && !this.layers0?.attributeStorageInfo?.length) {\n this._convertBatchTableInfoToNodeAttributes(batchTable);\n }\n }\n\n /**\n * Convert tile to one or more I3S nodes\n * @param sourceTile - source tile (3DTile)\n * result.geometry - ArrayBuffer with geometry attributes\n * result.compressedGeometry - ArrayBuffer with compressed (draco) geometry\n * result.texture - texture image\n * result.sharedResources - shared resource data object\n * result.meshMaterial - PBR-like material object\n * result.vertexCount - number of vertices in geometry\n * result.attributes - feature attributes\n * result.featureCount - number of features\n */\n private async _convertResources(sourceTile: TileHeader): Promise<I3SConvertedResources[] | null> {\n if (!this.isContentSupported(sourceTile)) {\n return null;\n }\n const resourcesData = await convertB3dmToI3sGeometry(\n sourceTile.content,\n Number(this.nodePages.nodesCounter),\n this.featuresHashArray,\n this.layers0?.attributeStorageInfo,\n this.options.draco,\n this.generateBoundingVolumes,\n this.geoidHeightModel!\n );\n return resourcesData;\n }\n\n /**\n * Create a new node object (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/node.cmn.md)\n * in node pages (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/nodePage.cmn.md)\n * @param maxScreenThresholdSQ - Level of Details (LOD) metric\n * @param boundingVolumes - Bounding volumes\n * @param sourceTile - source tile (3DTile)\n * @param parentId - id of parent node in node pages\n * @param resources - the node resources data\n * @param resources.meshMaterial - PBR-like material object\n * @param resources.texture - texture image\n * @param resources.vertexCount - number of vertices in geometry\n * @param resources.featureCount - number of features\n * @return the node object in node pages\n */\n private _createNodeInNodePages(\n maxScreenThresholdSQ: MaxScreenThresholdSQ,\n boundingVolumes: BoundingVolumes,\n sourceTile: TileHeader,\n parentId: number,\n resources: I3SConvertedResources\n ): NodeInPage {\n const {meshMaterial, texture, vertexCount, featureCount, geometry} = resources;\n const nodeInPage: NodeInPage = {\n index: 0,\n lodThreshold: maxScreenThresholdSQ.maxError,\n obb: boundingVolumes.obb,\n children: []\n };\n if (geometry && this.isContentSupported(sourceTile)) {\n nodeInPage.mesh = {\n geometry: {\n definition: texture ? 0 : 1,\n resource: 0\n },\n attribute: {\n resource: 0\n },\n material: {\n definition: 0\n }\n };\n }\n const nodeId = this.nodePages.push(nodeInPage, parentId);\n\n if (meshMaterial) {\n this.nodePages.updateMaterialByNodeId(nodeId, this._findOrCreateMaterial(meshMaterial));\n }\n\n if (texture) {\n const texelCountHint = texture.image.height * texture.image.width;\n this.nodePages.updateTexelCountHintByNodeId(nodeId, texelCountHint);\n }\n\n if (vertexCount) {\n this.vertexCounter += vertexCount;\n this.nodePages.updateVertexCountByNodeId(nodeId, vertexCount);\n }\n this.nodePages.updateNodeAttributeByNodeId(nodeId);\n if (featureCount) {\n this.nodePages.updateFeatureCountByNodeId(nodeId, featureCount);\n }\n\n return nodeInPage;\n }\n\n /**\n * Create a new node page object in node pages\n * @param parentNode - 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md object of the parent node\n * @param boundingVolumes - Bounding volumes\n * @param lodSelection - Level of Details (LOD) metrics\n * @param nodeInPage - corresponding node object in a node page\n * @param resources - the node resources data\n * @param resources.texture - texture image\n * @param resources.attributes - feature attributes\n * @return 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md object\n */\n private _createNodeIndexDocument(\n parentNode: Node3DIndexDocument,\n boundingVolumes: BoundingVolumes,\n lodSelection: LodSelection[],\n nodeInPage: NodeInPage,\n resources: I3SConvertedResources\n ): Node3DIndexDocument {\n const {texture, attributes} = resources;\n const nodeId = nodeInPage.index!;\n const nodeData = {\n version: parentNode.version,\n id: nodeId.toString(),\n path: nodeId.toString(),\n level: parentNode.level! + 1,\n ...boundingVolumes,\n lodSelection,\n parentNode: {\n id: parentNode.id,\n href: `../${parentNode.id}`,\n mbs: parentNode.mbs,\n obb: parentNode.obb\n },\n children: [],\n neighbors: []\n };\n const node = transform(nodeData, nodeTemplate());\n\n if (nodeInPage.mesh) {\n node.geometryData = [{href: './geometries/0'}];\n node.sharedResource = {href: './shared'};\n\n if (texture) {\n node.textureData = [{href: './textures/0'}, {href: './textures/1'}];\n }\n\n if (attributes && attributes.length && this.layers0?.attributeStorageInfo?.length) {\n node.attributeData = [];\n for (let index = 0; index < attributes.length; index++) {\n const folderName = this.layers0.attributeStorageInfo[index].key;\n node.attributeData.push({href: `./attributes/${folderName}/0`});\n }\n }\n }\n\n return node;\n }\n\n /**\n * Write node resources in files\n * @param resources - source tile (3DTile)\n * @param resources.geometry - Uint8Array with geometry attributes\n * @param resources.compressedGeometry - Uint8Array with compressed (draco) geometry\n * @param resources.texture - texture image\n * @param resources.sharedResources - shared resource data object\n * @param resources.attributes - feature attributes\n * @return {Promise<void>}\n */\n private async _writeResources(resources: I3SConvertedResources, nodePath: string): Promise<void> {\n const {\n geometry: geometryBuffer,\n compressedGeometry,\n texture,\n sharedResources,\n attributes\n } = resources;\n const childPath = join(this.layers0Path, 'nodes', nodePath);\n const slpkChildPath = join('nodes', nodePath);\n\n await this._writeGeometries(geometryBuffer!, compressedGeometry!, childPath, slpkChildPath);\n await this._writeShared(sharedResources!, childPath, slpkChildPath, nodePath);\n await this._writeTexture(texture, childPath, slpkChildPath);\n await this._writeAttributes(attributes, childPath, slpkChildPath);\n }\n\n /**\n * Write non-compressed and compressed geometries in files\n * @param geometryBuffer - Uint8Array with geometry attributes\n * @param compressedGeometry - Uint8Array with compressed (draco) geometry\n * @param childPath - a child path to write resources\n * @param slpkChildPath - resource path inside *slpk file\n */\n private async _writeGeometries(\n geometryBuffer: ArrayBuffer,\n compressedGeometry: ArrayBuffer,\n childPath: string,\n slpkChildPath: string\n ): Promise<void> {\n if (this.options.slpk) {\n const slpkGeometryPath = join(childPath, 'geometries');\n this.fileMap[`${slpkChildPath}/geometries/0.bin.gz`] = await writeFileForSlpk(\n slpkGeometryPath,\n geometryBuffer,\n '0.bin'\n );\n } else {\n const geometryPath = join(childPath, 'geometries/0/');\n await writeFile(geometryPath, geometryBuffer, 'index.bin');\n }\n\n if (this.options.draco) {\n if (this.options.slpk) {\n const slpkCompressedGeometryPath = join(childPath, 'geometries');\n this.fileMap[`${slpkChildPath}/geometries/1.bin.gz`] = await writeFileForSlpk(\n slpkCompressedGeometryPath,\n compressedGeometry,\n '1.bin'\n );\n } else {\n const compressedGeometryPath = join(childPath, 'geometries/1/');\n await writeFile(compressedGeometryPath, compressedGeometry, 'index.bin');\n }\n }\n }\n\n /**\n * Write shared resources in a file\n * @param sharedResources - shared resource data object\n * @param childPath - a child path to write resources\n * @param slpkChildPath - resource path inside *slpk file\n * @param nodePath - a node path\n */\n private async _writeShared(\n sharedResources: SharedResources,\n childPath: string,\n slpkChildPath: string,\n nodePath: string\n ): Promise<void> {\n sharedResources.nodePath = nodePath;\n const sharedData = transform(sharedResources, sharedResourcesTemplate());\n const sharedDataStr = JSON.stringify(sharedData);\n if (this.options.slpk) {\n const slpkSharedPath = join(childPath, 'shared');\n this.fileMap[`${slpkChildPath}/shared/sharedResource.json.gz`] = await writeFileForSlpk(\n slpkSharedPath,\n sharedDataStr,\n 'sharedResource.json'\n );\n } else {\n const sharedPath = join(childPath, 'shared/');\n await writeFile(sharedPath, sharedDataStr);\n }\n }\n\n /**\n * Generates textures based on texture mime type and fill in textureSetDefinitions data.\n * @param texture - the texture image\n * @param childPath - a child path to write resources\n * @param slpkChildPath - the resource path inside *slpk file\n */\n private async _writeTexture(\n texture: GLTFImagePostprocessed,\n childPath: string,\n slpkChildPath: string\n ): Promise<void> {\n if (texture) {\n const format = this._getFormatByMimeType(texture?.mimeType);\n const formats: TextureSetDefinitionFormats = [];\n const textureData = texture.bufferView!.data;\n\n switch (format) {\n case 'jpg':\n case 'png': {\n formats.push({name: '0', format});\n await this.writeTextureFile(textureData, '0', format, childPath, slpkChildPath);\n\n if (this.generateTextures) {\n formats.push({name: '1', format: 'ktx2'});\n const ktx2TextureData = new Uint8Array(\n await encode(texture.image, KTX2BasisUniversalTextureWriter)\n );\n await this.writeTextureFile(ktx2TextureData, '1', 'ktx2', childPath, slpkChildPath);\n }\n\n break;\n }\n\n case 'ktx2': {\n formats.push({name: '1', format});\n await this.writeTextureFile(textureData, '1', format, childPath, slpkChildPath);\n\n if (this.generateTextures) {\n formats.push({name: '0', format: 'jpg'});\n const decodedFromKTX2TextureData = new Uint8Array(\n await encode(texture.image!.data[0], ImageWriter)\n );\n await this.writeTextureFile(\n decodedFromKTX2TextureData,\n '0',\n 'jpg',\n childPath,\n slpkChildPath\n );\n }\n }\n }\n\n if (!this.layers0!.textureSetDefinitions!.length) {\n this.layers0!.textureSetDefinitions!.push({formats});\n }\n }\n }\n\n /**\n * Write the texture image in a file\n * @param textureData\n * @param name\n * @param format\n * @param childPath\n * @param slpkChildPath\n */\n private async writeTextureFile(\n textureData: ArrayBuffer,\n name: string,\n format: 'jpg' | 'png' | 'ktx2',\n childPath: string,\n slpkChildPath: string\n ): Promise<void> {\n const texturePath = join(childPath, `textures/${name}/`);\n await writeFile(texturePath, textureData, `index.${format}`);\n\n if (this.options.slpk) {\n const slpkTexturePath = join(childPath, 'textures');\n const compress = false;\n\n this.fileMap[`${slpkChildPath}/textures/${name}.${format}`] = await writeFileForSlpk(\n slpkTexturePath,\n textureData,\n `${name}.${format}`,\n compress\n );\n }\n }\n\n /**\n * Write feature attributes in files\n * @param attributes - feature attributes\n * @param childPath - a child path to write resources\n * @param slpkChildPath - the resource path inside *slpk file\n */\n private async _writeAttributes(\n attributes: ArrayBuffer[],\n childPath: string,\n slpkChildPath: string\n ): Promise<void> {\n if (attributes.length && this.layers0?.attributeStorageInfo?.length) {\n for (let index = 0; index < attributes.length; index++) {\n const folderName = this.layers0.attributeStorageInfo[index].key;\n const fileBuffer = new Uint8Array(attributes[index]);\n\n if (this.options.slpk) {\n const slpkAttributesPath = join(childPath, 'attributes', folderName);\n this.fileMap[`${slpkChildPath}/attributes/${folderName}.bin.gz`] = await writeFileForSlpk(\n slpkAttributesPath,\n fileBuffer,\n '0.bin'\n );\n } else {\n const attributesPath = join(childPath, `attributes/${folderName}/0`);\n await writeFile(attributesPath, fileBuffer, 'index.bin');\n }\n }\n }\n }\n\n /**\n * Return file format by its MIME type\n * @param mimeType - feature attributes\n */\n private _getFormatByMimeType(mimeType: string | undefined): 'jpg' | 'png' | 'ktx2' {\n switch (mimeType) {\n case 'image/jpeg':\n return 'jpg';\n case 'image/png':\n return 'png';\n case 'image/ktx2':\n return 'ktx2';\n default:\n return 'jpg';\n }\n }\n\n /**\n * Find or create material in materialDefinitions array\n * @param material - end-to-end index of the node\n * @return material id\n */\n private _findOrCreateMaterial(material: I3SMaterialDefinition): number {\n const hash = md5(JSON.stringify(material));\n if (this.materialMap.has(hash)) {\n return this.materialMap.get(hash);\n }\n const newMaterialId = this.materialDefinitions.push(material) - 1;\n this.materialMap.set(hash, newMaterialId);\n return newMaterialId;\n }\n\n /**\n * Generate storage attribute for map segmentation.\n * @param attributeIndex - order index of attribute (f_0, f_1 ...).\n * @param key - attribute key from batch table.\\\n * @param attributeType - attribute type.\n * @return Updated storageAttribute.\n */\n private _createdStorageAttribute(\n attributeIndex: number,\n key: string,\n attributeType: Attribute\n ): AttributeStorageInfo {\n const storageAttribute = {\n key: `f_${attributeIndex}`,\n name: key,\n ordering: ['attributeValues'],\n header: [{property: 'count', valueType: 'UInt32'}],\n attributeValues: {valueType: 'Int32', valuesPerElement: 1}\n };\n\n switch (attributeType) {\n case OBJECT_ID_TYPE:\n this._setupIdAttribute(storageAttribute);\n break;\n case STRING_TYPE:\n this._setupStringAttribute(storageAttribute);\n break;\n case DOUBLE_TYPE:\n this._setupDoubleAttribute(storageAttribute);\n break;\n case SHORT_INT_TYPE:\n break;\n default:\n this._setupStringAttribute(storageAttribute);\n }\n\n return storageAttribute;\n }\n\n /**\n * Get the attribute type for attributeStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md\n * @param key - attribute's key\n * @param attribute - attribute's type in batchTable\n */\n private getAttributeType(key: string, attribute: string): string {\n if (key === OBJECT_ID_TYPE) {\n return OBJECT_ID_TYPE;\n }\n if (typeof attribute === STRING_TYPE) {\n return STRING_TYPE;\n } else if (typeof attribute === 'number') {\n return Number.isInteger(attribute) ? SHORT_INT_TYPE : DOUBLE_TYPE;\n }\n return STRING_TYPE;\n }\n\n /**\n * Setup storage attribute as string.\n * @param storageAttribute - attribute for map segmentation.\n */\n private _setupStringAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.ordering!.unshift('attributeByteCounts');\n storageAttribute.header.push({property: 'attributeValuesByteCount', valueType: 'UInt32'});\n storageAttribute.attributeValues = {\n valueType: 'String',\n encoding: 'UTF-8',\n valuesPerElement: 1\n };\n storageAttribute.attributeByteCounts = {\n valueType: 'UInt32',\n valuesPerElement: 1\n };\n }\n\n /**\n * Setup Id attribute for map segmentation.\n * @param storageAttribute - attribute for map segmentation .\n */\n private _setupIdAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.attributeValues = {\n valueType: 'Oid32',\n valuesPerElement: 1\n };\n }\n\n /**\n * Setup double attribute for map segmentation.\n * @param storageAttribute - attribute for map segmentation .\n */\n private _setupDoubleAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.attributeValues = {\n valueType: 'Float64',\n valuesPerElement: 1\n };\n }\n\n /**\n * Setup field attribute for map segmentation.\n * @param key - attribute for map segmentation.\n * @param fieldAttributeType - esri attribute type ('esriFieldTypeString' or 'esriFieldTypeOID').\n */\n private _createFieldAttribute(key: string, fieldAttributeType: ESRIField): Field {\n return {\n name: key,\n type: fieldAttributeType,\n alias: key\n };\n }\n\n /**\n * Do conversion of 3DTiles batch table to I3s node attributes.\n * @param batchTable - Table with layer meta data.\n */\n private _convertBatchTableInfoToNodeAttributes(batchTable: BatchTableJson): void {\n let attributeIndex = 0;\n const batchTableWithObjectId = {\n OBJECTID: [0],\n ...batchTable\n };\n\n for (const key in batchTableWithObjectId) {\n const firstAttribute = batchTableWithObjectId[key][0];\n const attributeType = this.getAttributeType(key, firstAttribute);\n\n const storageAttribute = this._createdStorageAttribute(attributeIndex, key, attributeType);\n const fieldAttributeType = this._getFieldAttributeType(attributeType);\n const fieldAttribute = this._createFieldAttribute(key, fieldAttributeType);\n const popupInfo = this._createPopupInfo(batchTableWithObjectId);\n\n this.layers0!.attributeStorageInfo!.push(storageAttribute);\n this.layers0!.fields!.push(fieldAttribute);\n this.layers0!.popupInfo = popupInfo;\n this.layers0!.layerType = _3D_OBJECT_LAYER_TYPE;\n\n attributeIndex += 1;\n }\n }\n\n /**\n * Find and return attribute type based on key form Batch table.\n * @param attributeType\n */\n private _getFieldAttributeType(attributeType: Attribute): ESRIField {\n switch (attributeType) {\n case OBJECT_ID_TYPE:\n return 'esriFieldTypeOID';\n case STRING_TYPE:\n return 'esriFieldTypeString';\n case SHORT_INT_TYPE:\n return 'esriFieldTypeInteger';\n case DOUBLE_TYPE:\n return 'esriFieldTypeDouble';\n default:\n return 'esriFieldTypeString';\n }\n }\n\n /**\n * Generate popup info to show metadata on the map.\n * @param batchTable - Batch table data with OBJECTID.\n * @return data for correct rendering of popup.\n */\n private _createPopupInfo(batchTable: BatchTableJson): PopupInfo {\n const title = '{OBJECTID}';\n const mediaInfos = [];\n const fieldInfos: FieldInfo[] = [];\n const popupElements: {\n fieldInfos: FieldInfo[];\n type: string;\n }[] = [];\n const expressionInfos = [];\n\n for (const key in batchTable) {\n fieldInfos.push({\n fieldName: key,\n visible: true,\n isEditable: false,\n label: key\n });\n }\n popupElements.push({\n fieldInfos,\n type: 'fields'\n });\n\n return {\n title,\n mediaInfos,\n popupElements,\n fieldInfos,\n expressionInfos\n };\n }\n\n /**\n * Print statistics in the end of conversion\n * @param params - output files data\n */\n private async _finishConversion(params: {\n slpk: boolean;\n outputPath: string;\n tilesetName: string;\n }): Promise<void> {\n const {tilesCount, tilesWithAddRefineCount} = this.refinementCounter;\n const addRefinementPercentage = tilesWithAddRefineCount\n ? (tilesWithAddRefineCount / tilesCount) * 100\n : 0;\n const filesSize = await calculateFilesSize(params);\n const diff = process.hrtime(this.conversionStartTime);\n const conversionTime = timeConverter(diff);\n console.log(`------------------------------------------------`); // eslint-disable-line no-undef, no-console\n console.log(`Finishing conversion of ${_3D_TILES}`); // eslint-disable-line no-undef, no-console\n console.log(`Total conversion time: ${conversionTime}`); // eslint-disable-line no-undef, no-console\n console.log(`Vertex count: `, this.vertexCounter); // eslint-disable-line no-undef, no-console\n console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line no-undef, no-console\n console.log(`Percentage of tiles with \"ADD\" refinement type:`, addRefinementPercentage, '%'); // eslint-disable-line no-undef, no-console\n console.log(`------------------------------------------------`); // eslint-disable-line no-undef, no-console\n }\n\n /**\n * Fetch preload options for ION tileset\n */\n private async _fetchPreloadOptions(): Promise<any> {\n if (!this.Loader.preload) {\n return {};\n }\n const options = {\n 'cesium-ion': {accessToken: this.options.token || ION_DEFAULT_TOKEN}\n };\n const preloadOptions = await this.Loader.preload(this.options.inputUrl, options);\n this.refreshTokenTime = process.hrtime();\n return {...options, ...preloadOptions};\n }\n\n /**\n * Update options of source tileset\n */\n private async _updateTilesetOptions(): Promise<void> {\n const diff = process.hrtime(this.refreshTokenTime);\n if (diff[0] < REFRESH_TOKEN_TIMEOUT) {\n return;\n }\n this.refreshTokenTime = process.hrtime();\n\n const preloadOptions = await this._fetchPreloadOptions();\n this.sourceTileset!.options = {...this.sourceTileset!.options, ...preloadOptions};\n if (preloadOptions.headers) {\n this.sourceTileset!.loadOptions.fetch = {\n ...this.sourceTileset!.loadOptions.fetch,\n headers: preloadOptions.headers\n };\n console.log('Authorization Bearer token has been updated'); // eslint-disable-line no-undef, no-console\n }\n }\n\n /** Do calculations of all tiles and tiles with \"ADD\" type of refinement.\n * @param tile\n */\n private _checkAddRefinementTypeForTile(tile: TileHeader): void {\n const ADD_TILE_REFINEMENT = 1;\n\n if (tile.refine === ADD_TILE_REFINEMENT) {\n this.refinementCounter.tilesWithAddRefineCount += 1;\n console.warn('This tile uses \"ADD\" type of refinement'); // eslint-disable-line\n }\n\n this.refinementCounter.tilesCount += 1;\n }\n /**\n * Check if the tile's content format is supported by the converter\n * @param sourceRootTile\n * @returns\n */\n private isContentSupported(sourceRootTile: Tile3D): boolean {\n return ['b3dm', 'glTF'].includes(sourceRootTile?.content?.type);\n }\n}\n"],"file":"i3s-converter.js"}
@@ -0,0 +1,95 @@
1
+ export declare const LAYERS: () => {
2
+ version: {
3
+ path: string;
4
+ transform: (val: any) => any;
5
+ };
6
+ id: {
7
+ path: string;
8
+ default: number;
9
+ };
10
+ name: {
11
+ path: string;
12
+ };
13
+ href: {
14
+ path: string;
15
+ default: string;
16
+ };
17
+ layerType: {
18
+ path: string;
19
+ default: string;
20
+ };
21
+ spatialReference: {
22
+ path: string;
23
+ transform: (val: any) => any;
24
+ };
25
+ capabilities: {
26
+ path: string;
27
+ default: string[];
28
+ };
29
+ store: {
30
+ path: string;
31
+ transform: (val: any) => any;
32
+ };
33
+ heightModelInfo: {
34
+ path: string;
35
+ transform: (val: any) => any;
36
+ };
37
+ nodePages: {
38
+ path: string;
39
+ transform: (val: any) => any;
40
+ };
41
+ materialDefinitions: {
42
+ path: string;
43
+ default: never[];
44
+ };
45
+ textureSetDefinitions: {
46
+ path: string;
47
+ default: never[];
48
+ };
49
+ geometryDefinitions: {
50
+ path: string;
51
+ transform: (val: any) => {
52
+ geometryBuffers: never[];
53
+ }[];
54
+ default: {
55
+ geometryBuffers: {
56
+ offset: number;
57
+ position: {
58
+ type: string;
59
+ component: number;
60
+ };
61
+ normal: {
62
+ type: string;
63
+ component: number;
64
+ };
65
+ color: {
66
+ type: string;
67
+ component: number;
68
+ };
69
+ featureId: {
70
+ binding: string;
71
+ type: string;
72
+ component: number;
73
+ };
74
+ faceRange: {
75
+ binding: string;
76
+ type: string;
77
+ component: number;
78
+ };
79
+ }[];
80
+ }[];
81
+ };
82
+ attributeStorageInfo: {
83
+ path: string;
84
+ default: never[];
85
+ };
86
+ fields: {
87
+ path: string;
88
+ default: never[];
89
+ };
90
+ popupInfo: {
91
+ path: string;
92
+ default: null;
93
+ };
94
+ };
95
+ //# sourceMappingURL=layers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layers.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/json-templates/layers.ts"],"names":[],"mappings":"AAqHA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmFjB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/i3s-converter/json-templates/layers.ts"],"names":["transform","STORE","PLAIN_GEOMETRY_DEFINITION","offset","position","type","component","normal","uv0","color","featureId","binding","faceRange","PLAIN_GEOMETRY_DEFINITION_WITHOUT_UV0","COMPRESSED_GEOMETRY_DEFINITION","compressedAttributes","encoding","attributes","COMPRESSED_GEOMETRY_DEFINITION_WITHOUT_UV0","SPATIAL_REFERENCE","wkid","path","default","latestWkid","vcsWkid","latestVcsWkid","HEIGHT_MODEL_INFO","heightModel","vertCRS","heightUnit","NODE_PAGES","nodesPerPage","lodSelectionMetricType","LAYERS","version","val","toUpperCase","id","name","href","layerType","spatialReference","capabilities","store","heightModelInfo","nodePages","materialDefinitions","textureSetDefinitions","geometryDefinitions","result","geometryBuffers","push","attributeStorageInfo","fields","popupInfo"],"mappings":"AAAA,OAAOA,SAAP,MAAsB,oBAAtB;AACA,SAAQC,KAAR,QAAoB,SAApB;;AAEA,MAAMC,yBAAyB,GAAG,OAAO;AACvCC,EAAAA,MAAM,EAAE,CAD+B;AAEvCC,EAAAA,QAAQ,EAAE;AACRC,IAAAA,IAAI,EAAE,SADE;AAERC,IAAAA,SAAS,EAAE;AAFH,GAF6B;AAMvCC,EAAAA,MAAM,EAAE;AACNF,IAAAA,IAAI,EAAE,SADA;AAENC,IAAAA,SAAS,EAAE;AAFL,GAN+B;AAUvCE,EAAAA,GAAG,EAAE;AACHH,IAAAA,IAAI,EAAE,SADH;AAEHC,IAAAA,SAAS,EAAE;AAFR,GAVkC;AAcvCG,EAAAA,KAAK,EAAE;AACLJ,IAAAA,IAAI,EAAE,OADD;AAELC,IAAAA,SAAS,EAAE;AAFN,GAdgC;AAkBvCI,EAAAA,SAAS,EAAE;AACTC,IAAAA,OAAO,EAAE,aADA;AAETN,IAAAA,IAAI,EAAE,QAFG;AAGTC,IAAAA,SAAS,EAAE;AAHF,GAlB4B;AAuBvCM,EAAAA,SAAS,EAAE;AACTD,IAAAA,OAAO,EAAE,aADA;AAETN,IAAAA,IAAI,EAAE,QAFG;AAGTC,IAAAA,SAAS,EA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ClB,YAAMc,MAAM,GAAG,CAAC;AAACC,QAAAA,eAAe,EAAE;AAAlB,OAAD,EAAwB;AAACA,QAAAA,eAAe,EAAE;AAAlB,OAAxB,CAAf;AAGAD,MAAAA,MAAM,CAAC,CAAD,CAAN,CAAUC,eAAV,CAA0BC,IAA1B,CAA+BjD,yBAAyB,EAAxD;AAEA+C,MAAAA,MAAM,CAAC,CAAD,CAAN,CAAUC,eAAV,CAA0BC,IAA1B,CAA+BtC,qCAAqC,EAApE;;AACA,UAAIsB,GAAJ,EAAS;AAEPc,QAAAA,MAAM,CAAC,CAAD,CAAN,CAAUC,eAAV,CAA0BC,IAA1B,CAA+BrC,8BAA8B,EAA7D;AAEAmC,QAAAA,MAAM,CAAC,CAAD,CAAN,CAAUC,eAAV,CAA0BC,IAA1B,CAA+BjC,0CAA0C,EAAzE;AACD;;AACD,aAAO+B,MAAP;AACD,KAhBkB;AAiBnB3B,IAAAA,OAAO,EAAE,CACP;AACE4B,MAAAA,eAAe,EAAE,CAAChD,yBAAyB,EAA1B,EAA8BW,qCAAqC,EAAnE;AADnB,KADO;AAjBU,GAhDM;AAuE3BuC,EAAAA,oBAAoB,EAAE;AACpB/B,IAAAA,IAAI,EAAE,sBADc;AAEpBC,IAAAA,OAAO,EAAE;AAFW,GAvEK;AA2E3B+B,EAAAA,MAAM,EAAE;AACNhC,IAAAA,IAAI,EAAE,QADA;AAENC,IAAAA,OAAO,EAAE;AAFH,GA3EmB;AA+E3BgC,EAAAA,SAAS,EAAE;AACTjC,IAAAA,IAAI,EAAE,WADG;AAETC,IAAAA,OAAO,EAAE;AAFA;AA/EgB,CAAP,CAAf","sourcesContent":["import transform from 'json-map-transform';\nimport {STORE} from './store';\n\nconst PLAIN_GEOMETRY_DEFINITION = () => ({\n offset: 8,\n position: {\n type: 'Float32',\n component: 3\n },\n normal: {\n type: 'Float32',\n component: 3\n },\n uv0: {\n type: 'Float32',\n component: 2\n },\n color: {\n type: 'UInt8',\n component: 4\n },\n featureId: {\n binding: 'per-feature',\n type: 'UInt64',\n component: 1\n },\n faceRange: {\n binding: 'per-feature',\n type: 'UInt32',\n component: 2\n }\n});\n\nconst PLAIN_GEOMETRY_DEFINITION_WITHOUT_UV0 = () => ({\n offset: 8,\n position: {\n type: 'Float32',\n component: 3\n },\n normal: {\n type: 'Float32',\n component: 3\n },\n color: {\n type: 'UInt8',\n component: 4\n },\n featureId: {\n binding: 'per-feature',\n type: 'UInt64',\n component: 1\n },\n faceRange: {\n binding: 'per-feature',\n type: 'UInt32',\n component: 2\n }\n});\n\nconst COMPRESSED_GEOMETRY_DEFINITION = () => ({\n compressedAttributes: {\n encoding: 'draco',\n attributes: ['position', 'normal', 'uv0', 'color', 'feature-index']\n }\n});\n\nconst COMPRESSED_GEOMETRY_DEFINITION_WITHOUT_UV0 = () => ({\n compressedAttributes: {\n encoding: 'draco',\n attributes: ['position', 'normal', 'color', 'feature-index']\n }\n});\n\nconst SPATIAL_REFERENCE = () => ({\n wkid: {\n path: 'wkid',\n default: 4326\n },\n latestWkid: {\n path: 'latestWkid',\n default: 4326\n },\n vcsWkid: {\n path: 'vcsWkid',\n default: 5773\n },\n latestVcsWkid: {\n path: 'latestVcsWkid',\n default: 5773\n }\n});\n\nconst HEIGHT_MODEL_INFO = () => ({\n heightModel: {\n path: 'heightModel',\n default: 'gravity_related_height'\n },\n vertCRS: {\n path: 'vertCRS',\n default: 'EGM96_Geoid'\n },\n heightUnit: {\n path: 'heightUnit',\n default: 'meter'\n }\n});\n\nconst NODE_PAGES = () => ({\n nodesPerPage: {\n path: 'nodesPerPage'\n },\n lodSelectionMetricType: {\n path: 'lodSelectionMetricType',\n default: 'maxScreenThresholdSQ'\n }\n});\n\nexport const LAYERS = () => ({\n version: {\n path: 'version',\n transform: (val) => val.toUpperCase()\n },\n id: {\n path: 'id',\n default: 0\n },\n name: {\n path: 'name'\n },\n href: {\n path: 'href',\n default: './layers/0'\n },\n layerType: {\n path: 'layerType',\n default: 'IntegratedMesh'\n },\n spatialReference: {\n path: 'spatialReference',\n transform: (val) => transform(val, SPATIAL_REFERENCE())\n },\n capabilities: {\n path: 'capabilities',\n default: ['View', 'Query']\n },\n store: {\n path: 'store',\n transform: (val) => transform(val, STORE)\n },\n heightModelInfo: {\n path: 'heightModelInfo',\n transform: (val) => transform(val, HEIGHT_MODEL_INFO())\n },\n nodePages: {\n path: 'nodePages',\n transform: (val) => transform(val, NODE_PAGES())\n },\n materialDefinitions: {\n path: 'materialDefinitions',\n default: []\n },\n textureSetDefinitions: {\n path: 'textureSetDefinitions',\n default: []\n },\n geometryDefinitions: {\n path: 'compressGeometry',\n transform: (val) => {\n const result = [{geometryBuffers: []}, {geometryBuffers: []}];\n\n // @ts-expect-error\n result[0].geometryBuffers.push(PLAIN_GEOMETRY_DEFINITION());\n // @ts-expect-error\n result[1].geometryBuffers.push(PLAIN_GEOMETRY_DEFINITION_WITHOUT_UV0());\n if (val) {\n // @ts-expect-error\n result[0].geometryBuffers.push(COMPRESSED_GEOMETRY_DEFINITION());\n // @ts-expect-error\n result[1].geometryBuffers.push(COMPRESSED_GEOMETRY_DEFINITION_WITHOUT_UV0());\n }\n return result;\n },\n default: [\n {\n geometryBuffers: [PLAIN_GEOMETRY_DEFINITION(), PLAIN_GEOMETRY_DEFINITION_WITHOUT_UV0()]\n }\n ]\n },\n attributeStorageInfo: {\n path: 'attributeStorageInfo',\n default: []\n },\n fields: {\n path: 'fields',\n default: []\n },\n popupInfo: {\n path: 'popupInfo',\n default: null\n }\n});\n"],"file":"layers.js"}