@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,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const queue_1 = require("./queue");
4
+ class WriteQueue extends queue_1.Queue {
5
+ constructor(listeningInterval = 2000, writeConcurrency = 400) {
6
+ super();
7
+ this.writePromise = null;
8
+ this.fileMap = {};
9
+ this.listeningInterval = listeningInterval;
10
+ this.writeConcurrency = writeConcurrency;
11
+ }
12
+ startListening() {
13
+ this.intervalId = setInterval(this.startWrite.bind(this), this.listeningInterval);
14
+ }
15
+ stopListening() {
16
+ if (this.intervalId) {
17
+ clearInterval(this.intervalId);
18
+ }
19
+ }
20
+ async startWrite() {
21
+ if (this.writePromise) {
22
+ await this.writePromise;
23
+ this.writePromise = null;
24
+ return;
25
+ }
26
+ this.writePromise = this.doWrite();
27
+ await this.writePromise;
28
+ this.writePromise = null;
29
+ }
30
+ async finalize() {
31
+ this.stopListening();
32
+ await this.startWrite();
33
+ }
34
+ async doWrite() {
35
+ while (this.length) {
36
+ const promises = [];
37
+ const archiveKeys = [];
38
+ for (let i = 0; i < this.writeConcurrency; i++) {
39
+ const item = this.dequeue();
40
+ if (!item) {
41
+ break;
42
+ }
43
+ const { archiveKey, writePromise } = item;
44
+ archiveKeys.push(archiveKey);
45
+ promises.push(writePromise);
46
+ }
47
+ const writeResults = await Promise.all(promises);
48
+ this.updateFileMap(archiveKeys, writeResults);
49
+ }
50
+ this.writePromise = null;
51
+ }
52
+ updateFileMap(archiveKeys, writeResults) {
53
+ for (let i = 0; i < archiveKeys.length; i++) {
54
+ const archiveKey = archiveKeys[i];
55
+ if (!archiveKey) {
56
+ continue;
57
+ }
58
+ this.fileMap[archiveKey] = writeResults[i];
59
+ }
60
+ }
61
+ }
62
+ exports.default = WriteQueue;
@@ -0,0 +1,6 @@
1
+ import type { LoaderWithParser } from '@loaders.gl/loader-utils';
2
+ /**
3
+ * Loader for PGM - Netpbm grayscale image format
4
+ */
5
+ export declare const PGMLoader: LoaderWithParser;
6
+ //# sourceMappingURL=pgm-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pgm-loader.d.ts","sourceRoot":"","sources":["../src/pgm-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAQ/D;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,gBAYvB,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PGMLoader = void 0;
4
+ // __VERSION__ is injected by babel-plugin-version-inline
5
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
6
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
7
+ const geoid_1 = require("@math.gl/geoid");
8
+ /**
9
+ * Loader for PGM - Netpbm grayscale image format
10
+ */
11
+ exports.PGMLoader = {
12
+ name: 'PGM - Netpbm grayscale image format',
13
+ id: 'pgm',
14
+ module: 'tile-converter',
15
+ version: VERSION,
16
+ mimeTypes: ['image/x-portable-graymap'],
17
+ parse: async (arrayBuffer, options) => (0, geoid_1.parsePGM)(new Uint8Array(arrayBuffer), options),
18
+ extensions: ['pgm'],
19
+ options: {
20
+ // TODO - use pgm namespace
21
+ cubic: false
22
+ }
23
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=3d-tiles-attributes-worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"3d-tiles-attributes-worker.d.ts","sourceRoot":"","sources":["../../src/workers/3d-tiles-attributes-worker.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
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 worker_utils_1 = require("@loaders.gl/worker-utils");
7
+ const b3dm_converter_1 = __importDefault(require("../3d-tiles-converter/helpers/b3dm-converter"));
8
+ const b3dmConverter = new b3dm_converter_1.default();
9
+ (0, worker_utils_1.createWorker)(async (data, options = {}) => b3dmConverter.convert(data, options.attributes));
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=i3s-attributes-worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i3s-attributes-worker.d.ts","sourceRoot":"","sources":["../../src/workers/i3s-attributes-worker.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const worker_utils_1 = require("@loaders.gl/worker-utils");
4
+ const geometry_converter_1 = require("../i3s-converter/helpers/geometry-converter");
5
+ (0, worker_utils_1.createWorker)(async (data, options = {}) => await (0, geometry_converter_1.convertAttributes)(data, options.useCartesianPositions));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/tile-converter",
3
- "version": "3.1.8",
3
+ "version": "3.2.0-alpha.3",
4
4
  "description": "Converter",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -33,25 +33,26 @@
33
33
  "fs": false
34
34
  },
35
35
  "scripts": {
36
- "pre-build": "npm run build-bundle",
37
- "post-build": "npm run build-converter-bundle",
36
+ "pre-build": "npm run build-bundle && npm run build-converter-bundle && npm run build-i3s-attributes-worker && npm run build-3d-tiles-attributes-worker",
38
37
  "build-bundle": "esbuild ./src/index.ts --bundle --outfile=dist/dist.min.js --platform=node",
39
38
  "build-converter-bundle": "webpack --display errors-only --config ./converter-webpack/bundle.js",
40
- "build-bin": "BABEL_ENV=es5 babel scripts --config-file ../../babel.config.js --out-dir dist/scripts"
39
+ "build-i3s-attributes-worker": "esbuild src/workers/i3s-attributes-worker.ts --outfile=dist/i3s-attributes-worker.js --platform=node --target=esnext,node12 --minify --bundle --sourcemap --define:__VERSION__=\\\"$npm_package_version\\\"",
40
+ "build-3d-tiles-attributes-worker": "esbuild src/workers/3d-tiles-attributes-worker.ts --outfile=dist/3d-tiles-attributes-worker.js --platform=node --target=esnext,node12 --minify --bundle --sourcemap --define:__VERSION__=\\\"$npm_package_version\\\""
41
41
  },
42
42
  "dependencies": {
43
- "@loaders.gl/3d-tiles": "3.1.8",
44
- "@loaders.gl/crypto": "3.1.8",
45
- "@loaders.gl/draco": "3.1.8",
46
- "@loaders.gl/gltf": "3.1.8",
47
- "@loaders.gl/i3s": "3.1.8",
48
- "@loaders.gl/images": "3.1.8",
49
- "@loaders.gl/loader-utils": "3.1.8",
50
- "@loaders.gl/polyfills": "3.1.8",
51
- "@loaders.gl/textures": "3.1.8",
52
- "@loaders.gl/tiles": "3.1.8",
53
- "@loaders.gl/worker-utils": "3.1.8",
54
- "@loaders.gl/zip": "3.1.8",
43
+ "@loaders.gl/3d-tiles": "3.2.0-alpha.3",
44
+ "@loaders.gl/crypto": "3.2.0-alpha.3",
45
+ "@loaders.gl/draco": "3.2.0-alpha.3",
46
+ "@loaders.gl/gltf": "3.2.0-alpha.3",
47
+ "@loaders.gl/i3s": "3.2.0-alpha.3",
48
+ "@loaders.gl/images": "3.2.0-alpha.3",
49
+ "@loaders.gl/loader-utils": "3.2.0-alpha.3",
50
+ "@loaders.gl/polyfills": "3.2.0-alpha.3",
51
+ "@loaders.gl/schema": "3.2.0-alpha.3",
52
+ "@loaders.gl/textures": "3.2.0-alpha.3",
53
+ "@loaders.gl/tiles": "3.2.0-alpha.3",
54
+ "@loaders.gl/worker-utils": "3.2.0-alpha.3",
55
+ "@loaders.gl/zip": "3.2.0-alpha.3",
55
56
  "@luma.gl/engine": "^8.5.4",
56
57
  "@math.gl/core": "^3.5.1",
57
58
  "@math.gl/culling": "^3.5.1",
@@ -69,7 +70,7 @@
69
70
  "uuid": "^8.1.0"
70
71
  },
71
72
  "peerDependencies": {
72
- "@loaders.gl/core": "^3.1.0"
73
+ "@loaders.gl/core": "3.2.0-alpha.2"
73
74
  },
74
- "gitHead": "0ef07b4e9fc20f5a882224cf241c6fd1bad898d8"
75
+ "gitHead": "f0d4b801efeb7094283106352ee759eccfb21f10"
75
76
  }
