@loaders.gl/tile-converter 3.1.0-beta.2 → 3.1.1

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 (153) hide show
  1. package/dist/bundle.js +2413 -1590
  2. package/dist/converter.min.js +20 -20
  3. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +429 -189
  4. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  5. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +306 -209
  6. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  7. package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +8 -4
  8. package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
  9. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js +13 -13
  10. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
  11. package/dist/es5/3d-tiles-converter/json-templates/tileset.js +51 -32
  12. package/dist/es5/3d-tiles-converter/json-templates/tileset.js.map +1 -1
  13. package/dist/es5/bundle.js +1 -1
  14. package/dist/es5/bundle.js.map +1 -1
  15. package/dist/es5/deps-installer/deps-installer.js +61 -17
  16. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  17. package/dist/es5/i3s-converter/helpers/coordinate-converter.js +55 -16
  18. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  19. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js +33 -9
  20. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
  21. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +103 -93
  22. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  23. package/dist/es5/i3s-converter/helpers/geometry-converter.d.ts +5 -1
  24. package/dist/es5/i3s-converter/helpers/geometry-converter.js +547 -336
  25. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  26. package/dist/es5/i3s-converter/helpers/node-debug.js +27 -31
  27. package/dist/es5/i3s-converter/helpers/node-debug.js.map +1 -1
  28. package/dist/es5/i3s-converter/helpers/node-pages.js +209 -101
  29. package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
  30. package/dist/es5/i3s-converter/i3s-converter.js +1645 -700
  31. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  32. package/dist/es5/i3s-converter/json-templates/layers.js +213 -177
  33. package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
  34. package/dist/es5/i3s-converter/json-templates/metadata.js +24 -20
  35. package/dist/es5/i3s-converter/json-templates/metadata.js.map +1 -1
  36. package/dist/es5/i3s-converter/json-templates/node.js +92 -74
  37. package/dist/es5/i3s-converter/json-templates/node.js.map +1 -1
  38. package/dist/es5/i3s-converter/json-templates/scene-server.js +34 -28
  39. package/dist/es5/i3s-converter/json-templates/scene-server.js.map +1 -1
  40. package/dist/es5/i3s-converter/json-templates/shared-resources.js +162 -107
  41. package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -1
  42. package/dist/es5/i3s-converter/json-templates/store.js +4 -2
  43. package/dist/es5/i3s-converter/json-templates/store.js.map +1 -1
  44. package/dist/es5/i3s-converter/types.js +2 -0
  45. package/dist/es5/i3s-converter/types.js.map +1 -0
  46. package/dist/es5/i3s-server/app.js +6 -6
  47. package/dist/es5/i3s-server/app.js.map +1 -1
  48. package/dist/es5/i3s-server/controllers/index-controller.js +60 -20
  49. package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -1
  50. package/dist/es5/i3s-server/routes/index.js +41 -14
  51. package/dist/es5/i3s-server/routes/index.js.map +1 -1
  52. package/dist/es5/index.js +4 -4
  53. package/dist/es5/lib/utils/{compress-utils.d.ts → compress-util.d.ts} +0 -0
  54. package/dist/es5/lib/utils/compress-util.js +345 -123
  55. package/dist/es5/lib/utils/compress-util.js.map +1 -1
  56. package/dist/es5/lib/utils/file-utils.js +98 -20
  57. package/dist/es5/lib/utils/file-utils.js.map +1 -1
  58. package/dist/es5/lib/utils/lod-conversion-utils.js +9 -9
  59. package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
  60. package/dist/es5/lib/utils/statistic-utills.js +152 -41
  61. package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
  62. package/dist/es5/pgm-loader.js +31 -4
  63. package/dist/es5/pgm-loader.js.map +1 -1
  64. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +7 -6
  65. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  66. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +7 -0
  67. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  68. package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
  69. package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js +1 -1
  70. package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
  71. package/dist/esm/3d-tiles-converter/json-templates/tileset.js +12 -9
  72. package/dist/esm/3d-tiles-converter/json-templates/tileset.js.map +1 -1
  73. package/dist/esm/deps-installer/deps-installer.js +2 -6
  74. package/dist/esm/deps-installer/deps-installer.js.map +1 -1
  75. package/dist/esm/i3s-converter/helpers/coordinate-converter.js +35 -3
  76. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  77. package/dist/esm/i3s-converter/helpers/create-scene-server-path.js +2 -2
  78. package/dist/esm/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
  79. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  80. package/dist/esm/i3s-converter/helpers/geometry-converter.d.ts +5 -1
  81. package/dist/esm/i3s-converter/helpers/geometry-converter.js +50 -16
  82. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  83. package/dist/esm/i3s-converter/helpers/node-debug.js +2 -4
  84. package/dist/esm/i3s-converter/helpers/node-debug.js.map +1 -1
  85. package/dist/esm/i3s-converter/helpers/node-pages.js +15 -4
  86. package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
  87. package/dist/esm/i3s-converter/i3s-converter.js +147 -62
  88. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  89. package/dist/esm/i3s-converter/json-templates/layers.js +37 -27
  90. package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -1
  91. package/dist/esm/i3s-converter/json-templates/metadata.js +2 -2
  92. package/dist/esm/i3s-converter/json-templates/metadata.js.map +1 -1
  93. package/dist/esm/i3s-converter/json-templates/node.js +16 -12
  94. package/dist/esm/i3s-converter/json-templates/node.js.map +1 -1
  95. package/dist/esm/i3s-converter/json-templates/scene-server.js +2 -2
  96. package/dist/esm/i3s-converter/json-templates/scene-server.js.map +1 -1
  97. package/dist/esm/i3s-converter/json-templates/shared-resources.js +19 -14
  98. package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +1 -1
  99. package/dist/esm/i3s-converter/json-templates/store.js.map +1 -1
  100. package/dist/esm/i3s-converter/types.js +2 -0
  101. package/dist/esm/i3s-converter/types.js.map +1 -0
  102. package/dist/esm/lib/utils/{compress-utils.d.ts → compress-util.d.ts} +0 -0
  103. package/dist/esm/pgm-loader.js +3 -3
  104. package/dist/esm/pgm-loader.js.map +1 -1
  105. package/package.json +16 -14
  106. package/src/3d-tiles-converter/3d-tiles-converter.ts +21 -20
  107. package/src/3d-tiles-converter/helpers/{b3dm-converter.js → b3dm-converter.ts} +19 -2
  108. package/src/3d-tiles-converter/helpers/{i3s-obb-to-3d-tiles-obb.js → i3s-obb-to-3d-tiles-obb.ts} +16 -1
  109. package/src/3d-tiles-converter/helpers/texture-atlas.ts +4 -4
  110. package/src/3d-tiles-converter/json-templates/{tileset.js → tileset.ts} +9 -9
  111. package/src/deps-installer/deps-installer.js +2 -2
  112. package/src/i3s-converter/helpers/coordinate-converter.ts +62 -9
  113. package/src/i3s-converter/helpers/{create-scene-server-path.js → create-scene-server-path.ts} +2 -2
  114. package/src/i3s-converter/helpers/{geometry-attributes.js → geometry-attributes.ts} +4 -4
  115. package/src/i3s-converter/helpers/geometry-converter.d.ts +5 -1
  116. package/src/i3s-converter/helpers/geometry-converter.js +63 -13
  117. package/src/i3s-converter/helpers/{node-debug.js → node-debug.ts} +3 -2
  118. package/src/i3s-converter/helpers/{node-pages.js → node-pages.ts} +41 -26
  119. package/src/i3s-converter/i3s-converter.ts +204 -133
  120. package/src/i3s-converter/json-templates/{layers.js → layers.ts} +29 -27
  121. package/src/i3s-converter/json-templates/{metadata.js → metadata.ts} +2 -2
  122. package/src/i3s-converter/json-templates/{node.js → node.ts} +12 -12
  123. package/src/i3s-converter/json-templates/{scene-server.js → scene-server.ts} +2 -2
  124. package/src/i3s-converter/json-templates/{shared-resources.js → shared-resources.ts} +14 -14
  125. package/src/i3s-converter/json-templates/{store.js → store.ts} +0 -0
  126. package/src/i3s-converter/types.ts +14 -0
  127. package/src/lib/utils/{compress-utils.d.ts → compress-util.d.ts} +0 -0
  128. package/src/pgm-loader.ts +2 -2
  129. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.d.ts +0 -23
  130. package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +0 -16
  131. package/dist/es5/i3s-converter/helpers/node-pages.d.ts +0 -144
  132. package/dist/es5/lib/geoid-height-model.d.ts +0 -41
  133. package/dist/es5/lib/geoid-height-model.js +0 -149
  134. package/dist/es5/lib/geoid-height-model.js.map +0 -1
  135. package/dist/es5/lib/pgm-parser.d.ts +0 -14
  136. package/dist/es5/lib/pgm-parser.js +0 -192
  137. package/dist/es5/lib/pgm-parser.js.map +0 -1
  138. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.d.ts +0 -23
  139. package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +0 -16
  140. package/dist/esm/i3s-converter/helpers/node-pages.d.ts +0 -144
  141. package/dist/esm/lib/geoid-height-model.d.ts +0 -41
  142. package/dist/esm/lib/geoid-height-model.js +0 -140
  143. package/dist/esm/lib/geoid-height-model.js.map +0 -1
  144. package/dist/esm/lib/pgm-parser.d.ts +0 -14
  145. package/dist/esm/lib/pgm-parser.js +0 -183
  146. package/dist/esm/lib/pgm-parser.js.map +0 -1
  147. package/src/3d-tiles-converter/helpers/b3dm-converter.d.ts +0 -23
  148. package/src/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +0 -16
  149. package/src/i3s-converter/helpers/node-pages.d.ts +0 -144
  150. package/src/lib/geoid-height-model.d.ts +0 -41
  151. package/src/lib/geoid-height-model.js +0 -239
  152. package/src/lib/pgm-parser.d.ts +0 -14
  153. package/src/lib/pgm-parser.js +0 -179
