@loaders.gl/tile-converter 3.1.0-alpha.3 → 3.1.0-beta.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 (198) hide show
  1. package/bin/converter.js +1 -1
  2. package/dist/bundle.js +85947 -4
  3. package/dist/converter.min.js +292 -0
  4. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +267 -0
  5. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -0
  6. package/dist/{3d-tiles-converter → es5/3d-tiles-converter}/helpers/b3dm-converter.d.ts +0 -0
  7. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +269 -0
  8. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -0
  9. package/dist/{3d-tiles-converter → es5/3d-tiles-converter}/helpers/i3s-obb-to-3d-tiles-obb.d.ts +0 -0
  10. package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +22 -0
  11. package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -0
  12. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js +40 -0
  13. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +1 -0
  14. package/dist/es5/3d-tiles-converter/json-templates/tileset.js +48 -0
  15. package/dist/es5/3d-tiles-converter/json-templates/tileset.js.map +1 -0
  16. package/dist/es5/bundle.js +7 -0
  17. package/dist/es5/bundle.js.map +1 -0
  18. package/dist/{deps-installer → es5/deps-installer}/deps-installer.d.ts +0 -0
  19. package/dist/es5/deps-installer/deps-installer.js +39 -0
  20. package/dist/es5/deps-installer/deps-installer.js.map +1 -0
  21. package/dist/es5/i3s-converter/helpers/coordinate-converter.js +65 -0
  22. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -0
  23. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js +30 -0
  24. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +1 -0
  25. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +208 -0
  26. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -0
  27. package/dist/{i3s-converter → es5/i3s-converter}/helpers/geometry-converter.d.ts +0 -0
  28. package/dist/es5/i3s-converter/helpers/geometry-converter.js +700 -0
  29. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -0
  30. package/dist/es5/i3s-converter/helpers/node-debug.js +103 -0
  31. package/dist/es5/i3s-converter/helpers/node-debug.js.map +1 -0
  32. package/dist/{i3s-converter → es5/i3s-converter}/helpers/node-pages.d.ts +0 -0
  33. package/dist/es5/i3s-converter/helpers/node-pages.js +150 -0
  34. package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -0
  35. package/dist/es5/i3s-converter/i3s-converter.js +915 -0
  36. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -0
  37. package/dist/es5/i3s-converter/json-templates/layers.js +203 -0
  38. package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -0
  39. package/dist/es5/i3s-converter/json-templates/metadata.js +29 -0
  40. package/dist/es5/i3s-converter/json-templates/metadata.js.map +1 -0
  41. package/dist/es5/i3s-converter/json-templates/node.js +91 -0
  42. package/dist/es5/i3s-converter/json-templates/node.js.map +1 -0
  43. package/dist/es5/i3s-converter/json-templates/scene-server.js +35 -0
  44. package/dist/es5/i3s-converter/json-templates/scene-server.js.map +1 -0
  45. package/dist/es5/i3s-converter/json-templates/shared-resources.js +141 -0
  46. package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -0
  47. package/dist/es5/i3s-converter/json-templates/store.js +105 -0
  48. package/dist/es5/i3s-converter/json-templates/store.js.map +1 -0
  49. package/dist/es5/i3s-server/app.js +23 -0
  50. package/dist/es5/i3s-server/app.js.map +1 -0
  51. package/dist/{i3s-server → es5/i3s-server}/bin/www +0 -0
  52. package/dist/{i3s-server → es5/i3s-server}/certs/cert.pem +0 -0
  53. package/dist/{i3s-server → es5/i3s-server}/certs/key.pem +0 -0
  54. package/dist/es5/i3s-server/controllers/index-controller.js +33 -0
  55. package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -0
  56. package/dist/es5/i3s-server/routes/index.js +22 -0
  57. package/dist/es5/i3s-server/routes/index.js.map +1 -0
  58. package/dist/es5/index.js +40 -0
  59. package/dist/es5/index.js.map +1 -0
  60. package/dist/{lib → es5/lib}/geoid-height-model.d.ts +0 -0
  61. package/dist/es5/lib/geoid-height-model.js +149 -0
  62. package/dist/es5/lib/geoid-height-model.js.map +1 -0
  63. package/dist/{lib → es5/lib}/pgm-parser.d.ts +0 -0
  64. package/dist/es5/lib/pgm-parser.js +192 -0
  65. package/dist/es5/lib/pgm-parser.js.map +1 -0
  66. package/dist/es5/lib/utils/compress-util.js +202 -0
  67. package/dist/es5/lib/utils/compress-util.js.map +1 -0
  68. package/dist/{lib → es5/lib}/utils/compress-utils.d.ts +0 -0
  69. package/dist/{lib → es5/lib}/utils/file-utils.d.ts +0 -0
  70. package/dist/es5/lib/utils/file-utils.js +59 -0
  71. package/dist/es5/lib/utils/file-utils.js.map +1 -0
  72. package/dist/{lib → es5/lib}/utils/lod-conversion-utils.d.ts +0 -0
  73. package/dist/es5/lib/utils/lod-conversion-utils.js +52 -0
  74. package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -0
  75. package/dist/{lib → es5/lib}/utils/statistic-utills.d.ts +0 -0
  76. package/dist/es5/lib/utils/statistic-utills.js +85 -0
  77. package/dist/es5/lib/utils/statistic-utills.js.map +1 -0
  78. package/dist/es5/pgm-loader.js +24 -0
  79. package/dist/es5/pgm-loader.js.map +1 -0
  80. package/dist/{3d-tiles-converter → esm/3d-tiles-converter}/3d-tiles-converter.js +19 -13
  81. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -0
  82. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.d.ts +23 -0
  83. package/dist/{3d-tiles-converter → esm/3d-tiles-converter}/helpers/b3dm-converter.js +19 -8
  84. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -0
  85. package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +16 -0
  86. package/dist/{3d-tiles-converter → esm/3d-tiles-converter}/helpers/i3s-obb-to-3d-tiles-obb.js +0 -0
  87. package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -0
  88. package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js +33 -0
  89. package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +1 -0
  90. package/dist/{3d-tiles-converter → esm/3d-tiles-converter}/json-templates/tileset.js +0 -0
  91. package/dist/esm/3d-tiles-converter/json-templates/tileset.js.map +1 -0
  92. package/dist/esm/bundle.js +5 -0
  93. package/dist/esm/bundle.js.map +1 -0
  94. package/dist/esm/deps-installer/deps-installer.d.ts +10 -0
  95. package/dist/{deps-installer → esm/deps-installer}/deps-installer.js +0 -0
  96. package/dist/esm/deps-installer/deps-installer.js.map +1 -0
  97. package/dist/{i3s-converter → esm/i3s-converter}/helpers/coordinate-converter.js +0 -0
  98. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -0
  99. package/dist/{i3s-converter → esm/i3s-converter}/helpers/create-scene-server-path.js +0 -0
  100. package/dist/esm/i3s-converter/helpers/create-scene-server-path.js.map +1 -0
  101. package/dist/{i3s-converter → esm/i3s-converter}/helpers/geometry-attributes.js +0 -0
  102. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -0
  103. package/dist/esm/i3s-converter/helpers/geometry-converter.d.ts +40 -0
  104. package/dist/{i3s-converter → esm/i3s-converter}/helpers/geometry-converter.js +29 -31
  105. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -0
  106. package/dist/{i3s-converter → esm/i3s-converter}/helpers/node-debug.js +2 -2
  107. package/dist/esm/i3s-converter/helpers/node-debug.js.map +1 -0
  108. package/dist/esm/i3s-converter/helpers/node-pages.d.ts +144 -0
  109. package/dist/{i3s-converter → esm/i3s-converter}/helpers/node-pages.js +2 -2
  110. package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -0
  111. package/dist/{i3s-converter → esm/i3s-converter}/i3s-converter.js +50 -31
  112. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -0
  113. package/dist/{i3s-converter → esm/i3s-converter}/json-templates/layers.js +0 -0
  114. package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -0
  115. package/dist/{i3s-converter → esm/i3s-converter}/json-templates/metadata.js +1 -1
  116. package/dist/esm/i3s-converter/json-templates/metadata.js.map +1 -0
  117. package/dist/{i3s-converter → esm/i3s-converter}/json-templates/node.js +0 -0
  118. package/dist/esm/i3s-converter/json-templates/node.js.map +1 -0
  119. package/dist/{i3s-converter → esm/i3s-converter}/json-templates/scene-server.js +1 -1
  120. package/dist/esm/i3s-converter/json-templates/scene-server.js.map +1 -0
  121. package/dist/{i3s-converter → esm/i3s-converter}/json-templates/shared-resources.js +2 -2
  122. package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +1 -0
  123. package/dist/{i3s-converter → esm/i3s-converter}/json-templates/store.js +2 -2
  124. package/dist/esm/i3s-converter/json-templates/store.js.map +1 -0
  125. package/dist/{i3s-server → esm/i3s-server}/app.js +0 -0
  126. package/dist/esm/i3s-server/app.js.map +1 -0
  127. package/dist/esm/i3s-server/bin/www +102 -0
  128. package/dist/esm/i3s-server/certs/cert.pem +19 -0
  129. package/dist/esm/i3s-server/certs/key.pem +27 -0
  130. package/dist/{i3s-server → esm/i3s-server}/controllers/index-controller.js +2 -2
  131. package/dist/esm/i3s-server/controllers/index-controller.js.map +1 -0
  132. package/dist/{i3s-server → esm/i3s-server}/routes/index.js +0 -0
  133. package/dist/esm/i3s-server/routes/index.js.map +1 -0
  134. package/dist/{index.js → esm/index.js} +0 -0
  135. package/dist/esm/index.js.map +1 -0
  136. package/dist/esm/lib/geoid-height-model.d.ts +41 -0
  137. package/dist/{lib → esm/lib}/geoid-height-model.js +0 -0
  138. package/dist/esm/lib/geoid-height-model.js.map +1 -0
  139. package/dist/esm/lib/pgm-parser.d.ts +14 -0
  140. package/dist/{lib → esm/lib}/pgm-parser.js +0 -0
  141. package/dist/esm/lib/pgm-parser.js.map +1 -0
  142. package/dist/{lib → esm/lib}/utils/compress-util.js +13 -13
  143. package/dist/esm/lib/utils/compress-util.js.map +1 -0
  144. package/dist/esm/lib/utils/compress-utils.d.ts +53 -0
  145. package/dist/esm/lib/utils/file-utils.d.ts +43 -0
  146. package/dist/{lib → esm/lib}/utils/file-utils.js +1 -1
  147. package/dist/esm/lib/utils/file-utils.js.map +1 -0
  148. package/dist/esm/lib/utils/lod-conversion-utils.d.ts +32 -0
  149. package/dist/{lib → esm/lib}/utils/lod-conversion-utils.js +0 -0
  150. package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -0
  151. package/dist/esm/lib/utils/statistic-utills.d.ts +25 -0
  152. package/dist/{lib → esm/lib}/utils/statistic-utills.js +5 -5
  153. package/dist/esm/lib/utils/statistic-utills.js.map +1 -0
  154. package/dist/{pgm-loader.js → esm/pgm-loader.js} +1 -1
  155. package/dist/esm/pgm-loader.js.map +1 -0
  156. package/package.json +24 -21
  157. package/src/3d-tiles-converter/3d-tiles-converter.ts +4 -2
  158. package/src/3d-tiles-converter/helpers/b3dm-converter.js +35 -7
  159. package/src/3d-tiles-converter/helpers/texture-atlas.ts +55 -0
  160. package/src/i3s-converter/helpers/geometry-converter.js +21 -22
  161. package/src/i3s-converter/i3s-converter.ts +32 -7
  162. package/src/i3s-converter/json-templates/metadata.js +1 -1
  163. package/src/i3s-converter/json-templates/scene-server.js +1 -1
  164. package/src/i3s-converter/json-templates/store.js +2 -2
  165. package/src/i3s-server/controllers/index-controller.js +1 -1
  166. package/dist/3d-tiles-converter/3d-tiles-converter.js.map +0 -1
  167. package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +0 -1
  168. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +0 -1
  169. package/dist/3d-tiles-converter/json-templates/tileset.js.map +0 -1
  170. package/dist/bundle.js.map +0 -1
  171. package/dist/deps-installer/deps-installer.js.map +0 -1
  172. package/dist/dist.min.js +0 -94
  173. package/dist/dist.min.js.map +0 -1
  174. package/dist/i3s-converter/helpers/coordinate-converter.js.map +0 -1
  175. package/dist/i3s-converter/helpers/create-scene-server-path.js.map +0 -1
  176. package/dist/i3s-converter/helpers/geometry-attributes.js.map +0 -1
  177. package/dist/i3s-converter/helpers/geometry-converter.js.map +0 -1
  178. package/dist/i3s-converter/helpers/node-debug.js.map +0 -1
  179. package/dist/i3s-converter/helpers/node-pages.js.map +0 -1
  180. package/dist/i3s-converter/i3s-converter.js.map +0 -1
  181. package/dist/i3s-converter/json-templates/layers.js.map +0 -1
  182. package/dist/i3s-converter/json-templates/metadata.js.map +0 -1
  183. package/dist/i3s-converter/json-templates/node.js.map +0 -1
  184. package/dist/i3s-converter/json-templates/scene-server.js.map +0 -1
  185. package/dist/i3s-converter/json-templates/shared-resources.js.map +0 -1
  186. package/dist/i3s-converter/json-templates/store.js.map +0 -1
  187. package/dist/i3s-server/app.js.map +0 -1
  188. package/dist/i3s-server/controllers/index-controller.js.map +0 -1
  189. package/dist/i3s-server/routes/index.js.map +0 -1
  190. package/dist/index.js.map +0 -1
  191. package/dist/lib/geoid-height-model.js.map +0 -1
  192. package/dist/lib/pgm-parser.js.map +0 -1
  193. package/dist/lib/utils/compress-util.js.map +0 -1
  194. package/dist/lib/utils/file-utils.js.map +0 -1
  195. package/dist/lib/utils/lod-conversion-utils.js.map +0 -1
  196. package/dist/lib/utils/statistic-utills.js.map +0 -1
  197. package/dist/pgm-loader.js.map +0 -1
  198. package/dist/scripts/converter.js +0 -274
