@loaders.gl/tiles 3.4.13 → 3.4.15

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 (41) hide show
  1. package/dist/dist.min.js +122 -338
  2. package/dist/es5/bundle.js +1 -1
  3. package/dist/es5/bundle.js.map +1 -1
  4. package/dist/es5/constants.js +6 -6
  5. package/dist/es5/constants.js.map +1 -1
  6. package/dist/es5/index.js +13 -13
  7. package/dist/es5/tileset/format-3d-tiles/tileset-3d-traverser.js +32 -53
  8. package/dist/es5/tileset/format-3d-tiles/tileset-3d-traverser.js.map +1 -1
  9. package/dist/es5/tileset/format-i3s/i3s-pending-tiles-register.js +21 -32
  10. package/dist/es5/tileset/format-i3s/i3s-pending-tiles-register.js.map +1 -1
  11. package/dist/es5/tileset/format-i3s/i3s-tile-manager.js +66 -63
  12. package/dist/es5/tileset/format-i3s/i3s-tile-manager.js.map +1 -1
  13. package/dist/es5/tileset/format-i3s/i3s-tileset-traverser.js +54 -121
  14. package/dist/es5/tileset/format-i3s/i3s-tileset-traverser.js.map +1 -1
  15. package/dist/es5/tileset/helpers/bounding-volume.js +48 -62
  16. package/dist/es5/tileset/helpers/bounding-volume.js.map +1 -1
  17. package/dist/es5/tileset/helpers/frame-state.js +67 -80
  18. package/dist/es5/tileset/helpers/frame-state.js.map +1 -1
  19. package/dist/es5/tileset/helpers/i3s-lod.js +27 -27
  20. package/dist/es5/tileset/helpers/i3s-lod.js.map +1 -1
  21. package/dist/es5/tileset/helpers/tiles-3d-lod.js +51 -45
  22. package/dist/es5/tileset/helpers/tiles-3d-lod.js.map +1 -1
  23. package/dist/es5/tileset/helpers/transform-utils.js +17 -11
  24. package/dist/es5/tileset/helpers/transform-utils.js.map +1 -1
  25. package/dist/es5/tileset/helpers/zoom.js +28 -28
  26. package/dist/es5/tileset/helpers/zoom.js.map +1 -1
  27. package/dist/es5/tileset/tile-3d.js +316 -430
  28. package/dist/es5/tileset/tile-3d.js.map +1 -1
  29. package/dist/es5/tileset/tileset-3d.js +460 -701
  30. package/dist/es5/tileset/tileset-3d.js.map +1 -1
  31. package/dist/es5/tileset/tileset-cache.js +41 -58
  32. package/dist/es5/tileset/tileset-cache.js.map +1 -1
  33. package/dist/es5/tileset/tileset-traverser.js +189 -264
  34. package/dist/es5/tileset/tileset-traverser.js.map +1 -1
  35. package/dist/es5/utils/doubly-linked-list-node.js +10 -11
  36. package/dist/es5/utils/doubly-linked-list-node.js.map +1 -1
  37. package/dist/es5/utils/doubly-linked-list.js +53 -68
  38. package/dist/es5/utils/doubly-linked-list.js.map +1 -1
  39. package/dist/es5/utils/managed-array.js +69 -100
  40. package/dist/es5/utils/managed-array.js.map +1 -1
  41. package/package.json +5 -5
@@ -5,11 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.Tileset3D = void 0;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
9
  var _core = require("@math.gl/core");
15
10
  var _geospatial = require("@math.gl/geospatial");
@@ -24,12 +19,7 @@ var _constants = require("../constants");
24
19
  var _tilesetTraverser = require("./tileset-traverser");
25
20
  var _tileset3dTraverser = require("./format-3d-tiles/tileset-3d-traverser");
26
21
  var _i3sTilesetTraverser = require("./format-i3s/i3s-tileset-traverser");
