@loaders.gl/tile-converter 3.1.7 → 3.2.0-alpha.2

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 (224) 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.min.js +20 -20
  24. package/dist/deps-installer/deps-installer.d.ts +4 -0
  25. package/dist/deps-installer/deps-installer.d.ts.map +1 -0
  26. package/dist/deps-installer/deps-installer.js +21 -0
  27. package/dist/dist.min.js +1082 -1131
  28. package/dist/es5/3d-tiles-attributes-worker.js +29 -0
  29. package/dist/es5/3d-tiles-attributes-worker.js.map +1 -0
  30. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +104 -44
  31. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  32. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +34 -43
  33. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  34. package/dist/es5/i3s-attributes-worker.js +29 -0
  35. package/dist/es5/i3s-attributes-worker.js.map +1 -0
  36. package/dist/es5/i3s-converter/helpers/coordinate-converter.js +19 -11
  37. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  38. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +2 -2
  39. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  40. package/dist/es5/i3s-converter/helpers/geometry-converter.js +267 -178
  41. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  42. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +71 -0
  43. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -0
  44. package/dist/es5/i3s-converter/helpers/node-pages.js +43 -52
  45. package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
  46. package/dist/es5/i3s-converter/i3s-converter.js +264 -219
  47. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  48. package/dist/es5/index.js +8 -0
  49. package/dist/es5/index.js.map +1 -1
  50. package/dist/es5/lib/utils/compress-util.js +14 -17
  51. package/dist/es5/lib/utils/compress-util.js.map +1 -1
  52. package/dist/es5/lib/utils/file-utils.js +39 -14
  53. package/dist/es5/lib/utils/file-utils.js.map +1 -1
  54. package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
  55. package/dist/es5/lib/utils/queue.js +61 -0
  56. package/dist/es5/lib/utils/queue.js.map +1 -0
  57. package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
  58. package/dist/es5/lib/utils/write-queue.js +225 -0
  59. package/dist/es5/lib/utils/write-queue.js.map +1 -0
  60. package/dist/es5/pgm-loader.js +1 -1
  61. package/dist/es5/pgm-loader.js.map +1 -1
  62. package/dist/es5/workers/3d-tiles-attributes-worker.js +37 -0
  63. package/dist/es5/workers/3d-tiles-attributes-worker.js.map +1 -0
  64. package/dist/es5/workers/i3s-attributes-worker.js +40 -0
  65. package/dist/es5/workers/i3s-attributes-worker.js.map +1 -0
  66. package/dist/esm/3d-tiles-attributes-worker.js +16 -0
  67. package/dist/esm/3d-tiles-attributes-worker.js.map +1 -0
  68. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +32 -5
  69. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  70. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +23 -23
  71. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  72. package/dist/esm/i3s-attributes-worker.js +16 -0
  73. package/dist/esm/i3s-attributes-worker.js.map +1 -0
  74. package/dist/esm/i3s-converter/helpers/coordinate-converter.js +19 -11
  75. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  76. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +2 -2
  77. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  78. package/dist/esm/i3s-converter/helpers/geometry-converter.js +117 -58
  79. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  80. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +54 -0
  81. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -0
  82. package/dist/esm/i3s-converter/helpers/node-pages.js +12 -9
  83. package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
  84. package/dist/esm/i3s-converter/i3s-converter.js +115 -28
  85. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  86. package/dist/esm/index.js +1 -0
  87. package/dist/esm/index.js.map +1 -1
  88. package/dist/esm/lib/utils/compress-util.js +6 -8
  89. package/dist/esm/lib/utils/compress-util.js.map +1 -1
  90. package/dist/esm/lib/utils/file-utils.js +11 -1
  91. package/dist/esm/lib/utils/file-utils.js.map +1 -1
  92. package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
  93. package/dist/esm/lib/utils/queue.js +19 -0
  94. package/dist/esm/lib/utils/queue.js.map +1 -0
  95. package/dist/esm/lib/utils/statistic-utills.js.map +1 -1
  96. package/dist/esm/lib/utils/write-queue.js +88 -0
  97. package/dist/esm/lib/utils/write-queue.js.map +1 -0
  98. package/dist/esm/pgm-loader.js +1 -1
  99. package/dist/esm/pgm-loader.js.map +1 -1
  100. package/dist/esm/workers/3d-tiles-attributes-worker.js +5 -0
  101. package/dist/esm/workers/3d-tiles-attributes-worker.js.map +1 -0
  102. package/dist/esm/workers/i3s-attributes-worker.js +4 -0
  103. package/dist/esm/workers/i3s-attributes-worker.js.map +1 -0
  104. package/dist/i3s-attributes-worker.d.ts +33 -0
  105. package/dist/i3s-attributes-worker.d.ts.map +1 -0
  106. package/dist/i3s-attributes-worker.js +10 -0
  107. package/dist/i3s-attributes-worker.js.map +7 -0
  108. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +41 -0
  109. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -0
  110. package/dist/i3s-converter/helpers/coordinate-converter.js +122 -0
  111. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts +9 -0
  112. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts.map +1 -0
  113. package/dist/i3s-converter/helpers/create-scene-server-path.js +28 -0
  114. package/dist/i3s-converter/helpers/geometry-attributes.d.ts +8 -0
  115. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -0
  116. package/dist/i3s-converter/helpers/geometry-attributes.js +177 -0
  117. package/dist/i3s-converter/helpers/geometry-converter.d.ts +29 -0
  118. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -0
  119. package/dist/i3s-converter/helpers/geometry-converter.js +901 -0
  120. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +9 -0
  121. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -0
  122. package/dist/i3s-converter/helpers/gltf-attributes.js +56 -0
  123. package/dist/i3s-converter/helpers/node-debug.d.ts +8 -0
  124. package/dist/i3s-converter/helpers/node-debug.d.ts.map +1 -0
  125. package/dist/i3s-converter/helpers/node-debug.js +114 -0
  126. package/dist/i3s-converter/helpers/node-pages.d.ts +117 -0
  127. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -0
  128. package/dist/i3s-converter/helpers/node-pages.js +208 -0
  129. package/dist/i3s-converter/i3s-converter.d.ts +325 -0
  130. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -0
  131. package/dist/i3s-converter/i3s-converter.js +1056 -0
  132. package/dist/i3s-converter/json-templates/layers.d.ts +95 -0
  133. package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -0
  134. package/dist/i3s-converter/json-templates/layers.js +199 -0
  135. package/dist/i3s-converter/json-templates/metadata.d.ts +22 -0
  136. package/dist/i3s-converter/json-templates/metadata.d.ts.map +1 -0
  137. package/dist/i3s-converter/json-templates/metadata.js +25 -0
  138. package/dist/i3s-converter/json-templates/node.d.ts +61 -0
  139. package/dist/i3s-converter/json-templates/node.d.ts.map +1 -0
  140. package/dist/i3s-converter/json-templates/node.js +89 -0
  141. package/dist/i3s-converter/json-templates/scene-server.d.ts +28 -0
  142. package/dist/i3s-converter/json-templates/scene-server.d.ts.map +1 -0
  143. package/dist/i3s-converter/json-templates/scene-server.js +31 -0
  144. package/dist/i3s-converter/json-templates/shared-resources.d.ts +14 -0
  145. package/dist/i3s-converter/json-templates/shared-resources.d.ts.map +1 -0
  146. package/dist/i3s-converter/json-templates/shared-resources.js +129 -0
  147. package/dist/i3s-converter/json-templates/store.d.ts +95 -0
  148. package/dist/i3s-converter/json-templates/store.d.ts.map +1 -0
  149. package/dist/i3s-converter/json-templates/store.js +103 -0
  150. package/dist/i3s-converter/types.d.ts +114 -0
  151. package/dist/i3s-converter/types.d.ts.map +1 -0
  152. package/dist/i3s-converter/types.js +2 -0
  153. package/dist/i3s-server/app.d.ts +3 -0
  154. package/dist/i3s-server/app.d.ts.map +1 -0
  155. package/dist/i3s-server/app.js +14 -0
  156. package/dist/i3s-server/controllers/index-controller.d.ts +2 -0
  157. package/dist/i3s-server/controllers/index-controller.d.ts.map +1 -0
  158. package/dist/i3s-server/controllers/index-controller.js +23 -0
  159. package/dist/i3s-server/routes/index.d.ts +3 -0
  160. package/dist/i3s-server/routes/index.d.ts.map +1 -0
  161. package/dist/i3s-server/routes/index.js +16 -0
  162. package/dist/index.d.ts +6 -0
  163. package/dist/index.d.ts.map +1 -0
  164. package/dist/index.js +16 -0
  165. package/dist/lib/utils/compress-util.d.ts +45 -0
  166. package/dist/lib/utils/compress-util.d.ts.map +1 -0
  167. package/dist/lib/utils/compress-util.js +257 -0
  168. package/{src → dist}/lib/utils/file-utils.d.ts +6 -14
  169. package/dist/lib/utils/file-utils.d.ts.map +1 -0
  170. package/dist/lib/utils/file-utils.js +81 -0
  171. package/dist/lib/utils/lod-conversion-utils.d.ts +41 -0
  172. package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -0
  173. package/dist/lib/utils/lod-conversion-utils.js +76 -0
  174. package/dist/lib/utils/queue.d.ts +7 -0
  175. package/dist/lib/utils/queue.d.ts.map +1 -0
  176. package/dist/lib/utils/queue.js +18 -0
  177. package/dist/lib/utils/statistic-utills.d.ts +3 -0
  178. package/dist/lib/utils/statistic-utills.d.ts.map +1 -0
  179. package/dist/lib/utils/statistic-utills.js +64 -0
  180. package/dist/lib/utils/write-queue.d.ts +22 -0
  181. package/dist/lib/utils/write-queue.d.ts.map +1 -0
  182. package/dist/lib/utils/write-queue.js +62 -0
  183. package/dist/pgm-loader.d.ts +6 -0
  184. package/dist/pgm-loader.d.ts.map +1 -0
  185. package/dist/pgm-loader.js +23 -0
  186. package/dist/workers/3d-tiles-attributes-worker.d.ts +2 -0
  187. package/dist/workers/3d-tiles-attributes-worker.d.ts.map +1 -0
  188. package/dist/workers/3d-tiles-attributes-worker.js +9 -0
  189. package/dist/workers/i3s-attributes-worker.d.ts +2 -0
  190. package/dist/workers/i3s-attributes-worker.d.ts.map +1 -0
  191. package/dist/workers/i3s-attributes-worker.js +5 -0
  192. package/package.json +20 -18
  193. package/src/3d-tiles-attributes-worker.ts +43 -0
  194. package/src/3d-tiles-converter/3d-tiles-converter.ts +48 -5
  195. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +21 -18
  196. package/src/i3s-attributes-worker.ts +46 -0
  197. package/src/i3s-converter/helpers/coordinate-converter.ts +29 -24
  198. package/src/i3s-converter/helpers/geometry-attributes.ts +4 -3
  199. package/src/i3s-converter/helpers/{geometry-converter.js → geometry-converter.ts} +421 -175
  200. package/src/i3s-converter/helpers/gltf-attributes.ts +68 -0
  201. package/src/i3s-converter/helpers/node-pages.ts +25 -17
  202. package/src/i3s-converter/i3s-converter.ts +124 -69
  203. package/src/i3s-converter/types.ts +90 -8
  204. package/src/index.ts +1 -0
  205. package/src/lib/utils/{compress-util.js → compress-util.ts} +105 -18
  206. package/src/lib/utils/file-utils.ts +84 -0
  207. package/src/lib/utils/{lod-conversion-utils.js → lod-conversion-utils.ts} +27 -5
  208. package/src/lib/utils/queue.ts +17 -0
  209. package/src/lib/utils/{statistic-utills.js → statistic-utills.ts} +0 -0
  210. package/src/lib/utils/write-queue.ts +75 -0
  211. package/src/workers/3d-tiles-attributes-worker.ts +6 -0
  212. package/src/workers/i3s-attributes-worker.ts +6 -0
  213. package/dist/es5/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  214. package/dist/es5/lib/utils/compress-util.d.ts +0 -53
  215. package/dist/es5/lib/utils/file-utils.d.ts +0 -43
  216. package/dist/es5/lib/utils/lod-conversion-utils.d.ts +0 -32
  217. package/dist/esm/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  218. package/dist/esm/lib/utils/compress-util.d.ts +0 -53
  219. package/dist/esm/lib/utils/file-utils.d.ts +0 -43
  220. package/dist/esm/lib/utils/lod-conversion-utils.d.ts +0 -32
  221. package/src/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  222. package/src/lib/utils/compress-util.d.ts +0 -53
  223. package/src/lib/utils/file-utils.js +0 -38
  224. 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.7",