@@ -0,0 +1,40 @@
1
+ import {Vector3, Matrix4} from '@math.gl/core';
2
+ /**
3
+ * Convert binary data from b3dm file to i3s resources
4
+ *
5
+ * @param tileContent - 3d tile content
6
+ * @param options - converter options
7
+ * @returns A promise that resolves to object with `geometry`, compressedGeometry`, `texture` and `sharedResources` appropriate
8
+ * for use I3S tiles.
9
+ */
10
+ export default function convertB3dmToI3sGeometry(
11
+ tileContent: {
12
+ batchTableJson: {
13
+ id: [];
14
+ };
15
+ cartographicOrigin: Vector3;
16
+ cartesianModelMatrix: Matrix4;
17
+ gltf: {
18
+ scene: {
19
+ nodes: [];
20
+ };
21
+ images: [];
22
+ materials: [];
23
+ };
24
+ },
25
+ nodeId: number,
26
+ featuresHashArray: any,
27
+ attributeStorageInfo: any,
28
+ draco: boolean
29
+ ): Promise<
30
+ {
31
+ geometry: ArrayBuffer;
32
+ compressedGeometry: ArrayBuffer;
33
+ texture: any;
34
+ sharedResources: any;
35
+ meshMaterial: any;
36
+ vertexCount: number;
37
+ attributes: any;
38
+ featureCount: number;
39
+ }[]
40
+ >;
@@ -25,11 +25,18 @@ export default async function convertB3dmToI3sGeometry(tileContent, nodeId, feat
25
25
 
26
26
  const result = [];
27
27
  let nodesCounter = nodeId;
28
+ let {
29
+ materials = []
30
+ } = tileContent.gltf;
28
31
 
29
- for (let i = 0; i < (tileContent.gltf.materials.length || 1); i++) {
30
- const sourceMaterial = tileContent.gltf.materials[i] || {
32
+ if (!materials.length === 0) {
33
+ materials.push({
31
34
  id: 'default'
32
- };
35
+ });
36
+ }
37
+
38
+ for (let i = 0; i < materials.length; i++) {
39
+ const sourceMaterial = materials[i];
33
40
 
34
41
  if (!convertedAttributesMap.has(sourceMaterial.id)) {
35
42
  continue;
@@ -53,6 +60,10 @@ export default async function convertB3dmToI3sGeometry(tileContent, nodeId, feat
53
60
  nodesCounter++;
54
61
  }
55
62
 
63
+ if (!result.length) {
64
+ return null;
65
+ }
66
+
56
67
  return result;
57
68
  }
58
69
 
@@ -111,6 +122,8 @@ async function _makeNodeResources({
111
122
  }
112
123
 
113
124
  function convertAttributes(tileContent) {
125
+ var _tileContent$gltf$sce;
126
+
114
127
  const attributesMap = new Map();
115
128
 
116
129
  for (const material of tileContent.gltf.materials || [{
@@ -125,7 +138,7 @@ function convertAttributes(tileContent) {
125
138
  });
126
139
  }
127
140
 
128
- const nodes = tileContent.gltf.scene.nodes;
141
+ const nodes = (tileContent.gltf.scene || ((_tileContent$gltf$sce = tileContent.gltf.scenes) === null || _tileContent$gltf$sce === void 0 ? void 0 : _tileContent$gltf$sce[0]) || tileContent.gltf).nodes;
129
142
  convertNodes(nodes, tileContent, attributesMap);
130
143
 
131
144
  for (const attrKey of attributesMap.keys()) {
@@ -136,24 +149,6 @@ function convertAttributes(tileContent) {
136
149
  continue;
137
150
  }
138
151
 
139
- const vertexCount = attributes.positions.length / VALUES_PER_VERTEX;
140
-
141
- if (!attributes.colors.length) {
142
- attributes.colors = new Uint8Array(vertexCount * VALUES_PER_COLOR_ELEMENT);
143
-
144
- for (let index = 0; index < attributes.colors.length; index += 4) {
145
- attributes.colors.set([255, 255, 255, 255], index);
146
- }
147
- }
148
-
149
- if (!attributes.texCoords.length) {
150
- attributes.texCoords = new Float32Array(vertexCount * VALUES_PER_TEX_COORD);
151
-
152
- for (let index = 0; index < attributes.texCoords.length; index += 2) {
153
- attributes.texCoords.set([1, 1], index);
154
- }
155
- }
156
-
157
152
  attributes.featureIndices = attributes.featureIndices.reduce((acc, value) => acc.concat(value));
158
153
  }
159
154
 
@@ -271,12 +266,13 @@ function transformVertexNormals(vertexVector, calleeArgs) {
271
266
  }
272
267
 
273
268
  function flattenTexCoords(texCoords, indices) {
269
+ const newTexCoords = new Float32Array(indices.length * VALUES_PER_TEX_COORD);
270
+
274
271
  if (!texCoords) {
275
- return new Float32Array(0);
272
+ newTexCoords.fill(1);
273
+ return newTexCoords;
276
274
  }
277
275
 
278
- const newTexCoords = new Float32Array(indices.length * VALUES_PER_TEX_COORD);
279
-
280
276
  for (let i = 0; i < indices.length; i++) {
281
277
  const coordIndex = indices[i] * VALUES_PER_TEX_COORD;
282
278
  const texCoord = texCoords.subarray(coordIndex, coordIndex + VALUES_PER_TEX_COORD);
@@ -288,13 +284,15 @@ function flattenTexCoords(texCoords, indices) {
288
284
  }
289
285
 
290
286
  function flattenColors(colorsAttribute, indices) {
287
+ const components = (colorsAttribute === null || colorsAttribute === void 0 ? void 0 : colorsAttribute.components) || VALUES_PER_COLOR_ELEMENT;
288
+ const newColors = new Uint8Array(indices.length * components);
289
+
291
290
  if (!colorsAttribute) {
292
- return new Uint8Array(0);
291
+ newColors.fill(255);
292
+ return newColors;
293
293
  }
294
294
 
295
- const components = colorsAttribute.components;
296
295
  const colors = colorsAttribute.value;
297
- const newColors = new Uint8Array(indices.length * components);
298
296
 
299
297
  for (let i = 0; i < indices.length; i++) {
300
298
  const colorIndex = indices[i] * components;
@@ -343,7 +341,7 @@ function getBatchIdsByAttributeName(attributes) {
343
341
 
344
342
  function convertMaterials(tileContent) {
345
343
  const result = [];
346
- const sourceMaterials = tileContent.gltf.materials;
344
+ const sourceMaterials = tileContent.gltf.materials || [];
347
345
 
348
346
  for (const sourceMaterial of sourceMaterials) {
349
347
  result.push(convertMaterial(sourceMaterial));
@@ -487,7 +485,7 @@ function generateImageId(texture, nodeId) {
487
485
  const shiftedWidth = width - 1 << 12;
488
486
  const shiftedHeight = height - 1 << 0;
489
487
  const leftHalf = shiftedLevelCountOfTexture + shiftedIndexOfLevel + shiftedWidth + shiftedHeight;
490
- const imageId = BigInt(`0b${leftHalf.toString(2)}${rightHalf}`);
488
+ const imageId = BigInt("0b".concat(leftHalf.toString(2)).concat(rightHalf));
491
489
  return imageId.toString();
492
490
  }
493
491
 
@@ -599,7 +597,7 @@ function generateStringAttributeBuffer(batchAttributes) {
599
597
  const stringBufferArray = [];
600
598
 
601
599
  for (let index = 0; index < batchAttributes.length; index++) {
602
- const currentString = `${String(batchAttributes[index])}\0`;
600
+ const currentString = "".concat(String(batchAttributes[index]), "\0");
603
601
  const currentStringBuffer = Buffer.from(currentString);
604
602
  const currentStringSize = currentStringBuffer.length;
605
603
  totalNumberOfBytes += currentStringSize;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/i3s-converter/helpers/geometry-converter.js"],"names":["Vector3","Matrix4","Vector4","Ellipsoid","DracoWriter","encode","assert","concatenateArrayBuffers","concatenateTypedArrays","md5","generateAttributes","VALUES_PER_VERTEX","VALUES_PER_TEX_COORD","VALUES_PER_COLOR_ELEMENT","STRING_TYPE","SHORT_INT_TYPE","DOUBLE_TYPE","OBJECT_ID_TYPE","BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES","convertB3dmToI3sGeometry","tileContent","nodeId","featuresHashArray","attributeStorageInfo","draco","materialAndTextureList","convertMaterials","convertedAttributesMap","convertAttributes","has","push","material","getDefaultMaterial","result","nodesCounter","materials","gltf","length","id","i","sourceMaterial","convertedAttributes","get","texture","_makeNodeResources","vertexCount","positions","triangleCount","faceRange","featureIds","normals","colors","texCoords","featureCount","batchTableJson","makeFeatureIdsUnique","featureIndices","header","Uint32Array","typedFeatureIds","generateBigUint64Array","set","fileBuffer","Uint8Array","buffer","ArrayBuffer","compressedGeometry","generateCompressedGeometry","Float32Array","attributes","convertBatchTableToAttributeBuffers","geometry","sharedResources","getSharedResources","meshMaterial","attributesMap","Map","nodes","scene","scenes","convertNodes","attrKey","keys","delete","reduce","acc","value","concat","matrix","node","convertNode","nodeMatrix","compositeMatrix","multiplyRight","mesh","convertMesh","children","content","primitive","primitives","outputAttributes","transformVertexArray","vertices","POSITION","cartographicOrigin","cartesianModelMatrix","indices","attributeSpecificTransformation","transformVertexPositions","NORMAL","transformVertexNormals","flattenTexCoords","TEXCOORD_0","flattenColors","COLOR_0","flattenBatchIds","getBatchIdsByAttributeName","args","newVertices","coordIndex","vertex","subarray","vertexVector","Array","from","x","y","z","calleeArgs","transform","WGS84","cartesianToCartographic","subtract","transformAsVector","newTexCoords","fill","texCoord","colorsAttribute","components","newColors","colorIndex","color","colorUint8","j","batchedIds","newBatchIds","batchIds","index","possibleBatchIdAttributeName","sourceMaterials","convertMaterial","doubleSided","emissiveFactor","map","c","Math","round","alphaMode","toLowerCase","pbrMetallicRoughness","roughnessFactor","metallicFactor","baseColorTexture","source","textureSetDefinitionId","emissiveTexture","baseColorFactor","undefined","gltfMaterials","i3sResources","materialDefinitionInfos","gltfMaterial","materialDefinitionInfo","textureDefinitionInfo","convertGLTFMaterialToI3sSharedResources","textureDefinitionInfos","extractSharedResourcesTextureInfo","colorFactor","extractSharedResourcesMaterialInfo","matDielectricColorComponent","black","unitVector","dielectricSpecular","baseColorVector","firstOperand","multiply","diffuse","lerp","specular","toArray","encoding","mimeType","images","generateImageId","size","image","width","data","height","levelCountOfTexture","indexOfLevel","indexOfTextureInStore","zerosCount","toString","rightHalf","repeat","shiftedLevelCountOfTexture","shiftedIndexOfLevel","shiftedWidth","shiftedHeight","leftHalf","imageId","BigInt","batchTable","replaceMap","getFeaturesReplaceMap","replaceIndicesByUnique","featureMap","oldFeatureId","uniqueFeatureId","getOrCreateUniqueFeatureId","generateStringFromBatchTableByIndex","str","key","batchTableStr","hash","includes","indexOf","indicesArray","attributeBuffers","batchTableWithFeatureIds","OBJECTID","type","getAttributeType","attributeBuffer","generateShortIntegerAttributeBuffer","generateDoubleAttributeBuffer","generateStringAttributeBuffer","attribute","find","attr","name","attributeValues","valueType","count","valuesArray","padding","Float64Array","batchAttributes","stringCountArray","totalNumberOfBytes","stringSizesArray","stringBufferArray","currentString","String","currentStringBuffer","Buffer","currentStringSize","totalBytes","BigUint64Array","featureIndex","generateFeatureIndexAttribute","compressedAttributes","attributesMetadata","Int32Array","method","orderedFeatureIndices","fillIndex","startIndex","endIndex"],"mappings":"AAAA,SAAQA,OAAR,EAAiBC,OAAjB,EAA0BC,OAA1B,QAAwC,eAAxC;AACA,SAAQC,SAAR,QAAwB,qBAAxB;AAEA,SAAQC,WAAR,QAA0B,mBAA1B;AACA,SAAQC,MAAR,EAAgBC,MAAhB,QAA6B,kBAA7B;AACA,SAAQC,uBAAR,EAAiCC,sBAAjC,QAA8D,0BAA9D;AACA,OAAOC,GAAP,MAAgB,KAAhB;AACA,SAAQC,kBAAR,QAAiC,uBAA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B;AACD;;AAED,SAAOH,qBAAP;AACD","sourcesContent":["import {Vector3, Matrix4, Vector4} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\n\nimport {DracoWriter} from '@loaders.gl/draco';\nimport {encode, assert} from '@loaders.gl/core';\nimport {concatenateArrayBuffers, concatenateTypedArrays} from '@loaders.gl/loader-utils';\nimport md5 from 'md5';\nimport {generateAttributes} from './geometry-attributes';\n\nconst VALUES_PER_VERTEX = 3;\nconst VALUES_PER_TEX_COORD = 2;\nconst VALUES_PER_COLOR_ELEMENT = 4;\n\nconst STRING_TYPE = 'string';\nconst SHORT_INT_TYPE = 'Int32';\nconst DOUBLE_TYPE = 'Float64';\nconst OBJECT_ID_TYPE = 'Oid32';\n/*\n * 'CUSTOM_ATTRIBUTE_2' - Attribute name which includes batch info and used by New York map.\n * _BATCHID - Default attribute name which includes batch info.\n * BATCHID - Legacy attribute name which includes batch info.\n */\nconst BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ['CUSTOM_ATTRIBUTE_2', '_BATCHID', 'BATCHID'];\n\nexport default async function convertB3dmToI3sGeometry(\n tileContent,\n nodeId,\n featuresHashArray,\n attributeStorageInfo,\n draco\n) {\n const materialAndTextureList = convertMaterials(tileContent);\n const convertedAttributesMap = convertAttributes(tileContent);\n\n if (convertedAttributesMap.has('default')) {\n materialAndTextureList.push({\n material: getDefaultMaterial()\n });\n }\n\n const result = [];\n let nodesCounter = nodeId;\n let {materials = []} = tileContent.gltf;\n if (!materials.length === 0) {\n materials.push({id: 'default'});\n }\n for (let i = 0; i < materials.length; i++) {\n const sourceMaterial = materials[i];\n if (!convertedAttributesMap.has(sourceMaterial.id)) {\n continue; // eslint-disable-line no-continue\n }\n const convertedAttributes = convertedAttributesMap.get(sourceMaterial.id);\n const {material, texture} = materialAndTextureList[i];\n result.push(\n await _makeNodeResources({\n convertedAttributes,\n material,\n texture,\n tileContent,\n nodeId: nodesCounter,\n featuresHashArray,\n attributeStorageInfo,\n draco\n })\n );\n nodesCounter++;\n }\n\n if (!result.length) {\n return null;\n }\n return result;\n}\n\nasync function _makeNodeResources({\n convertedAttributes,\n material,\n texture,\n tileContent,\n nodeId,\n featuresHashArray,\n attributeStorageInfo,\n draco\n}) {\n const vertexCount = convertedAttributes.positions.length / VALUES_PER_VERTEX;\n const triangleCount = vertexCount / 3;\n const {faceRange, featureIds, positions, normals, colors, texCoords, featureCount} =\n generateAttributes({triangleCount, ...convertedAttributes});\n\n if (tileContent.batchTableJson) {\n makeFeatureIdsUnique(\n featureIds,\n convertedAttributes.featureIndices,\n featuresHashArray,\n tileContent.batchTableJson\n );\n }\n\n const header = new Uint32Array(2);\n const typedFeatureIds = generateBigUint64Array(featureIds);\n\n header.set([vertexCount, featureCount], 0);\n const fileBuffer = new Uint8Array(\n concatenateArrayBuffers(\n header.buffer,\n positions.buffer,\n normals.buffer,\n texture ? texCoords.buffer : new ArrayBuffer(0),\n colors.buffer,\n typedFeatureIds.buffer,\n faceRange.buffer\n )\n );\n const compressedGeometry = draco\n ? await generateCompressedGeometry(vertexCount, convertedAttributes, {\n positions,\n normals,\n texCoords: texture ? texCoords : new Float32Array(0),\n colors,\n featureIds,\n faceRange\n })\n : null;\n\n const attributes = convertBatchTableToAttributeBuffers(\n tileContent.batchTableJson,\n featureIds,\n attributeStorageInfo\n );\n\n return {\n geometry: fileBuffer,\n compressedGeometry,\n texture,\n sharedResources: getSharedResources(tileContent, nodeId),\n meshMaterial: material,\n vertexCount,\n attributes,\n featureCount\n };\n}\n\n/**\n * Convert attributes from the gltf nodes tree to i3s plain geometry\n * @param {Object} tileContent - 3d tile content\n * @returns {Map}\n * Map<{\n * positions: Float32Array,\n * normals: Float32Array,\n * colors: Uint8Array,\n * texCoords: Float32Array\n * }>\n * @todo implement colors support (if applicable for gltf format)\n */\nfunction convertAttributes(tileContent) {\n const attributesMap = new Map();\n\n for (const material of tileContent.gltf.materials || [{id: 'default'}]) {\n attributesMap.set(material.id, {\n positions: new Float32Array(0),\n normals: new Float32Array(0),\n texCoords: new Float32Array(0),\n colors: new Uint8Array(0),\n featureIndices: []\n });\n }\n\n const nodes = (tileContent.gltf.scene || tileContent.gltf.scenes?.[0] || tileContent.gltf).nodes;\n convertNodes(nodes, tileContent, attributesMap);\n\n for (const attrKey of attributesMap.keys()) {\n const attributes = attributesMap.get(attrKey);\n if (attributes.positions.length === 0) {\n attributesMap.delete(attrKey);\n continue; // eslint-disable-line no-continue\n }\n attributes.featureIndices = attributes.featureIndices.reduce((acc, value) => acc.concat(value));\n }\n\n return attributesMap;\n}\n\n/**\n * Gltf has hierarchical structure of nodes. This function converts nodes starting from those which are in gltf scene object.\n * The goal is applying tranformation matrix for all children. Functions \"convertNodes\" and \"convertNode\" work together recursively.\n * @param {Object[]} nodes - gltf nodes array\n * @param {Object} tileContent - 3d tile content\n * @param {Map} attributesMap Map<{positions: Float32Array, normals: Float32Array, texCoords: Float32Array, colors: UInt8Array, featureIndices: Array}> - for recursive concatenation of\n * attributes\n * @param {Matrix4} matrix - transformation matrix - cumulative transformation matrix formed from all parent node matrices\n * @returns {void}\n */\nfunction convertNodes(\n nodes,\n tileContent,\n attributesMap,\n matrix = new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])\n) {\n if (nodes) {\n for (const node of nodes) {\n convertNode(node, tileContent, attributesMap, matrix);\n }\n }\n}\n\n/**\n * Convert all primitives of node and all children nodes\n * @param {Object} node - gltf node\n * @param {Object} tileContent - 3d tile content\n * @param {Map} attributesMap Map<{positions: Float32Array, normals: Float32Array, texCoords: Float32Array, colors: Uint8Array, featureIndices: Array}> - for recursive concatenation of\n * attributes\n * @param {Matrix4} matrix - transformation matrix - cumulative transformation matrix formed from all parent node matrices\n * @todo: optimize arrays concatenation\n */\nfunction convertNode(\n node,\n tileContent,\n attributesMap,\n matrix = new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])\n) {\n const nodeMatrix = node.matrix;\n const compositeMatrix = nodeMatrix ? matrix.multiplyRight(nodeMatrix) : matrix;\n\n const mesh = node.mesh;\n if (mesh) {\n convertMesh(mesh, tileContent, attributesMap, compositeMatrix);\n }\n\n convertNodes(node.children, tileContent, attributesMap, compositeMatrix);\n}\n\n/**\n * Convert all primitives of node and all children nodes\n * @param {Object} mesh - gltf node\n * @param {Object} content - 3d tile content\n * @param {Map} attributesMap Map<{positions: Float32Array, normals: Float32Array, texCoords: Float32Array, colors: Uint8Array, featureIndices: Array}> - for recursive concatenation of\n * attributes\n * @param {Matrix4} matrix - transformation matrix - cumulative transformation matrix formed from all parent node matrices\n * @todo: optimize arrays concatenation\n */\nfunction convertMesh(\n mesh,\n content,\n attributesMap,\n matrix = new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])\n) {\n for (const primitive of mesh.primitives) {\n let outputAttributes = null;\n if (primitive.material) {\n outputAttributes = attributesMap.get(primitive.material.id);\n } else if (attributesMap.has('default')) {\n outputAttributes = attributesMap.get('default');\n }\n assert(outputAttributes !== null, 'Primitive - material mapping failed');\n const attributes = primitive.attributes;\n\n outputAttributes.positions = concatenateTypedArrays(\n outputAttributes.positions,\n transformVertexArray({\n vertices: attributes.POSITION.value,\n cartographicOrigin: content.cartographicOrigin,\n cartesianModelMatrix: content.cartesianModelMatrix,\n nodeMatrix: matrix,\n indices: primitive.indices.value,\n attributeSpecificTransformation: transformVertexPositions\n })\n );\n outputAttributes.normals = concatenateTypedArrays(\n outputAttributes.normals,\n transformVertexArray({\n vertices: attributes.NORMAL && attributes.NORMAL.value,\n cartographicOrigin: content.cartographicOrigin,\n cartesianModelMatrix: content.cartesianModelMatrix,\n nodeMatrix: matrix,\n indices: primitive.indices.value,\n attributeSpecificTransformation: transformVertexNormals\n })\n );\n outputAttributes.texCoords = concatenateTypedArrays(\n outputAttributes.texCoords,\n flattenTexCoords(\n attributes.TEXCOORD_0 && attributes.TEXCOORD_0.value,\n primitive.indices.value\n )\n );\n\n outputAttributes.colors = concatenateTypedArrays(\n outputAttributes.colors,\n flattenColors(attributes.COLOR_0, primitive.indices.value)\n );\n\n outputAttributes.featureIndices.push(\n flattenBatchIds(getBatchIdsByAttributeName(attributes), primitive.indices.value)\n );\n }\n}\n\n/**\n * Convert vertices attributes (POSITIONS or NORMALS) to i3s compatible format\n * @param {object} args - source tile (3DTile)\n * @param {Float32Array} args.vertices - gltf primitive POSITION or NORMAL attribute\n * @param {Object} args.cartographicOrigin - cartographic origin coordinates\n * @param {Object} args.cartesianModelMatrix - a cartesian model matrix to transform coordnates from cartesian to cartographic format\n * @param {Matrix4} args.nodeMatrix - a gltf node transformation matrix - cumulative transformation matrix formed from all parent node matrices\n * @param {Uint8Array} args.indices - gltf primitive indices\n * @param {Function} args.attributeSpecificTransformation - function to do attribute - specific transformations\n * @returns {Float32Array}\n */\nfunction transformVertexArray(args) {\n const {vertices, indices, attributeSpecificTransformation} = args;\n const newVertices = new Float32Array(indices.length * VALUES_PER_VERTEX);\n if (!vertices) {\n return newVertices;\n }\n for (let i = 0; i < indices.length; i++) {\n const coordIndex = indices[i] * VALUES_PER_VERTEX;\n const vertex = vertices.subarray(coordIndex, coordIndex + VALUES_PER_VERTEX);\n let vertexVector = new Vector3(Array.from(vertex));\n\n vertexVector = attributeSpecificTransformation(vertexVector, args);\n\n newVertices[i * VALUES_PER_VERTEX] = vertexVector.x;\n newVertices[i * VALUES_PER_VERTEX + 1] = vertexVector.y;\n newVertices[i * VALUES_PER_VERTEX + 2] = vertexVector.z;\n }\n return newVertices;\n}\n\nfunction transformVertexPositions(vertexVector, calleeArgs) {\n const {cartesianModelMatrix, cartographicOrigin, nodeMatrix} = calleeArgs;\n\n if (nodeMatrix) {\n vertexVector = vertexVector.transform(nodeMatrix);\n }\n\n vertexVector = vertexVector.transform(cartesianModelMatrix);\n Ellipsoid.WGS84.cartesianToCartographic(\n [vertexVector[0], vertexVector[1], vertexVector[2]],\n vertexVector\n );\n vertexVector = vertexVector.subtract(cartographicOrigin);\n return vertexVector;\n}\n\nfunction transformVertexNormals(vertexVector, calleeArgs) {\n const {cartesianModelMatrix, nodeMatrix} = calleeArgs;\n\n if (nodeMatrix) {\n vertexVector = vertexVector.transformAsVector(nodeMatrix);\n }\n\n vertexVector = vertexVector.transformAsVector(cartesianModelMatrix);\n return vertexVector;\n}\n\n/**\n * Convert uv0 (texture coordinates) from coords based on indices to plain arrays, compatible with i3s\n * @param {Float32Array} texCoords - gltf primitive TEXCOORD_0 attribute\n * @param {Uint8Array} indices - gltf primitive indices\n * @returns {Float32Array}\n */\nfunction flattenTexCoords(texCoords, indices) {\n const newTexCoords = new Float32Array(indices.length * VALUES_PER_TEX_COORD);\n if (!texCoords) {\n // We need dummy UV0s because it is required in 1.6\n // https://github.com/Esri/i3s-spec/blob/master/docs/1.6/vertexAttribute.cmn.md\n newTexCoords.fill(1);\n return newTexCoords;\n }\n for (let i = 0; i < indices.length; i++) {\n const coordIndex = indices[i] * VALUES_PER_TEX_COORD;\n const texCoord = texCoords.subarray(coordIndex, coordIndex + VALUES_PER_TEX_COORD);\n newTexCoords[i * VALUES_PER_TEX_COORD] = texCoord[0];\n newTexCoords[i * VALUES_PER_TEX_COORD + 1] = texCoord[1];\n }\n return newTexCoords;\n}\n\n/**\n * Convert color from COLOR_0 based on indices to plain arrays, compatible with i3s\n * @param {object} colorsAttribute - gltf primitive COLOR_0 attribute\n * @param {Uint8Array} indices - gltf primitive indices\n * @returns {Uint8Array}\n */\nfunction flattenColors(colorsAttribute, indices) {\n const components = colorsAttribute?.components || VALUES_PER_COLOR_ELEMENT;\n const newColors = new Uint8Array(indices.length * components);\n if (!colorsAttribute) {\n // Vertex color multiplies by material color so it must be normalized 1 by default\n newColors.fill(255);\n return newColors;\n }\n const colors = colorsAttribute.value;\n for (let i = 0; i < indices.length; i++) {\n const colorIndex = indices[i] * components;\n const color = colors.subarray(colorIndex, colorIndex + components);\n const colorUint8 = new Uint8Array(components);\n for (let j = 0; j < color.length; j++) {\n colorUint8[j] = color[j] * 255;\n }\n newColors.set(colorUint8, i * components);\n }\n return newColors;\n}\n\n/**\n * Flatten batchedIds list based on indices to right ordered array, compatible with i3s\n * @param {Array} batchedIds - gltf primitive\n * @param {Uint8Array} indices - gltf primitive indices\n * @returns {Array}\n */\nfunction flattenBatchIds(batchedIds, indices) {\n if (!batchedIds.length || !indices.length) {\n return [];\n }\n const newBatchIds = [];\n for (let i = 0; i < indices.length; i++) {\n const coordIndex = indices[i];\n newBatchIds.push(batchedIds[coordIndex]);\n }\n return newBatchIds;\n}\n/**\n * Return batchIds based on possible attribute names for different kind of maps.\n * @param {Object} attributes {attributeName: Float32Array}\n * @returns {Array}\n */\nfunction getBatchIdsByAttributeName(attributes) {\n let batchIds = [];\n\n for (let index = 0; index < BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES.length; index++) {\n const possibleBatchIdAttributeName = BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES[index];\n if (\n attributes[possibleBatchIdAttributeName] &&\n attributes[possibleBatchIdAttributeName].value\n ) {\n batchIds = attributes[possibleBatchIdAttributeName].value;\n break;\n }\n }\n\n return batchIds;\n}\n\nfunction convertMaterials(tileContent) {\n const result = [];\n const sourceMaterials = tileContent.gltf.materials || [];\n for (const sourceMaterial of sourceMaterials) {\n result.push(convertMaterial(sourceMaterial));\n }\n return result;\n}\n\n/**\n * Convert texture and material from gltf 2.0 material object\n * @param {Object} sourceMaterial - material object\n * @returns {Object}\n */\nfunction convertMaterial(sourceMaterial) {\n const material = {\n doubleSided: sourceMaterial.doubleSided,\n emissiveFactor: sourceMaterial.emissiveFactor.map((c) => Math.round(c * 255)),\n // It is in upper case in GLTF: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#alpha-coverage\n // But it is in lower case in I3S: https://github.com/Esri/i3s-spec/blob/master/docs/1.7/materialDefinitions.cmn.md\n alphaMode: (sourceMaterial.alphaMode || 'OPAQUE').toLowerCase(),\n pbrMetallicRoughness: {\n roughnessFactor: sourceMaterial.pbrMetallicRoughness.roughnessFactor,\n metallicFactor: sourceMaterial.pbrMetallicRoughness.metallicFactor\n }\n };\n\n let texture;\n if (sourceMaterial.pbrMetallicRoughness.baseColorTexture) {\n texture = sourceMaterial.pbrMetallicRoughness.baseColorTexture.texture.source;\n material.pbrMetallicRoughness.baseColorTexture = {\n textureSetDefinitionId: 0\n };\n } else if (sourceMaterial.emissiveTexture) {\n texture = sourceMaterial.emissiveTexture.texture.source;\n // ArcGIS webscene doesn't show emissiveTexture but shows baseColorTexture\n material.pbrMetallicRoughness.baseColorTexture = {\n textureSetDefinitionId: 0\n };\n }\n\n if (!texture) {\n // Should use default baseColorFactor if it is not present in source material\n // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-pbrmetallicroughness\n const baseColorFactor = sourceMaterial.pbrMetallicRoughness.baseColorFactor;\n material.pbrMetallicRoughness.baseColorFactor =\n (baseColorFactor && baseColorFactor.map((c) => Math.round(c * 255))) || undefined;\n }\n\n return {material, texture};\n}\n\nfunction getDefaultMaterial() {\n return {\n alphaMode: 'opaque',\n pbrMetallicRoughness: {}\n };\n}\n\n/**\n * Form \"sharedResources\" from gltf materials array\n * @param {Object} tileContent - 3d tile content\n * @returns {Object} {materialDefinitionInfos: Object[], textureDefinitionInfos: Object[]} -\n * 2 arrays in format of i3s sharedResources data https://github.com/Esri/i3s-spec/blob/master/docs/1.7/sharedResource.cmn.md\n */\nfunction getSharedResources(tileContent, nodeId) {\n const gltfMaterials = tileContent.gltf.materials;\n const i3sResources = {};\n\n if (!gltfMaterials || !gltfMaterials.length) {\n return i3sResources;\n }\n\n i3sResources.materialDefinitionInfos = [];\n for (const gltfMaterial of gltfMaterials) {\n const {materialDefinitionInfo, textureDefinitionInfo} = convertGLTFMaterialToI3sSharedResources(\n gltfMaterial,\n nodeId\n );\n i3sResources.materialDefinitionInfos.push(materialDefinitionInfo);\n if (textureDefinitionInfo) {\n i3sResources.textureDefinitionInfos = i3sResources.textureDefinitionInfos || [];\n i3sResources.textureDefinitionInfos.push(textureDefinitionInfo);\n }\n }\n return i3sResources;\n}\n\n/**\n * Convert gltf material into I3S sharedResources data\n * @param {Object} gltfMaterial - gltf material data\n * @returns {Object} - Couple {materialDefinitionInfo, textureDefinitionInfo} extracted from gltf material data\n */\nfunction convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {\n const texture =\n gltfMaterial.pbrMetallicRoughness.baseColorTexture || gltfMaterial.emissiveTexture;\n let textureDefinitionInfo = null;\n if (texture) {\n textureDefinitionInfo = extractSharedResourcesTextureInfo(texture.texture, nodeId);\n }\n const {baseColorFactor, metallicFactor} = gltfMaterial.pbrMetallicRoughness;\n let colorFactor = baseColorFactor;\n // If alpha channel is 0 try to get emissive factor from gltf material.\n if ((!baseColorFactor || baseColorFactor[3] === 0) && gltfMaterial.emissiveFactor) {\n colorFactor = gltfMaterial.emissiveFactor;\n colorFactor[3] = colorFactor[3] || 1;\n }\n\n return {\n materialDefinitionInfo: extractSharedResourcesMaterialInfo(colorFactor, metallicFactor),\n textureDefinitionInfo\n };\n}\n\n/**\n * Form \"materialDefinition\" which is part of \"sharedResouces\"\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#materials\n * See formulas in appendix \"Appendix B: BRDF Implementation\":\n * const dielectricSpecular = rgb(0.04, 0.04, 0.04)\n * const black = rgb(0, 0, 0)\n * cdiff = lerp(baseColor.rgb * (1 - dielectricSpecular.r), black, metallic)\n * F0 = lerp(dieletricSpecular, baseColor.rgb, metallic)\n *\n * Assumption: F0 - specular in i3s (\"specular reflection\" <-> \"reflectance value at normal incidence\")\n * cdiff - diffuse in i3s (\"Diffuse color\" <-> \"'c' diffuse\" (c means color?))\n * @param {number[]} baseColorFactor - RGBA color in 0..1 format\n * @param {number} metallicFactor - \"metallicFactor\" attribute of gltf material object\n * @returns {Object}\n */\nfunction extractSharedResourcesMaterialInfo(baseColorFactor, metallicFactor = 0) {\n const matDielectricColorComponent = 0.04 / 255; // Color from rgb (255) to 0..1 resolution\n // All color resolutions are 0..1\n const black = new Vector4(0, 0, 0, 1);\n const unitVector = new Vector4(1, 1, 1, 1);\n const dielectricSpecular = new Vector4(\n matDielectricColorComponent,\n matDielectricColorComponent,\n matDielectricColorComponent,\n 0\n );\n const baseColorVector = new Vector4(baseColorFactor);\n // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#metallic-roughness-material\n // Formulas for Cdiff & F0\n const firstOperand = unitVector.subtract(dielectricSpecular).multiply(baseColorVector);\n const diffuse = firstOperand.lerp(firstOperand, black, metallicFactor);\n dielectricSpecular[3] = 1;\n const specular = dielectricSpecular.lerp(dielectricSpecular, baseColorVector, metallicFactor);\n return {\n diffuse: diffuse.toArray(),\n specular: specular.toArray()\n };\n}\n\n/**\n * Form \"textureDefinition\" which is part of \"sharedResouces\"\n * @param {Object} texture - texture image info\n * @returns {Object}\n */\nfunction extractSharedResourcesTextureInfo(texture, nodeId) {\n return {\n encoding: [texture.source.mimeType],\n images: [\n {\n // 'i3s' has just size which is width of the image. Images are supposed to be square.\n // https://github.com/Esri/i3s-spec/blob/master/docs/1.7/image.cmn.md\n id: generateImageId(texture, nodeId),\n size: texture.source.image.width,\n length: [texture.source.image.data.length]\n }\n ]\n };\n}\n/*\n * Formula for counting imageId:\n * https://github.com/Esri/i3s-spec/blob/0a6366a9249b831db8436c322f8d27521e86cf07/format/Indexed%203d%20Scene%20Layer%20Format%20Specification.md#generating-image-ids\n * @param {Object} texture - texture image info\n * @returns {string}\n */\nfunction generateImageId(texture, nodeId) {\n const {width, height} = texture.source.image;\n const levelCountOfTexture = 1;\n const indexOfLevel = 0;\n const indexOfTextureInStore = nodeId + 1;\n\n const zerosCount = 32 - indexOfTextureInStore.toString(2).length;\n const rightHalf = '0'.repeat(zerosCount).concat(indexOfTextureInStore.toString(2));\n\n const shiftedLevelCountOfTexture = levelCountOfTexture << 28;\n const shiftedIndexOfLevel = indexOfLevel << 24;\n const shiftedWidth = (width - 1) << 12;\n const shiftedHeight = (height - 1) << 0;\n\n const leftHalf = shiftedLevelCountOfTexture + shiftedIndexOfLevel + shiftedWidth + shiftedHeight;\n const imageId = BigInt(`0b${leftHalf.toString(2)}${rightHalf}`);\n return imageId.toString();\n}\n\n/**\n * Make all feature ids unique through all nodes in layout.\n * @param {Array} featureIds\n * @param {Array} featureIndices\n * @param {Array} featuresHashArray\n * @param {Object} batchTable\n * @returns {void}\n */\nfunction makeFeatureIdsUnique(featureIds, featureIndices, featuresHashArray, batchTable) {\n const replaceMap = getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray);\n replaceIndicesByUnique(featureIndices, replaceMap);\n replaceIndicesByUnique(featureIds, replaceMap);\n}\n\n/**\n * Generate replace map to make featureIds unique.\n * @param {Array} featureIds\n * @param {Object} batchTable\n * @param {Array} featuresHashArray\n * @returns {Object}\n */\nfunction getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray) {\n const featureMap = {};\n\n for (let index = 0; index < featureIds.length; index++) {\n const oldFeatureId = featureIds[index];\n const uniqueFeatureId = getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray);\n featureMap[oldFeatureId.toString()] = uniqueFeatureId;\n }\n\n return featureMap;\n}\n\n/**\n * Generates string for unique batch id creation.\n * @param {Object} batchTable\n * @param {Number} index\n * @returns {String}\n */\nfunction generateStringFromBatchTableByIndex(batchTable, index) {\n let str = '';\n for (const key in batchTable) {\n str += batchTable[key][index];\n }\n return str;\n}\n\n/**\n * Return already exited featureId or creates and returns new to support unique feature ids throw nodes.\n * @param {Number} index\n * @param {Object} batchTable\n * @param {Array} featuresHashArray\n * @returns {Number}\n */\nfunction getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray) {\n const batchTableStr = generateStringFromBatchTableByIndex(batchTable, index);\n const hash = md5(batchTableStr);\n\n if (featuresHashArray.includes(hash)) {\n return featuresHashArray.indexOf(hash);\n }\n return featuresHashArray.push(hash) - 1;\n}\n\n/**\n * Do replacement of indices for making them unique through all nodes.\n * @param {Array} indicesArray\n * @param {Object} featureMap\n * @returns {void}\n */\nfunction replaceIndicesByUnique(indicesArray, featureMap) {\n for (let index = 0; index < indicesArray.length; index++) {\n indicesArray[index] = featureMap[indicesArray[index]];\n }\n}\n\n/**\n * Convert batch table data to attribute buffers.\n * @param {Object} batchTable - table with metadata for particular feature.\n * @param {Array} featureIds\n * @param {Array} attributeStorageInfo\n * @returns {Array} - Array of file buffers.\n */\nfunction convertBatchTableToAttributeBuffers(batchTable, featureIds, attributeStorageInfo) {\n const attributeBuffers = [];\n\n if (batchTable) {\n const batchTableWithFeatureIds = {\n OBJECTID: featureIds,\n ...batchTable\n };\n\n for (const key in batchTableWithFeatureIds) {\n const type = getAttributeType(key, attributeStorageInfo);\n\n let attributeBuffer = null;\n\n switch (type) {\n case OBJECT_ID_TYPE:\n case SHORT_INT_TYPE:\n attributeBuffer = generateShortIntegerAttributeBuffer(batchTableWithFeatureIds[key]);\n break;\n case DOUBLE_TYPE:\n attributeBuffer = generateDoubleAttributeBuffer(batchTableWithFeatureIds[key]);\n break;\n case STRING_TYPE:\n attributeBuffer = generateStringAttributeBuffer(batchTableWithFeatureIds[key]);\n break;\n default:\n attributeBuffer = generateStringAttributeBuffer(batchTableWithFeatureIds[key]);\n }\n\n attributeBuffers.push(attributeBuffer);\n }\n }\n\n return attributeBuffers;\n}\n/**\n * Return attribute type.\n * @param {String} key\n * @param {Array} attributeStorageInfo\n * @returns {String} attribute type.\n */\nfunction getAttributeType(key, attributeStorageInfo) {\n const attribute = attributeStorageInfo.find((attr) => attr.name === key);\n return attribute.attributeValues.valueType;\n}\n\n/**\n * Convert short integer to attribute arrayBuffer.\n * @param {Array} featureIds\n * @returns {ArrayBuffer} - Buffer with objectId data.\n */\nfunction generateShortIntegerAttributeBuffer(featureIds) {\n const count = new Uint32Array([featureIds.length]);\n const valuesArray = new Uint32Array(featureIds);\n return concatenateArrayBuffers(count.buffer, valuesArray.buffer);\n}\n\n/**\n * Convert double to attribute arrayBuffer.\n * @param {Array} featureIds\n * @returns {ArrayBuffer} - Buffer with objectId data.\n */\nfunction generateDoubleAttributeBuffer(featureIds) {\n const count = new Uint32Array([featureIds.length]);\n const padding = new Uint8Array(4);\n const valuesArray = new Float64Array(featureIds);\n\n return concatenateArrayBuffers(count.buffer, padding.buffer, valuesArray.buffer);\n}\n\n/**\n * Convert batch table attributes to array buffer with batch table data.\n * @param {Array} batchAttributes\n * @returns {ArrayBuffer} - Buffer with batch table data.\n */\nfunction generateStringAttributeBuffer(batchAttributes) {\n const stringCountArray = new Uint32Array([batchAttributes.length]);\n let totalNumberOfBytes = 0;\n const stringSizesArray = new Uint32Array(batchAttributes.length);\n const stringBufferArray = [];\n\n for (let index = 0; index < batchAttributes.length; index++) {\n const currentString = `${String(batchAttributes[index])}\\0`;\n const currentStringBuffer = Buffer.from(currentString);\n const currentStringSize = currentStringBuffer.length;\n totalNumberOfBytes += currentStringSize;\n stringSizesArray[index] = currentStringSize;\n stringBufferArray.push(currentStringBuffer);\n }\n\n const totalBytes = new Uint32Array([totalNumberOfBytes]);\n\n return concatenateArrayBuffers(\n stringCountArray.buffer,\n totalBytes.buffer,\n stringSizesArray.buffer,\n ...stringBufferArray\n );\n}\n\n/**\n * Convert featureIds to BigUint64Array.\n * @param {Array} featureIds\n * @returns {BigUint64Array} - Array of feature ids in BigUint64 format.\n */\nfunction generateBigUint64Array(featureIds) {\n const typedFeatureIds = new BigUint64Array(featureIds.length);\n for (let index = 0; index < featureIds.length; index++) {\n typedFeatureIds[index] = BigInt(featureIds[index]);\n }\n return typedFeatureIds;\n}\n\n/**\n * Generates draco compressed geometry\n * @param {Number} vertexCount\n * @param {Object} convertedAttributes\n * @returns {Promise<object>} - COmpressed geometry.\n */\nasync function generateCompressedGeometry(vertexCount, convertedAttributes, attributes) {\n const {positions, normals, texCoords, colors, featureIds, faceRange} = attributes;\n const indices = new Uint32Array(vertexCount);\n\n for (let index = 0; index < indices.length; index++) {\n indices.set([index], index);\n }\n\n const featureIndices = new Uint32Array(\n convertedAttributes.featureIndices.length ? convertedAttributes.featureIndices : vertexCount\n );\n\n const featureIndex = generateFeatureIndexAttribute(featureIndices, faceRange);\n\n const compressedAttributes = {\n positions,\n normals,\n colors,\n 'feature-index': featureIndex\n };\n\n if (texCoords.length) {\n compressedAttributes.texCoords = texCoords;\n }\n\n const attributesMetadata = {\n 'feature-index': {\n 'i3s-attribute-type': 'feature-index',\n 'i3s-feature-ids': new Int32Array(featureIds)\n }\n };\n\n return new Uint8Array(\n await encode({attributes: compressedAttributes, indices}, DracoWriter, {\n draco: {\n method: 'MESH_SEQUENTIAL_ENCODING',\n attributesMetadata\n }\n })\n );\n}\n\n/**\n * Generates ordered feature indices based on face range\n * @param {Uint32Array} featureIndex\n * @param {Uint32Array} faceRange\n * @returns {Uint32Array}\n */\nfunction generateFeatureIndexAttribute(featureIndex, faceRange) {\n const orderedFeatureIndices = new Uint32Array(featureIndex.length);\n let fillIndex = 0;\n let startIndex = 0;\n\n for (let index = 1; index < faceRange.length; index += 2) {\n const endIndex = (faceRange[index] + 1) * VALUES_PER_VERTEX;\n\n orderedFeatureIndices.fill(fillIndex, startIndex, endIndex);\n\n fillIndex++;\n startIndex = endIndex + 1;\n }\n\n return orderedFeatureIndices;\n}\n"],"file":"geometry-converter.js"}
@@ -22,7 +22,7 @@ function validateObb(tileWarnings, node) {
22
22
  return;
23
23
  }
24
24
 
25
- const title = `OBB of Tile (${node.id}) doesn't fit into Parent (${node.parentNode.id}) tile OBB`;
25
+ const title = "OBB of Tile (".concat(node.id, ") doesn't fit into Parent (").concat(node.parentNode.id, ") tile OBB");
26
26
  tileWarnings.push(title);
27
27
  }
28
28
 
@@ -32,7 +32,7 @@ function validateMbs(tileWarnings, node) {
32
32
  const distanceBetweenCenters = tileMbs.center.distanceTo(parentMbs.center);
33
33
 
34
34
  if (distanceBetweenCenters + tileMbs.radius > parentMbs.radius) {
35
- const title = `MBS of Tile (${node.id}) doesn't fit into Parent (${node.parentNode.id}) tile MBS`;
35
+ const title = "MBS of Tile (".concat(node.id, ") doesn't fit into Parent (").concat(node.parentNode.id, ") tile MBS");
36
36
  tileWarnings.push(title);
37
37
  }
38
38
  }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/i3s-converter/helpers/node-debug.js"],"names":["OrientedBoundingBox","BoundingSphere","CubeGeometry","Vector3","Ellipsoid","validateNodeBoundingVolumes","node","parentNode","obb","mbs","tileWarnings","validateObb","validateMbs","parentObb","createBoundingBoxFromTileObb","tileVertices","getTileObbVertices","isTileObbInsideParentObb","isAllVerticesInsideBoundingVolume","title","id","push","tileMbs","createBoundingSphereFromTileMbs","parentMbs","distanceBetweenCenters","center","distanceTo","radius","halfSize","quaternion","fromCenterHalfSizeQuaternion","geometry","attributes","positions","Float32Array","POSITION","value","obbCenterCartesian","WGS84","cartographicToCartesian","vertices","i","length","positionsVector","rotatedPositions","transformByQuaternion","add","concat","boundingVolume","isVerticesInsideObb","index","point","cartographicPoint","cartesianToCartographic","distance"],"mappings":"AAAA,SAAQA,mBAAR,EAA6BC,cAA7B,QAAkD,kBAAlD;AACA,SAAQC,YAAR,QAA2B,iBAA3B;AACA,SAAQC,OAAR,QAAsB,eAAtB;AACA,SAAQC,SAAR,QAAwB,qBAAxB;AAGA,OAAO,SAASC,2BAAT,CAAqCC,IAArC,EAA2C;AAChD,MAAI,CAACA,IAAI,CAACC,UAAL,CAAgBC,GAAjB,IAAwB,CAACF,IAAI,CAACC,UAAL,CAAgBE,GAA7C,EAAkD;AAChD,WAAO,IAAP;AACD;;AACD,QAAMC,YAAY,GAAG,EAArB;AAEAC,EAAAA,WAAW,CAACD,YAAD,EAAeJ,IAAf,CAAX;AACAM,EAAAA,WAAW,CAACF,YAAD,EAAeJ,IAAf,CAAX;AAEA,SAAOI,YAAP;AACD;;AAED,SAASC,WAAT,CAAqBD,YAArB,EAAmCJ,IAAnC,EAAyC;AACvC,QAAMO,SAAS,GAAGC,4BAA4B,CAACR,IAAI,CAACC,UAAL,CAAgBC,GAAjB,CAA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,OAAK,IAAIC,KAAK,GAAG,CAAjB,EAAoBA,KAAK,GAAGjB,SAAS,CAACS,MAAV,GAAmB,CAA/C,EAAkDQ,KAAK,IAAI,CAA3D,EAA8D;AAC5D,UAAMC,KAAK,GAAG,CAAClB,SAAS,CAACiB,KAAD,CAAV,EAAmBjB,SAAS,CAACiB,KAAK,GAAG,CAAT,CAA5B,EAAyCjB,SAAS,CAACiB,KAAK,GAAG,CAAT,CAAlD,CAAd;AACA,UAAME,iBAAiB,GAAGjD,SAAS,CAACmC,KAAV,CAAgBe,uBAAhB,CAAwCF,KAAxC,CAA1B;AAEA,UAAMG,QAAQ,GAAGN,cAAc,CAACtB,UAAf,CAA0B0B,iBAA1B,CAAjB;;AAEA,QAAIE,QAAQ,GAAG,CAAf,EAAkB;AAChBL,MAAAA,mBAAmB,GAAG,KAAtB;AACA;AACD;AACF;;AAED,SAAOA,mBAAP;AACD","sourcesContent":["import {OrientedBoundingBox, BoundingSphere} from '@math.gl/culling';\nimport {CubeGeometry} from '@luma.gl/engine';\nimport {Vector3} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\n\n// TODO Unite Tile validation logic in i3s-17-and-debug with this code.\nexport function validateNodeBoundingVolumes(node) {\n if (!node.parentNode.obb || !node.parentNode.mbs) {\n return null;\n }\n const tileWarnings = [];\n\n validateObb(tileWarnings, node);\n validateMbs(tileWarnings, node);\n\n return tileWarnings;\n}\n\nfunction validateObb(tileWarnings, node) {\n const parentObb = createBoundingBoxFromTileObb(node.parentNode.obb);\n const tileVertices = getTileObbVertices(node);\n const isTileObbInsideParentObb = isAllVerticesInsideBoundingVolume(parentObb, tileVertices);\n\n if (isTileObbInsideParentObb) {\n return;\n }\n\n const title = `OBB of Tile (${node.id}) doesn't fit into Parent (${node.parentNode.id}) tile OBB`;\n tileWarnings.push(title);\n}\n\nfunction validateMbs(tileWarnings, node) {\n const tileMbs = createBoundingSphereFromTileMbs(node.mbs);\n const parentMbs = createBoundingSphereFromTileMbs(node.parentNode.mbs);\n const distanceBetweenCenters = tileMbs.center.distanceTo(parentMbs.center);\n\n if (distanceBetweenCenters + tileMbs.radius > parentMbs.radius) {\n const title = `MBS of Tile (${node.id}) doesn't fit into Parent (${node.parentNode.id}) tile MBS`;\n tileWarnings.push(title);\n }\n}\n\nfunction createBoundingSphereFromTileMbs(mbs) {\n return new BoundingSphere([mbs[0], mbs[1], mbs[2]], mbs[3]);\n}\n\nfunction createBoundingBoxFromTileObb(obb) {\n const {center, halfSize, quaternion} = obb;\n return new OrientedBoundingBox().fromCenterHalfSizeQuaternion(center, halfSize, quaternion);\n}\n\n// TODO check if Obb generates properly\nfunction getTileObbVertices(node) {\n const geometry = new CubeGeometry();\n const halfSize = node.obb.halfSize;\n const {attributes} = geometry;\n const positions = new Float32Array(attributes.POSITION.value);\n const obbCenterCartesian = Ellipsoid.WGS84.cartographicToCartesian(node.obb.center);\n\n let vertices = [];\n\n for (let i = 0; i < positions.length; i += 3) {\n const positionsVector = new Vector3(\n (positions[i] *= halfSize[0]),\n (positions[i + 1] *= halfSize[1]),\n (positions[i + 2] *= halfSize[2])\n );\n const rotatedPositions = positionsVector\n .transformByQuaternion(node.obb.quaternion)\n .add(obbCenterCartesian);\n vertices = vertices.concat(rotatedPositions);\n }\n\n return vertices;\n}\n\nfunction isAllVerticesInsideBoundingVolume(boundingVolume, positions) {\n let isVerticesInsideObb = true;\n\n for (let index = 0; index < positions.length / 3; index += 3) {\n const point = [positions[index], positions[index + 1], positions[index + 2]];\n const cartographicPoint = Ellipsoid.WGS84.cartesianToCartographic(point);\n\n const distance = boundingVolume.distanceTo(cartographicPoint);\n\n if (distance > 0) {\n isVerticesInsideObb = false;\n break;\n }\n }\n\n return isVerticesInsideObb;\n}\n"],"file":"node-debug.js"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Represents one page node
3
+ * {@link https://github.com/Esri/i3s-spec/blob/master/docs/1.7/node.cmn.md}
4
+ */
5
+ export type PageNodeType = {
6
+ lodThreshold: number;
7
+ obb: any;
8
+ children: any[];
9
+ mesh?: {
10
+ geometry: {
11
+ resource?: number;
12
+ definition?: number;
13
+ };
14
+ material?: {
15
+ resource?: number;
16
+ definition?: number;
17
+ };
18
+ };
19
+ };
20
+
21
+ /**
22
+ * class NodePages - wrapper of nodePages array
23
+ *
24
+ * @example
25
+ * import writeFile from './helpers/write-file';
26
+ *
27
+ * // create an instance of the class
28
+ * const nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);
29
+ * ...
30
+ * // push root node
31
+ * const parentId = nodePages.push({
32
+ lodThreshold: HARDCODED_MAX_SCREEN_THRESHOLD_SQ,
33
+ obb: coordinates.obb,
34
+ children: []
35
+ });
36
+ * ...
37
+ * // push node with parent relation
38
+ * const nodeInPage = {
39
+ lodThreshold: HARDCODED_MAX_SCREEN_THRESHOLD_SQ,
40
+ obb: coordinates.obb,
41
+ children: [],
42
+ mesh: {
43
+ geometry: {
44
+ definition: 0
45
+ }
46
+ }
47
+ };
48
+ * const nodeId = this.nodePages.push(nodeInPage, parentId);
49
+ * ...
50
+ * // save all the nodePages in the end of pushing all the nodes
51
+ * await this.nodePages.save(layers0path);
52
+ */
53
+ export default class NodePages {
54
+ readonly nodesPerPage: number;
55
+ readonly nodesCounter: number;
56
+ readonly writeFile: any;
57
+ readonly nodePages: {nodes: PageNodeType[]}[];
58
+
59
+ /**
60
+ * @constructs
61
+ * Create a nodePages instance.
62
+ * @param writeFileFunc - function to save one nodePage into a file
63
+ * @param nodesPerPage - length limit for one nodePage. An additional nodePage is created when this limit is met
64
+ */
65
+ constructor(writeFileFunc, nodesPerPage);
66
+
67
+ /**
68
+ * Setup function to save node pages
69
+ * @param func - function which should be used to save node pages
70
+ */
71
+ useWriteFunction(func: Function): void;
72
+
73
+ /**
74
+ * Get the node by its end-to-end index
75
+ * @param id - end-to-end index of the node
76
+ * @return the node object
77
+ */
78
+ getNodeById(id: number): object;
79
+
80
+ /**
81
+ * Add a child id into the parent node.children array
82
+ * @param parentId - end-to-end parent node index
83
+ * @param childId - end-to-end child node index
84
+ */
85
+ addChildRelation(parentId: number, childId: number): void;
86
+
87
+ /**
88
+ * Update resource index in node.mesh object
89
+ * @param {object} node - node object
90
+ */
91
+ updateResourceInMesh(node: object): void;
92
+
93
+ /**
94
+ * Update material in node.mesh object by node id
95
+ * @param id - end-to-end index of the node
96
+ * @param materialId - id from scene layer materialDefinitions
97
+ */
98
+ updateMaterialByNodeId(id: number, materialId: number);
99
+
100
+ /**
101
+ * Update vertexCount in node.mesh.geometry object by node id
102
+ * @param id - end-to-end index of the node
103
+ * @param vertexCount - vertex count for particular node
104
+ */
105
+ updateVertexCountByNodeId(id: number, vertexCount: number);
106
+
107
+ /**
108
+ * Update resource in node.mesh.attribute object by node id
109
+ * @param id - end-to-end index of the node
110
+ */
111
+ updateNodeAttributeByNodeId(id: number);
112
+
113
+ /**
114
+ * Update featureCount in node.mesh.geometry object by node id
115
+ * @param id - end-to-end index of the node
116
+ * @param featureCount - features count of the node
117
+ */
118
+ updateFeatureCountByNodeId(id: number, featureCount: number);
119
+
120
+ /**
121
+ * Update texelCountHint in node.mesh.material object by node id
122
+ * @param id - end-to-end index of the node
123
+ * @param texelCountHint - texelCountHint of particular node
124
+ */
125
+ updateTexelCountHintByNodeId(id: number, texelCountHint: number);
126
+
127
+ /**
128
+ * Put new node in nodePages array
129
+ * @param node - node object
130
+ * @param parentId - index of parent node
131
+ * @return
132
+ */
133
+ push(node: PageNodeType, parentId?: number): number;
134
+
135
+ /**
136
+ * Save all the node pages
137
+ * Run this method when all nodes is pushed in nodePages
138
+ * @param {string} layers0path - path of layer
139
+ * @param {Object} fileMap - fileMap which keep info for slpk archive
140
+ * @param {boolean} slpk
141
+ * @return {promise}
142
+ */
143
+ save(layers0path: string, fileMap: Object, slpk: boolean): Promise<void>;
144
+ }
@@ -112,8 +112,8 @@ export default class NodePages {
112
112
  for (const [index, nodePage] of this.nodePages.entries()) {
113
113
  const nodePageStr = JSON.stringify(nodePage);
114
114
  const slpkPath = join(layers0Path, 'nodepages');
115
- promises.push(this.writeFile(slpkPath, nodePageStr, `${index.toString()}.json`));
116
- fileMap[`nodePages/${index.toString()}.json.gz`] = `${slpkPath}.json.gz`;
115
+ promises.push(this.writeFile(slpkPath, nodePageStr, "".concat(index.toString(), ".json")));
116
+ fileMap["nodePages/".concat(index.toString(), ".json.gz")] = "".concat(slpkPath, ".json.gz");
117
117
  }
118
118
 
119
119
  const metadata = transform({
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/i3s-converter/helpers/node-pages.js"],"names":["join","transform","METADATA","metadataTemplate","NodePages","constructor","writeFileFunc","nodesPerPage","nodesCounter","nodePages","nodes","writeFile","useWriteFunction","func","getNodeById","id","pageIndex","Math","floor","nodeIndex","updateMaterialByNodeId","materialId","node","mesh","material","definition","resource","index","updateVertexCountByNodeId","vertexCount","geometry","updateNodeAttributeByNodeId","attribute","updateFeatureCountByNodeId","featureCount","updateTexelCountHintByNodeId","texelCountHint","addChildRelation","parentId","childId","parentNode","children","push","updateResourceInMesh","currentNodePage","length","save","layers0Path","fileMap","slpk","promises","nodePage","entries","nodePageStr","JSON","stringify","slpkPath","toString","metadata","nodeCount","compress","nodePagePath","Promise","all"],"mappings":"AAAA,SAAQA,IAAR,QAAmB,MAAnB;AACA,OAAOC,SAAP,MAAsB,oBAAtB;AACA,SAAQC,QAAQ,IAAIC,gBAApB,QAA2C,4BAA3C;AAkCA,eAAe,MAAMC,SAAN,CAAgB;AAO7BC,EAAAA,WAAW,CAACC,aAAD,EAAgBC,YAAhB,EAA8B;AACvC,SAAKA,YAAL,GAAoBA,YAApB;AACA,SAAKC,YAAL,GAAoB,CAApB;AACA,SAAKC,SAAL,GAAiB,CAAC,EAAD,CAAjB;AACA,SAAKA,SAAL,CAAe,CAAf,EAAkBC,KAAlB,GAA0B,EAA1B;AACA,SAAKC,SAAL,GAAiBL,aAAjB;AACD;;AAEDM,EAAAA,gBAAgB,CAACC,IAAD,EAAO;AACrB,SAA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AAf,EAAhC,EAA0D;AACxD,cAAMC,WAAW,GAAGC,IAAI,CAACC,SAAL,CAAeJ,QAAf,CAApB;AACA,cAAMU,YAAY,GAAG7D,IAAI,CAAC+C,WAAD,EAAc,WAAd,EAA2BpB,KAAK,CAAC8B,QAAN,EAA3B,CAAzB;AACAP,QAAAA,QAAQ,CAACR,IAAT,CAAc,KAAK/B,SAAL,CAAekD,YAAf,EAA6BR,WAA7B,CAAd;AACD;AACF;;AAED,UAAMS,OAAO,CAACC,GAAR,CAAYb,QAAZ,CAAN;AACD;;AA1K4B","sourcesContent":["import {join} from 'path';\nimport transform from 'json-map-transform';\nimport {METADATA as metadataTemplate} from '../json-templates/metadata';\n\n/**\n * class NodePages - wrapper of nodePages array\n *\n * @example\n * import {writeFile} from './helpers/write-file';\n *\n * // create an instance of the class\n * const nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);\n * ...\n * // push root node\n * const parentId = nodePages.push({\n lodThreshold: HARDCODED_MAX_SCREEN_THRESHOLD_SQ,\n obb: coordinates.obb,\n children: []\n });\n * ...\n * // push node with parent relation\n * const nodeInPage = {\n lodThreshold: HARDCODED_MAX_SCREEN_THRESHOLD_SQ,\n obb: coordinates.obb,\n children: [],\n mesh: {\n geometry: {\n definition: 0\n }\n }\n };\n * const nodeId = this.nodePages.push(nodeInPage, parentId);\n * ...\n * // save all the nodePages in the end of pushing all the nodes\n * await this.nodePages.save(layers0path);\n */\nexport default class NodePages {\n /**\n * @constructs\n * Create a nodePages instance.\n * @param writeFileFunc - function to save one nodePage into a file\n * @param nodesPerPage - length limit for one nodePage. An additional nodePage is created when this limit is met\n */\n constructor(writeFileFunc, nodesPerPage) {\n this.nodesPerPage = nodesPerPage;\n this.nodesCounter = 0;\n this.nodePages = [{}];\n this.nodePages[0].nodes = [];\n this.writeFile = writeFileFunc;\n }\n\n useWriteFunction(func) {\n this.writeFile = func;\n }\n\n /**\n * Get the node by its end-to-end index\n * @param {number} id - end-to-end index of the node\n * @return {object} the node object\n */\n getNodeById(id) {\n const pageIndex = Math.floor(id / this.nodesPerPage);\n const nodeIndex = id % this.nodesPerPage;\n return this.nodePages[pageIndex].nodes[nodeIndex];\n }\n\n /**\n * Update material in node.mesh object by node id\n * @param id - end-to-end index of the node\n * @param materialId - id from scene layer materialDefinitions\n */\n updateMaterialByNodeId(id, materialId) {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.material = {\n definition: materialId,\n resource: node.index\n };\n }\n\n /**\n * Update vertexCount in node.mesh.geometry object by node id\n * @param id - end-to-end index of the node\n * @param vertexCount - vertex count for particular node\n */\n updateVertexCountByNodeId(id, vertexCount) {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.geometry.vertexCount = vertexCount;\n }\n\n /**\n * Update resource in node.mesh.attribute object by node id\n * @param id - end-to-end index of the node\n */\n updateNodeAttributeByNodeId(id) {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.attribute.resource = node.index;\n }\n\n /**\n * Update featureCount in node.mesh.geometry object by node id\n * @param id - end-to-end index of the node\n * @param featureCount - features count of the node\n */\n updateFeatureCountByNodeId(id, featureCount) {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.geometry.featureCount = featureCount;\n }\n\n updateTexelCountHintByNodeId(id, texelCountHint) {\n const node = this.getNodeById(id);\n if (!node.mesh || !node.mesh.material) {\n return;\n }\n node.mesh.material.texelCountHint = texelCountHint;\n }\n\n /**\n * Add a child id into the parent node.children array\n * @param {number | null} parentId - end-to-end parent node index\n * @param {number} childId - end-to-end child node index\n * @return {void}\n */\n addChildRelation(parentId, childId) {\n if (parentId === null) {\n return;\n }\n const parentNode = this.getNodeById(parentId);\n parentNode.children.push(childId);\n }\n\n /**\n * Update resource index in node.mesh object\n * @param {object} node - node object\n * @return {void}\n */\n updateResourceInMesh(node) {\n if (node.mesh) {\n node.mesh.geometry.resource = node.index;\n }\n }\n\n /**\n * Put new node in nodePages array\n * @param {object} node - node object\n * @param {number | null} parentId - index of parent node\n * @return {number}\n */\n push(node, parentId = null) {\n let currentNodePage = this.nodePages[this.nodePages.length - 1];\n if (currentNodePage.nodes.length === this.nodesPerPage) {\n currentNodePage = {nodes: []};\n this.nodePages.push(currentNodePage);\n }\n node.index = this.nodesCounter++;\n currentNodePage.nodes.push(node);\n this.addChildRelation(parentId, node.index);\n this.updateResourceInMesh(node);\n return node.index;\n }\n\n /**\n * Save all the node pages\n * Run this method when all nodes is pushed in nodePages\n * @param {string} layers0Path - path of layer\n * @param {Object} fileMap\n * @param {boolean} slpk\n * @return {promise}\n */\n async save(layers0Path, fileMap, slpk = false) {\n const promises = [];\n if (slpk) {\n for (const [index, nodePage] of this.nodePages.entries()) {\n const nodePageStr = JSON.stringify(nodePage);\n const slpkPath = join(layers0Path, 'nodepages');\n promises.push(this.writeFile(slpkPath, nodePageStr, `${index.toString()}.json`));\n fileMap[`nodePages/${index.toString()}.json.gz`] = `${slpkPath}.json.gz`;\n }\n const metadata = transform({nodeCount: this.nodesCounter}, metadataTemplate);\n const compress = false;\n fileMap['metadata.json'] = await this.writeFile(\n layers0Path,\n JSON.stringify(metadata),\n 'metadata.json',\n compress\n );\n } else {\n for (const [index, nodePage] of this.nodePages.entries()) {\n const nodePageStr = JSON.stringify(nodePage);\n const nodePagePath = join(layers0Path, 'nodepages', index.toString());\n promises.push(this.writeFile(nodePagePath, nodePageStr));\n }\n }\n\n await Promise.all(promises);\n }\n}\n"],"file":"node-pages.js"}