@@ -7,6 +7,10 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.createSceneServerPath = createSceneServerPath;
9
9
 
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
12
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
+
10
14
  var _uuid = require("uuid");
11
15
 
12
16
  var _jsonMapTransform = _interopRequireDefault(require("json-map-transform"));
@@ -17,14 +21,34 @@ var _sceneServer = require("../json-templates/scene-server");
17
21
 
18
22
  var _fileUtils = require("../../lib/utils/file-utils");
19
23
 
20
- async function createSceneServerPath(layerName, layers0, rootPath) {
21
- const sceneServerData = {
22
- serviceItemId: (0, _uuid.v4)().replace(/-/gi, ''),
23
- layerName,
24
- layers0
25
- };
26
- const sceneServer = (0, _jsonMapTransform.default)(sceneServerData, _sceneServer.SCENE_SERVER_TEMPLATE);
27
- const nodePagePath = (0, _path.join)(rootPath, 'SceneServer');
28
- await (0, _fileUtils.writeFile)(nodePagePath, JSON.stringify(sceneServer));
24
+ function createSceneServerPath(_x, _x2, _x3) {
25
+ return _createSceneServerPath.apply(this, arguments);
26
+ }
27
+
28
+ function _createSceneServerPath() {
29
+ _createSceneServerPath = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(layerName, layers0, rootPath) {
30
+ var sceneServerData, sceneServer, nodePagePath;
31
+ return _regenerator.default.wrap(function _callee$(_context) {
32
+ while (1) {
33
+ switch (_context.prev = _context.next) {
34
+ case 0:
35
+ sceneServerData = {
36
+ serviceItemId: (0, _uuid.v4)().replace(/-/gi, ''),
37
+ layerName: layerName,
38
+ layers0: layers0
39
+ };
40
+ sceneServer = (0, _jsonMapTransform.default)(sceneServerData, (0, _sceneServer.SCENE_SERVER)());
41
+ nodePagePath = (0, _path.join)(rootPath, 'SceneServer');
42
+ _context.next = 5;
43
+ return (0, _fileUtils.writeFile)(nodePagePath, JSON.stringify(sceneServer));
44
+
45
+ case 5:
46
+ case "end":
47
+ return _context.stop();
48
+ }
49
+ }
50
+ }, _callee);
51
+ }));
52
+ return _createSceneServerPath.apply(this, arguments);
29
53
  }