3
+ "version": "3.2.0-alpha.2",
4
4
  "description": "Converter",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -33,25 +33,27 @@
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-bin": "BABEL_ENV=es5 babel scripts --config-file ../../babel.config.js --out-dir dist/scripts",
40
+ "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\\\"",
41
+ "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
42
  },
42
43
  "dependencies": {
43
- "@loaders.gl/3d-tiles": "3.1.7",
44
- "@loaders.gl/crypto": "3.1.7",
45
- "@loaders.gl/draco": "3.1.7",
46
- "@loaders.gl/gltf": "3.1.7",
47
- "@loaders.gl/i3s": "3.1.7",
48
- "@loaders.gl/images": "3.1.7",
49
- "@loaders.gl/loader-utils": "3.1.7",
50
- "@loaders.gl/polyfills": "3.1.7",
51
- "@loaders.gl/textures": "3.1.7",
52
- "@loaders.gl/tiles": "3.1.7",
53
- "@loaders.gl/worker-utils": "3.1.7",
54
- "@loaders.gl/zip": "3.1.7",
44
+ "@loaders.gl/3d-tiles": "3.2.0-alpha.2",
45
+ "@loaders.gl/crypto": "3.2.0-alpha.2",
46
+ "@loaders.gl/draco": "3.2.0-alpha.2",
47
+ "@loaders.gl/gltf": "3.2.0-alpha.2",
48
+ "@loaders.gl/i3s": "3.2.0-alpha.2",
49
+ "@loaders.gl/images": "3.2.0-alpha.2",
50
+ "@loaders.gl/loader-utils": "3.2.0-alpha.2",
51
+ "@loaders.gl/polyfills": "3.2.0-alpha.2",
52
+ "@loaders.gl/schema": "3.2.0-alpha.2",
53
+ "@loaders.gl/textures": "3.2.0-alpha.2",
54
+ "@loaders.gl/tiles": "3.2.0-alpha.2",
55
+ "@loaders.gl/worker-utils": "3.2.0-alpha.2",
56
+ "@loaders.gl/zip": "3.2.0-alpha.2",
55
57
  "@luma.gl/engine": "^8.5.4",
56
58
  "@math.gl/core": "^3.5.1",
57
59
  "@math.gl/culling": "^3.5.1",
@@ -69,7 +71,7 @@
69
71
  "uuid": "^8.1.0"
70
72
  },
