@loaders.gl/tile-converter 3.1.0-beta.5 → 3.1.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 (153) hide show
  1. package/dist/converter.min.js +20 -20
  2. package/dist/{bundle.js → dist.min.js} +2228 -1482
  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 +17 -15
  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,12 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = convertB3dmToI3sGeometry;
9
9
 
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
15
+
10
16
  var _core = require("@math.gl/core");
11
17
 
12
18
  var _geospatial = require("@math.gl/geospatial");
@@ -21,227 +27,388 @@ var _md = _interopRequireDefault(require("md5"));
21
27
 
22
28
  var _geometryAttributes = require("./geometry-attributes");
23
29
 
24
- const VALUES_PER_VERTEX = 3;
25
- const VALUES_PER_TEX_COORD = 2;
26
- const VALUES_PER_COLOR_ELEMENT = 4;
27
- const STRING_TYPE = 'string';
28
- const SHORT_INT_TYPE = 'Int32';
29
- const DOUBLE_TYPE = 'Float64';
30
- const OBJECT_ID_TYPE = 'Oid32';
31
- const BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ['CUSTOM_ATTRIBUTE_2', '_BATCHID', 'BATCHID'];
30
+ var _coordinateConverter = require("./coordinate-converter");
32
31
 
33
- async function convertB3dmToI3sGeometry(tileContent, nodeId, featuresHashArray, attributeStorageInfo, draco) {
34
- const materialAndTextureList = convertMaterials(tileContent);
35
- const convertedAttributesMap = convertAttributes(tileContent);
32
+ 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; }
36
33
 
37
- if (convertedAttributesMap.has('default')) {
38
- materialAndTextureList.push({
39
- material: getDefaultMaterial()
40
- });
41
- }
34
+ 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; }
42
35
 
43
- const result = [];
44
- let nodesCounter = nodeId;
45
- let {
46
- materials = []
47
- } = tileContent.gltf;
36
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
37
+
38
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
48
39
 
49
- if (!materials.length === 0) {
50
- materials.push({
51
- id: 'default'
52
- });
53
- }
40
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
54
41
 
55
- for (let i = 0; i < materials.length; i++) {
56
- const sourceMaterial = materials[i];
42
+ var VALUES_PER_VERTEX = 3;
43
+ var VALUES_PER_TEX_COORD = 2;
44
+ var VALUES_PER_COLOR_ELEMENT = 4;
45
+ var STRING_TYPE = 'string';
46
+ var SHORT_INT_TYPE = 'Int32';
47
+ var DOUBLE_TYPE = 'Float64';
48
+ var OBJECT_ID_TYPE = 'Oid32';
49
+ var BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ['CUSTOM_ATTRIBUTE_2', '_BATCHID', 'BATCHID'];
50
+ var scratchVector = new _core.Vector3();
57
51
 
58
- if (!convertedAttributesMap.has(sourceMaterial.id)) {
59
- continue;
60
- }
52
+ function convertB3dmToI3sGeometry(_x, _x2, _x3, _x4, _x5, _x6, _x7) {
53
+ return _convertB3dmToI3sGeometry.apply(this, arguments);
54
+ }
61
55
 
62
- const convertedAttributes = convertedAttributesMap.get(sourceMaterial.id);
63
- const {
64
- material,
65
- texture
66
- } = materialAndTextureList[i];
67
- result.push(await _makeNodeResources({
68
- convertedAttributes,
69
- material,
70
- texture,
71
- tileContent,
72
- nodeId: nodesCounter,
73
- featuresHashArray,
74
- attributeStorageInfo,
75
- draco
76
- }));
77
- nodesCounter++;
78
- }
56
+ function _convertB3dmToI3sGeometry() {
57
+ _convertB3dmToI3sGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(tileContent, nodeId, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, geoidHeightModel) {
58
+ var useCartesianPositions, materialAndTextureList, convertedAttributesMap, result, nodesCounter, _tileContent$gltf$mat, materials, i, sourceMaterial, convertedAttributes, _materialAndTextureLi, material, texture;
79
59
 
80
- if (!result.length) {
81
- return null;
82
- }
60
+ return _regenerator.default.wrap(function _callee$(_context) {
61
+ while (1) {
62
+ switch (_context.prev = _context.next) {
63
+ case 0:
64
+ useCartesianPositions = generateBoundingVolumes;
65
+ materialAndTextureList = convertMaterials(tileContent);
66
+ convertedAttributesMap = convertAttributes(tileContent, useCartesianPositions);
83
67
 
84
- return result;
68
+ if (generateBoundingVolumes) {
69
+ _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel);
70
+ }
71
+
72
+ if (convertedAttributesMap.has('default')) {
73
+ materialAndTextureList.push({
74
+ material: getDefaultMaterial()
75
+ });
76
+ }
77
+
78
+ result = [];
79
+ nodesCounter = nodeId;
80
+ _tileContent$gltf$mat = tileContent.gltf.materials, materials = _tileContent$gltf$mat === void 0 ? [] : _tileContent$gltf$mat;
81
+
82
+ if (!(materials !== null && materials !== void 0 && materials.length)) {
83
+ materials.push({
84
+ id: 'default'
85
+ });
86
+ }
87
+
88
+ i = 0;
89
+
90
+ case 10:
91
+ if (!(i < materials.length)) {
92
+ _context.next = 25;
93
+ break;
94
+ }
95
+
96
+ sourceMaterial = materials[i];
97
+
98
+ if (convertedAttributesMap.has(sourceMaterial.id)) {
99
+ _context.next = 14;
100
+ break;
101
+ }
102
+
103
+ return _context.abrupt("continue", 22);
104
+
105
+ case 14:
106
+ convertedAttributes = convertedAttributesMap.get(sourceMaterial.id);
107
+ _materialAndTextureLi = materialAndTextureList[i], material = _materialAndTextureLi.material, texture = _materialAndTextureLi.texture;
108
+ _context.t0 = result;
109
+ _context.next = 19;
110
+ return _makeNodeResources({
111
+ convertedAttributes: convertedAttributes,
112
+ material: material,
113
+ texture: texture,
114
+ tileContent: tileContent,
115
+ nodeId: nodesCounter,
116
+ featuresHashArray: featuresHashArray,
117
+ attributeStorageInfo: attributeStorageInfo,
118
+ draco: draco
119
+ });
120
+
121
+ case 19:
122
+ _context.t1 = _context.sent;
123
+
124
+ _context.t0.push.call(_context.t0, _context.t1);
125
+
126
+ nodesCounter++;
127
+
128
+ case 22:
129
+ i++;
130
+ _context.next = 10;
131
+ break;
132
+
133
+ case 25:
134
+ if (result.length) {
135
+ _context.next = 27;
136
+ break;
137
+ }
138
+
139
+ return _context.abrupt("return", null);
140
+
141
+ case 27:
142
+ return _context.abrupt("return", result);
143
+
144
+ case 28:
145
+ case "end":
146
+ return _context.stop();
147
+ }
148
+ }
149
+ }, _callee);
150
+ }));
151
+ return _convertB3dmToI3sGeometry.apply(this, arguments);
85
152
  }