30
54
  //# sourceMappingURL=create-scene-server-path.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/i3s-converter/helpers/create-scene-server-path.js"],"names":["createSceneServerPath","layerName","layers0","rootPath","sceneServerData","serviceItemId","replace","sceneServer","SCENE_SERVER_TEMPLATE","nodePagePath","JSON","stringify"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AASO,eAAeA,qBAAf,CAAqCC,SAArC,EAAgDC,OAAhD,EAAyDC,QAAzD,EAAmE;AACxE,QAAMC,eAAe,GAAG;AACtBC,IAAAA,aAAa,EAAE,gBAASC,OAAT,CAAiB,KAAjB,EAAwB,EAAxB,CADO;AAEtBL,IAAAA,SAFsB;AAGtBC,IAAAA;AAHsB,GAAxB;AAMA,QAAMK,WAAW,GAAG,+BAAUH,eAAV,EAA2BI,kCAA3B,CAApB;AACA,QAAMC,YAAY,GAAG,gBAAKN,QAAL,EAAe,aAAf,CAArB;AACA,QAAM,0BAAUM,YAAV,EAAwBC,IAAI,CAACC,SAAL,CAAeJ,WAAf,CAAxB,CAAN;AACD","sourcesContent":["import {v4 as uuidv4} from 'uuid';\nimport transform from 'json-map-transform';\nimport {join} from 'path';\n\nimport {SCENE_SERVER_TEMPLATE} from '../json-templates/scene-server';\nimport {writeFile} from '../../lib/utils/file-utils';\n\n/**\n * Form and save sceneServer meta data into a file\n * @param {string} layerName - layer name to display\n * @param {object} layers0 - layer object embedded into sceneServer meta data\n * @param {string} rootPath - root path of new converted tileset\n * @return {promise}\n */\nexport async function createSceneServerPath(layerName, layers0, rootPath) {\n const sceneServerData = {\n serviceItemId: uuidv4().replace(/-/gi, ''),\n layerName,\n layers0\n };\n\n const sceneServer = transform(sceneServerData, SCENE_SERVER_TEMPLATE);\n const nodePagePath = join(rootPath, 'SceneServer');\n await writeFile(nodePagePath, JSON.stringify(sceneServer));\n}\n"],"file":"create-scene-server-path.js"}
1
+ {"version":3,"sources":["../../../../src/i3s-converter/helpers/create-scene-server-path.ts"],"names":["createSceneServerPath","layerName","layers0","rootPath","sceneServerData","serviceItemId","replace","sceneServer","nodePagePath","JSON","stringify"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;SASsBA,qB;;;;;qFAAf,iBAAqCC,SAArC,EAAgDC,OAAhD,EAAyDC,QAAzD;AAAA;AAAA;AAAA;AAAA;AAAA;AACCC,YAAAA,eADD,GACmB;AACtBC,cAAAA,aAAa,EAAE,gBAASC,OAAT,CAAiB,KAAjB,EAAwB,EAAxB,CADO;AAEtBL,cAAAA,SAAS,EAATA,SAFsB;AAGtBC,cAAAA,OAAO,EAAPA;AAHsB,aADnB;AAOCK,YAAAA,WAPD,GAOe,+BAAUH,eAAV,EAA2B,gCAA3B,CAPf;AAQCI,YAAAA,YARD,GAQgB,gBAAKL,QAAL,EAAe,aAAf,CARhB;AAAA;AAAA,mBASC,0BAAUK,YAAV,EAAwBC,IAAI,CAACC,SAAL,CAAeH,WAAf,CAAxB,CATD;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G","sourcesContent":["import {v4 as uuidv4} from 'uuid';\nimport transform from 'json-map-transform';\nimport {join} from 'path';\n\nimport {SCENE_SERVER as sceneServerTemplate} from '../json-templates/scene-server';\nimport {writeFile} from '../../lib/utils/file-utils';\n\n/**\n * Form and save sceneServer meta data into a file\n * @param {string} layerName - layer name to display\n * @param {object} layers0 - layer object embedded into sceneServer meta data\n * @param {string} rootPath - root path of new converted tileset\n * @return {promise}\n */\nexport async function createSceneServerPath(layerName, layers0, rootPath) {\n const sceneServerData = {\n serviceItemId: uuidv4().replace(/-/gi, ''),\n layerName,\n layers0\n };\n\n const sceneServer = transform(sceneServerData, sceneServerTemplate());\n const nodePagePath = join(rootPath, 'SceneServer');\n await writeFile(nodePagePath, JSON.stringify(sceneServer));\n}\n"],"file":"create-scene-server-path.js"}
@@ -1,66 +1,70 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.generateAttributes = generateAttributes;
7
9
 
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
8
12
  var _loaderUtils = require("@loaders.gl/loader-utils");
9
13
 
10
- const VALUES_PER_VERTEX = 3;
11
- const POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;
14
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
15
+
16
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17
+
18
+ var VALUES_PER_VERTEX = 3;
19
+ var POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;
12
20
 
13
21
  function generateAttributes(attributes) {
14
- const {
15
- positions,
16
- normals,
17
- texCoords,
18
- colors,
19
- featureIndices,
20
- triangleCount
21
- } = attributes;
22
+ var positions = attributes.positions,
23
+ normals = attributes.normals,
24
+ texCoords = attributes.texCoords,
25
+ colors = attributes.colors,
26
+ featureIndices = attributes.featureIndices,
27
+ triangleCount = attributes.triangleCount;
22
28
 
23
29
  if (!featureIndices.length) {
24
30
  return {
25
31
  faceRange: new Uint32Array([0, triangleCount - 1]),
26
32
  featureIds: [0],
27
33
  featureCount: 1,
28
- positions,
29
- normals,
30
- texCoords,
31
- colors
34
+ positions: positions,
35
+ normals: normals,
36
+ texCoords: texCoords,
37
+ colors: colors
32
38
  };
33
39
  }
34
40
 
35
- const {
36
- faceRange,
37
- featureCount,
38
- featureIds
39
- } = calculateFaceRangesAndFeaturesCount(featureIndices);
40
- const attributeObjects = makeAttributeObjects({
41
- faceRange,
42
- featureIds,
43
- ...attributes
44
- });
45
- const unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);
46
- const groupedAttributes = groupAttributesAndRangesByFeatureId(unifiedAttributeObjectsByFeatureIds);
47
- return {
48
- featureCount,
49
- ...groupedAttributes
50
- };
41
+ var _calculateFaceRangesA = calculateFaceRangesAndFeaturesCount(featureIndices),
42
+ faceRange = _calculateFaceRangesA.faceRange,
43
+ featureCount = _calculateFaceRangesA.featureCount,
44
+ featureIds = _calculateFaceRangesA.featureIds;
45
+
46
+ var attributeObjects = makeAttributeObjects(_objectSpread({
47
+ faceRange: faceRange,
48
+ featureIds: featureIds
49
+ }, attributes));
50
+ var unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);
51
+ var groupedAttributes = groupAttributesAndRangesByFeatureId(unifiedAttributeObjectsByFeatureIds);
52
+ return _objectSpread({
53
+ featureCount: featureCount
54
+ }, groupedAttributes);
51
55
  }