71
73
  "peerDependencies": {
72
- "@loaders.gl/core": "^3.1.0"
74
+ "@loaders.gl/core": "3.2.0-alpha.1"
73
75
  },
74
- "gitHead": "e48d29e426e9f23879875763e73efc5c58345be1"
76
+ "gitHead": "52a602739cbfce60fc314f474efc984d199dff78"
75
77
  }
@@ -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
  /**
@@ -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';
@@ -0,0 +1,46 @@
1
+ import type {WorkerObject} from '@loaders.gl/worker-utils';
2
+ import type {ConvertedAttributes} from './i3s-converter/types';
3
+ import type {Matrix4, Vector3} from '@math.gl/core';
4
+
5
+ import {processOnWorker} from '@loaders.gl/worker-utils';
6
+
7
+ // __VERSION__ is injected by babel-plugin-version-inline
8
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
9
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
10
+
11
+ export type I3SAttributesWorkerOptions = {
12
+ useCartesianPositions: boolean;
13
+ source: string;
14
+ };
15
+
16
+ export type B3DMAttributesData = {
17
+ gltfMaterials?: {id: string}[];
18
+ nodes: any;
19
+ cartographicOrigin: Vector3;
20
+ cartesianModelMatrix: Matrix4;
21
+ };
22
+
23
+ /**
24
+ * I3S Attributes Worker to handle B3DM object
25
+ */
26
+ export const I3SAttributesWorker = {
27
+ id: 'i3s-attributes',
28
+ name: 'I3S Attributes Worker',
29
+ module: 'tile-converter',
30
+ version: VERSION,
31
+ options: {
32
+ useCartesianPositions: false
33
+ }
34
+ };
35
+
36
+ /**
37
+ * Performs I3S attributes transformation
38
+ */
39
+ export function transformI3SAttributesOnWorker(
40
+ attributesData: B3DMAttributesData,
41
+ options: I3SAttributesWorkerOptions
42
+ ): Promise<Map<string, ConvertedAttributes>> {
43
+ return processOnWorker(I3SAttributesWorker, attributesData, options);
44
+ }
45
+
46
+ export const _typecheckI3SAttributesWorker: WorkerObject = I3SAttributesWorker;
@@ -1,15 +1,15 @@
1
- import type {BoundingVolumes, Extent, Mbs, Obb} from '@loaders.gl/i3s';
1
+ import type {BoundingVolumes, FullExtent, Mbs, Obb} from '@loaders.gl/i3s';
2
2
 