27
- 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; } } }; }
28
- 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); }
29
- 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; }
30
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
31
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
32
- var DEFAULT_PROPS = {
22
+ const DEFAULT_PROPS = {
33
23
  description: '',
34
24
  ellipsoid: _geospatial.Ellipsoid.WGS84,
35
25
  modelMatrix: new _core.Matrix4(),
@@ -38,12 +28,10 @@ var DEFAULT_PROPS = {
38
28
  maximumMemoryUsage: 32,
39
29
  maximumTilesSelected: 0,
40
30
  debounceTime: 0,
41
- onTileLoad: function onTileLoad() {},
42
- onTileUnload: function onTileUnload() {},
43
- onTileError: function onTileError() {},
44
- onTraversalComplete: function onTraversalComplete(selectedTiles) {
45
- return selectedTiles;
46
- },
31
+ onTileLoad: () => {},
32
+ onTileUnload: () => {},
33
+ onTileError: () => {},
34
+ onTraversalComplete: selectedTiles => selectedTiles,
47
35
  contentLoader: undefined,
48
36
  viewDistanceScale: 1.0,
49
37
  maximumScreenSpaceError: 8,
@@ -57,19 +45,18 @@ var DEFAULT_PROPS = {
57
45
  basePath: '',
58
46
  i3s: {}
59
47
  };
60
- var TILES_TOTAL = 'Tiles In Tileset(s)';
61
- var TILES_IN_MEMORY = 'Tiles In Memory';
62
- var TILES_IN_VIEW = 'Tiles In View';
63
- var TILES_RENDERABLE = 'Tiles To Render';
64
- var TILES_LOADED = 'Tiles Loaded';
65
- var TILES_LOADING = 'Tiles Loading';
66
- var TILES_UNLOADED = 'Tiles Unloaded';
67
- var TILES_LOAD_FAILED = 'Failed Tile Loads';
68
- var POINTS_COUNT = 'Points/Vertices';
69
- var TILES_GPU_MEMORY = 'Tile Memory Use';
70
- var Tileset3D = function () {
71
- function Tileset3D(tileset, options) {
72
- (0, _classCallCheck2.default)(this, Tileset3D);
48
+ const TILES_TOTAL = 'Tiles In Tileset(s)';
49
+ const TILES_IN_MEMORY = 'Tiles In Memory';
50
+ const TILES_IN_VIEW = 'Tiles In View';
51
+ const TILES_RENDERABLE = 'Tiles To Render';
52
+ const TILES_LOADED = 'Tiles Loaded';
53
+ const TILES_LOADING = 'Tiles Loading';
54
+ const TILES_UNLOADED = 'Tiles Unloaded';
55
+ const TILES_LOAD_FAILED = 'Failed Tile Loads';
56
+ const POINTS_COUNT = 'Points/Vertices';
57
+ const TILES_GPU_MEMORY = 'Tile Memory Use';
58
+ class Tileset3D {
59
+ constructor(tileset, options) {
73
60
  (0, _defineProperty2.default)(this, "options", void 0);
74
61
  (0, _defineProperty2.default)(this, "loadOptions", void 0);
75
62
  (0, _defineProperty2.default)(this, "type", void 0);
@@ -121,7 +108,10 @@ var Tileset3D = function () {
121
108
  (0, _defineProperty2.default)(this, "_requestScheduler", void 0);
122
109
  (0, _defineProperty2.default)(this, "updatePromise", null);
123
110
  (0, _defineProperty2.default)(this, "tilesetInitializationPromise", void 0);
124
- this.options = _objectSpread(_objectSpread({}, DEFAULT_PROPS), options);
111
+ this.options = {
112
+ ...DEFAULT_PROPS,
113
+ ...options
114
+ };
125
115
  this.tileset = tileset;
126
116
  this.loader = tileset.loader;
127
117
  this.type = tileset.type;
@@ -144,712 +134,481 @@ var Tileset3D = function () {
144
134
  this._initializeStats();
145
135
  this.tilesetInitializationPromise = this._initializeTileSet(tileset);
146
136
  }
147
- (0, _createClass2.default)(Tileset3D, [{
148
- key: "destroy",
149
- value: function destroy() {
150
- this._destroy();
151
- }
152
- }, {
153
- key: "isLoaded",
154
- value: function isLoaded() {
155
- return this._pendingCount === 0 && this._frameNumber !== 0 && this._requestedTiles.length === 0;
156
- }
157
- }, {
158
- key: "tiles",
159
- get: function get() {
160
- return Object.values(this._tiles);
161
- }
162
- }, {
163
- key: "frameNumber",
164
- get: function get() {
165
- return this._frameNumber;
166
- }
167
- }, {
168
- key: "queryParams",
169
- get: function get() {
170
- return new URLSearchParams(this._queryParams).toString();
171
- }
172
- }, {
173
- key: "setProps",
174
- value: function setProps(props) {
175
- this.options = _objectSpread(_objectSpread({}, this.options), props);
176
- }
177
- }, {
178
- key: "setOptions",
179
- value: function setOptions(options) {
180
- this.options = _objectSpread(_objectSpread({}, this.options), options);
181
- }
182
- }, {
183
- key: "getTileUrl",
184
- value: function getTileUrl(tilePath) {
185
- var isDataUrl = tilePath.startsWith('data:');
186
- if (isDataUrl) {
187
- return tilePath;
188
- }
189
- return "".concat(tilePath).concat(tilePath.includes('?') ? '&' : '?').concat(this.queryParams);
190
- }
191
- }, {
192
- key: "hasExtension",
193
- value: function hasExtension(extensionName) {
194
- return Boolean(this._extensionsUsed.indexOf(extensionName) > -1);
195
- }
196
- }, {
197
- key: "update",
198
- value: function update() {
199
- var _this = this;
200
- var viewports = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
201
- this.tilesetInitializationPromise.then(function () {
202
- if (!viewports && _this.lastUpdatedVieports) {
203
- viewports = _this.lastUpdatedVieports;
204
- } else {
205
- _this.lastUpdatedVieports = viewports;
206
- }
207
- if (viewports) {
208
- _this.doUpdate(viewports);
209
- }
210
- });
137
+ destroy() {
138
+ this._destroy();
139
+ }
140
+ isLoaded() {
141
+ return this._pendingCount === 0 && this._frameNumber !== 0 && this._requestedTiles.length === 0;
142
+ }
143
+ get tiles() {
144
+ return Object.values(this._tiles);
145
+ }
146
+ get frameNumber() {
147
+ return this._frameNumber;
148
+ }
149
+ get queryParams() {
150
+ return new URLSearchParams(this._queryParams).toString();
151
+ }
152
+ setProps(props) {
153
+ this.options = {
154
+ ...this.options,
155
+ ...props
156
+ };
157
+ }
158
+ setOptions(options) {
159
+ this.options = {
160
+ ...this.options,
161
+ ...options
162
+ };
163
+ }
164
+ getTileUrl(tilePath) {
165
+ const isDataUrl = tilePath.startsWith('data:');
166
+ if (isDataUrl) {
167
+ return tilePath;
211
168
  }
212
- }, {
213
- key: "selectTiles",
214
- value: function () {
215
- var _selectTiles = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee() {
216
- var _this2 = this;
217
- var viewports,
218
- _args = arguments;
219
- return _regenerator.default.wrap(function _callee$(_context) {
220
- while (1) switch (_context.prev = _context.next) {
221
- case 0:
222
- viewports = _args.length > 0 && _args[0] !== undefined ? _args[0] : null;
223
- _context.next = 3;
224
- return this.tilesetInitializationPromise;
225
- case 3:
226
- if (viewports) {
227
- this.lastUpdatedVieports = viewports;
228
- }
229
- if (!this.updatePromise) {
230
- this.updatePromise = new Promise(function (resolve) {
231
- setTimeout(function () {
232
- if (_this2.lastUpdatedVieports) {
233
- _this2.doUpdate(_this2.lastUpdatedVieports);
234
- }
235
- resolve(_this2._frameNumber);
236
- _this2.updatePromise = null;
237
- }, _this2.options.debounceTime);
238
- });
239
- }
240
- return _context.abrupt("return", this.updatePromise);
241
- case 6:
242
- case "end":
243
- return _context.stop();
244
- }
245
- }, _callee, this);
246
- }));
247
- function selectTiles() {
248
- return _selectTiles.apply(this, arguments);
249
- }
250
- return selectTiles;
251
- }()
252
- }, {
253
- key: "doUpdate",
254
- value: function doUpdate(viewports) {
255
- if ('loadTiles' in this.options && !this.options.loadTiles) {
256
- return;
257
- }
258
- if (this.traverseCounter > 0) {
259
- return;
169
+ return "".concat(tilePath).concat(tilePath.includes('?') ? '&' : '?').concat(this.queryParams);
170
+ }
171
+ hasExtension(extensionName) {
172
+ return Boolean(this._extensionsUsed.indexOf(extensionName) > -1);
173
+ }
174
+ update() {
175
+ let viewports = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
176
+ this.tilesetInitializationPromise.then(() => {
177
+ if (!viewports && this.lastUpdatedVieports) {
178
+ viewports = this.lastUpdatedVieports;
179
+ } else {
180
+ this.lastUpdatedVieports = viewports;
260
181
  }
261
- var preparedViewports = viewports instanceof Array ? viewports : [viewports];
262
- this._cache.reset();
263
- this._frameNumber++;
264
- this.traverseCounter = preparedViewports.length;
265
- var viewportsToTraverse = [];
266
- var _iterator = _createForOfIteratorHelper(preparedViewports),
267
- _step;
268
- try {
269
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
270
- var viewport = _step.value;
271
- var id = viewport.id;
272
- if (this._needTraverse(id)) {
273
- viewportsToTraverse.push(id);
274
- } else {
275
- this.traverseCounter--;
276
- }
277
- }
278
- } catch (err) {
279
- _iterator.e(err);
280
- } finally {
281
- _iterator.f();
182
+ if (viewports) {
183
+ this.doUpdate(viewports);
282
184
  }
283
- var _iterator2 = _createForOfIteratorHelper(preparedViewports),
284
- _step2;
285
- try {
286
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
287
- var _viewport = _step2.value;
288
- var _id = _viewport.id;
289
- if (!this.roots[_id]) {
290
- this.roots[_id] = this._initializeTileHeaders(this.tileset, null);
291
- }
292
- if (!viewportsToTraverse.includes(_id)) {
293
- continue;
185
+ });
186
+ }
187
+ async selectTiles() {
188
+ let viewports = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
189
+ await this.tilesetInitializationPromise;
190
+ if (viewports) {
191
+ this.lastUpdatedVieports = viewports;
192
+ }
193
+ if (!this.updatePromise) {
194
+ this.updatePromise = new Promise(resolve => {
195
+ setTimeout(() => {
196
+ if (this.lastUpdatedVieports) {
197
+ this.doUpdate(this.lastUpdatedVieports);
294
198
  }
295
- var frameState = (0, _frameState.getFrameState)(_viewport, this._frameNumber);
296
- this._traverser.traverse(this.roots[_id], frameState, this.options);
297
- }
298
- } catch (err) {
299
- _iterator2.e(err);
300
- } finally {
301
- _iterator2.f();
199
+ resolve(this._frameNumber);
200
+ this.updatePromise = null;
201
+ }, this.options.debounceTime);
202
+ });
203
+ }
204
+ return this.updatePromise;
205
+ }
206
+ doUpdate(viewports) {
207
+ if ('loadTiles' in this.options && !this.options.loadTiles) {
208
+ return;
209
+ }
210
+ if (this.traverseCounter > 0) {
211
+ return;
212
+ }
213
+ const preparedViewports = viewports instanceof Array ? viewports : [viewports];
214
+ this._cache.reset();
215
+ this._frameNumber++;
216
+ this.traverseCounter = preparedViewports.length;
217
+ const viewportsToTraverse = [];
218
+ for (const viewport of preparedViewports) {
219
+ const id = viewport.id;
220
+ if (this._needTraverse(id)) {
221
+ viewportsToTraverse.push(id);
222
+ } else {
223
+ this.traverseCounter--;
302
224
  }
303
225
  }
304
- }, {
305
- key: "_needTraverse",
306
- value: function _needTraverse(viewportId) {
307
- var traverserId = viewportId;
308
- if (this.options.viewportTraversersMap) {
309
- traverserId = this.options.viewportTraversersMap[viewportId];
226
+ for (const viewport of preparedViewports) {
227
+ const id = viewport.id;
228
+ if (!this.roots[id]) {
229
+ this.roots[id] = this._initializeTileHeaders(this.tileset, null);
310
230
  }
311
- if (traverserId !== viewportId) {
312
- return false;
231
+ if (!viewportsToTraverse.includes(id)) {
232
+ continue;
313
233
  }
234
+ const frameState = (0, _frameState.getFrameState)(viewport, this._frameNumber);
235
+ this._traverser.traverse(this.roots[id], frameState, this.options);
236
+ }
237
+ }
238
+ _needTraverse(viewportId) {
239
+ let traverserId = viewportId;
240
+ if (this.options.viewportTraversersMap) {
241
+ traverserId = this.options.viewportTraversersMap[viewportId];
242
+ }
243
+ if (traverserId !== viewportId) {
244
+ return false;
245
+ }
246
+ return true;
247
+ }
248
+ _onTraversalEnd(frameState) {
249
+ const id = frameState.viewport.id;
250
+ if (!this.frameStateData[id]) {
251
+ this.frameStateData[id] = {
252
+ selectedTiles: [],
253
+ _requestedTiles: [],
254
+ _emptyTiles: []
255
+ };
256
+ }
257
+ const currentFrameStateData = this.frameStateData[id];
258
+ const selectedTiles = Object.values(this._traverser.selectedTiles);
259
+ const [filteredSelectedTiles, unselectedTiles] = (0, _frameState.limitSelectedTiles)(selectedTiles, frameState, this.options.maximumTilesSelected);
260
+ currentFrameStateData.selectedTiles = filteredSelectedTiles;
261
+ for (const tile of unselectedTiles) {
262
+ tile.unselect();
263
+ }
264
+ currentFrameStateData._requestedTiles = Object.values(this._traverser.requestedTiles);
265
+ currentFrameStateData._emptyTiles = Object.values(this._traverser.emptyTiles);
266
+ this.traverseCounter--;
267
+ if (this.traverseCounter > 0) {
268
+ return;
269
+ }
270
+ this._updateTiles();
271
+ }
272
+ _updateTiles() {
273
+ this.selectedTiles = [];
274
+ this._requestedTiles = [];
275
+ this._emptyTiles = [];
276
+ for (const frameStateKey in this.frameStateData) {
277
+ const frameStateDataValue = this.frameStateData[frameStateKey];
278
+ this.selectedTiles = this.selectedTiles.concat(frameStateDataValue.selectedTiles);
279
+ this._requestedTiles = this._requestedTiles.concat(frameStateDataValue._requestedTiles);
280
+ this._emptyTiles = this._emptyTiles.concat(frameStateDataValue._emptyTiles);
281
+ }
282
+ this.selectedTiles = this.options.onTraversalComplete(this.selectedTiles);
283
+ for (const tile of this.selectedTiles) {
284
+ this._tiles[tile.id] = tile;
285
+ }
286
+ this._loadTiles();
287
+ this._unloadTiles();
288
+ this._updateStats();
289
+ }
290
+ _tilesChanged(oldSelectedTiles, selectedTiles) {
291
+ if (oldSelectedTiles.length !== selectedTiles.length) {
314
292
  return true;
315
293
  }
316
- }, {
317
- key: "_onTraversalEnd",
318
- value: function _onTraversalEnd(frameState) {
319
- var id = frameState.viewport.id;
320
- if (!this.frameStateData[id]) {
321
- this.frameStateData[id] = {
322
- selectedTiles: [],
323
- _requestedTiles: [],
324
- _emptyTiles: []
325
- };
326
- }
327
- var currentFrameStateData = this.frameStateData[id];
328
- var selectedTiles = Object.values(this._traverser.selectedTiles);
329
- var _limitSelectedTiles = (0, _frameState.limitSelectedTiles)(selectedTiles, frameState, this.options.maximumTilesSelected),
330
- _limitSelectedTiles2 = (0, _slicedToArray2.default)(_limitSelectedTiles, 2),
331
- filteredSelectedTiles = _limitSelectedTiles2[0],
332
- unselectedTiles = _limitSelectedTiles2[1];
333
- currentFrameStateData.selectedTiles = filteredSelectedTiles;
334
- var _iterator3 = _createForOfIteratorHelper(unselectedTiles),
335
- _step3;
336
- try {
337
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
338
- var _tile = _step3.value;
339
- _tile.unselect();
340
- }
341
- } catch (err) {
342
- _iterator3.e(err);
343
- } finally {
344
- _iterator3.f();
345
- }
346
- currentFrameStateData._requestedTiles = Object.values(this._traverser.requestedTiles);
347
- currentFrameStateData._emptyTiles = Object.values(this._traverser.emptyTiles);
348
- this.traverseCounter--;
349
- if (this.traverseCounter > 0) {
350
- return;
351
- }
352
- this._updateTiles();
353
- }
354
- }, {
355
- key: "_updateTiles",
356
- value: function _updateTiles() {
357
- this.selectedTiles = [];
358
- this._requestedTiles = [];
359
- this._emptyTiles = [];
360
- for (var frameStateKey in this.frameStateData) {
361
- var frameStateDataValue = this.frameStateData[frameStateKey];
362
- this.selectedTiles = this.selectedTiles.concat(frameStateDataValue.selectedTiles);
363
- this._requestedTiles = this._requestedTiles.concat(frameStateDataValue._requestedTiles);
364
- this._emptyTiles = this._emptyTiles.concat(frameStateDataValue._emptyTiles);
365
- }
366
- this.selectedTiles = this.options.onTraversalComplete(this.selectedTiles);
367
- var _iterator4 = _createForOfIteratorHelper(this.selectedTiles),
368
- _step4;
369
- try {
370
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
371
- var _tile2 = _step4.value;
372
- this._tiles[_tile2.id] = _tile2;
373
- }
374
- } catch (err) {
375
- _iterator4.e(err);
376
- } finally {
377
- _iterator4.f();
378
- }
379
- this._loadTiles();
380
- this._unloadTiles();
381
- this._updateStats();
382
- }
383
- }, {
384
- key: "_tilesChanged",
385
- value: function _tilesChanged(oldSelectedTiles, selectedTiles) {
386
- if (oldSelectedTiles.length !== selectedTiles.length) {
387
- return true;
294
+ const set1 = new Set(oldSelectedTiles.map(t => t.id));
295
+ const set2 = new Set(selectedTiles.map(t => t.id));
296
+ let changed = oldSelectedTiles.filter(x => !set2.has(x.id)).length > 0;
297
+ changed = changed || selectedTiles.filter(x => !set1.has(x.id)).length > 0;
298
+ return changed;
299
+ }
300
+ _loadTiles() {
301
+ for (const tile of this._requestedTiles) {
302
+ if (tile.contentUnloaded) {
303
+ this._loadTile(tile);
388
304
  }
389
- var set1 = new Set(oldSelectedTiles.map(function (t) {
390
- return t.id;
391
- }));
392
- var set2 = new Set(selectedTiles.map(function (t) {
393
- return t.id;
394
- }));
395
- var changed = oldSelectedTiles.filter(function (x) {
396
- return !set2.has(x.id);
397
- }).length > 0;
398
- changed = changed || selectedTiles.filter(function (x) {
399
- return !set1.has(x.id);
400
- }).length > 0;
401
- return changed;
402
- }
403
- }, {
404
- key: "_loadTiles",
405
- value: function _loadTiles() {
406
- var _iterator5 = _createForOfIteratorHelper(this._requestedTiles),
407
- _step5;
408
- try {
409
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
410
- var _tile3 = _step5.value;
411
- if (_tile3.contentUnloaded) {
412
- this._loadTile(_tile3);
413
- }
305
+ }
306
+ }
307
+ _unloadTiles() {
308
+ this._cache.unloadTiles(this, (tileset, tile) => tileset._unloadTile(tile));
309
+ }
310
+ _updateStats() {
311
+ let tilesRenderable = 0;
312
+ let pointsRenderable = 0;
313
+ for (const tile of this.selectedTiles) {
314
+ if (tile.contentAvailable && tile.content) {
315
+ tilesRenderable++;
316
+ if (tile.content.pointCount) {
317
+ pointsRenderable += tile.content.pointCount;
318
+ } else {
319
+ pointsRenderable += tile.content.vertexCount;
414
320
  }
415
- } catch (err) {
416
- _iterator5.e(err);
417
- } finally {
418
- _iterator5.f();
419
321
  }
420
322
  }
421
- }, {
422
- key: "_unloadTiles",
423
- value: function _unloadTiles() {
424
- this._cache.unloadTiles(this, function (tileset, tile) {
425
- return tileset._unloadTile(tile);
426
- });
323
+ this.stats.get(TILES_IN_VIEW).count = this.selectedTiles.length;
324
+ this.stats.get(TILES_RENDERABLE).count = tilesRenderable;
325
+ this.stats.get(POINTS_COUNT).count = pointsRenderable;
326
+ }
327
+ async _initializeTileSet(tilesetJson) {
328
+ if (this.type === _constants.TILESET_TYPE.I3S) {
329
+ this.calculateViewPropsI3S();
330
+ tilesetJson.root = await tilesetJson.root;
427
331
  }
428
- }, {
429
- key: "_updateStats",
430
- value: function _updateStats() {
431
- var tilesRenderable = 0;
432
- var pointsRenderable = 0;
433
- var _iterator6 = _createForOfIteratorHelper(this.selectedTiles),
434
- _step6;
435
- try {
436
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
437
- var _tile4 = _step6.value;
438
- if (_tile4.contentAvailable && _tile4.content) {
439
- tilesRenderable++;
440
- if (_tile4.content.pointCount) {
441
- pointsRenderable += _tile4.content.pointCount;
442
- } else {
443
- pointsRenderable += _tile4.content.vertexCount;
444
- }
445
- }
446
- }
447
- } catch (err) {
448
- _iterator6.e(err);
449
- } finally {
450
- _iterator6.f();
451
- }
452
- this.stats.get(TILES_IN_VIEW).count = this.selectedTiles.length;
453
- this.stats.get(TILES_RENDERABLE).count = tilesRenderable;
454
- this.stats.get(POINTS_COUNT).count = pointsRenderable;
455
- }
456
- }, {
457
- key: "_initializeTileSet",
458
- value: function () {
459
- var _initializeTileSet2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(tilesetJson) {
460
- return _regenerator.default.wrap(function _callee2$(_context2) {
461
- while (1) switch (_context2.prev = _context2.next) {
462
- case 0:
463
- if (!(this.type === _constants.TILESET_TYPE.I3S)) {
464
- _context2.next = 5;
465
- break;
466
- }
467
- this.calculateViewPropsI3S();
468
- _context2.next = 4;
469
- return tilesetJson.root;
470
- case 4:
471
- tilesetJson.root = _context2.sent;
472
- case 5:
473
- this.root = this._initializeTileHeaders(tilesetJson, null);
474
- if (this.type === _constants.TILESET_TYPE.TILES3D) {
475
- this._initializeTiles3DTileset(tilesetJson);
476
- this.calculateViewPropsTiles3D();
477
- }
478
- if (this.type === _constants.TILESET_TYPE.I3S) {
479
- this._initializeI3STileset();
480
- }
481
- case 8:
482
- case "end":
483
- return _context2.stop();
484
- }
485
- }, _callee2, this);
486
- }));
487
- function _initializeTileSet(_x) {
488
- return _initializeTileSet2.apply(this, arguments);
489
- }
490
- return _initializeTileSet;
491
- }()
492
- }, {
493
- key: "calculateViewPropsI3S",
494
- value: function calculateViewPropsI3S() {
495
- var _this$tileset$store;
496
- var fullExtent = this.tileset.fullExtent;
497
- if (fullExtent) {
498
- var xmin = fullExtent.xmin,
499
- xmax = fullExtent.xmax,
500
- ymin = fullExtent.ymin,
501
- ymax = fullExtent.ymax,
502
- zmin = fullExtent.zmin,
503
- zmax = fullExtent.zmax;
504
- this.cartographicCenter = new _core.Vector3(xmin + (xmax - xmin) / 2, ymin + (ymax - ymin) / 2, zmin + (zmax - zmin) / 2);
505
- this.cartesianCenter = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter, new _core.Vector3());
506
- this.zoom = (0, _zoom.getZoomFromFullExtent)(fullExtent, this.cartographicCenter, this.cartesianCenter);
507
- return;
508
- }
509
- var extent = (_this$tileset$store = this.tileset.store) === null || _this$tileset$store === void 0 ? void 0 : _this$tileset$store.extent;
510
- if (extent) {
511
- var _extent = (0, _slicedToArray2.default)(extent, 4),
512
- _xmin = _extent[0],
513
- _ymin = _extent[1],
514
- _xmax = _extent[2],
515
- _ymax = _extent[3];
516
- this.cartographicCenter = new _core.Vector3(_xmin + (_xmax - _xmin) / 2, _ymin + (_ymax - _ymin) / 2, 0);
517
- this.cartesianCenter = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter, new _core.Vector3());
518
- this.zoom = (0, _zoom.getZoomFromExtent)(extent, this.cartographicCenter, this.cartesianCenter);
519
- return;
520
- }
521
- console.warn('Extent is not defined in the tileset header');
332
+ this.root = this._initializeTileHeaders(tilesetJson, null);
333
+ if (this.type === _constants.TILESET_TYPE.TILES3D) {
334
+ this._initializeTiles3DTileset(tilesetJson);
335
+ this.calculateViewPropsTiles3D();
336
+ }
337
+ if (this.type === _constants.TILESET_TYPE.I3S) {
338
+ this._initializeI3STileset();
339
+ }
340
+ }
341
+ calculateViewPropsI3S() {
342
+ var _this$tileset$store;
343
+ const fullExtent = this.tileset.fullExtent;
344
+ if (fullExtent) {
345
+ const {
346
+ xmin,
347
+ xmax,
348
+ ymin,
349
+ ymax,
350
+ zmin,
351
+ zmax
352
+ } = fullExtent;
353
+ this.cartographicCenter = new _core.Vector3(xmin + (xmax - xmin) / 2, ymin + (ymax - ymin) / 2, zmin + (zmax - zmin) / 2);
354
+ this.cartesianCenter = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter, new _core.Vector3());
355
+ this.zoom = (0, _zoom.getZoomFromFullExtent)(fullExtent, this.cartographicCenter, this.cartesianCenter);
356
+ return;
357
+ }
358
+ const extent = (_this$tileset$store = this.tileset.store) === null || _this$tileset$store === void 0 ? void 0 : _this$tileset$store.extent;
359
+ if (extent) {
360
+ const [xmin, ymin, xmax, ymax] = extent;
361
+ this.cartographicCenter = new _core.Vector3(xmin + (xmax - xmin) / 2, ymin + (ymax - ymin) / 2, 0);
362
+ this.cartesianCenter = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter, new _core.Vector3());
363
+ this.zoom = (0, _zoom.getZoomFromExtent)(extent, this.cartographicCenter, this.cartesianCenter);
364
+ return;
365
+ }
366
+ console.warn('Extent is not defined in the tileset header');
367
+ this.cartographicCenter = new _core.Vector3();
368
+ this.zoom = 1;
369
+ return;
370
+ }
371
+ calculateViewPropsTiles3D() {
372
+ const root = this.root;
373
+ const {
374
+ center
375
+ } = root.boundingVolume;
376
+ if (!center) {
377
+ console.warn('center was not pre-calculated for the root tile');
522
378
  this.cartographicCenter = new _core.Vector3();
523
379
  this.zoom = 1;
524
380
  return;
525
381
  }
526
- }, {
527
- key: "calculateViewPropsTiles3D",
528
- value: function calculateViewPropsTiles3D() {
529
- var root = this.root;
530
- var center = root.boundingVolume.center;
531
- if (!center) {
532
- console.warn('center was not pre-calculated for the root tile');
533
- this.cartographicCenter = new _core.Vector3();
534
- this.zoom = 1;
535
- return;
536
- }
537
- if (center[0] !== 0 || center[1] !== 0 || center[2] !== 0) {
538
- this.cartographicCenter = _geospatial.Ellipsoid.WGS84.cartesianToCartographic(center, new _core.Vector3());
539
- } else {
540
- this.cartographicCenter = new _core.Vector3(0, 0, -_geospatial.Ellipsoid.WGS84.radii[0]);
541
- }
542
- this.cartesianCenter = center;
543
- this.zoom = (0, _zoom.getZoomFromBoundingVolume)(root.boundingVolume, this.cartographicCenter);
544
- }
545
- }, {
546
- key: "_initializeStats",
547
- value: function _initializeStats() {
548
- this.stats.get(TILES_TOTAL);
549
- this.stats.get(TILES_LOADING);
550
- this.stats.get(TILES_IN_MEMORY);
551
- this.stats.get(TILES_IN_VIEW);
552
- this.stats.get(TILES_RENDERABLE);
553
- this.stats.get(TILES_LOADED);
554
- this.stats.get(TILES_UNLOADED);
555
- this.stats.get(TILES_LOAD_FAILED);
556
- this.stats.get(POINTS_COUNT);
557
- this.stats.get(TILES_GPU_MEMORY, 'memory');
558
- }
559
- }, {
560
- key: "_initializeTileHeaders",
561
- value: function _initializeTileHeaders(tilesetJson, parentTileHeader) {
562
- var rootTile = new _tile3d.Tile3D(this, tilesetJson.root, parentTileHeader);
563
- if (parentTileHeader) {
564
- parentTileHeader.children.push(rootTile);
565
- rootTile.depth = parentTileHeader.depth + 1;
566
- }
567
- if (this.type === _constants.TILESET_TYPE.TILES3D) {
568
- var stack = [];
569
- stack.push(rootTile);
570
- while (stack.length > 0) {
571
- var _tile5 = stack.pop();
572
- this.stats.get(TILES_TOTAL).incrementCount();
573
- var children = _tile5.header.children || [];
574
- var _iterator7 = _createForOfIteratorHelper(children),
575
- _step7;
576
- try {
577
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
578
- var _childTile$contentUrl;
579
- var childHeader = _step7.value;
580
- var childTile = new _tile3d.Tile3D(this, childHeader, _tile5);
581
- if ((_childTile$contentUrl = childTile.contentUrl) !== null && _childTile$contentUrl !== void 0 && _childTile$contentUrl.includes('?session=')) {
582
- var _url = new URL(childTile.contentUrl);
583
- var session = _url.searchParams.get('session');
584
- if (session) {
585
- this._queryParams.session = session;
586
- }
587
- }
588
- _tile5.children.push(childTile);
589
- childTile.depth = _tile5.depth + 1;
590
- stack.push(childTile);
382
+ if (center[0] !== 0 || center[1] !== 0 || center[2] !== 0) {
383
+ this.cartographicCenter = _geospatial.Ellipsoid.WGS84.cartesianToCartographic(center, new _core.Vector3());
384
+ } else {
385
+ this.cartographicCenter = new _core.Vector3(0, 0, -_geospatial.Ellipsoid.WGS84.radii[0]);
386
+ }
387
+ this.cartesianCenter = center;
388
+ this.zoom = (0, _zoom.getZoomFromBoundingVolume)(root.boundingVolume, this.cartographicCenter);
389
+ }
390
+ _initializeStats() {
391
+ this.stats.get(TILES_TOTAL);
392
+ this.stats.get(TILES_LOADING);
393
+ this.stats.get(TILES_IN_MEMORY);
394
+ this.stats.get(TILES_IN_VIEW);
395
+ this.stats.get(TILES_RENDERABLE);
396
+ this.stats.get(TILES_LOADED);
397
+ this.stats.get(TILES_UNLOADED);
398
+ this.stats.get(TILES_LOAD_FAILED);
399
+ this.stats.get(POINTS_COUNT);
400
+ this.stats.get(TILES_GPU_MEMORY, 'memory');
401
+ }
402
+ _initializeTileHeaders(tilesetJson, parentTileHeader) {
403
+ const rootTile = new _tile3d.Tile3D(this, tilesetJson.root, parentTileHeader);
404
+ if (parentTileHeader) {
405
+ parentTileHeader.children.push(rootTile);
406
+ rootTile.depth = parentTileHeader.depth + 1;
407
+ }
408
+ if (this.type === _constants.TILESET_TYPE.TILES3D) {
409
+ const stack = [];
410
+ stack.push(rootTile);
411
+ while (stack.length > 0) {
412
+ const tile = stack.pop();
413
+ this.stats.get(TILES_TOTAL).incrementCount();
414
+ const children = tile.header.children || [];
415
+ for (const childHeader of children) {
416
+ var _childTile$contentUrl;
417
+ const childTile = new _tile3d.Tile3D(this, childHeader, tile);
418
+ if ((_childTile$contentUrl = childTile.contentUrl) !== null && _childTile$contentUrl !== void 0 && _childTile$contentUrl.includes('?session=')) {
419
+ const url = new URL(childTile.contentUrl);
420
+ const session = url.searchParams.get('session');
421
+ if (session) {
422
+ this._queryParams.session = session;
591
423
  }
592
- } catch (err) {
593
- _iterator7.e(err);
594
- } finally {
595
- _iterator7.f();
596
424
  }
425
+ tile.children.push(childTile);
426
+ childTile.depth = tile.depth + 1;
427
+ stack.push(childTile);
597
428
  }
598
429
  }
599
- return rootTile;
600
- }
601
- }, {
602
- key: "_initializeTraverser",
603
- value: function _initializeTraverser() {
604
- var TraverserClass;
605
- var type = this.type;
606
- switch (type) {
607
- case _constants.TILESET_TYPE.TILES3D:
608
- TraverserClass = _tileset3dTraverser.Tileset3DTraverser;
430
+ }
431
+ return rootTile;
432
+ }
433
+ _initializeTraverser() {
434
+ let TraverserClass;
435
+ const type = this.type;
436
+ switch (type) {
437
+ case _constants.TILESET_TYPE.TILES3D:
438
+ TraverserClass = _tileset3dTraverser.Tileset3DTraverser;
439
+ break;
440
+ case _constants.TILESET_TYPE.I3S:
441
+ TraverserClass = _i3sTilesetTraverser.I3STilesetTraverser;
442
+ break;
443
+ default:
444
+ TraverserClass = _tilesetTraverser.TilesetTraverser;
445
+ }
446
+ return new TraverserClass({
447
+ basePath: this.basePath,
448
+ onTraversalEnd: this._onTraversalEnd.bind(this)
449
+ });
450
+ }
451
+ _destroyTileHeaders(parentTile) {
452
+ this._destroySubtree(parentTile);
453
+ }
454
+ async _loadTile(tile) {
455
+ let loaded;
456
+ try {
457
+ this._onStartTileLoading();
458
+ loaded = await tile.loadContent();
459
+ } catch (error) {
460
+ this._onTileLoadError(tile, error instanceof Error ? error : new Error('load failed'));
461
+ } finally {
462
+ this._onEndTileLoading();
463
+ this._onTileLoad(tile, loaded);
464
+ }
465
+ }
466
+ _onTileLoadError(tile, error) {
467
+ this.stats.get(TILES_LOAD_FAILED).incrementCount();
468
+ const message = error.message || error.toString();
469
+ const url = tile.url;
470
+ console.error("A 3D tile failed to load: ".concat(tile.url, " ").concat(message));
471
+ this.options.onTileError(tile, message, url);
472
+ }
473
+ _onTileLoad(tile, loaded) {
474
+ if (!loaded) {
475
+ return;
476
+ }
477
+ if (this.type === _constants.TILESET_TYPE.I3S) {
478
+ var _this$tileset, _this$tileset$nodePag;
479
+ const nodesInNodePages = ((_this$tileset = this.tileset) === null || _this$tileset === void 0 ? void 0 : (_this$tileset$nodePag = _this$tileset.nodePagesTile) === null || _this$tileset$nodePag === void 0 ? void 0 : _this$tileset$nodePag.nodesInNodePages) || 0;
480
+ this.stats.get(TILES_TOTAL).reset();
481
+ this.stats.get(TILES_TOTAL).addCount(nodesInNodePages);
482
+ }
483
+ if (tile && tile.content) {
484
+ (0, _transformUtils.calculateTransformProps)(tile, tile.content);
485
+ }
486
+ this.updateContentTypes(tile);
487
+ this._addTileToCache(tile);
488
+ this.options.onTileLoad(tile);
489
+ }
490
+ updateContentTypes(tile) {
491
+ if (this.type === _constants.TILESET_TYPE.I3S) {
492
+ if (tile.header.isDracoGeometry) {
493
+ this.contentFormats.draco = true;
494
+ }
495
+ switch (tile.header.textureFormat) {
496
+ case 'dds':
497
+ this.contentFormats.dds = true;
609
498
  break;
610
- case _constants.TILESET_TYPE.I3S:
611
- TraverserClass = _i3sTilesetTraverser.I3STilesetTraverser;
499
+ case 'ktx2':
500
+ this.contentFormats.ktx2 = true;
612
501
  break;
613
502
  default:
614
- TraverserClass = _tilesetTraverser.TilesetTraverser;
615
- }
616
- return new TraverserClass({
617
- basePath: this.basePath,
618
- onTraversalEnd: this._onTraversalEnd.bind(this)
619
- });
620
- }
621
- }, {
622
- key: "_destroyTileHeaders",
623
- value: function _destroyTileHeaders(parentTile) {
624
- this._destroySubtree(parentTile);
625
- }
626
- }, {
627
- key: "_loadTile",
628
- value: function () {
629
- var _loadTile2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(tile) {
630
- var loaded;
631
- return _regenerator.default.wrap(function _callee3$(_context3) {
632
- while (1) switch (_context3.prev = _context3.next) {
633
- case 0:
634
- _context3.prev = 0;
635
- this._onStartTileLoading();
636
- _context3.next = 4;
637
- return tile.loadContent();
638
- case 4:
639
- loaded = _context3.sent;
640
- _context3.next = 10;
641
- break;
642
- case 7:
643
- _context3.prev = 7;
644
- _context3.t0 = _context3["catch"](0);
645
- this._onTileLoadError(tile, _context3.t0 instanceof Error ? _context3.t0 : new Error('load failed'));
646
- case 10:
647
- _context3.prev = 10;
648
- this._onEndTileLoading();
649
- this._onTileLoad(tile, loaded);
650
- return _context3.finish(10);
651
- case 14:
652
- case "end":
653
- return _context3.stop();
654
- }
655
- }, _callee3, this, [[0, 7, 10, 14]]);
656
- }));
657
- function _loadTile(_x2) {
658
- return _loadTile2.apply(this, arguments);
659
503
  }
660
- return _loadTile;
661
- }()
662
- }, {
663
- key: "_onTileLoadError",
664
- value: function _onTileLoadError(tile, error) {
665
- this.stats.get(TILES_LOAD_FAILED).incrementCount();
666
- var message = error.message || error.toString();
667
- var url = tile.url;
668
- console.error("A 3D tile failed to load: ".concat(tile.url, " ").concat(message));
669
- this.options.onTileError(tile, message, url);
670
- }
671
- }, {
672
- key: "_onTileLoad",
673
- value: function _onTileLoad(tile, loaded) {
674
- if (!loaded) {
675
- return;
504
+ } else if (this.type === _constants.TILESET_TYPE.TILES3D) {
505
+ var _tile$content;
506
+ const {
507
+ extensionsRemoved = []
508
+ } = ((_tile$content = tile.content) === null || _tile$content === void 0 ? void 0 : _tile$content.gltf) || {};
509
+ if (extensionsRemoved.includes('KHR_draco_mesh_compression')) {
510
+ this.contentFormats.draco = true;
676
511
  }
677
- if (this.type === _constants.TILESET_TYPE.I3S) {
678
- var _this$tileset, _this$tileset$nodePag;
679
- var nodesInNodePages = ((_this$tileset = this.tileset) === null || _this$tileset === void 0 ? void 0 : (_this$tileset$nodePag = _this$tileset.nodePagesTile) === null || _this$tileset$nodePag === void 0 ? void 0 : _this$tileset$nodePag.nodesInNodePages) || 0;
680
- this.stats.get(TILES_TOTAL).reset();
681
- this.stats.get(TILES_TOTAL).addCount(nodesInNodePages);
512
+ if (extensionsRemoved.includes('EXT_meshopt_compression')) {
513
+ this.contentFormats.meshopt = true;
682
514
  }
683
- if (tile && tile.content) {
684
- (0, _transformUtils.calculateTransformProps)(tile, tile.content);
685
- }
686
- this.updateContentTypes(tile);
687
- this._addTileToCache(tile);
688
- this.options.onTileLoad(tile);
689
- }
690
- }, {
691
- key: "updateContentTypes",
692
- value: function updateContentTypes(tile) {
693
- if (this.type === _constants.TILESET_TYPE.I3S) {
694
- if (tile.header.isDracoGeometry) {
695
- this.contentFormats.draco = true;
696
- }
697
- switch (tile.header.textureFormat) {
698
- case 'dds':
699
- this.contentFormats.dds = true;
700
- break;
701
- case 'ktx2':
702
- this.contentFormats.ktx2 = true;
703
- break;
704
- default:
705
- }
706
- } else if (this.type === _constants.TILESET_TYPE.TILES3D) {
707
- var _tile$content;
708
- var _ref = ((_tile$content = tile.content) === null || _tile$content === void 0 ? void 0 : _tile$content.gltf) || {},
709
- _ref$extensionsRemove = _ref.extensionsRemoved,
710
- extensionsRemoved = _ref$extensionsRemove === void 0 ? [] : _ref$extensionsRemove;
711
- if (extensionsRemoved.includes('KHR_draco_mesh_compression')) {
712
- this.contentFormats.draco = true;
713
- }
714
- if (extensionsRemoved.includes('EXT_meshopt_compression')) {
715
- this.contentFormats.meshopt = true;
716
- }
717
- if (extensionsRemoved.includes('KHR_texture_basisu')) {
718
- this.contentFormats.ktx2 = true;
719
- }
515
+ if (extensionsRemoved.includes('KHR_texture_basisu')) {
516
+ this.contentFormats.ktx2 = true;
720
517
  }
721
518
  }
722
- }, {
723
- key: "_onStartTileLoading",
724
- value: function _onStartTileLoading() {
725
- this._pendingCount++;
726
- this.stats.get(TILES_LOADING).incrementCount();
727
- }
728
- }, {
729
- key: "_onEndTileLoading",
730
- value: function _onEndTileLoading() {
731
- this._pendingCount--;
732
- this.stats.get(TILES_LOADING).decrementCount();
733
- }
734
- }, {
735
- key: "_addTileToCache",
736
- value: function _addTileToCache(tile) {
737
- this._cache.add(this, tile, function (tileset) {
738
- return tileset._updateCacheStats(tile);
739
- });
519
+ }
520
+ _onStartTileLoading() {
521
+ this._pendingCount++;
522
+ this.stats.get(TILES_LOADING).incrementCount();
523
+ }
524
+ _onEndTileLoading() {
525
+ this._pendingCount--;
526
+ this.stats.get(TILES_LOADING).decrementCount();
527
+ }
528
+ _addTileToCache(tile) {
529
+ this._cache.add(this, tile, tileset => tileset._updateCacheStats(tile));
530
+ }
531
+ _updateCacheStats(tile) {
532
+ this.stats.get(TILES_LOADED).incrementCount();
533
+ this.stats.get(TILES_IN_MEMORY).incrementCount();
534
+ this.gpuMemoryUsageInBytes += tile.gpuMemoryUsageInBytes || 0;
535
+ this.stats.get(TILES_GPU_MEMORY).count = this.gpuMemoryUsageInBytes;
536
+ }
537
+ _unloadTile(tile) {
538
+ this.gpuMemoryUsageInBytes -= tile.gpuMemoryUsageInBytes || 0;
539
+ this.stats.get(TILES_IN_MEMORY).decrementCount();
540
+ this.stats.get(TILES_UNLOADED).incrementCount();
541
+ this.stats.get(TILES_GPU_MEMORY).count = this.gpuMemoryUsageInBytes;
542
+ this.options.onTileUnload(tile);
543
+ tile.unloadContent();
544
+ }
545
+ _destroy() {
546
+ const stack = [];
547
+ if (this.root) {
548
+ stack.push(this.root);
740
549
  }
741
- }, {
742
- key: "_updateCacheStats",
743
- value: function _updateCacheStats(tile) {
744
- this.stats.get(TILES_LOADED).incrementCount();
745
- this.stats.get(TILES_IN_MEMORY).incrementCount();
746
- this.gpuMemoryUsageInBytes += tile.gpuMemoryUsageInBytes || 0;
747
- this.stats.get(TILES_GPU_MEMORY).count = this.gpuMemoryUsageInBytes;
748
- }
749
- }, {
750
- key: "_unloadTile",
751
- value: function _unloadTile(tile) {
752
- this.gpuMemoryUsageInBytes -= tile.gpuMemoryUsageInBytes || 0;
753
- this.stats.get(TILES_IN_MEMORY).decrementCount();
754
- this.stats.get(TILES_UNLOADED).incrementCount();
755
- this.stats.get(TILES_GPU_MEMORY).count = this.gpuMemoryUsageInBytes;
756
- this.options.onTileUnload(tile);
757
- tile.unloadContent();
758
- }
759
- }, {
760
- key: "_destroy",
761
- value: function _destroy() {
762
- var stack = [];
763
- if (this.root) {
764
- stack.push(this.root);
765
- }
766
- while (stack.length > 0) {
767
- var _tile6 = stack.pop();
768
- var _iterator8 = _createForOfIteratorHelper(_tile6.children),
769
- _step8;
770
- try {
771
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
772
- var child = _step8.value;
773
- stack.push(child);
774
- }
775
- } catch (err) {
776
- _iterator8.e(err);
777
- } finally {
778
- _iterator8.f();
779
- }
780
- this._destroyTile(_tile6);
781
- }
782
- this.root = null;
783
- }
784
- }, {
785
- key: "_destroySubtree",
786
- value: function _destroySubtree(tile) {
787
- var root = tile;
788
- var stack = [];
789
- stack.push(root);
790
- while (stack.length > 0) {
791
- tile = stack.pop();
792
- var _iterator9 = _createForOfIteratorHelper(tile.children),
793
- _step9;
794
- try {
795
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
796
- var child = _step9.value;
797
- stack.push(child);
798
- }
799
- } catch (err) {
800
- _iterator9.e(err);
801
- } finally {
802
- _iterator9.f();
803
- }
804
- if (tile !== root) {
805
- this._destroyTile(tile);
806
- }
807
- }
808
- root.children = [];
809
- }
810
- }, {
811
- key: "_destroyTile",
812
- value: function _destroyTile(tile) {
813
- this._cache.unloadTile(this, tile);
814
- this._unloadTile(tile);
815
- tile.destroy();
816
- }
817
- }, {
818
- key: "_initializeTiles3DTileset",
819
- value: function _initializeTiles3DTileset(tilesetJson) {
820
- if (tilesetJson.queryString) {
821
- var searchParams = new URLSearchParams(tilesetJson.queryString);
822
- var queryParams = Object.fromEntries(searchParams.entries());
823
- this._queryParams = _objectSpread(_objectSpread({}, this._queryParams), queryParams);
824
- }
825
- this.asset = tilesetJson.asset;
826
- if (!this.asset) {
827
- throw new Error('Tileset must have an asset property.');
550
+ while (stack.length > 0) {
551
+ const tile = stack.pop();
552
+ for (const child of tile.children) {
553
+ stack.push(child);
828
554
  }
829
- if (this.asset.version !== '0.0' && this.asset.version !== '1.0') {
830
- throw new Error('The tileset must be 3D Tiles version 0.0 or 1.0.');
555
+ this._destroyTile(tile);
556
+ }
557
+ this.root = null;
558
+ }
559
+ _destroySubtree(tile) {
560
+ const root = tile;
561
+ const stack = [];
562
+ stack.push(root);
563
+ while (stack.length > 0) {
564
+ tile = stack.pop();
565
+ for (const child of tile.children) {
566
+ stack.push(child);
831
567
  }
832
- if ('tilesetVersion' in this.asset) {
833
- this._queryParams.v = this.asset.tilesetVersion;
568
+ if (tile !== root) {
569
+ this._destroyTile(tile);
834
570
  }
835
- this.credits = {
836
- attributions: this.options.attributions || []
571
+ }
572
+ root.children = [];
573
+ }
574
+ _destroyTile(tile) {
575
+ this._cache.unloadTile(this, tile);
576
+ this._unloadTile(tile);
577
+ tile.destroy();
578
+ }
579
+ _initializeTiles3DTileset(tilesetJson) {
580
+ if (tilesetJson.queryString) {
581
+ const searchParams = new URLSearchParams(tilesetJson.queryString);
582
+ const queryParams = Object.fromEntries(searchParams.entries());
583
+ this._queryParams = {
584
+ ...this._queryParams,
585
+ ...queryParams
837
586
  };
838
- this.description = this.options.description || '';
839
- this.properties = tilesetJson.properties;
840
- this.geometricError = tilesetJson.geometricError;
841
- this._extensionsUsed = tilesetJson.extensionsUsed || [];
842
- this.extras = tilesetJson.extras;
843
- }
844
- }, {
845
- key: "_initializeI3STileset",
846
- value: function _initializeI3STileset() {
847
- if (this.loadOptions.i3s && 'token' in this.loadOptions.i3s) {
848
- this._queryParams.token = this.loadOptions.i3s.token;
849
- }
850
587
  }
851
- }]);
852
- return Tileset3D;
853
- }();
588
+ this.asset = tilesetJson.asset;
589
+ if (!this.asset) {
590
+ throw new Error('Tileset must have an asset property.');
591
+ }
592
+ if (this.asset.version !== '0.0' && this.asset.version !== '1.0') {
593
+ throw new Error('The tileset must be 3D Tiles version 0.0 or 1.0.');
594
+ }
595
+ if ('tilesetVersion' in this.asset) {
596
+ this._queryParams.v = this.asset.tilesetVersion;
597
+ }
598
+ this.credits = {
599
+ attributions: this.options.attributions || []
600
+ };
601
+ this.description = this.options.description || '';
602
+ this.properties = tilesetJson.properties;
603
+ this.geometricError = tilesetJson.geometricError;
604
+ this._extensionsUsed = tilesetJson.extensionsUsed || [];
605
+ this.extras = tilesetJson.extras;
606
+ }
607
+ _initializeI3STileset() {
608
+ if (this.loadOptions.i3s && 'token' in this.loadOptions.i3s) {
609
+ this._queryParams.token = this.loadOptions.i3s.token;
610
+ }
611
+ }
612
+ }
854
613
  exports.Tileset3D = Tileset3D;
855
614
  //# sourceMappingURL=tileset-3d.js.map