52
56
 
53
57
  function calculateFaceRangesAndFeaturesCount(featureIndices) {
54
- let rangeIndex = 1;
55
- let featureIndex = 1;
56
- let currentFeatureId = featureIndices[0];
57
- const faceRangeList = [];
58
- const featureIds = [];
59
- const uniqueFeatureIds = [currentFeatureId];
58
+ var rangeIndex = 1;
59
+ var featureIndex = 1;
60
+ var currentFeatureId = featureIndices[0];
61
+ var faceRangeList = [];
62
+ var featureIds = [];
63
+ var uniqueFeatureIds = [currentFeatureId];
60
64
  faceRangeList[0] = 0;
61
65
  featureIds[0] = currentFeatureId;
62
66
 
63
- for (let index = 1; index < featureIndices.length; index++) {
67
+ for (var index = 1; index < featureIndices.length; index++) {
64
68
  if (currentFeatureId !== featureIndices[index]) {
65
69
  faceRangeList[rangeIndex] = index / VALUES_PER_VERTEX - 1;
66
70
  faceRangeList[rangeIndex + 1] = index / VALUES_PER_VERTEX;
@@ -78,38 +82,36 @@ function calculateFaceRangesAndFeaturesCount(featureIndices) {
78
82
  }
79
83
 
80
84
  faceRangeList[rangeIndex] = featureIndices.length / VALUES_PER_VERTEX - 1;
81
- const faceRange = new Uint32Array(faceRangeList);
82
- const featureCount = uniqueFeatureIds.length;
85
+ var faceRange = new Uint32Array(faceRangeList);
86
+ var featureCount = uniqueFeatureIds.length;
83
87
  return {
84
- faceRange,
85
- featureCount,
86
- featureIds
88
+ faceRange: faceRange,
89
+ featureCount: featureCount,
90
+ featureIds: featureIds
87
91
  };
88
92
  }
89
93
 
90
94
  function makeAttributeObjects(attributes) {
91
- const {
92
- featureIds,
93
- positions,
94
- normals,
95
- colors,
96
- texCoords,
97
- faceRange
98
- } = attributes;
99
- const groupedData = [];
100
- let positionsList = new Float32Array(positions);
101
- let normalsList = new Float32Array(normals);
102
- let colorsList = new Uint8Array(colors);
103
- let texCoordsList = new Float32Array(texCoords);
104
- let faceRangeIndex = 0;
105
-
106
- for (let index = 0; index < featureIds.length; index++) {
107
- const startIndex = faceRange[index + faceRangeIndex];
108
- const endIndex = faceRange[index + faceRangeIndex + 1];
109
- const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);
110
- const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);
111
- const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);
112
- const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);
95
+ var featureIds = attributes.featureIds,
96
+ positions = attributes.positions,
97
+ normals = attributes.normals,
98
+ colors = attributes.colors,
99
+ texCoords = attributes.texCoords,
100
+ faceRange = attributes.faceRange;
101
+ var groupedData = [];
102
+ var positionsList = new Float32Array(positions);
103
+ var normalsList = new Float32Array(normals);
104
+ var colorsList = new Uint8Array(colors);
105
+ var texCoordsList = new Float32Array(texCoords);
106
+ var faceRangeIndex = 0;
107
+
108
+ for (var index = 0; index < featureIds.length; index++) {
109
+ var startIndex = faceRange[index + faceRangeIndex];
110
+ var endIndex = faceRange[index + faceRangeIndex + 1];
111
+ var positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);
112
+ var normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);
113
+ var colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);
114
+ var texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);
113
115
  groupedData.push({
114
116
  featureId: featureIds[index],
115
117
  positions: positionsList.slice(0, positionsCount),
@@ -124,14 +126,16 @@ function makeAttributeObjects(attributes) {
124
126
  faceRangeIndex += 1;
125
127
  }
126
128
 
127
- return groupedData.sort((first, second) => first.featureId - second.featureId);
129
+ return groupedData.sort(function (first, second) {
130
+ return first.featureId - second.featureId;
131
+ });
128
132
  }
129
133
 
130
134
  function getSliceAttributeCount(attributeName, startIndex, endIndex) {
131
- const colorsPerVertex = 4;
132
- const texCoordsPerVertex = 2;
133
- const trianglesCount = endIndex - startIndex + 1;
134
- const vertexCount = trianglesCount * 3;
135
+ var colorsPerVertex = 4;
136
+ var texCoordsPerVertex = 2;
137
+ var trianglesCount = endIndex - startIndex + 1;
138
+ var vertexCount = trianglesCount * 3;
135
139
 
136
140
  switch (attributeName) {
137
141
  case 'positions':
@@ -150,11 +154,13 @@ function getSliceAttributeCount(attributeName, startIndex, endIndex) {
150
154
  }
151
155
 
152
156
  function unifyObjectsByFeatureId(sortedData) {
153
- const uniqueObjects = [];
157
+ var uniqueObjects = [];
154
158
 
155
- for (let index = 0; index < sortedData.length; index++) {
156
- const currentObject = sortedData[index];
157
- const existedObject = uniqueObjects.find(obj => obj.featureId === currentObject.featureId);
159
+ var _loop = function _loop(index) {
160
+ var currentObject = sortedData[index];
161
+ var existedObject = uniqueObjects.find(function (obj) {
162
+ return obj.featureId === currentObject.featureId;
163
+ });
158
164
 
159
165
  if (existedObject) {
160
166
  existedObject.positions = (0, _loaderUtils.concatenateTypedArrays)(existedObject.positions, currentObject.positions);
@@ -164,30 +170,34 @@ function unifyObjectsByFeatureId(sortedData) {
164
170
  } else {
165
171
  uniqueObjects.push(currentObject);
166
172
  }
173
+ };
174
+
175
+ for (var index = 0; index < sortedData.length; index++) {
176
+ _loop(index);
167
177
  }
168
178
 
169
179
  return uniqueObjects;
170
180
  }
171
181
 
172
182
  function groupAttributesAndRangesByFeatureId(unifiedObjects) {
173
- const firstAttributeObject = unifiedObjects[0];
174
- const featureIds = [firstAttributeObject.featureId];
175
- let positions = new Float32Array(firstAttributeObject.positions);
176
- let normals = new Float32Array(firstAttributeObject.normals);
177
- let colors = new Uint8Array(firstAttributeObject.colors);
178
- let texCoords = new Float32Array(firstAttributeObject.texCoords);
179
- const range = [0];
180
- let objIndex = 0;
181
- let sum = 0;
182
-
183
- for (let index = 1; index < unifiedObjects.length; index++) {
184
- const currentAttributesObject = unifiedObjects[index];
183
+ var firstAttributeObject = unifiedObjects[0];
184
+ var featureIds = [firstAttributeObject.featureId];
185
+ var positions = new Float32Array(firstAttributeObject.positions);
186
+ var normals = new Float32Array(firstAttributeObject.normals);
187
+ var colors = new Uint8Array(firstAttributeObject.colors);
188
+ var texCoords = new Float32Array(firstAttributeObject.texCoords);
189
+ var range = [0];
190
+ var objIndex = 0;
191
+ var sum = 0;
192
+
193
+ for (var index = 1; index < unifiedObjects.length; index++) {
194
+ var currentAttributesObject = unifiedObjects[index];
185
195
  featureIds.push(currentAttributesObject.featureId);
186
196
  positions = (0, _loaderUtils.concatenateTypedArrays)(positions, currentAttributesObject.positions);
187
197
  normals = (0, _loaderUtils.concatenateTypedArrays)(normals, currentAttributesObject.normals);
188
198
  colors = (0, _loaderUtils.concatenateTypedArrays)(colors, currentAttributesObject.colors);
189
199
  texCoords = (0, _loaderUtils.concatenateTypedArrays)(texCoords, currentAttributesObject.texCoords);
190
- const groupedObject = unifiedObjects[objIndex];
200
+ var groupedObject = unifiedObjects[objIndex];
191
201
  range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);
192
202
  range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE + sum);
193
203
  sum += groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;
@@ -195,14 +205,14 @@ function groupAttributesAndRangesByFeatureId(unifiedObjects) {
195
205
  }
196
206
 
197
207
  range.push(positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);
198
- const faceRange = new Uint32Array(range);
208
+ var faceRange = new Uint32Array(range);
199
209
  return {
200
- faceRange,
201
- featureIds,
202
- positions,
203
- normals,
204
- colors,
205
- texCoords
210
+ faceRange: faceRange,
211
+ featureIds: featureIds,
212
+ positions: positions,
213
+ normals: normals,
214
+ colors: colors,
215
+ texCoords: texCoords
206
216
  };
207
217
  }
208
218
  //# sourceMappingURL=geometry-attributes.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/i3s-converter/helpers/geometry-attributes.js"],"names":["VALUES_PER_VERTEX","POSITIONS_AND_NORMALS_PER_TRIANGLE","generateAttributes","attributes","positions","normals","texCoords","colors","featureIndices","triangleCount","length","faceRange","Uint32Array","featureIds","featureCount","calculateFaceRangesAndFeaturesCount","attributeObjects","makeAttributeObjects","unifiedAttributeObjectsByFeatureIds","unifyObjectsByFeatureId","groupedAttributes","groupAttributesAndRangesByFeatureId","rangeIndex","featureIndex","currentFeatureId","faceRangeList","uniqueFeatureIds","index","includes","push","groupedData","positionsList","Float32Array","normalsList","colorsList","Uint8Array","texCoordsList","faceRangeIndex","startIndex","endIndex","positionsCount","getSliceAttributeCount","normalsCount","colorsCount","texCoordsCount","featureId","slice","sort","first","second","attributeName","colorsPerVertex","texCoordsPerVertex","trianglesCount","vertexCount","sortedData","uniqueObjects","currentObject","existedObject","find","obj","unifiedObjects","firstAttributeObject","range","objIndex","sum","currentAttributesObject","groupedObject"],"mappings":";;;;;;;AAAA;;AAEA,MAAMA,iBAAiB,GAAG,CAA1B;AACA,MAAMC,kCAAkC,GAAG,CAA3C;;AAOO,SAASC,kBAAT,CAA4BC,UAA5B,EAAwC;AAC7C,QAAM;AAACC,IAAAA,SAAD;AAAYC,IAAAA,OAAZ;AAAqBC,IAAAA,SAArB;AAAgCC,IAAAA,MAAhC;AAAwCC,IAAAA,cAAxC;AAAwDC,IAAAA;AAAxD,MAAyEN,UAA/E;;AAEA,MAAI,CAACK,cAAc,CAACE,MAApB,EAA4B;AAC1B,WAAO;AACLC,MAAAA,SAAS,EAAE,IAAIC,WAAJ,CAAgB,CAAC,CAAD,EAAIH,aAAa,GAAG,CAApB,CAAhB,CADN;AAELI,MAAAA,UAAU,EAAE,CAAC,CAAD,CAFP;AAGLC,MAAAA,YAAY,EAAE,CAHT;AAILV,MAAAA,SAJK;AAKLC,MAAAA,OALK;AAMLC,MAAAA,SANK;AAOLC,MAAAA;AAPK,KAAP;AASD;;AAED,QAAM;AAACI,IAAAA,SAAD;AAAYG,IAAAA,YAAZ;AAA0BD,IAAAA;AAA1B,MAAwCE,mCAAmC,CAACP,cAAD,CAAjF;AACA,QAAMQ,gBAAgB,GAAGC,oBAAoB,CAAC;AAACN,I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CAAZ;AAEA,UAAM6D,aAAa,GAAGN,cAAc,CAACG,QAAD,CAApC;AACAD,IAAAA,KAAK,CAAClC,IAAN,CAAWsC,aAAa,CAAC/D,SAAd,CAAwBM,MAAxB,GAAiCT,kCAAjC,GAAsE,CAAtE,GAA0EgE,GAArF;AACAF,IAAAA,KAAK,CAAClC,IAAN,CAAWsC,aAAa,CAAC/D,SAAd,CAAwBM,MAAxB,GAAiCT,kCAAjC,GAAsEgE,GAAjF;AAEAA,IAAAA,GAAG,IAAIE,aAAa,CAAC/D,SAAd,CAAwBM,MAAxB,GAAiCT,kCAAxC;AACA+D,IAAAA,QAAQ,IAAI,CAAZ;AACD;;AAEDD,EAAAA,KAAK,CAAClC,IAAN,CAAWzB,SAAS,CAACM,MAAV,GAAmBT,kCAAnB,GAAwD,CAAnE;AAEA,QAAMU,SAAS,GAAG,IAAIC,WAAJ,CAAgBmD,KAAhB,CAAlB;AACA,SAAO;AAACpD,IAAAA,SAAD;AAAYE,IAAAA,UAAZ;AAAwBT,IAAAA,SAAxB;AAAmCC,IAAAA,OAAnC;AAA4CE,IAAAA,MAA5C;AAAoDD,IAAAA;AAApD,GAAP;AACD","sourcesContent":["import {concatenateTypedArrays} from '@loaders.gl/loader-utils';\n\nconst VALUES_PER_VERTEX = 3;\nconst POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;\n\n/**\n * Generate geometry attributes with faceRange and featureCount\n * @param {Object} attributes\n * @returns {Object} Object with featureCount, reordered attributes and changed faceRange.\n */\nexport function generateAttributes(attributes) {\n const {positions, normals, texCoords, colors, featureIndices, triangleCount} = attributes;\n\n if (!featureIndices.length) {\n return {\n faceRange: new Uint32Array([0, triangleCount - 1]),\n featureIds: [0],\n featureCount: 1,\n positions,\n normals,\n texCoords,\n colors\n };\n }\n\n const {faceRange, featureCount, featureIds} = calculateFaceRangesAndFeaturesCount(featureIndices);\n const attributeObjects = makeAttributeObjects({faceRange, featureIds, ...attributes});\n const unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);\n const groupedAttributes = groupAttributesAndRangesByFeatureId(\n unifiedAttributeObjectsByFeatureIds\n );\n return {featureCount, ...groupedAttributes};\n}\n\n/**\n * Calculates face Ranges and feature count based on featureIndices.\n * @param {Object} featureIndices\n * @returns {Object} Object with featureCount, reordered attributes and changed faceRange.\n */\nfunction calculateFaceRangesAndFeaturesCount(featureIndices) {\n let rangeIndex = 1;\n let featureIndex = 1;\n let currentFeatureId = featureIndices[0];\n const faceRangeList = [];\n const featureIds = [];\n const uniqueFeatureIds = [currentFeatureId];\n\n faceRangeList[0] = 0;\n featureIds[0] = currentFeatureId;\n\n for (let index = 1; index < featureIndices.length; index++) {\n if (currentFeatureId !== featureIndices[index]) {\n faceRangeList[rangeIndex] = index / VALUES_PER_VERTEX - 1;\n faceRangeList[rangeIndex + 1] = index / VALUES_PER_VERTEX;\n featureIds[featureIndex] = featureIndices[index];\n\n if (!uniqueFeatureIds.includes(featureIndices[index])) {\n uniqueFeatureIds.push(featureIndices[index]);\n }\n\n rangeIndex += 2;\n featureIndex += 1;\n }\n currentFeatureId = featureIndices[index];\n }\n\n faceRangeList[rangeIndex] = featureIndices.length / VALUES_PER_VERTEX - 1;\n\n const faceRange = new Uint32Array(faceRangeList);\n const featureCount = uniqueFeatureIds.length;\n\n return {faceRange, featureCount, featureIds};\n}\n\n/**\n * Generate list of attribute object grouped by feature ids.\n * @param {Object} attributes\n * @returns {Array} sorted list of attribute objects.\n */\nfunction makeAttributeObjects(attributes) {\n const {featureIds, positions, normals, colors, texCoords, faceRange} = attributes;\n const groupedData = [];\n\n let positionsList = new Float32Array(positions);\n let normalsList = new Float32Array(normals);\n let colorsList = new Uint8Array(colors);\n let texCoordsList = new Float32Array(texCoords);\n\n let faceRangeIndex = 0;\n\n for (let index = 0; index < featureIds.length; index++) {\n const startIndex = faceRange[index + faceRangeIndex];\n const endIndex = faceRange[index + faceRangeIndex + 1];\n\n const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);\n const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);\n const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);\n const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);\n\n groupedData.push({\n featureId: featureIds[index],\n positions: positionsList.slice(0, positionsCount),\n normals: normalsList.slice(0, normalsCount),\n colors: colorsList.slice(0, colorsCount),\n texCoords: texCoordsList.slice(0, texCoordsCount)\n });\n\n positionsList = positionsList.slice(positionsCount);\n normalsList = normalsList.slice(normalsCount);\n colorsList = colorsList.slice(colorsCount);\n texCoordsList = texCoordsList.slice(texCoordsCount);\n\n faceRangeIndex += 1;\n }\n\n return groupedData.sort((first, second) => first.featureId - second.featureId);\n}\n\n/**\n * Generate sliced count for generating attribute objects depends on attribute name and range.\n * @param {String} attributeName\n * @param {Number} startIndex\n * @param {Number} endIndex\n * @returns {Number} - sliced count\n */\nfunction getSliceAttributeCount(attributeName, startIndex, endIndex) {\n const colorsPerVertex = 4;\n const texCoordsPerVertex = 2;\n\n const trianglesCount = endIndex - startIndex + 1;\n const vertexCount = trianglesCount * 3;\n\n switch (attributeName) {\n case 'positions':\n case 'normals':\n return trianglesCount * POSITIONS_AND_NORMALS_PER_TRIANGLE;\n case 'colors':\n return vertexCount * colorsPerVertex;\n case 'texCoords':\n return vertexCount * texCoordsPerVertex;\n default:\n return 0;\n }\n}\n\n/**\n * Generates unique object list depends on feature ids and concantenate their attributes.\n * @param {Array} sortedData\n * @returns {Array} - unique list of objects\n */\nfunction unifyObjectsByFeatureId(sortedData) {\n const uniqueObjects = [];\n\n for (let index = 0; index < sortedData.length; index++) {\n const currentObject = sortedData[index];\n const existedObject = uniqueObjects.find((obj) => obj.featureId === currentObject.featureId);\n\n if (existedObject) {\n existedObject.positions = concatenateTypedArrays(\n existedObject.positions,\n currentObject.positions\n );\n existedObject.normals = concatenateTypedArrays(existedObject.normals, currentObject.normals);\n existedObject.colors = concatenateTypedArrays(existedObject.colors, currentObject.colors);\n existedObject.texCoords = concatenateTypedArrays(\n existedObject.texCoords,\n currentObject.texCoords\n );\n } else {\n uniqueObjects.push(currentObject);\n }\n }\n\n return uniqueObjects;\n}\n\n/**\n * Generates attribute objects with new faceRange and reordered attributes.\n * @param {Array} unifiedObjects\n * @returns {Object} - ugenerated attributes with new faceRange.\n */\nfunction groupAttributesAndRangesByFeatureId(unifiedObjects) {\n const firstAttributeObject = unifiedObjects[0];\n const featureIds = [firstAttributeObject.featureId];\n\n let positions = new Float32Array(firstAttributeObject.positions);\n let normals = new Float32Array(firstAttributeObject.normals);\n let colors = new Uint8Array(firstAttributeObject.colors);\n let texCoords = new Float32Array(firstAttributeObject.texCoords);\n const range = [0];\n\n let objIndex = 0;\n let sum = 0;\n\n for (let index = 1; index < unifiedObjects.length; index++) {\n const currentAttributesObject = unifiedObjects[index];\n featureIds.push(currentAttributesObject.featureId);\n\n positions = concatenateTypedArrays(positions, currentAttributesObject.positions);\n normals = concatenateTypedArrays(normals, currentAttributesObject.normals);\n colors = concatenateTypedArrays(colors, currentAttributesObject.colors);\n texCoords = concatenateTypedArrays(texCoords, currentAttributesObject.texCoords);\n\n const groupedObject = unifiedObjects[objIndex];\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE + sum);\n\n sum += groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;\n objIndex += 1;\n }\n\n range.push(positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);\n\n const faceRange = new Uint32Array(range);\n return {faceRange, featureIds, positions, normals, colors, texCoords};\n}\n"],"file":"geometry-attributes.js"}
1
+ {"version":3,"sources":["../../../../src/i3s-converter/helpers/geometry-attributes.ts"],"names":["VALUES_PER_VERTEX","POSITIONS_AND_NORMALS_PER_TRIANGLE","generateAttributes","attributes","positions","normals","texCoords","colors","featureIndices","triangleCount","length","faceRange","Uint32Array","featureIds","featureCount","calculateFaceRangesAndFeaturesCount","attributeObjects","makeAttributeObjects","unifiedAttributeObjectsByFeatureIds","unifyObjectsByFeatureId","groupedAttributes","groupAttributesAndRangesByFeatureId","rangeIndex","featureIndex","currentFeatureId","faceRangeList","uniqueFeatureIds","index","includes","push","groupedData","positionsList","Float32Array","normalsList","colorsList","Uint8Array","texCoordsList","faceRangeIndex","startIndex","endIndex","positionsCount","getSliceAttributeCount","normalsCount","colorsCount","texCoordsCount","featureId","slice","sort","first","second","attributeName","colorsPerVertex","texCoordsPerVertex","trianglesCount","vertexCount","sortedData","uniqueObjects","currentObject","existedObject","find","obj","unifiedObjects","firstAttributeObject","range","objIndex","sum","currentAttributesObject","groupedObject"],"mappings":";;;;;;;;;;;AAAA;;;;;;AAEA,IAAMA,iBAAiB,GAAG,CAA1B;AACA,IAAMC,kCAAkC,GAAG,CAA3C;;AAOO,SAASC,kBAAT,CAA4BC,UAA5B,EAAwC;AAC7C,MAAOC,SAAP,GAA+ED,UAA/E,CAAOC,SAAP;AAAA,MAAkBC,OAAlB,GAA+EF,UAA/E,CAAkBE,OAAlB;AAAA,MAA2BC,SAA3B,GAA+EH,UAA/E,CAA2BG,SAA3B;AAAA,MAAsCC,MAAtC,GAA+EJ,UAA/E,CAAsCI,MAAtC;AAAA,MAA8CC,cAA9C,GAA+EL,UAA/E,CAA8CK,cAA9C;AAAA,MAA8DC,aAA9D,GAA+EN,UAA/E,CAA8DM,aAA9D;;AAEA,MAAI,CAACD,cAAc,CAACE,MAApB,EAA4B;AAC1B,WAAO;AACLC,MAAAA,SAAS,EAAE,IAAIC,WAAJ,CAAgB,CAAC,CAAD,EAAIH,aAAa,GAAG,CAApB,CAAhB,CADN;AAELI,MAAAA,UAAU,EAAE,CAAC,CAAD,CAFP;AAGLC,MAAAA,YAAY,EAAE,CAHT;AAILV,MAAAA,SAAS,EAATA,SAJK;AAKLC,MAAAA,OAAO,EAAPA,OALK;AAMLC,MAAAA,SAAS,EAATA,SANK;AAOLC,MAAAA,MAAM,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,IAAAA,OAAO,EAAPA,OAAnC;AAA4CE,IAAAA,MAAM,EAANA,MAA5C;AAAoDD,IAAAA,SAAS,EAATA;AAApD,GAAP;AACD","sourcesContent":["import {concatenateTypedArrays} from '@loaders.gl/loader-utils';\n\nconst VALUES_PER_VERTEX = 3;\nconst POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;\n\n/**\n * Generate geometry attributes with faceRange and featureCount\n * @param {Object} attributes\n * @returns {Object} Object with featureCount, reordered attributes and changed faceRange.\n */\nexport function generateAttributes(attributes) {\n const {positions, normals, texCoords, colors, featureIndices, triangleCount} = attributes;\n\n if (!featureIndices.length) {\n return {\n faceRange: new Uint32Array([0, triangleCount - 1]),\n featureIds: [0],\n featureCount: 1,\n positions,\n normals,\n texCoords,\n colors\n };\n }\n\n const {faceRange, featureCount, featureIds} = calculateFaceRangesAndFeaturesCount(featureIndices);\n const attributeObjects = makeAttributeObjects({faceRange, featureIds, ...attributes});\n const unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);\n const groupedAttributes = groupAttributesAndRangesByFeatureId(\n unifiedAttributeObjectsByFeatureIds\n );\n return {featureCount, ...groupedAttributes};\n}\n\n/**\n * Calculates face Ranges and feature count based on featureIndices.\n * @param {Object} featureIndices\n * @returns {Object} Object with featureCount, reordered attributes and changed faceRange.\n */\nfunction calculateFaceRangesAndFeaturesCount(featureIndices) {\n let rangeIndex = 1;\n let featureIndex = 1;\n let currentFeatureId = featureIndices[0];\n const faceRangeList: any[] = [];\n const featureIds: any[] = [];\n const uniqueFeatureIds = [currentFeatureId];\n\n faceRangeList[0] = 0;\n featureIds[0] = currentFeatureId;\n\n for (let index = 1; index < featureIndices.length; index++) {\n if (currentFeatureId !== featureIndices[index]) {\n faceRangeList[rangeIndex] = index / VALUES_PER_VERTEX - 1;\n faceRangeList[rangeIndex + 1] = index / VALUES_PER_VERTEX;\n featureIds[featureIndex] = featureIndices[index];\n\n if (!uniqueFeatureIds.includes(featureIndices[index])) {\n uniqueFeatureIds.push(featureIndices[index]);\n }\n\n rangeIndex += 2;\n featureIndex += 1;\n }\n currentFeatureId = featureIndices[index];\n }\n\n faceRangeList[rangeIndex] = featureIndices.length / VALUES_PER_VERTEX - 1;\n\n const faceRange = new Uint32Array(faceRangeList);\n const featureCount = uniqueFeatureIds.length;\n\n return {faceRange, featureCount, featureIds};\n}\n\n/**\n * Generate list of attribute object grouped by feature ids.\n * @param {Object} attributes\n * @returns {Array} sorted list of attribute objects.\n */\nfunction makeAttributeObjects(attributes) {\n const {featureIds, positions, normals, colors, texCoords, faceRange} = attributes;\n const groupedData: any[] = [];\n\n let positionsList = new Float32Array(positions);\n let normalsList = new Float32Array(normals);\n let colorsList = new Uint8Array(colors);\n let texCoordsList = new Float32Array(texCoords);\n\n let faceRangeIndex = 0;\n\n for (let index = 0; index < featureIds.length; index++) {\n const startIndex = faceRange[index + faceRangeIndex];\n const endIndex = faceRange[index + faceRangeIndex + 1];\n\n const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);\n const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);\n const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);\n const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);\n\n groupedData.push({\n featureId: featureIds[index],\n positions: positionsList.slice(0, positionsCount),\n normals: normalsList.slice(0, normalsCount),\n colors: colorsList.slice(0, colorsCount),\n texCoords: texCoordsList.slice(0, texCoordsCount)\n });\n\n positionsList = positionsList.slice(positionsCount);\n normalsList = normalsList.slice(normalsCount);\n colorsList = colorsList.slice(colorsCount);\n texCoordsList = texCoordsList.slice(texCoordsCount);\n\n faceRangeIndex += 1;\n }\n\n return groupedData.sort((first, second) => first.featureId - second.featureId);\n}\n\n/**\n * Generate sliced count for generating attribute objects depends on attribute name and range.\n * @param {String} attributeName\n * @param {Number} startIndex\n * @param {Number} endIndex\n * @returns {Number} - sliced count\n */\nfunction getSliceAttributeCount(attributeName, startIndex, endIndex) {\n const colorsPerVertex = 4;\n const texCoordsPerVertex = 2;\n\n const trianglesCount = endIndex - startIndex + 1;\n const vertexCount = trianglesCount * 3;\n\n switch (attributeName) {\n case 'positions':\n case 'normals':\n return trianglesCount * POSITIONS_AND_NORMALS_PER_TRIANGLE;\n case 'colors':\n return vertexCount * colorsPerVertex;\n case 'texCoords':\n return vertexCount * texCoordsPerVertex;\n default:\n return 0;\n }\n}\n\n/**\n * Generates unique object list depends on feature ids and concantenate their attributes.\n * @param {Array} sortedData\n * @returns {Array} - unique list of objects\n */\nfunction unifyObjectsByFeatureId(sortedData) {\n const uniqueObjects: any[] = [];\n\n for (let index = 0; index < sortedData.length; index++) {\n const currentObject = sortedData[index];\n const existedObject = uniqueObjects.find((obj) => obj.featureId === currentObject.featureId);\n\n if (existedObject) {\n existedObject.positions = concatenateTypedArrays(\n existedObject.positions,\n currentObject.positions\n );\n existedObject.normals = concatenateTypedArrays(existedObject.normals, currentObject.normals);\n existedObject.colors = concatenateTypedArrays(existedObject.colors, currentObject.colors);\n existedObject.texCoords = concatenateTypedArrays(\n existedObject.texCoords,\n currentObject.texCoords\n );\n } else {\n uniqueObjects.push(currentObject);\n }\n }\n\n return uniqueObjects;\n}\n\n/**\n * Generates attribute objects with new faceRange and reordered attributes.\n * @param {Array} unifiedObjects\n * @returns {Object} - ugenerated attributes with new faceRange.\n */\nfunction groupAttributesAndRangesByFeatureId(unifiedObjects) {\n const firstAttributeObject = unifiedObjects[0];\n const featureIds = [firstAttributeObject.featureId];\n\n let positions = new Float32Array(firstAttributeObject.positions);\n let normals = new Float32Array(firstAttributeObject.normals);\n let colors = new Uint8Array(firstAttributeObject.colors);\n let texCoords = new Float32Array(firstAttributeObject.texCoords);\n const range = [0];\n\n let objIndex = 0;\n let sum = 0;\n\n for (let index = 1; index < unifiedObjects.length; index++) {\n const currentAttributesObject = unifiedObjects[index];\n featureIds.push(currentAttributesObject.featureId);\n\n positions = concatenateTypedArrays(positions, currentAttributesObject.positions);\n normals = concatenateTypedArrays(normals, currentAttributesObject.normals);\n colors = concatenateTypedArrays(colors, currentAttributesObject.colors);\n texCoords = concatenateTypedArrays(texCoords, currentAttributesObject.texCoords);\n\n const groupedObject = unifiedObjects[objIndex];\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE + sum);\n\n sum += groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;\n objIndex += 1;\n }\n\n range.push(positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);\n\n const faceRange = new Uint32Array(range);\n return {faceRange, featureIds, positions, normals, colors, texCoords};\n}\n"],"file":"geometry-attributes.js"}
@@ -1,4 +1,5 @@
1
1
  import {Vector3, Matrix4} from '@math.gl/core';
2
+ import {GeoidHeightModel} from '../../lib/geoid-height-model';
2
3
  /**
3
4
  * Convert binary data from b3dm file to i3s resources
4
5
  *
@@ -25,7 +26,9 @@ export default function convertB3dmToI3sGeometry(
25
26
  nodeId: number,
26
27
  featuresHashArray: any,
27
28
  attributeStorageInfo: any,
28
- draco: boolean
29
+ draco: boolean,
30
+ generateBoundingVolumes: boolean,
31
+ geoidHeightModel: GeoidHeightModel
29
32
  ): Promise<
30
33
  {
31
34
  geometry: ArrayBuffer;
@@ -36,5 +39,6 @@ export default function convertB3dmToI3sGeometry(
36
39
  vertexCount: number;
37
40
  attributes: any;
38
41
  featureCount: number;
42
+ boundingVolumes: any;
39
43
  }[]
40
44
  >;