3
3
  import {Matrix3, Quaternion, Vector3} from '@math.gl/core';
4
4
  import {Ellipsoid} from '@math.gl/geospatial';
5
5
  import {
6
6
  OrientedBoundingBox,
7
7
  makeOrientedBoundingBoxFromPoints,
8
- makeBoundingSphereFromPoints
8
+ makeBoundingSphereFromPoints,
9
+ BoundingSphere
9
10
  } from '@math.gl/culling';
10
11
  import TileHeader from '@loaders.gl/tiles/src/tileset/tile-3d';
11
12
  import {Geoid} from '@math.gl/geoid';
12
- import {Tileset3D} from '@loaders.gl/tiles';
13
13
 
14
14
  /**
15
15
  * Create bounding volumes object from tile and geoid height model.
@@ -101,34 +101,39 @@ export function convertPositionsToVectors(positions: Float32Array): Vector3[] {
101
101
  }
102
102
 
103
103
  /**
104
- * Convert common coordinate to extent coordinate
105
- * @param tileset
106
- * @returns - Extent
107
- * @todo why lodMetricValue is radius? need to check this function
104
+ * Convert common coordinate to fullExtent https://github.com/Esri/i3s-spec/blob/master/docs/1.8/fullExtent.cmn.md
105
+ * @param
106
+ * @param boundingVolume
107
+ * @returns - fullExtent object
108
108
  */