@@ -0,0 +1,43 @@
1
+ import type {WorkerObject} from '@loaders.gl/worker-utils';
2
+ import type {FeatureAttribute} from '@loaders.gl/i3s';
3
+
4
+ import {processOnWorker} from '@loaders.gl/worker-utils';
5
+
6
+ // __VERSION__ is injected by babel-plugin-version-inline
7
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
8
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
9
+
10
+ export type Tile3DAttributesWorkerOptions = {
11
+ featureAttributes: FeatureAttribute | null;
12
+ source: string;
13
+ };
14
+
15
+ export type I3SAttributesData = {
16
+ tileContent: any;
17
+ textureFormat: string;
18
+ };
19
+
20
+ /**
21
+ * I3S Attributes Worker to handle B3DM object
22
+ */
23
+ export const Tile3dAttributesWorker = {
24
+ id: '3d-tiles-attributes',
25
+ name: '3DTiles Attributes Worker',
26
+ module: 'tile-converter',
27
+ version: VERSION,
28
+ options: {
29
+ attributes: null
30
+ }
31
+ };
32
+
33
+ /**
34
+ * Performs I3S attributes transformation
35
+ */
36
+ export function transform3DTilesAttributesOnWorker(
37
+ i3sAttributesData: I3SAttributesData,
38
+ options: Tile3DAttributesWorkerOptions
39
+ ): Promise<ArrayBuffer> {
40
+ return processOnWorker(Tile3dAttributesWorker, i3sAttributesData, options);
41
+ }
42
+
43
+ export const _typecheckI3SAttributesWorker: WorkerObject = Tile3dAttributesWorker;
@@ -4,7 +4,7 @@ import type {Node3D} from '@loaders.gl/3d-tiles';
4
4
  import {join} from 'path';
