@loaders.gl/tiles 3.0.9 → 3.0.13

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 (48) hide show
  1. package/dist/dist.es5.min.js +1 -1
  2. package/dist/dist.es5.min.js.map +1 -1
  3. package/dist/dist.min.js +1 -1
  4. package/dist/dist.min.js.map +1 -1
  5. package/dist/es5/bundle.js +2 -2
  6. package/dist/es5/bundle.js.map +1 -1
  7. package/dist/es5/constants.js +6 -6
  8. package/dist/es5/constants.js.map +1 -1
  9. package/dist/es5/index.js +12 -12
  10. package/dist/es5/tileset/helpers/bounding-volume.js +25 -37
  11. package/dist/es5/tileset/helpers/bounding-volume.js.map +1 -1
  12. package/dist/es5/tileset/helpers/frame-state.js +29 -25
  13. package/dist/es5/tileset/helpers/frame-state.js.map +1 -1
  14. package/dist/es5/tileset/helpers/i3s-lod.js +51 -66
  15. package/dist/es5/tileset/helpers/i3s-lod.js.map +1 -1
  16. package/dist/es5/tileset/helpers/tiles-3d-lod.js +51 -47
  17. package/dist/es5/tileset/helpers/tiles-3d-lod.js.map +1 -1
  18. package/dist/es5/tileset/helpers/transform-utils.js +17 -11
  19. package/dist/es5/tileset/helpers/transform-utils.js.map +1 -1
  20. package/dist/es5/tileset/helpers/zoom.js +17 -15
  21. package/dist/es5/tileset/helpers/zoom.js.map +1 -1
  22. package/dist/es5/tileset/tile-3d.js +328 -421
  23. package/dist/es5/tileset/tile-3d.js.map +1 -1
  24. package/dist/es5/tileset/tileset-3d.js +381 -563
  25. package/dist/es5/tileset/tileset-3d.js.map +1 -1
  26. package/dist/es5/tileset/tileset-cache.js +50 -63
  27. package/dist/es5/tileset/tileset-cache.js.map +1 -1
  28. package/dist/es5/tileset/traversers/i3s-tile-manager.js +32 -44
  29. package/dist/es5/tileset/traversers/i3s-tile-manager.js.map +1 -1
  30. package/dist/es5/tileset/traversers/i3s-tileset-traverser.js +53 -143
  31. package/dist/es5/tileset/traversers/i3s-tileset-traverser.js.map +1 -1
  32. package/dist/es5/tileset/traversers/tileset-3d-traverser.js +34 -62
  33. package/dist/es5/tileset/traversers/tileset-3d-traverser.js.map +1 -1
  34. package/dist/es5/tileset/traversers/tileset-traverser.js +209 -282
  35. package/dist/es5/tileset/traversers/tileset-traverser.js.map +1 -1
  36. package/dist/es5/utils/doubly-linked-list-node.js +7 -9
  37. package/dist/es5/utils/doubly-linked-list-node.js.map +1 -1
  38. package/dist/es5/utils/doubly-linked-list.js +64 -76
  39. package/dist/es5/utils/doubly-linked-list.js.map +1 -1
  40. package/dist/es5/utils/managed-array.js +86 -108
  41. package/dist/es5/utils/managed-array.js.map +1 -1
  42. package/dist/esm/tileset/tile-3d.js +1 -1
  43. package/dist/esm/tileset/tile-3d.js.map +1 -1
  44. package/dist/esm/tileset/tileset-3d.js +5 -5
  45. package/dist/esm/tileset/tileset-3d.js.map +1 -1
  46. package/dist/esm/tileset/traversers/i3s-tileset-traverser.js +2 -2
  47. package/dist/esm/tileset/traversers/i3s-tileset-traverser.js.map +1 -1
  48. package/package.json +5 -5
@@ -7,14 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
-
16
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
-
18
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
19
11
 
20
12
  var _core = require("@math.gl/core");
@@ -35,20 +27,14 @@ var _dTilesOptions = require("./helpers/3d-tiles-options");
35
27
 
36
28
  var _tilesetTraverser = _interopRequireDefault(require("./traversers/tileset-traverser"));
37
29
 
38
- 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; }
39
-
40
- 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; }
41
-
42
- var scratchVector = new _core.Vector3();
30
+ const scratchVector = new _core.Vector3();
43
31
 
44
32
  function defined(x) {
45
33
  return x !== undefined && x !== null;
46
34
  }
47
35
 