109
- export function convertCommonToI3SExtentCoordinate(tileset: Tileset3D | null): Extent | null {
110
- const cartesianCenter = tileset?.cartesianCenter;
111
- if (!cartesianCenter) {
112
- return null;
109
+ export function convertBoundingVolumeToI3SFullExtent(
110
+ boundingVolume: OrientedBoundingBox | BoundingSphere
111
+ ): FullExtent {
112
+ let sphere: BoundingSphere;
113
+ if (boundingVolume instanceof BoundingSphere) {
114
+ sphere = boundingVolume;
115
+ } else {
116
+ sphere = boundingVolume.getBoundingSphere();
113
117
  }
114
- const radius = tileset?.lodMetricValue;
115
- const rightTop = Ellipsoid.WGS84.cartesianToCartographic(
116
- new Vector3(cartesianCenter[0] + radius, cartesianCenter[1] + radius, cartesianCenter[2]),
118
+ const center: Vector3 = sphere.center;
119
+ const radius: number = sphere.radius;
120
+ const vertexMax = Ellipsoid.WGS84.cartesianToCartographic(
121
+ new Vector3(center[0] + radius, center[1] + radius, center[2] + radius),
117
122
  new Vector3()
118
123
  );
119
- const leftBottom = Ellipsoid.WGS84.cartesianToCartographic(
120
- new Vector3(cartesianCenter[0] - radius, cartesianCenter[1] - radius, cartesianCenter[2]),
124
+ const vertexMin = Ellipsoid.WGS84.cartesianToCartographic(
125
+ new Vector3(center[0] - radius, center[1] - radius, center[2] - radius),
121
126
  new Vector3()
122
127
  );
123
- const isFirstRight = rightTop[0] < leftBottom[0];
124
- const isFirstTop = rightTop[1] < leftBottom[1];
125
128
 
126
- return [
127
- isFirstRight ? rightTop[0] : leftBottom[0],
128
- isFirstTop ? rightTop[1] : leftBottom[1],
129
- isFirstRight ? leftBottom[0] : rightTop[0],
130
- isFirstTop ? leftBottom[1] : rightTop[1]
131
- ];
129
+ return {
130
+ xmin: vertexMin[0],
131
+ xmax: vertexMax[0],
132
+ ymin: vertexMin[1],
133
+ ymax: vertexMax[1],
134
+ zmin: vertexMin[2],
135
+ zmax: vertexMax[2]
136
+ };
132
137
  }
133
138
 
134
139
  /**
@@ -1,4 +1,4 @@
1
- import type {GeometryAttributes, AttributesData, GroupedByFeatureIdAttributes} from '../types';
1
+ import type {GeometryAttributes, ConvertedAttributes, GroupedByFeatureIdAttributes} from '../types';
2
2
  import {concatenateTypedArrays} from '@loaders.gl/loader-utils';
3
3
 
4
4
  const VALUES_PER_VERTEX = 3;
@@ -9,8 +9,9 @@ const POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;
9
9
  * @param attributes
10
10
  * @returns attirbutes with featureCount, featureIds and changed faceRange.
11
11
  */
12
- export function generateAttributes(attributes: AttributesData): GeometryAttributes {
13
- const {positions, normals, texCoords, colors, featureIndices, triangleCount} = attributes;
12
+ export function generateAttributes(attributes: ConvertedAttributes): GeometryAttributes {
13
+ const {positions, normals, texCoords, colors, featureIndices} = attributes;
14
+ const triangleCount = positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;
14
15
 
15
16
  if (!featureIndices.length) {
16
17
  return {