86
153
 
87
- async function _makeNodeResources({
88
- convertedAttributes,
89
- material,
90
- texture,
91
- tileContent,
92
- nodeId,
93
- featuresHashArray,
94
- attributeStorageInfo,
95
- draco
96
- }) {
97
- const vertexCount = convertedAttributes.positions.length / VALUES_PER_VERTEX;
98
- const triangleCount = vertexCount / 3;
99
- const {
100
- faceRange,
101
- featureIds,
102
- positions,
103
- normals,
104
- colors,
105
- texCoords,
106
- featureCount
107
- } = (0, _geometryAttributes.generateAttributes)({
108
- triangleCount,
109
- ...convertedAttributes
110
- });
154
+ function _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel) {
155
+ var _iterator = _createForOfIteratorHelper(convertedAttributesMap.values()),
156
+ _step;
111
157
 
112
- if (tileContent.batchTableJson) {
113
- makeFeatureIdsUnique(featureIds, convertedAttributes.featureIndices, featuresHashArray, tileContent.batchTableJson);
114
- }
115
-
116
- const header = new Uint32Array(2);
117
- const typedFeatureIds = generateBigUint64Array(featureIds);
118
- header.set([vertexCount, featureCount], 0);
119
- const fileBuffer = new Uint8Array((0, _loaderUtils.concatenateArrayBuffers)(header.buffer, positions.buffer, normals.buffer, texture ? texCoords.buffer : new ArrayBuffer(0), colors.buffer, typedFeatureIds.buffer, faceRange.buffer));
120
- const compressedGeometry = draco ? await generateCompressedGeometry(vertexCount, convertedAttributes, {
121
- positions,
122
- normals,
123
- texCoords: texture ? texCoords : new Float32Array(0),
124
- colors,
125
- featureIds,
126
- faceRange
127
- }) : null;
128
- const attributes = convertBatchTableToAttributeBuffers(tileContent.batchTableJson, featureIds, attributeStorageInfo);
129
- return {
130
- geometry: fileBuffer,
131
- compressedGeometry,
132
- texture,
133
- sharedResources: getSharedResources(tileContent, nodeId),
134
- meshMaterial: material,
135
- vertexCount,
136
- attributes,
137
- featureCount
138
- };
158
+ try {
159
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
160
+ var attributes = _step.value;
161
+ var boundingVolumes = (0, _coordinateConverter.createBoundingVolumesFromGeometry)(attributes.positions, geoidHeightModel);
162
+ attributes.boundingVolumes = boundingVolumes;
163
+ var cartographicOrigin = boundingVolumes.obb.center;
164
+
165
+ for (var index = 0; index < attributes.positions.length; index += VALUES_PER_VERTEX) {
166
+ var vertex = attributes.positions.subarray(index, index + VALUES_PER_VERTEX);
167
+
168
+ _geospatial.Ellipsoid.WGS84.cartesianToCartographic(Array.from(vertex), scratchVector);
169
+
170
+ scratchVector[2] = scratchVector[2] - geoidHeightModel.getHeight(scratchVector[1], scratchVector[0]);
171
+ scratchVector = scratchVector.subtract(cartographicOrigin);
172
+ attributes.positions.set(scratchVector, index);
173
+ }
174
+ }
175
+ } catch (err) {
176
+ _iterator.e(err);
177
+ } finally {
178
+ _iterator.f();
179
+ }
180
+ }
181
+
182
+ function _makeNodeResources(_x8) {
183
+ return _makeNodeResources2.apply(this, arguments);
184
+ }
185
+
186
+ function _makeNodeResources2() {
187
+ _makeNodeResources2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(_ref) {
188
+ var convertedAttributes, material, texture, tileContent, nodeId, featuresHashArray, attributeStorageInfo, draco, boundingVolumes, vertexCount, triangleCount, _generateAttributes, faceRange, featureIds, positions, normals, colors, texCoords, featureCount, header, typedFeatureIds, fileBuffer, compressedGeometry, attributes;
189
+
190
+ return _regenerator.default.wrap(function _callee2$(_context2) {
191
+ while (1) {
192
+ switch (_context2.prev = _context2.next) {
193
+ case 0:
194
+ convertedAttributes = _ref.convertedAttributes, material = _ref.material, texture = _ref.texture, tileContent = _ref.tileContent, nodeId = _ref.nodeId, featuresHashArray = _ref.featuresHashArray, attributeStorageInfo = _ref.attributeStorageInfo, draco = _ref.draco;
195
+ boundingVolumes = convertedAttributes.boundingVolumes;
196
+ vertexCount = convertedAttributes.positions.length / VALUES_PER_VERTEX;
197
+ triangleCount = vertexCount / 3;
198
+ _generateAttributes = (0, _geometryAttributes.generateAttributes)(_objectSpread({
199
+ triangleCount: triangleCount
200
+ }, convertedAttributes)), faceRange = _generateAttributes.faceRange, featureIds = _generateAttributes.featureIds, positions = _generateAttributes.positions, normals = _generateAttributes.normals, colors = _generateAttributes.colors, texCoords = _generateAttributes.texCoords, featureCount = _generateAttributes.featureCount;
201
+
202
+ if (tileContent.batchTableJson) {
203
+ makeFeatureIdsUnique(featureIds, convertedAttributes.featureIndices, featuresHashArray, tileContent.batchTableJson);
204
+ }
205
+
206
+ header = new Uint32Array(2);
207
+ typedFeatureIds = generateBigUint64Array(featureIds);
208
+ header.set([vertexCount, featureCount], 0);
209
+ fileBuffer = new Uint8Array((0, _loaderUtils.concatenateArrayBuffers)(header.buffer, positions.buffer, normals.buffer, texture ? texCoords.buffer : new ArrayBuffer(0), colors.buffer, typedFeatureIds.buffer, faceRange.buffer));
210
+
211
+ if (!draco) {
212
+ _context2.next = 16;
213
+ break;
214
+ }
215
+
216
+ _context2.next = 13;
217
+ return generateCompressedGeometry(vertexCount, convertedAttributes, {
218
+ positions: positions,
219
+ normals: normals,
220
+ texCoords: texture ? texCoords : new Float32Array(0),
221
+ colors: colors,
222
+ featureIds: featureIds,
223
+ faceRange: faceRange
224
+ });
225
+
226
+ case 13:
227
+ _context2.t0 = _context2.sent;
228
+ _context2.next = 17;
229
+ break;
230
+
231
+ case 16:
232
+ _context2.t0 = null;
233
+
234
+ case 17:
235
+ compressedGeometry = _context2.t0;
236
+ attributes = convertBatchTableToAttributeBuffers(tileContent.batchTableJson, featureIds, attributeStorageInfo);
237
+ return _context2.abrupt("return", {
238
+ geometry: fileBuffer,
239
+ compressedGeometry: compressedGeometry,
240
+ texture: texture,
241
+ sharedResources: getSharedResources(tileContent, nodeId),
242
+ meshMaterial: material,
243
+ vertexCount: vertexCount,
244
+ attributes: attributes,
245
+ featureCount: featureCount,
246
+ boundingVolumes: boundingVolumes
247
+ });
248
+
249
+ case 20:
250
+ case "end":
251
+ return _context2.stop();
252
+ }
253
+ }
254
+ }, _callee2);
255
+ }));
256
+ return _makeNodeResources2.apply(this, arguments);
139
257
  }