48
- var TileHeader = function () {
49
- function TileHeader(tileset, header, parentHeader) {
50
- var extendedId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
51
- (0, _classCallCheck2.default)(this, TileHeader);
36
+ class TileHeader {
37
+ constructor(tileset, header, parentHeader, extendedId = '') {
52
38
  (0, _defineProperty2.default)(this, "tileset", void 0);
53
39
  (0, _defineProperty2.default)(this, "header", void 0);
54
40
  (0, _defineProperty2.default)(this, "id", void 0);
@@ -150,454 +136,375 @@ var TileHeader = function () {
150
136
  Object.seal(this);
151
137
  }
152
138
 
153
- (0, _createClass2.default)(TileHeader, [{
154
- key: "destroy",
155
- value: function destroy() {
156
- this.header = null;
157
- }
158
- }, {
159
- key: "isDestroyed",
160
- value: function isDestroyed() {
161
- return this.header === null;
162
- }
163
- }, {
164
- key: "selected",
165
- get: function get() {
166
- return this._selectedFrame === this.tileset._frameNumber;
167
- }
168
- }, {
169
- key: "isVisible",
170
- get: function get() {
171
- return this._visible;
172
- }
173
- }, {
174
- key: "isVisibleAndInRequestVolume",
175
- get: function get() {
176
- return this._visible && this._inRequestVolume;
177
- }
178
- }, {
179
- key: "hasRenderContent",
180
- get: function get() {
181
- return !this.hasEmptyContent && !this.hasTilesetContent;
182
- }
183
- }, {
184
- key: "hasChildren",
185
- get: function get() {
186
- return this.children.length > 0 || this.header.children && this.header.children.length > 0;
187
- }
188
- }, {
189
- key: "contentReady",
190
- get: function get() {
191
- return this.contentState === _constants.TILE_CONTENT_STATE.READY || this.hasEmptyContent;
192
- }
193
- }, {
194
- key: "contentAvailable",
195
- get: function get() {
196
- return Boolean(this.contentReady && this.hasRenderContent || this._expiredContent && !this.contentFailed);
197
- }
198
- }, {
199
- key: "hasUnloadedContent",
200
- get: function get() {
201
- return this.hasRenderContent && this.contentUnloaded;
202
- }
203
- }, {
204
- key: "contentUnloaded",
205
- get: function get() {
206
- return this.contentState === _constants.TILE_CONTENT_STATE.UNLOADED;
139
+ destroy() {
140
+ this.header = null;
141
+ }
142
+
143
+ isDestroyed() {
144
+ return this.header === null;
145
+ }
146
+
147
+ get selected() {
148
+ return this._selectedFrame === this.tileset._frameNumber;
149
+ }
150
+
151
+ get isVisible() {
152
+ return this._visible;
153
+ }
154
+
155
+ get isVisibleAndInRequestVolume() {
156
+ return this._visible && this._inRequestVolume;
157
+ }
158
+
159
+ get hasRenderContent() {
160
+ return !this.hasEmptyContent && !this.hasTilesetContent;
161
+ }
162
+
163
+ get hasChildren() {
164
+ return this.children.length > 0 || this.header.children && this.header.children.length > 0;
165
+ }
166
+
167
+ get contentReady() {
168
+ return this.contentState === _constants.TILE_CONTENT_STATE.READY || this.hasEmptyContent;
169
+ }
170
+
171
+ get contentAvailable() {
172
+ return Boolean(this.contentReady && this.hasRenderContent || this._expiredContent && !this.contentFailed);
173
+ }
174
+
175
+ get hasUnloadedContent() {
176
+ return this.hasRenderContent && this.contentUnloaded;
177
+ }
178
+
179
+ get contentUnloaded() {
180
+ return this.contentState === _constants.TILE_CONTENT_STATE.UNLOADED;
181
+ }
182
+
183
+ get contentExpired() {
184
+ return this.contentState === _constants.TILE_CONTENT_STATE.EXPIRED;
185
+ }
186
+
187
+ get contentFailed() {
188
+ return this.contentState === _constants.TILE_CONTENT_STATE.FAILED;
189
+ }
190
+
191
+ getScreenSpaceError(frameState, useParentLodMetric) {
192
+ switch (this.tileset.type) {
193
+ case _constants.TILESET_TYPE.I3S:
194
+ return (0, _i3sLod.getI3ScreenSize)(this, frameState);
195
+
196
+ case _constants.TILESET_TYPE.TILES3D:
197
+ return (0, _tiles3dLod.getTiles3DScreenSpaceError)(this, frameState, useParentLodMetric);
198
+
199
+ default:
200
+ throw new Error('Unsupported tileset type');
207
201
  }
208
- }, {
209
- key: "contentExpired",
210
- get: function get() {
211
- return this.contentState === _constants.TILE_CONTENT_STATE.EXPIRED;
202
+ }
203
+
204
+ _getPriority() {
205
+ const traverser = this.tileset._traverser;
206
+ const {
207
+ skipLevelOfDetail
208
+ } = traverser.options;
209
+ const maySkipTile = this.refine === _constants.TILE_REFINEMENT.ADD || skipLevelOfDetail;
210
+
211
+ if (maySkipTile && !this.isVisible && this._visible !== undefined) {
212
+ return -1;
212
213
  }
213
- }, {
214
- key: "contentFailed",
215
- get: function get() {
216
- return this.contentState === _constants.TILE_CONTENT_STATE.FAILED;
214
+
215
+ if (this.tileset._frameNumber - this._touchedFrame >= 1) {
216
+ return -1;
217
217
  }
218
- }, {
219
- key: "getScreenSpaceError",
220
- value: function getScreenSpaceError(frameState, useParentLodMetric) {
221
- switch (this.tileset.type) {
222
- case _constants.TILESET_TYPE.I3S:
223
- return (0, _i3sLod.getI3ScreenSize)(this, frameState);
224
-
225
- case _constants.TILESET_TYPE.TILES3D:
226
- return (0, _tiles3dLod.getTiles3DScreenSpaceError)(this, frameState, useParentLodMetric);
227
-
228
- default:
229
- throw new Error('Unsupported tileset type');
230
- }
218
+
219
+ if (this.contentState === _constants.TILE_CONTENT_STATE.UNLOADED) {
220
+ return -1;
231
221
  }
232
- }, {
233
- key: "_getPriority",
234
- value: function _getPriority() {
235
- var traverser = this.tileset._traverser;
236
- var skipLevelOfDetail = traverser.options.skipLevelOfDetail;
237
- var maySkipTile = this.refine === _constants.TILE_REFINEMENT.ADD || skipLevelOfDetail;
238
-
239
- if (maySkipTile && !this.isVisible && this._visible !== undefined) {
240
- return -1;
241
- }
242
222
 
243
- if (this.tileset._frameNumber - this._touchedFrame >= 1) {
244
- return -1;
245
- }
223
+ const parent = this.parent;
224
+ const useParentScreenSpaceError = parent && (!maySkipTile || this._screenSpaceError === 0.0 || parent.hasTilesetContent);
225
+ const screenSpaceError = useParentScreenSpaceError ? parent._screenSpaceError : this._screenSpaceError;
226
+ const rootScreenSpaceError = traverser.root ? traverser.root._screenSpaceError : 0.0;
227
+ return Math.max(rootScreenSpaceError - screenSpaceError, 0);
228
+ }
246
229
 
247
- if (this.contentState === _constants.TILE_CONTENT_STATE.UNLOADED) {
248
- return -1;
249
- }
230
+ async loadContent() {
231
+ if (this.hasEmptyContent) {
232
+ return false;
233
+ }
250
234
 
251
- var parent = this.parent;
252
- var useParentScreenSpaceError = parent && (!maySkipTile || this._screenSpaceError === 0.0 || parent.hasTilesetContent);
253
- var screenSpaceError = useParentScreenSpaceError ? parent._screenSpaceError : this._screenSpaceError;
254
- var rootScreenSpaceError = traverser.root ? traverser.root._screenSpaceError : 0.0;
255
- return Math.max(rootScreenSpaceError - screenSpaceError, 0);
235
+ if (this.content) {
236
+ return true;
256
237
  }
257
- }, {
258
- key: "loadContent",
259
- value: function () {
260
- var _loadContent = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee() {
261
- var expired, requestToken, contentUrl, loader, options;
262
- return _regenerator.default.wrap(function _callee$(_context) {
263
- while (1) {
264
- switch (_context.prev = _context.next) {
265
- case 0:
266
- if (!this.hasEmptyContent) {
267
- _context.next = 2;
268
- break;
269
- }
270
-
271
- return _context.abrupt("return", false);
272
-
273
- case 2:
274
- if (!this.content) {
275
- _context.next = 4;
276
- break;
277
- }
278
-
279
- return _context.abrupt("return", true);
280
-
281
- case 4:
282
- expired = this.contentExpired;
283
-
284
- if (expired) {
285
- this._expireDate = null;
286
- }
287
-
288
- this.contentState = _constants.TILE_CONTENT_STATE.LOADING;
289
- _context.next = 9;
290
- return this.tileset._requestScheduler.scheduleRequest(this.id, this._getPriority.bind(this));
291
-
292
- case 9:
293
- requestToken = _context.sent;
294
-
295
- if (requestToken) {
296
- _context.next = 13;
297
- break;
298
- }
299
-
300
- this.contentState = _constants.TILE_CONTENT_STATE.UNLOADED;
301
- return _context.abrupt("return", false);
302
-
303
- case 13:
304
- _context.prev = 13;
305
- contentUrl = this.tileset.getTileUrl(this.contentUrl);
306
- loader = this.tileset.loader;
307
- options = _objectSpread(_objectSpread({}, this.tileset.loadOptions), {}, (0, _defineProperty2.default)({}, loader.id, _objectSpread(_objectSpread({}, this.tileset.loadOptions[loader.id]), {}, {
308
- isTileset: this.type === 'json'
309
- }, this._getLoaderSpecificOptions(loader.id))));
310
- _context.next = 19;
311
- return (0, _core2.load)(contentUrl, loader, options);
312
-
313
- case 19:
314
- this.content = _context.sent;
315
-
316
- if (!this.tileset.options.contentLoader) {
317
- _context.next = 23;
318
- break;
319
- }
320
-
321
- _context.next = 23;
322
- return this.tileset.options.contentLoader(this);
323
-
324
- case 23:
325
- if (this._isTileset()) {
326
- this.tileset._initializeTileHeaders(this.content, this);
327
- }
328
-
329
- this.contentState = _constants.TILE_CONTENT_STATE.READY;
330
-
331
- this._onContentLoaded();
332
-
333
- return _context.abrupt("return", true);
334
-
335
- case 29:
336
- _context.prev = 29;
337
- _context.t0 = _context["catch"](13);
338
- this.contentState = _constants.TILE_CONTENT_STATE.FAILED;
339
- throw _context.t0;
340
-
341
- case 33:
342
- _context.prev = 33;
343
- requestToken.done();
344
- return _context.finish(33);
345
-
346
- case 36:
347
- case "end":
348
- return _context.stop();
349
- }
350
- }
351
- }, _callee, this, [[13, 29, 33, 36]]);
352
- }));
353
-
354
- function loadContent() {
355
- return _loadContent.apply(this, arguments);
356
- }
357
238
 
358
- return loadContent;
359
- }()
360
- }, {
361
- key: "unloadContent",
362
- value: function unloadContent() {
363
- if (this.content && this.content.destroy) {
364
- this.content.destroy();
365
- }
239
+ const expired = this.contentExpired;
366
240
 
367
- this.content = null;
241
+ if (expired) {
242
+ this._expireDate = null;
243
+ }
368
244
 
369
- if (this.header.content && this.header.content.destroy) {
370
- this.header.content.destroy();
371
- }
245
+ this.contentState = _constants.TILE_CONTENT_STATE.LOADING;
246
+ const requestToken = await this.tileset._requestScheduler.scheduleRequest(this.id, this._getPriority.bind(this));
372
247
 
373
- this.header.content = null;
248
+ if (!requestToken) {
374
249
  this.contentState = _constants.TILE_CONTENT_STATE.UNLOADED;
375
- return true;
250
+ return false;
376
251
  }
377
- }, {
378
- key: "updateVisibility",
379
- value: function updateVisibility(frameState, viewportIds) {
380
- if (this._frameNumber === frameState.frameNumber) {
381
- return;
382
- }
383
252
 
384
- var parent = this.parent;
385
- var parentVisibilityPlaneMask = parent ? parent._visibilityPlaneMask : _culling.CullingVolume.MASK_INDETERMINATE;
253
+ try {
254
+ const contentUrl = this.tileset.getTileUrl(this.contentUrl);
255
+ const loader = this.tileset.loader;
256
+ const options = { ...this.tileset.loadOptions,
257
+ [loader.id]: { ...this.tileset.loadOptions[loader.id],
258
+ isTileset: this.type === 'json',
259
+ ...this._getLoaderSpecificOptions(loader.id)
260
+ }
261
+ };
262
+ this.content = await (0, _core2.load)(contentUrl, loader, options);
386
263
 
387
- if (this.tileset._traverser.options.updateTransforms) {
388
- var parentTransform = parent ? parent.computedTransform : this.tileset.modelMatrix;
264
+ if (this.tileset.options.contentLoader) {
265
+ await this.tileset.options.contentLoader(this);
266
+ }
389
267
 
390
- this._updateTransform(parentTransform);
268
+ if (this._isTileset()) {
269
+ this.tileset._initializeTileHeaders(this.content, this);
391
270
  }
392
271
 
393
- this._distanceToCamera = this.distanceToTile(frameState);
394
- this._screenSpaceError = this.getScreenSpaceError(frameState, false);
395
- this._visibilityPlaneMask = this.visibility(frameState, parentVisibilityPlaneMask);
396
- this._visible = this._visibilityPlaneMask !== _culling.CullingVolume.MASK_OUTSIDE;
397
- this._inRequestVolume = this.insideViewerRequestVolume(frameState);
398
- this._frameNumber = frameState.frameNumber;
399
- this.viewportIds = viewportIds;
400
- }
401
- }, {
402
- key: "visibility",
403
- value: function visibility(frameState, parentVisibilityPlaneMask) {
404
- var cullingVolume = frameState.cullingVolume;
405
- var boundingVolume = this.boundingVolume;
406
- return cullingVolume.computeVisibilityWithPlaneMask(boundingVolume, parentVisibilityPlaneMask);
407
- }
408
- }, {
409
- key: "contentVisibility",
410
- value: function contentVisibility() {
272
+ this.contentState = _constants.TILE_CONTENT_STATE.READY;
273
+
274
+ this._onContentLoaded();
275
+
411
276
  return true;
277
+ } catch (error) {
278
+ this.contentState = _constants.TILE_CONTENT_STATE.FAILED;
279
+ throw error;
280
+ } finally {
281
+ requestToken.done();
412
282
  }
413
- }, {
414
- key: "distanceToTile",
415
- value: function distanceToTile(frameState) {
416
- var boundingVolume = this.boundingVolume;
417
- return Math.sqrt(Math.max(boundingVolume.distanceSquaredTo(frameState.camera.position), 0));
418
- }
419
- }, {
420
- key: "cameraSpaceZDepth",
421
- value: function cameraSpaceZDepth(_ref) {
422
- var camera = _ref.camera;
423
- var boundingVolume = this.boundingVolume;
424
- scratchVector.subVectors(boundingVolume.center, camera.position);
425
- return camera.direction.dot(scratchVector);
283
+ }
284
+
285
+ unloadContent() {
286
+ if (this.content && this.content.destroy) {
287
+ this.content.destroy();
426
288
  }
427
- }, {
428
- key: "insideViewerRequestVolume",
429
- value: function insideViewerRequestVolume(frameState) {
430
- var viewerRequestVolume = this._viewerRequestVolume;
431
- return !viewerRequestVolume || viewerRequestVolume.distanceSquaredTo(frameState.camera.position) <= 0;
289
+
290
+ this.content = null;
291
+
292
+ if (this.header.content && this.header.content.destroy) {
293
+ this.header.content.destroy();
432
294
  }
433
- }, {
434
- key: "updateExpiration",
435
- value: function updateExpiration() {
436
- if (defined(this._expireDate) && this.contentReady && !this.hasEmptyContent) {
437
- var now = Date.now();
438
-
439
- if (Date.lessThan(this._expireDate, now)) {
440
- this.contentState = _constants.TILE_CONTENT_STATE.EXPIRED;
441
- this._expiredContent = this.content;
442
- }
443
- }
295
+
296
+ this.header.content = null;
297
+ this.contentState = _constants.TILE_CONTENT_STATE.UNLOADED;
298
+ return true;
299
+ }
300
+
301
+ updateVisibility(frameState, viewportIds) {
302
+ if (this._frameNumber === frameState.frameNumber) {
303
+ return;
444
304
  }
445
- }, {
446
- key: "extras",
447
- get: function get() {
448
- return this.header.extras;
305
+
306
+ const parent = this.parent;
307
+ const parentVisibilityPlaneMask = parent ? parent._visibilityPlaneMask : _culling.CullingVolume.MASK_INDETERMINATE;
308
+
309
+ if (this.tileset._traverser.options.updateTransforms) {
310
+ const parentTransform = parent ? parent.computedTransform : this.tileset.modelMatrix;
311
+
312
+ this._updateTransform(parentTransform);
449
313
  }
450
- }, {
451
- key: "_initializeLodMetric",
452
- value: function _initializeLodMetric(header) {
453
- if ('lodMetricType' in header) {
454
- this.lodMetricType = header.lodMetricType;
455
- } else {
456
- this.lodMetricType = this.parent && this.parent.lodMetricType || this.tileset.lodMetricType;
457
- console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType");
458
- }
459
314
 
460
- if ('lodMetricValue' in header) {
461
- this.lodMetricValue = header.lodMetricValue;
462
- } else {
463
- this.lodMetricValue = this.parent && this.parent.lodMetricValue || this.tileset.lodMetricValue;
464
- console.warn('3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue');
315
+ this._distanceToCamera = this.distanceToTile(frameState);
316
+ this._screenSpaceError = this.getScreenSpaceError(frameState, false);
317
+ this._visibilityPlaneMask = this.visibility(frameState, parentVisibilityPlaneMask);
318
+ this._visible = this._visibilityPlaneMask !== _culling.CullingVolume.MASK_OUTSIDE;
319
+ this._inRequestVolume = this.insideViewerRequestVolume(frameState);
320
+ this._frameNumber = frameState.frameNumber;
321
+ this.viewportIds = viewportIds;
322
+ }
323
+
324
+ visibility(frameState, parentVisibilityPlaneMask) {
325
+ const {
326
+ cullingVolume
327
+ } = frameState;
328
+ const {
329
+ boundingVolume
330
+ } = this;
331
+ return cullingVolume.computeVisibilityWithPlaneMask(boundingVolume, parentVisibilityPlaneMask);
332
+ }
333
+
334
+ contentVisibility() {
335
+ return true;
336
+ }
337
+
338
+ distanceToTile(frameState) {
339
+ const boundingVolume = this.boundingVolume;
340
+ return Math.sqrt(Math.max(boundingVolume.distanceSquaredTo(frameState.camera.position), 0));
341
+ }
342
+
343
+ cameraSpaceZDepth({
344
+ camera
345
+ }) {
346
+ const boundingVolume = this.boundingVolume;
347
+ scratchVector.subVectors(boundingVolume.center, camera.position);
348
+ return camera.direction.dot(scratchVector);
349
+ }
350
+
351
+ insideViewerRequestVolume(frameState) {
352
+ const viewerRequestVolume = this._viewerRequestVolume;
353
+ return !viewerRequestVolume || viewerRequestVolume.distanceSquaredTo(frameState.camera.position) <= 0;
354
+ }
355
+
356
+ updateExpiration() {
357
+ if (defined(this._expireDate) && this.contentReady && !this.hasEmptyContent) {
358
+ const now = Date.now();
359
+
360
+ if (Date.lessThan(this._expireDate, now)) {
361
+ this.contentState = _constants.TILE_CONTENT_STATE.EXPIRED;
362
+ this._expiredContent = this.content;
465
363
  }
466
364
  }
467
- }, {
468
- key: "_initializeTransforms",
469
- value: function _initializeTransforms(tileHeader) {
470
- this.transform = tileHeader.transform ? new _core.Matrix4(tileHeader.transform) : new _core.Matrix4();
471
- var parent = this.parent;
472
- var tileset = this.tileset;
473
- var parentTransform = parent && parent.computedTransform ? parent.computedTransform.clone() : tileset.modelMatrix.clone();
474
- this.computedTransform = new _core.Matrix4(parentTransform).multiplyRight(this.transform);
475
- var parentInitialTransform = parent && parent._initialTransform ? parent._initialTransform.clone() : new _core.Matrix4();
476
- this._initialTransform = new _core.Matrix4(parentInitialTransform).multiplyRight(this.transform);
477
- }
478
- }, {
479
- key: "_initializeBoundingVolumes",
480
- value: function _initializeBoundingVolumes(tileHeader) {
481
- this._contentBoundingVolume = null;
482
- this._viewerRequestVolume = null;
365
+ }
483
366
 
484
- this._updateBoundingVolume(tileHeader);
367
+ get extras() {
368
+ return this.header.extras;
369
+ }
370
+
371
+ _initializeLodMetric(header) {
372
+ if ('lodMetricType' in header) {
373
+ this.lodMetricType = header.lodMetricType;
374
+ } else {
375
+ this.lodMetricType = this.parent && this.parent.lodMetricType || this.tileset.lodMetricType;
376
+ console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType");
485
377
  }
486
- }, {
487
- key: "_initializeContent",
488
- value: function _initializeContent(tileHeader) {
489
- this.content = {
490
- _tileset: this.tileset,
491
- _tile: this
492
- };
493
- this.hasEmptyContent = true;
494
- this.contentState = _constants.TILE_CONTENT_STATE.UNLOADED;
495
- this.hasTilesetContent = false;
496
378
 
497
- if (tileHeader.contentUrl) {
498
- this.content = null;
499
- this.hasEmptyContent = false;
500
- }
379
+ if ('lodMetricValue' in header) {
380
+ this.lodMetricValue = header.lodMetricValue;
381
+ } else {
382
+ this.lodMetricValue = this.parent && this.parent.lodMetricValue || this.tileset.lodMetricValue;
383
+ console.warn('3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue');
501
384
  }
502
- }, {
503
- key: "_initializeRenderingState",
504
- value: function _initializeRenderingState(header) {
505
- this.depth = header.level || (this.parent ? this.parent.depth + 1 : 0);
506
- this._shouldRefine = false;
507
- this._distanceToCamera = 0;
508
- this._centerZDepth = 0;
509
- this._screenSpaceError = 0;
510
- this._visibilityPlaneMask = _culling.CullingVolume.MASK_INDETERMINATE;
511
- this._visible = undefined;
512
- this._inRequestVolume = false;
513
- this._stackLength = 0;
514
- this._selectionDepth = 0;
515
- this._frameNumber = 0;
516
- this._touchedFrame = 0;
517
- this._visitedFrame = 0;
518
- this._selectedFrame = 0;
519
- this._requestedFrame = 0;
520
- this._priority = 0.0;
385
+ }
386
+
387
+ _initializeTransforms(tileHeader) {
388
+ this.transform = tileHeader.transform ? new _core.Matrix4(tileHeader.transform) : new _core.Matrix4();
389
+ const parent = this.parent;
390
+ const tileset = this.tileset;
391
+ const parentTransform = parent && parent.computedTransform ? parent.computedTransform.clone() : tileset.modelMatrix.clone();
392
+ this.computedTransform = new _core.Matrix4(parentTransform).multiplyRight(this.transform);
393
+ const parentInitialTransform = parent && parent._initialTransform ? parent._initialTransform.clone() : new _core.Matrix4();
394
+ this._initialTransform = new _core.Matrix4(parentInitialTransform).multiplyRight(this.transform);
395
+ }
396
+
397
+ _initializeBoundingVolumes(tileHeader) {
398
+ this._contentBoundingVolume = null;
399
+ this._viewerRequestVolume = null;
400
+
401
+ this._updateBoundingVolume(tileHeader);
402
+ }
403
+
404
+ _initializeContent(tileHeader) {
405
+ this.content = {
406
+ _tileset: this.tileset,
407
+ _tile: this
408
+ };
409
+ this.hasEmptyContent = true;
410
+ this.contentState = _constants.TILE_CONTENT_STATE.UNLOADED;
411
+ this.hasTilesetContent = false;
412
+
413
+ if (tileHeader.contentUrl) {
414
+ this.content = null;
415
+ this.hasEmptyContent = false;
521
416
  }
522
- }, {
523
- key: "_getRefine",
524
- value: function _getRefine(refine) {
525
- return refine || this.parent && this.parent.refine || _constants.TILE_REFINEMENT.REPLACE;
417
+ }
418
+
419
+ _initializeRenderingState(header) {
420
+ this.depth = header.level || (this.parent ? this.parent.depth + 1 : 0);
421
+ this._shouldRefine = false;
422
+ this._distanceToCamera = 0;
423
+ this._centerZDepth = 0;
424
+ this._screenSpaceError = 0;
425
+ this._visibilityPlaneMask = _culling.CullingVolume.MASK_INDETERMINATE;
426
+ this._visible = undefined;
427
+ this._inRequestVolume = false;
428
+ this._stackLength = 0;
429
+ this._selectionDepth = 0;
430
+ this._frameNumber = 0;
431
+ this._touchedFrame = 0;
432
+ this._visitedFrame = 0;
433
+ this._selectedFrame = 0;
434
+ this._requestedFrame = 0;
435
+ this._priority = 0.0;
436
+ }
437
+
438
+ _getRefine(refine) {
439
+ return refine || this.parent && this.parent.refine || _constants.TILE_REFINEMENT.REPLACE;
440
+ }
441
+
442
+ _isTileset() {
443
+ return this.contentUrl.indexOf('.json') !== -1;
444
+ }
445
+
446
+ _onContentLoaded() {
447
+ switch (this.content && this.content.type) {
448
+ case 'vctr':
449
+ case 'geom':
450
+ this.tileset._traverser.disableSkipLevelOfDetail = true;
451
+ break;
452
+
453
+ default:
526
454
  }
527
- }, {
528
- key: "_isTileset",
529
- value: function _isTileset() {
530
- return this.contentUrl.indexOf('.json') !== -1;
455
+
456
+ if (this._isTileset()) {
457
+ this.hasTilesetContent = true;
531
458
  }
532
- }, {
533
- key: "_onContentLoaded",
534
- value: function _onContentLoaded() {
535
- switch (this.content && this.content.type) {
536
- case 'vctr':
537
- case 'geom':
538
- this.tileset._traverser.disableSkipLevelOfDetail = true;
539
- break;
540
-
541
- default:
542
- }
459
+ }
543
460
 
544
- if (this._isTileset()) {
545
- this.hasTilesetContent = true;
546
- }
461
+ _updateBoundingVolume(header) {
462
+ this.boundingVolume = (0, _boundingVolume.createBoundingVolume)(header.boundingVolume, this.computedTransform, this.boundingVolume);
463
+ const content = header.content;
464
+
465
+ if (!content) {
466
+ return;
547
467
  }
548
- }, {
549
- key: "_updateBoundingVolume",
550
- value: function _updateBoundingVolume(header) {
551
- this.boundingVolume = (0, _boundingVolume.createBoundingVolume)(header.boundingVolume, this.computedTransform, this.boundingVolume);
552
- var content = header.content;
553
-
554
- if (!content) {
555
- return;
556
- }
557
468
 
558
- if (content.boundingVolume) {
559
- this._contentBoundingVolume = (0, _boundingVolume.createBoundingVolume)(content.boundingVolume, this.computedTransform, this._contentBoundingVolume);
560
- }
469
+ if (content.boundingVolume) {
470
+ this._contentBoundingVolume = (0, _boundingVolume.createBoundingVolume)(content.boundingVolume, this.computedTransform, this._contentBoundingVolume);
471
+ }
561
472
 
562
- if (header.viewerRequestVolume) {
563
- this._viewerRequestVolume = (0, _boundingVolume.createBoundingVolume)(header.viewerRequestVolume, this.computedTransform, this._viewerRequestVolume);
564
- }
473
+ if (header.viewerRequestVolume) {
474
+ this._viewerRequestVolume = (0, _boundingVolume.createBoundingVolume)(header.viewerRequestVolume, this.computedTransform, this._viewerRequestVolume);
565
475
  }
566
- }, {
567
- key: "_updateTransform",
568
- value: function _updateTransform() {
569
- var parentTransform = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new _core.Matrix4();
570
- var computedTransform = parentTransform.clone().multiplyRight(this.transform);
571
- var didTransformChange = !computedTransform.equals(this.computedTransform);
572
-
573
- if (!didTransformChange) {
574
- return;
575
- }
476
+ }
576
477
 
577
- this.computedTransform = computedTransform;
478
+ _updateTransform(parentTransform = new _core.Matrix4()) {
479
+ const computedTransform = parentTransform.clone().multiplyRight(this.transform);
480
+ const didTransformChange = !computedTransform.equals(this.computedTransform);
578
481
 
579
- this._updateBoundingVolume(this.header);
482
+ if (!didTransformChange) {
483
+ return;
580
484
  }
581
- }, {
582
- key: "_getLoaderSpecificOptions",
583
- value: function _getLoaderSpecificOptions(loaderId) {
584
- switch (loaderId) {
585
- case 'i3s':
586
- return _objectSpread(_objectSpread({}, this.tileset.options.i3s), {}, {
587
- tile: this.header,
588
- tileset: this.tileset.tileset,
589
- isTileHeader: false
590
- });
591
-
592
- case '3d-tiles':
593
- case 'cesium-ion':
594
- default:
595
- return (0, _dTilesOptions.get3dTilesOptions)(this.tileset.tileset);
596
- }
485
+
486
+ this.computedTransform = computedTransform;
487
+
488
+ this._updateBoundingVolume(this.header);
489
+ }
490
+
491
+ _getLoaderSpecificOptions(loaderId) {
492
+ switch (loaderId) {
493
+ case 'i3s':
494
+ return { ...this.tileset.options.i3s,
495
+ tile: this.header,
496
+ tileset: this.tileset.tileset,
497
+ isTileHeader: false
498
+ };
499
+
500
+ case '3d-tiles':
501
+ case 'cesium-ion':
502
+ default:
503
+ return (0, _dTilesOptions.get3dTilesOptions)(this.tileset.tileset);
597
504
  }
598
- }]);
599
- return TileHeader;
600
- }();
505
+ }
506
+
507
+ }
601
508
 
602
509
  exports.default = TileHeader;
603
510
  //# sourceMappingURL=tile-3d.js.map