5
5
  import process from 'process';
6
6
  import transform from 'json-map-transform';
7
- import {load} from '@loaders.gl/core';
7
+ import {fetchFile, getLoaderOptions, load} from '@loaders.gl/core';
8
8
  import {I3SLoader, I3SAttributeLoader, COORDINATE_SYSTEM} from '@loaders.gl/i3s';
9
9
  import {Tileset3D, Tile3D} from '@loaders.gl/tiles';
10
10
  import {Geoid} from '@math.gl/geoid';
@@ -17,6 +17,12 @@ import {calculateFilesSize, timeConverter} from '../lib/utils/statistic-utills';
17
17
  import {TILESET as tilesetTemplate} from './json-templates/tileset';
18
18
  import B3dmConverter from './helpers/b3dm-converter';
19
19
  import {createObbFromMbs} from '../i3s-converter/helpers/coordinate-converter';
20
+ import {
21
+ I3SAttributesData,
22
+ Tile3dAttributesWorker
23
+ /*transform3DTilesAttributesOnWorker*/
24
+ } from '../3d-tiles-attributes-worker';
25
+ import {getWorkerURL, WorkerFarm} from '@loaders.gl/worker-utils';
20
26
 
21
27
  const I3S = 'I3S';
22
28
 
@@ -31,6 +37,7 @@ export default class Tiles3DConverter {
31
37
  geoidHeightModel: Geoid | null;
32
38
  sourceTileset: Tileset3D | null;
33
39
  attributeStorageInfo: AttributeStorageInfo | null;
40
+ workerSource: {[key: string]: string} = {};
34
41
 
35
42
  constructor() {
36
43
  this.options = {};
@@ -40,6 +47,7 @@ export default class Tiles3DConverter {
40
47
  this.geoidHeightModel = null;
41
48
  this.sourceTileset = null;
42
49
  this.attributeStorageInfo = null;
50
+ this.workerSource = {};
43
51
  }
44
52
 
45
53
  /**
@@ -55,7 +63,7 @@ export default class Tiles3DConverter {
55
63
  inputUrl: string;
56
64
  outputPath: string;
57
65
  tilesetName: string;
58
- maxDepth: number;
66
+ maxDepth?: number;
59
67
  egmFilePath: string;
60
68
  }): Promise<any> {
61
69
  const {inputUrl, outputPath, tilesetName, maxDepth, egmFilePath} = options;
@@ -66,11 +74,17 @@ export default class Tiles3DConverter {
66
74
  this.geoidHeightModel = await load(egmFilePath, PGMLoader);
67
75
  console.log('Loading egm file completed!'); // eslint-disable-line
68
76
 
77
+ await this.loadWorkers();
78
+
69
79
  const sourceTilesetJson = await load(inputUrl, I3SLoader, {});
80
+
70
81
  this.sourceTileset = new Tileset3D(sourceTilesetJson, {
71
- loadOptions: {i3s: {coordinateSystem: COORDINATE_SYSTEM.LNGLAT_OFFSETS}}
82
+ loadOptions: {
83
+ i3s: {coordinateSystem: COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false}
84
+ }
72
85
  });
73
86
 
87
+ await this.sourceTileset.tilesetInitializationPromise;
74
88
  const rootNode = this.sourceTileset.root!;
75
89
  if (!rootNode.header.obb) {
76
90
  rootNode.header.obb = createObbFromMbs(rootNode.header.mbs);
@@ -99,6 +113,10 @@ export default class Tiles3DConverter {
99
113
  await writeFile(this.tilesetPath, JSON.stringify(tileset), 'tileset.json');
100
114
 
101
115
  this._finishConversion({slpk: false, outputPath, tilesetName});
116
+
117
+ // Clean up worker pools
118
+ const workerFarm = WorkerFarm.getWorkerFarm({});
119
+ workerFarm.destroy();
102
120
  }
103
121
 
104
122
  /**
@@ -122,9 +140,12 @@ export default class Tiles3DConverter {
122
140
  await this.sourceTileset!._loadTile(sourceChild);
123
141
  this.vertexCounter += sourceChild.content.vertexCount;
124
142
 
125
- let attributes: FeatureAttribute | null = null;
143
+ let featureAttributes: FeatureAttribute | null = null;
126
144
  if (this.attributeStorageInfo) {
127
- attributes = await this._loadChildAttributes(sourceChild, this.attributeStorageInfo);
145
+ featureAttributes = await this._loadChildAttributes(
146
+ sourceChild,
147
+ this.attributeStorageInfo
148
+ );
128
149
  }
129
150
 
130
151
  if (!sourceChild.header.obb) {
@@ -140,7 +161,19 @@ export default class Tiles3DConverter {
140
161
  children: []
141
162
  };
142
163
 
143
- const b3dm = await new B3dmConverter().convert(sourceChild, attributes);
164
+ const i3sAttributesData: I3SAttributesData = {
165
+ tileContent: sourceChild.content,
166
+ textureFormat: sourceChild?.header?.textureFormat
167
+ };
168
+
169
+ // TODO Uncomment when 3d-tiles-attributes-worker will be published on CDN.
170
+ // const b3dm = await transform3DTilesAttributesOnWorker(i3sAttributesData, {
171
+ // source: this.workerSource.tile3dWorkerSource,
172
+ // featureAttributes
173
+ // });
174
+
175
+ const b3dm = await new B3dmConverter().convert(i3sAttributesData, featureAttributes);
176
+
144
177
  child.content = {
145
178
  uri: `${sourceChild.id}.b3dm`,
146
179
  boundingVolume
@@ -287,4 +320,14 @@ export default class Tiles3DConverter {
287
320
  console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line
288
321
  console.log(`------------------------------------------------`); // eslint-disable-line
289
322
  }
323
+
324
+ private async loadWorkers(): Promise<void> {
325
+ console.log(`Loading workers source...`); // eslint-disable-line no-undef, no-console
326
+ const tile3dAttributesWorkerUrl = getWorkerURL(Tile3dAttributesWorker, {...getLoaderOptions()});
327
+ const sourceResponse = await fetchFile(tile3dAttributesWorkerUrl);
328
+ const source = await sourceResponse.text();
329
+
330
+ this.workerSource.tile3dWorkerSource = source;
331
+ console.log(`Loading workers source completed!`); // eslint-disable-line no-undef, no-console
332
+ }
290
333
  }
@@ -1,7 +1,8 @@
1
- import {encode, encodeSync} from '@loaders.gl/core';
1
+ import type {I3SAttributesData} from '../../3d-tiles-attributes-worker';
2
+
3
+ import {encodeSync} from '@loaders.gl/core';
2
4
  import {GLTFScenegraph, GLTFWriter} from '@loaders.gl/gltf';
3
5
  import {Tile3DWriter} from '@loaders.gl/3d-tiles';
4
- import {ImageWriter} from '@loaders.gl/images';
5
6
  import {Matrix4, Vector3} from '@math.gl/core';
6
7
  import {Ellipsoid} from '@math.gl/geospatial';
7
8
  import {convertTextureAtlas} from './texture-atlas';
@@ -22,15 +23,17 @@ export default class B3dmConverter {
22
23
  * @param i3sTile - Tile3D instance for I3S node
23
24
  * @returns - encoded content
24
25
  */
25
- async convert(i3sTile: Object, attributes: any = null): Promise<ArrayBuffer> {
26
- this.i3sTile = i3sTile;
27
- const gltf = await this.buildGltf(i3sTile);
26
+ async convert(
27
+ i3sAttributesData: I3SAttributesData,
28
+ featureAttributes: any = null
29
+ ): Promise<ArrayBuffer> {
30
+ const gltf = await this.buildGltf(i3sAttributesData);
28
31
  const b3dm = encodeSync(
29
32
  {
30
33
  gltfEncoded: new Uint8Array(gltf),
31
34
  type: 'b3dm',
32
- featuresLength: this._getFeaturesLength(attributes),
33
- batchTable: attributes
35
+ featuresLength: this._getFeaturesLength(featureAttributes),
36
+ batchTable: featureAttributes
34
37
  },
35
38
  Tile3DWriter
36
39
  );
@@ -42,7 +45,8 @@ export default class B3dmConverter {
42
45
  * @param i3sTile - Tile3D instance for I3S node
43
46
  * @returns - encoded glb content
44
47
  */
45
- async buildGltf(i3sTile): Promise<ArrayBuffer> {
48
+ async buildGltf(i3sAttributesData: I3SAttributesData): Promise<ArrayBuffer> {
49
+ const {tileContent, textureFormat} = i3sAttributesData;
46
50
  const {
47
51
  material,
48
52
  attributes,
@@ -50,10 +54,10 @@ export default class B3dmConverter {
50
54
  cartesianOrigin,
51
55
  cartographicOrigin,
52
56
  modelMatrix
53
- } = i3sTile.content;
57
+ } = tileContent;
54
58
  const gltfBuilder = new GLTFScenegraph();
55
59
 
56
- const textureIndex = await this._addI3sTextureToGltf(i3sTile, gltfBuilder);
60
+ const textureIndex = await this._addI3sTextureToGltf(tileContent, textureFormat, gltfBuilder);
57
61
  const pbrMaterialInfo = this._convertI3sMaterialToGltfMaterial(material, textureIndex);
58
62
  const materialIndex = gltfBuilder.addMaterial(pbrMaterialInfo);
59
63
 
@@ -81,7 +85,8 @@ export default class B3dmConverter {
81
85
  const meshIndex = gltfBuilder.addMesh({
82
86
  attributes,
83
87
  indices,
84
- material: materialIndex
88
+ material: materialIndex,
89
+ mode: 4
85
90
  });
86
91
  const transformMatrix = this._generateTransformMatrix(cartesianOrigin);
87
92
  const nodeIndex = gltfBuilder.addNode({meshIndex, matrix: transformMatrix});
@@ -101,11 +106,8 @@ export default class B3dmConverter {
101
106
  * @param {GLTFScenegraph} gltfBuilder - gltfScenegraph instance to construct GLTF
102
107
  * @returns {Promise<number | null>} - GLTF texture index
103
108
  */
104
- async _addI3sTextureToGltf(i3sTile, gltfBuilder) {
105
- const {
106
- content: {texture, material, attributes},
107
- header: {textureFormat}
108
- } = i3sTile;
109
+ async _addI3sTextureToGltf(tileContent, textureFormat, gltfBuilder) {
110
+ const {texture, material, attributes} = tileContent;
109
111
  let textureIndex = null;
110
112
  let selectedTexture = texture;
111
113
  if (!texture && material) {
@@ -116,8 +118,7 @@ export default class B3dmConverter {
116
118
  }
117
119
  if (selectedTexture) {
118
120
  const mimeType = this._deduceMimeTypeFromFormat(textureFormat);
119
- const imageBuffer = await encode(selectedTexture, ImageWriter);
120
- const imageIndex = gltfBuilder.addImage(imageBuffer, mimeType);
121
+ const imageIndex = gltfBuilder.addImage(selectedTexture, mimeType);
121
122
  textureIndex = gltfBuilder.addTexture({imageIndex});
122
123
  delete attributes.colors;
123
124
  }
@@ -210,6 +211,8 @@ export default class B3dmConverter {
210
211
  return 'image/jpeg';
211
212
  case 'png':
212
213
  return 'image/png';
214
+ case 'ktx2':
215
+ return 'image/ktx2';
213
216
  default:
214
217
  console.warn(`Unexpected texture format in I3S: ${format}`); // eslint-disable-line no-console, no-undef
215
218
  return 'image/jpeg';