140
258
 
141
- function convertAttributes(tileContent) {
259
+ function convertAttributes(tileContent, useCartesianPositions) {
142
260
  var _tileContent$gltf$sce;
143
261
 
144
- const attributesMap = new Map();
262
+ var attributesMap = new Map();
145
263
 
146
- for (const material of tileContent.gltf.materials || [{
264
+ var _iterator2 = _createForOfIteratorHelper(tileContent.gltf.materials || [{
147
265
  id: 'default'
148
- }]) {
149
- attributesMap.set(material.id, {
150
- positions: new Float32Array(0),
151
- normals: new Float32Array(0),
152
- texCoords: new Float32Array(0),
153
- colors: new Uint8Array(0),
154
- featureIndices: []
155
- });
266
+ }]),
267
+ _step2;
268
+
269
+ try {
270
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
271
+ var material = _step2.value;
272
+ attributesMap.set(material.id, {
273
+ positions: new Float32Array(0),
274
+ normals: new Float32Array(0),
275
+ texCoords: new Float32Array(0),
276
+ colors: new Uint8Array(0),
277
+ featureIndices: [],
278
+ boundingVolumes: null
279
+ });
280
+ }
281
+ } catch (err) {
282
+ _iterator2.e(err);
283
+ } finally {
284
+ _iterator2.f();
156
285
  }
157
286
 
158
- 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;
159
- convertNodes(nodes, tileContent, attributesMap);
287
+ var 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;
288
+ convertNodes(nodes, tileContent, attributesMap, useCartesianPositions);
160
289
 
161
- for (const attrKey of attributesMap.keys()) {
162
- const attributes = attributesMap.get(attrKey);
290
+ var _iterator3 = _createForOfIteratorHelper(attributesMap.keys()),
291
+ _step3;
163
292
 
164
- if (attributes.positions.length === 0) {
165
- attributesMap.delete(attrKey);
166
- continue;
167
- }
293
+ try {
294
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
295
+ var attrKey = _step3.value;
296
+ var attributes = attributesMap.get(attrKey);
168
297
 
169
- attributes.featureIndices = attributes.featureIndices.reduce((acc, value) => acc.concat(value));
298
+ if (attributes.positions.length === 0) {
299
+ attributesMap.delete(attrKey);
300
+ continue;
301
+ }
302
+
303
+ attributes.featureIndices = attributes.featureIndices.reduce(function (acc, value) {
304
+ return acc.concat(value);
305
+ });
306
+ }
307
+ } catch (err) {
308
+ _iterator3.e(err);
309
+ } finally {
310
+ _iterator3.f();
170
311
  }
171
312
 
172
313
  return attributesMap;
173
314
  }
174
315
 
175
- function convertNodes(nodes, tileContent, attributesMap, matrix = new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
316
+ function convertNodes(nodes, tileContent, attributesMap, useCartesianPositions) {
317
+ var matrix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
318
+
176
319
  if (nodes) {
177
- for (const node of nodes) {
178
- convertNode(node, tileContent, attributesMap, matrix);
320
+ var _iterator4 = _createForOfIteratorHelper(nodes),
321
+ _step4;
322
+
323
+ try {
324
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
325
+ var node = _step4.value;
326
+ convertNode(node, tileContent, attributesMap, useCartesianPositions, matrix);
327
+ }
328
+ } catch (err) {
329
+ _iterator4.e(err);
330
+ } finally {
331
+ _iterator4.f();
179
332
  }
180
333
  }
181
334
  }
182
335
 
183
- function convertNode(node, tileContent, attributesMap, matrix = new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
184
- const nodeMatrix = node.matrix;
185
- const compositeMatrix = nodeMatrix ? matrix.multiplyRight(nodeMatrix) : matrix;
186
- const mesh = node.mesh;
336
+ function convertNode(node, tileContent, attributesMap, useCartesianPositions) {
337
+ var matrix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
338
+ var nodeMatrix = node.matrix;
339
+ var compositeMatrix = nodeMatrix ? matrix.multiplyRight(nodeMatrix) : matrix;
340
+ var mesh = node.mesh;
187
341
 
188
342
  if (mesh) {
189
- convertMesh(mesh, tileContent, attributesMap, compositeMatrix);
343
+ convertMesh(mesh, tileContent, attributesMap, useCartesianPositions, compositeMatrix);
190
344
  }
191
345
 
192
- convertNodes(node.children, tileContent, attributesMap, compositeMatrix);
346
+ convertNodes(node.children, tileContent, attributesMap, useCartesianPositions, compositeMatrix);
193
347
  }
194
348
 
195
- function convertMesh(mesh, content, attributesMap, matrix = new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
196
- for (const primitive of mesh.primitives) {
197
- let outputAttributes = null;
349
+ function convertMesh(mesh, content, attributesMap) {
350
+ var useCartesianPositions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
351
+ var matrix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
198
352
 
199
- if (primitive.material) {
200
- outputAttributes = attributesMap.get(primitive.material.id);
201
- } else if (attributesMap.has('default')) {
202
- outputAttributes = attributesMap.get('default');
203
- }
353
+ var _iterator5 = _createForOfIteratorHelper(mesh.primitives),
354
+ _step5;
355
+
356
+ try {
357
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
358
+ var primitive = _step5.value;
359
+ var outputAttributes = null;
360
+
361
+ if (primitive.material) {
362
+ outputAttributes = attributesMap.get(primitive.material.id);
363
+ } else if (attributesMap.has('default')) {
364
+ outputAttributes = attributesMap.get('default');
365
+ }
204
366
 
205
- (0, _core2.assert)(outputAttributes !== null, 'Primitive - material mapping failed');
206
- const attributes = primitive.attributes;
207
- outputAttributes.positions = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.positions, transformVertexArray({
208
- vertices: attributes.POSITION.value,
209
- cartographicOrigin: content.cartographicOrigin,
210
- cartesianModelMatrix: content.cartesianModelMatrix,
211
- nodeMatrix: matrix,
212
- indices: primitive.indices.value,
213
- attributeSpecificTransformation: transformVertexPositions
214
- }));
215
- outputAttributes.normals = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.normals, transformVertexArray({
216
- vertices: attributes.NORMAL && attributes.NORMAL.value,
217
- cartographicOrigin: content.cartographicOrigin,
218
- cartesianModelMatrix: content.cartesianModelMatrix,
219
- nodeMatrix: matrix,
220
- indices: primitive.indices.value,
221
- attributeSpecificTransformation: transformVertexNormals
222
- }));
223
- outputAttributes.texCoords = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.texCoords, flattenTexCoords(attributes.TEXCOORD_0 && attributes.TEXCOORD_0.value, primitive.indices.value));
224
- outputAttributes.colors = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.colors, flattenColors(attributes.COLOR_0, primitive.indices.value));
225
- outputAttributes.featureIndices.push(flattenBatchIds(getBatchIdsByAttributeName(attributes), primitive.indices.value));
367
+ (0, _core2.assert)(outputAttributes !== null, 'Primitive - material mapping failed');
368
+ var attributes = primitive.attributes;
369
+ outputAttributes.positions = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.positions, transformVertexArray({
370
+ vertices: attributes.POSITION.value,
371
+ cartographicOrigin: content.cartographicOrigin,
372
+ cartesianModelMatrix: content.cartesianModelMatrix,
373
+ nodeMatrix: matrix,
374
+ indices: primitive.indices.value,
375
+ attributeSpecificTransformation: transformVertexPositions,
376
+ useCartesianPositions: useCartesianPositions
377
+ }));
378
+ outputAttributes.normals = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.normals, transformVertexArray({
379
+ vertices: attributes.NORMAL && attributes.NORMAL.value,
380
+ cartographicOrigin: content.cartographicOrigin,
381
+ cartesianModelMatrix: content.cartesianModelMatrix,
382
+ nodeMatrix: matrix,
383
+ indices: primitive.indices.value,
384
+ attributeSpecificTransformation: transformVertexNormals,
385
+ useCartesianPositions: false
386
+ }));
387
+ outputAttributes.texCoords = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.texCoords, flattenTexCoords(attributes.TEXCOORD_0 && attributes.TEXCOORD_0.value, primitive.indices.value));
388
+ outputAttributes.colors = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.colors, flattenColors(attributes.COLOR_0, primitive.indices.value));
389
+ outputAttributes.featureIndices.push(flattenBatchIds(getBatchIdsByAttributeName(attributes), primitive.indices.value));
390
+ }
391
+ } catch (err) {
392
+ _iterator5.e(err);
393
+ } finally {
394
+ _iterator5.f();
226
395
  }
227
396
  }
228
397
 
229
398
  function transformVertexArray(args) {
230
- const {
231
- vertices,
232
- indices,
233
- attributeSpecificTransformation
234
- } = args;
235
- const newVertices = new Float32Array(indices.length * VALUES_PER_VERTEX);
399
+ var vertices = args.vertices,
400
+ indices = args.indices,
401
+ attributeSpecificTransformation = args.attributeSpecificTransformation;
402
+ var newVertices = new Float32Array(indices.length * VALUES_PER_VERTEX);
236
403
 
237
404
  if (!vertices) {
238
405
  return newVertices;
239
406
  }
240
407
 
241
- for (let i = 0; i < indices.length; i++) {
242
- const coordIndex = indices[i] * VALUES_PER_VERTEX;
243
- const vertex = vertices.subarray(coordIndex, coordIndex + VALUES_PER_VERTEX);
244
- let vertexVector = new _core.Vector3(Array.from(vertex));
408
+ for (var i = 0; i < indices.length; i++) {
409
+ var coordIndex = indices[i] * VALUES_PER_VERTEX;
410
+ var vertex = vertices.subarray(coordIndex, coordIndex + VALUES_PER_VERTEX);
411
+ var vertexVector = new _core.Vector3(Array.from(vertex));
245
412
  vertexVector = attributeSpecificTransformation(vertexVector, args);
246
413
  newVertices[i * VALUES_PER_VERTEX] = vertexVector.x;
247
414
  newVertices[i * VALUES_PER_VERTEX + 1] = vertexVector.y;
@@ -252,11 +419,10 @@ function transformVertexArray(args) {
252
419
  }
253
420
 
254
421
  function transformVertexPositions(vertexVector, calleeArgs) {
255
- const {
256
- cartesianModelMatrix,
257
- cartographicOrigin,
258
- nodeMatrix
259
- } = calleeArgs;
422
+ var cartesianModelMatrix = calleeArgs.cartesianModelMatrix,
423
+ cartographicOrigin = calleeArgs.cartographicOrigin,
424
+ nodeMatrix = calleeArgs.nodeMatrix,
425
+ useCartesianPositions = calleeArgs.useCartesianPositions;
260
426
 
261
427
  if (nodeMatrix) {
262
428
  vertexVector = vertexVector.transform(nodeMatrix);
@@ -264,6 +430,10 @@ function transformVertexPositions(vertexVector, calleeArgs) {
264
430
 
265
431
  vertexVector = vertexVector.transform(cartesianModelMatrix);
266
432
 
433
+ if (useCartesianPositions) {
434
+ return vertexVector;
435
+ }
436
+
267
437
  _geospatial.Ellipsoid.WGS84.cartesianToCartographic([vertexVector[0], vertexVector[1], vertexVector[2]], vertexVector);
268
438
 
269
439
  vertexVector = vertexVector.subtract(cartographicOrigin);
@@ -271,10 +441,8 @@ function transformVertexPositions(vertexVector, calleeArgs) {
271
441
  }
272
442
 
273
443
  function transformVertexNormals(vertexVector, calleeArgs) {
274
- const {
275
- cartesianModelMatrix,
276
- nodeMatrix
277
- } = calleeArgs;
444
+ var cartesianModelMatrix = calleeArgs.cartesianModelMatrix,
445
+ nodeMatrix = calleeArgs.nodeMatrix;
278
446
 
279
447
  if (nodeMatrix) {
280
448
  vertexVector = vertexVector.transformAsVector(nodeMatrix);
@@ -285,16 +453,16 @@ function transformVertexNormals(vertexVector, calleeArgs) {
285
453
  }
286
454
 
287
455
  function flattenTexCoords(texCoords, indices) {
288
- const newTexCoords = new Float32Array(indices.length * VALUES_PER_TEX_COORD);
456
+ var newTexCoords = new Float32Array(indices.length * VALUES_PER_TEX_COORD);
289
457
 
290
458
  if (!texCoords) {
291
459
  newTexCoords.fill(1);
292
460
  return newTexCoords;
293
461
  }
294
462
 
295
- for (let i = 0; i < indices.length; i++) {
296
- const coordIndex = indices[i] * VALUES_PER_TEX_COORD;
297
- const texCoord = texCoords.subarray(coordIndex, coordIndex + VALUES_PER_TEX_COORD);
463
+ for (var i = 0; i < indices.length; i++) {
464
+ var coordIndex = indices[i] * VALUES_PER_TEX_COORD;
465
+ var texCoord = texCoords.subarray(coordIndex, coordIndex + VALUES_PER_TEX_COORD);
298
466
  newTexCoords[i * VALUES_PER_TEX_COORD] = texCoord[0];
299
467
  newTexCoords[i * VALUES_PER_TEX_COORD + 1] = texCoord[1];
300
468
  }
@@ -303,22 +471,22 @@ function flattenTexCoords(texCoords, indices) {
303
471
  }
304
472
 
305
473
  function flattenColors(colorsAttribute, indices) {
306
- const components = (colorsAttribute === null || colorsAttribute === void 0 ? void 0 : colorsAttribute.components) || VALUES_PER_COLOR_ELEMENT;
307
- const newColors = new Uint8Array(indices.length * components);
474
+ var components = (colorsAttribute === null || colorsAttribute === void 0 ? void 0 : colorsAttribute.components) || VALUES_PER_COLOR_ELEMENT;
475
+ var newColors = new Uint8Array(indices.length * components);
308
476
 
309
477
  if (!colorsAttribute) {
310
478
  newColors.fill(255);
311
479
  return newColors;
312
480
  }
313
481
 
314
- const colors = colorsAttribute.value;
482
+ var colors = colorsAttribute.value;
315
483
 
316
- for (let i = 0; i < indices.length; i++) {
317
- const colorIndex = indices[i] * components;
318
- const color = colors.subarray(colorIndex, colorIndex + components);
319
- const colorUint8 = new Uint8Array(components);
484
+ for (var i = 0; i < indices.length; i++) {
485
+ var colorIndex = indices[i] * components;
486
+ var color = colors.subarray(colorIndex, colorIndex + components);
487
+ var colorUint8 = new Uint8Array(components);
320
488
 
321
- for (let j = 0; j < color.length; j++) {
489
+ for (var j = 0; j < color.length; j++) {
322
490
  colorUint8[j] = color[j] * 255;
323
491
  }
324
492
 
@@ -333,10 +501,10 @@ function flattenBatchIds(batchedIds, indices) {
333
501
  return [];
334
502
  }
335
503
 
336
- const newBatchIds = [];
504
+ var newBatchIds = [];
337
505
 
338
- for (let i = 0; i < indices.length; i++) {
339
- const coordIndex = indices[i];
506
+ for (var i = 0; i < indices.length; i++) {
507
+ var coordIndex = indices[i];
340
508
  newBatchIds.push(batchedIds[coordIndex]);
341
509
  }
342
510
 
@@ -344,10 +512,10 @@ function flattenBatchIds(batchedIds, indices) {
344
512
  }
345
513
 
346
514
  function getBatchIdsByAttributeName(attributes) {
347
- let batchIds = [];
515
+ var batchIds = [];
348
516
 
349
- for (let index = 0; index < BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES.length; index++) {
350
- const possibleBatchIdAttributeName = BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES[index];
517
+ for (var index = 0; index < BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES.length; index++) {
518
+ var possibleBatchIdAttributeName = BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES[index];
351
519
 
352
520
  if (attributes[possibleBatchIdAttributeName] && attributes[possibleBatchIdAttributeName].value) {
353
521
  batchIds = attributes[possibleBatchIdAttributeName].value;
@@ -359,27 +527,39 @@ function getBatchIdsByAttributeName(attributes) {
359
527
  }
360
528
 
361
529
  function convertMaterials(tileContent) {
362
- const result = [];
363
- const sourceMaterials = tileContent.gltf.materials || [];
530
+ var result = [];
531
+ var sourceMaterials = tileContent.gltf.materials || [];
364
532
 
365
- for (const sourceMaterial of sourceMaterials) {
366
- result.push(convertMaterial(sourceMaterial));
533
+ var _iterator6 = _createForOfIteratorHelper(sourceMaterials),
534
+ _step6;
535
+
536
+ try {
537
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
538
+ var sourceMaterial = _step6.value;
539
+ result.push(convertMaterial(sourceMaterial));
540
+ }
541
+ } catch (err) {
542
+ _iterator6.e(err);
543
+ } finally {
544
+ _iterator6.f();
367
545
  }
368
546
 
369
547
  return result;
370
548
  }
371
549
 
372
550
  function convertMaterial(sourceMaterial) {
373
- const material = {
551
+ var material = {
374
552
  doubleSided: sourceMaterial.doubleSided,
375
- emissiveFactor: sourceMaterial.emissiveFactor.map(c => Math.round(c * 255)),
553
+ emissiveFactor: sourceMaterial.emissiveFactor.map(function (c) {
554
+ return Math.round(c * 255);
555
+ }),
376
556
  alphaMode: (sourceMaterial.alphaMode || 'OPAQUE').toLowerCase(),
377
557
  pbrMetallicRoughness: {
378
558
  roughnessFactor: sourceMaterial.pbrMetallicRoughness.roughnessFactor,
379
559
  metallicFactor: sourceMaterial.pbrMetallicRoughness.metallicFactor
380
560
  }
381
561
  };
382
- let texture;
562
+ var texture;
383
563
 
384
564
  if (sourceMaterial.pbrMetallicRoughness.baseColorTexture) {
385
565
  texture = sourceMaterial.pbrMetallicRoughness.baseColorTexture.texture.source;
@@ -394,13 +574,15 @@ function convertMaterial(sourceMaterial) {
394
574
  }
395
575
 
396
576
  if (!texture) {
397
- const baseColorFactor = sourceMaterial.pbrMetallicRoughness.baseColorFactor;
398
- material.pbrMetallicRoughness.baseColorFactor = baseColorFactor && baseColorFactor.map(c => Math.round(c * 255)) || undefined;
577
+ var baseColorFactor = sourceMaterial.pbrMetallicRoughness.baseColorFactor;
578
+ material.pbrMetallicRoughness.baseColorFactor = baseColorFactor && baseColorFactor.map(function (c) {
579
+ return Math.round(c * 255);
580
+ }) || undefined;
399
581
  }
400
582
 
401
583
  return {
402
- material,
403
- texture
584
+ material: material,
585
+ texture: texture
404
586
  };
405
587
  }
406
588
 
@@ -412,8 +594,8 @@ function getDefaultMaterial() {
412
594
  }
413
595
 
414
596
  function getSharedResources(tileContent, nodeId) {
415
- const gltfMaterials = tileContent.gltf.materials;
416
- const i3sResources = {};
597
+ var gltfMaterials = tileContent.gltf.materials;
598
+ var i3sResources = {};
417
599
 
418
600
  if (!gltfMaterials || !gltfMaterials.length) {
419
601
  return i3sResources;
@@ -421,35 +603,45 @@ function getSharedResources(tileContent, nodeId) {
421
603
 
422
604
  i3sResources.materialDefinitionInfos = [];
423
605
 
424
- for (const gltfMaterial of gltfMaterials) {
425
- const {
426
- materialDefinitionInfo,
427
- textureDefinitionInfo
428
- } = convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId);
429
- i3sResources.materialDefinitionInfos.push(materialDefinitionInfo);
606
+ var _iterator7 = _createForOfIteratorHelper(gltfMaterials),
607
+ _step7;
608
+
609
+ try {
610
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
611
+ var gltfMaterial = _step7.value;
612
+
613
+ var _convertGLTFMaterialT = convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId),
614
+ materialDefinitionInfo = _convertGLTFMaterialT.materialDefinitionInfo,
615
+ textureDefinitionInfo = _convertGLTFMaterialT.textureDefinitionInfo;
430
616
 
431
- if (textureDefinitionInfo) {
432
- i3sResources.textureDefinitionInfos = i3sResources.textureDefinitionInfos || [];
433
- i3sResources.textureDefinitionInfos.push(textureDefinitionInfo);
617
+ i3sResources.materialDefinitionInfos.push(materialDefinitionInfo);
618
+
619
+ if (textureDefinitionInfo) {
620
+ i3sResources.textureDefinitionInfos = i3sResources.textureDefinitionInfos || [];
621
+ i3sResources.textureDefinitionInfos.push(textureDefinitionInfo);
622
+ }
434
623
  }
624
+ } catch (err) {
625
+ _iterator7.e(err);
626
+ } finally {
627
+ _iterator7.f();
435
628
  }
436
629
 
437
630
  return i3sResources;
438
631
  }
439
632
 
440
633
  function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
441
- const texture = gltfMaterial.pbrMetallicRoughness.baseColorTexture || gltfMaterial.emissiveTexture;
442
- let textureDefinitionInfo = null;
634
+ var texture = gltfMaterial.pbrMetallicRoughness.baseColorTexture || gltfMaterial.emissiveTexture;
635
+ var textureDefinitionInfo = null;
443
636
 
444
637
  if (texture) {
445
638
  textureDefinitionInfo = extractSharedResourcesTextureInfo(texture.texture, nodeId);
446
639
  }
447
640
 
448
- const {
449
- baseColorFactor,
450
- metallicFactor
451
- } = gltfMaterial.pbrMetallicRoughness;
452
- let colorFactor = baseColorFactor;
641
+ var _gltfMaterial$pbrMeta = gltfMaterial.pbrMetallicRoughness,
642
+ baseColorFactor = _gltfMaterial$pbrMeta.baseColorFactor,
643
+ metallicFactor = _gltfMaterial$pbrMeta.metallicFactor;
644
+ var colorFactor = baseColorFactor;
453
645
 
454
646
  if ((!baseColorFactor || baseColorFactor[3] === 0) && gltfMaterial.emissiveFactor) {
455
647
  colorFactor = gltfMaterial.emissiveFactor;
@@ -458,20 +650,21 @@ function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
458
650
 
459
651
  return {
460
652
  materialDefinitionInfo: extractSharedResourcesMaterialInfo(colorFactor, metallicFactor),
461
- textureDefinitionInfo
653
+ textureDefinitionInfo: textureDefinitionInfo
462
654
  };
463
655
  }
464
656
 
465
- function extractSharedResourcesMaterialInfo(baseColorFactor, metallicFactor = 0) {
466
- const matDielectricColorComponent = 0.04 / 255;
467
- const black = new _core.Vector4(0, 0, 0, 1);
468
- const unitVector = new _core.Vector4(1, 1, 1, 1);
469
- const dielectricSpecular = new _core.Vector4(matDielectricColorComponent, matDielectricColorComponent, matDielectricColorComponent, 0);
470
- const baseColorVector = new _core.Vector4(baseColorFactor);
471
- const firstOperand = unitVector.subtract(dielectricSpecular).multiply(baseColorVector);
472
- const diffuse = firstOperand.lerp(firstOperand, black, metallicFactor);
657
+ function extractSharedResourcesMaterialInfo(baseColorFactor) {
658
+ var metallicFactor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
659
+ var matDielectricColorComponent = 0.04 / 255;
660
+ var black = new _core.Vector4(0, 0, 0, 1);
661
+ var unitVector = new _core.Vector4(1, 1, 1, 1);
662
+ var dielectricSpecular = new _core.Vector4(matDielectricColorComponent, matDielectricColorComponent, matDielectricColorComponent, 0);
663
+ var baseColorVector = new _core.Vector4(baseColorFactor);
664
+ var firstOperand = unitVector.subtract(dielectricSpecular).multiply(baseColorVector);
665
+ var diffuse = firstOperand.lerp(firstOperand, black, metallicFactor);
473
666
  dielectricSpecular[3] = 1;
474
- const specular = dielectricSpecular.lerp(dielectricSpecular, baseColorVector, metallicFactor);
667
+ var specular = dielectricSpecular.lerp(dielectricSpecular, baseColorVector, metallicFactor);
475
668
  return {
476
669
  diffuse: diffuse.toArray(),
477
670
  specular: specular.toArray()
@@ -490,36 +683,35 @@ function extractSharedResourcesTextureInfo(texture, nodeId) {
490
683
  }
491
684
 
492
685
  function generateImageId(texture, nodeId) {
493
- const {
494
- width,
495
- height
496
- } = texture.source.image;
497
- const levelCountOfTexture = 1;
498
- const indexOfLevel = 0;
499
- const indexOfTextureInStore = nodeId + 1;
500
- const zerosCount = 32 - indexOfTextureInStore.toString(2).length;
501
- const rightHalf = '0'.repeat(zerosCount).concat(indexOfTextureInStore.toString(2));
502
- const shiftedLevelCountOfTexture = levelCountOfTexture << 28;
503
- const shiftedIndexOfLevel = indexOfLevel << 24;
504
- const shiftedWidth = width - 1 << 12;
505
- const shiftedHeight = height - 1 << 0;
506
- const leftHalf = shiftedLevelCountOfTexture + shiftedIndexOfLevel + shiftedWidth + shiftedHeight;
507
- const imageId = BigInt("0b".concat(leftHalf.toString(2)).concat(rightHalf));
686
+ var _texture$source$image = texture.source.image,
687
+ width = _texture$source$image.width,
688
+ height = _texture$source$image.height;
689
+ var levelCountOfTexture = 1;
690
+ var indexOfLevel = 0;
691
+ var indexOfTextureInStore = nodeId + 1;
692
+ var zerosCount = 32 - indexOfTextureInStore.toString(2).length;
693
+ var rightHalf = '0'.repeat(zerosCount).concat(indexOfTextureInStore.toString(2));
694
+ var shiftedLevelCountOfTexture = levelCountOfTexture << 28;
695
+ var shiftedIndexOfLevel = indexOfLevel << 24;
696
+ var shiftedWidth = width - 1 << 12;
697
+ var shiftedHeight = height - 1 << 0;
698
+ var leftHalf = shiftedLevelCountOfTexture + shiftedIndexOfLevel + shiftedWidth + shiftedHeight;
699
+ var imageId = BigInt("0b".concat(leftHalf.toString(2)).concat(rightHalf));
508
700
  return imageId.toString();
509
701
  }
510
702
 
511
703
  function makeFeatureIdsUnique(featureIds, featureIndices, featuresHashArray, batchTable) {
512
- const replaceMap = getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray);
704
+ var replaceMap = getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray);
513
705
  replaceIndicesByUnique(featureIndices, replaceMap);
514
706
  replaceIndicesByUnique(featureIds, replaceMap);
515
707
  }
516
708
 
517
709
  function getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray) {
518
- const featureMap = {};
710
+ var featureMap = {};
519
711
 
520
- for (let index = 0; index < featureIds.length; index++) {
521
- const oldFeatureId = featureIds[index];
522
- const uniqueFeatureId = getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray);
712
+ for (var index = 0; index < featureIds.length; index++) {
713
+ var oldFeatureId = featureIds[index];
714
+ var uniqueFeatureId = getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray);
523
715
  featureMap[oldFeatureId.toString()] = uniqueFeatureId;
524
716
  }
525
717
 
@@ -527,9 +719,9 @@ function getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray) {
527
719
  }
528
720
 
529
721
  function generateStringFromBatchTableByIndex(batchTable, index) {
530
- let str = '';
722
+ var str = '';
531
723
 
532
- for (const key in batchTable) {
724
+ for (var key in batchTable) {
533
725
  str += batchTable[key][index];
534
726
  }
535
727
 
@@ -537,8 +729,8 @@ function generateStringFromBatchTableByIndex(batchTable, index) {
537
729
  }
538
730
 
539
731
  function getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray) {
540
- const batchTableStr = generateStringFromBatchTableByIndex(batchTable, index);
541
- const hash = (0, _md.default)(batchTableStr);
732
+ var batchTableStr = generateStringFromBatchTableByIndex(batchTable, index);
733
+ var hash = (0, _md.default)(batchTableStr);
542
734
 
543
735
  if (featuresHashArray.includes(hash)) {
544
736
  return featuresHashArray.indexOf(hash);
@@ -548,23 +740,22 @@ function getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray) {
548
740
  }
549
741
 
550
742
  function replaceIndicesByUnique(indicesArray, featureMap) {
551
- for (let index = 0; index < indicesArray.length; index++) {
743
+ for (var index = 0; index < indicesArray.length; index++) {
552
744
  indicesArray[index] = featureMap[indicesArray[index]];
553
745
  }
554
746
  }
555
747
 
556
748
  function convertBatchTableToAttributeBuffers(batchTable, featureIds, attributeStorageInfo) {
557
- const attributeBuffers = [];
749
+ var attributeBuffers = [];
558
750
 
559
751
  if (batchTable) {
560
- const batchTableWithFeatureIds = {
561
- OBJECTID: featureIds,
562
- ...batchTable
563
- };
752
+ var batchTableWithFeatureIds = _objectSpread({
753
+ OBJECTID: featureIds
754
+ }, batchTable);
564
755
 
565
- for (const key in batchTableWithFeatureIds) {
566
- const type = getAttributeType(key, attributeStorageInfo);
567
- let attributeBuffer = null;
756
+ for (var key in batchTableWithFeatureIds) {
757
+ var type = getAttributeType(key, attributeStorageInfo);
758
+ var attributeBuffer = null;
568
759
 
569
760
  switch (type) {
570
761
  case OBJECT_ID_TYPE:
@@ -592,104 +783,124 @@ function convertBatchTableToAttributeBuffers(batchTable, featureIds, attributeSt
592
783
  }
593
784
 
594
785
  function getAttributeType(key, attributeStorageInfo) {
595
- const attribute = attributeStorageInfo.find(attr => attr.name === key);
786
+ var attribute = attributeStorageInfo.find(function (attr) {
787
+ return attr.name === key;
788
+ });
596
789
  return attribute.attributeValues.valueType;
597
790
  }
598
791
 
599
792
  function generateShortIntegerAttributeBuffer(featureIds) {
600
- const count = new Uint32Array([featureIds.length]);
601
- const valuesArray = new Uint32Array(featureIds);
793
+ var count = new Uint32Array([featureIds.length]);
794
+ var valuesArray = new Uint32Array(featureIds);
602
795
  return (0, _loaderUtils.concatenateArrayBuffers)(count.buffer, valuesArray.buffer);
603
796
  }
604
797
 
605
798
  function generateDoubleAttributeBuffer(featureIds) {
606
- const count = new Uint32Array([featureIds.length]);
607
- const padding = new Uint8Array(4);
608
- const valuesArray = new Float64Array(featureIds);
799
+ var count = new Uint32Array([featureIds.length]);
800
+ var padding = new Uint8Array(4);
801
+ var valuesArray = new Float64Array(featureIds);
609
802
  return (0, _loaderUtils.concatenateArrayBuffers)(count.buffer, padding.buffer, valuesArray.buffer);
610
803
  }
611
804
 
612
805
  function generateStringAttributeBuffer(batchAttributes) {
613
- const stringCountArray = new Uint32Array([batchAttributes.length]);
614
- let totalNumberOfBytes = 0;
615
- const stringSizesArray = new Uint32Array(batchAttributes.length);
616
- const stringBufferArray = [];
617
-
618
- for (let index = 0; index < batchAttributes.length; index++) {
619
- const currentString = "".concat(String(batchAttributes[index]), "\0");
620
- const currentStringBuffer = Buffer.from(currentString);
621
- const currentStringSize = currentStringBuffer.length;
806
+ var stringCountArray = new Uint32Array([batchAttributes.length]);
807
+ var totalNumberOfBytes = 0;
808
+ var stringSizesArray = new Uint32Array(batchAttributes.length);
809
+ var stringBufferArray = [];
810
+
811
+ for (var index = 0; index < batchAttributes.length; index++) {
812
+ var currentString = "".concat(String(batchAttributes[index]), "\0");
813
+ var currentStringBuffer = Buffer.from(currentString);
814
+ var currentStringSize = currentStringBuffer.length;
622
815
  totalNumberOfBytes += currentStringSize;
623
816
  stringSizesArray[index] = currentStringSize;
624
817
  stringBufferArray.push(currentStringBuffer);
625
818
  }
626
819
 
627
- const totalBytes = new Uint32Array([totalNumberOfBytes]);
628
- return (0, _loaderUtils.concatenateArrayBuffers)(stringCountArray.buffer, totalBytes.buffer, stringSizesArray.buffer, ...stringBufferArray);
820
+ var totalBytes = new Uint32Array([totalNumberOfBytes]);
821
+ return _loaderUtils.concatenateArrayBuffers.apply(void 0, [stringCountArray.buffer, totalBytes.buffer, stringSizesArray.buffer].concat(stringBufferArray));
629
822
  }
630
823
 
631
824
  function generateBigUint64Array(featureIds) {
632
- const typedFeatureIds = new BigUint64Array(featureIds.length);
825
+ var typedFeatureIds = new BigUint64Array(featureIds.length);
633
826
 
634
- for (let index = 0; index < featureIds.length; index++) {
827
+ for (var index = 0; index < featureIds.length; index++) {
635
828
  typedFeatureIds[index] = BigInt(featureIds[index]);
636
829
  }
637
830
 
638
831
  return typedFeatureIds;
639
832
  }
640
833
 
641
- async function generateCompressedGeometry(vertexCount, convertedAttributes, attributes) {
642
- const {
643
- positions,
644
- normals,
645
- texCoords,
646
- colors,
647
- featureIds,
648
- faceRange
649
- } = attributes;
650
- const indices = new Uint32Array(vertexCount);
651
-
652
- for (let index = 0; index < indices.length; index++) {
653
- indices.set([index], index);
654
- }
655
-
656
- const featureIndices = new Uint32Array(convertedAttributes.featureIndices.length ? convertedAttributes.featureIndices : vertexCount);
657
- const featureIndex = generateFeatureIndexAttribute(featureIndices, faceRange);
658
- const compressedAttributes = {
659
- positions,
660
- normals,
661
- colors,
662
- 'feature-index': featureIndex
663
- };
664
-
665
- if (texCoords.length) {
666
- compressedAttributes.texCoords = texCoords;
667
- }
668
-
669
- const attributesMetadata = {
670
- 'feature-index': {
671
- 'i3s-attribute-type': 'feature-index',
672
- 'i3s-feature-ids': new Int32Array(featureIds)
673
- }
674
- };
675
- return new Uint8Array(await (0, _core2.encode)({
676
- attributes: compressedAttributes,
677
- indices
678
- }, _draco.DracoWriter, {
679
- draco: {
680
- method: 'MESH_SEQUENTIAL_ENCODING',
681
- attributesMetadata
682
- }
834
+ function generateCompressedGeometry(_x9, _x10, _x11) {
835
+ return _generateCompressedGeometry.apply(this, arguments);
836
+ }
837
+
838
+ function _generateCompressedGeometry() {
839
+ _generateCompressedGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(vertexCount, convertedAttributes, attributes) {
840
+ var positions, normals, texCoords, colors, featureIds, faceRange, indices, index, featureIndices, featureIndex, compressedAttributes, attributesMetadata;
841
+ return _regenerator.default.wrap(function _callee3$(_context3) {
842
+ while (1) {
843
+ switch (_context3.prev = _context3.next) {
844
+ case 0:
845
+ positions = attributes.positions, normals = attributes.normals, texCoords = attributes.texCoords, colors = attributes.colors, featureIds = attributes.featureIds, faceRange = attributes.faceRange;
846
+ indices = new Uint32Array(vertexCount);
847
+
848
+ for (index = 0; index < indices.length; index++) {
849
+ indices.set([index], index);
850
+ }
851
+
852
+ featureIndices = new Uint32Array(convertedAttributes.featureIndices.length ? convertedAttributes.featureIndices : vertexCount);
853
+ featureIndex = generateFeatureIndexAttribute(featureIndices, faceRange);
854
+ compressedAttributes = {
855
+ positions: positions,
856
+ normals: normals,
857
+ colors: colors,
858
+ 'feature-index': featureIndex
859
+ };
860
+
861
+ if (texCoords.length) {
862
+ compressedAttributes.texCoords = texCoords;
863
+ }
864
+
865
+ attributesMetadata = {
866
+ 'feature-index': {
867
+ 'i3s-attribute-type': 'feature-index',
868
+ 'i3s-feature-ids': new Int32Array(featureIds)
869
+ }
870
+ };
871
+ _context3.t0 = Uint8Array;
872
+ _context3.next = 11;
873
+ return (0, _core2.encode)({
874
+ attributes: compressedAttributes,
875
+ indices: indices
876
+ }, _draco.DracoWriter, {
877
+ draco: {
878
+ method: 'MESH_SEQUENTIAL_ENCODING',
879
+ attributesMetadata: attributesMetadata
880
+ }
881
+ });
882
+
883
+ case 11:
884
+ _context3.t1 = _context3.sent;
885
+ return _context3.abrupt("return", new _context3.t0(_context3.t1));
886
+
887
+ case 13:
888
+ case "end":
889
+ return _context3.stop();
890
+ }
891
+ }
892
+ }, _callee3);
683
893
  }));
894
+ return _generateCompressedGeometry.apply(this, arguments);
684
895
  }
685
896
 
686
897
  function generateFeatureIndexAttribute(featureIndex, faceRange) {
687
- const orderedFeatureIndices = new Uint32Array(featureIndex.length);
688
- let fillIndex = 0;
689
- let startIndex = 0;
898
+ var orderedFeatureIndices = new Uint32Array(featureIndex.length);
899
+ var fillIndex = 0;
900
+ var startIndex = 0;
690
901
 
691
- for (let index = 1; index < faceRange.length; index += 2) {
692
- const endIndex = (faceRange[index] + 1) * VALUES_PER_VERTEX;
902
+ for (var index = 1; index < faceRange.length; index += 2) {
903
+ var endIndex = (faceRange[index] + 1) * VALUES_PER_VERTEX;
693
904
  orderedFeatureIndices.fill(fillIndex, startIndex, endIndex);
694
905
  fillIndex++;
695
906
  startIndex = endIndex + 1;