@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,10 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.Tile3D = void 0;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
9
  var _core = require("@math.gl/core");
14
10
  var _culling = require("@math.gl/culling");
@@ -19,16 +15,13 @@ var _tiles3dLod = require("./helpers/tiles-3d-lod");
19
15
  var _i3sLod = require("./helpers/i3s-lod");
20
16
  var _dTilesOptions = require("./helpers/3d-tiles-options");
21
17
  var _tilesetTraverser = require("./tileset-traverser");
22
- 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; }
23
- 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; }
24
- var scratchVector = new _core.Vector3();
18
+ const scratchVector = new _core.Vector3();
25
19
  function defined(x) {
26
20
  return x !== undefined && x !== null;
27
21
  }
28
- var Tile3D = function () {
29
- function Tile3D(tileset, header, parentHeader) {
30
- var extendedId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
31
- (0, _classCallCheck2.default)(this, Tile3D);
22
+ class Tile3D {
23
+ constructor(tileset, header, parentHeader) {
24
+ let extendedId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
32
25
  (0, _defineProperty2.default)(this, "tileset", void 0);
33
26
  (0, _defineProperty2.default)(this, "header", void 0);
34
27
  (0, _defineProperty2.default)(this, "id", void 0);
@@ -92,445 +85,338 @@ var Tile3D = function () {
92
85
  this._initializeRenderingState(header);
93
86
  Object.seal(this);
94
87
  }
95
- (0, _createClass2.default)(Tile3D, [{
96
- key: "destroy",
97
- value: function destroy() {
98
- this.header = null;
99
- }
100
- }, {
101
- key: "isDestroyed",
102
- value: function isDestroyed() {
103
- return this.header === null;
104
- }
105
- }, {
106
- key: "selected",
107
- get: function get() {
108
- return this._selectedFrame === this.tileset._frameNumber;
109
- }
110
- }, {
111
- key: "isVisible",
112
- get: function get() {
113
- return this._visible;
114
- }
115
- }, {
116
- key: "isVisibleAndInRequestVolume",
117
- get: function get() {
118
- return this._visible && this._inRequestVolume;
119
- }
120
- }, {
121
- key: "hasRenderContent",
122
- get: function get() {
123
- return !this.hasEmptyContent && !this.hasTilesetContent;
124
- }
125
- }, {
126
- key: "hasChildren",
127
- get: function get() {
128
- return this.children.length > 0 || this.header.children && this.header.children.length > 0;
129
- }
130
- }, {
131
- key: "contentReady",
132
- get: function get() {
133
- return this.contentState === _constants.TILE_CONTENT_STATE.READY || this.hasEmptyContent;
134
- }
135
- }, {
136
- key: "contentAvailable",
137
- get: function get() {
138
- return Boolean(this.contentReady && this.hasRenderContent || this._expiredContent && !this.contentFailed);
139
- }
140
- }, {
141
- key: "hasUnloadedContent",
142
- get: function get() {
143
- return this.hasRenderContent && this.contentUnloaded;
144
- }
145
- }, {
146
- key: "contentUnloaded",
147
- get: function get() {
148
- return this.contentState === _constants.TILE_CONTENT_STATE.UNLOADED;
149
- }
150
- }, {
151
- key: "contentExpired",
152
- get: function get() {
153
- return this.contentState === _constants.TILE_CONTENT_STATE.EXPIRED;
154
- }
155
- }, {
156
- key: "contentFailed",
157
- get: function get() {
158
- return this.contentState === _constants.TILE_CONTENT_STATE.FAILED;
159
- }
160
- }, {
161
- key: "distanceToCamera",
162
- get: function get() {
163
- return this._distanceToCamera;
164
- }
165
- }, {
166
- key: "screenSpaceError",
167
- get: function get() {
168
- return this._screenSpaceError;
169
- }
170
- }, {
171
- key: "boundingBox",
172
- get: function get() {
173
- if (!this._boundingBox) {
174
- this._boundingBox = (0, _boundingVolume.getCartographicBounds)(this.header.boundingVolume, this.boundingVolume);
175
- }
176
- return this._boundingBox;
177
- }
178
- }, {
179
- key: "getScreenSpaceError",
180
- value: function getScreenSpaceError(frameState, useParentLodMetric) {
181
- switch (this.tileset.type) {
182
- case _constants.TILESET_TYPE.I3S:
183
- return (0, _i3sLod.getProjectedRadius)(this, frameState);
184
- case _constants.TILESET_TYPE.TILES3D:
185
- return (0, _tiles3dLod.getTiles3DScreenSpaceError)(this, frameState, useParentLodMetric);
186
- default:
187
- throw new Error('Unsupported tileset type');
188
- }
189
- }
190
- }, {
191
- key: "unselect",
192
- value: function unselect() {
193
- this._selectedFrame = 0;
194
- }
195
- }, {
196
- key: "_getGpuMemoryUsageInBytes",
197
- value: function _getGpuMemoryUsageInBytes() {
198
- return this.content.gpuMemoryUsageInBytes || this.content.byteLength || 0;
199
- }
200
- }, {
201
- key: "_getPriority",
202
- value: function _getPriority() {
203
- var traverser = this.tileset._traverser;
204
- var skipLevelOfDetail = traverser.options.skipLevelOfDetail;
205
- var maySkipTile = this.refine === _constants.TILE_REFINEMENT.ADD || skipLevelOfDetail;
206
- if (maySkipTile && !this.isVisible && this._visible !== undefined) {
207
- return -1;
208
- }
209
- if (this.tileset._frameNumber - this._touchedFrame >= 1) {
210
- return -1;
211
- }
212
- if (this.contentState === _constants.TILE_CONTENT_STATE.UNLOADED) {
213
- return -1;
214
- }
215
- var parent = this.parent;
216
- var useParentScreenSpaceError = parent && (!maySkipTile || this._screenSpaceError === 0.0 || parent.hasTilesetContent);
217
- var screenSpaceError = useParentScreenSpaceError ? parent._screenSpaceError : this._screenSpaceError;
218
- var rootScreenSpaceError = traverser.root ? traverser.root._screenSpaceError : 0.0;
219
- return Math.max(rootScreenSpaceError - screenSpaceError, 0);
220
- }
221
- }, {
222
- key: "loadContent",
223
- value: function () {
224
- var _loadContent = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee() {
225
- var expired, requestToken, contentUrl, loader, options;
226
- return _regenerator.default.wrap(function _callee$(_context) {
227
- while (1) switch (_context.prev = _context.next) {
228
- case 0:
229
- if (!this.hasEmptyContent) {
230
- _context.next = 2;
231
- break;
232
- }
233
- return _context.abrupt("return", false);
234
- case 2:
235
- if (!this.content) {
236
- _context.next = 4;
237
- break;
238
- }
239
- return _context.abrupt("return", true);
240
- case 4:
241
- expired = this.contentExpired;
242
- if (expired) {
243
- this._expireDate = null;
244
- }
245
- this.contentState = _constants.TILE_CONTENT_STATE.LOADING;
246
- _context.next = 9;
247
- return this.tileset._requestScheduler.scheduleRequest(this.id, this._getPriority.bind(this));
248
- case 9:
249
- requestToken = _context.sent;
250
- if (requestToken) {
251
- _context.next = 13;
252
- break;
253
- }
254
- this.contentState = _constants.TILE_CONTENT_STATE.UNLOADED;
255
- return _context.abrupt("return", false);
256
- case 13:
257
- _context.prev = 13;
258
- contentUrl = this.tileset.getTileUrl(this.contentUrl);
259
- loader = this.tileset.loader;
260
- options = _objectSpread(_objectSpread({}, this.tileset.loadOptions), {}, (0, _defineProperty2.default)({}, loader.id, _objectSpread(_objectSpread({}, this.tileset.loadOptions[loader.id]), {}, {
261
- isTileset: this.type === 'json'
262
- }, this._getLoaderSpecificOptions(loader.id))));
263
- _context.next = 19;
264
- return (0, _core2.load)(contentUrl, loader, options);
265
- case 19:
266
- this.content = _context.sent;
267
- if (!this.tileset.options.contentLoader) {
268
- _context.next = 23;
269
- break;
270
- }
271
- _context.next = 23;
272
- return this.tileset.options.contentLoader(this);
273
- case 23:
274
- if (this._isTileset()) {
275
- this.tileset._initializeTileHeaders(this.content, this);
276
- }
277
- this.contentState = _constants.TILE_CONTENT_STATE.READY;
278
- this._onContentLoaded();
279
- return _context.abrupt("return", true);
280
- case 29:
281
- _context.prev = 29;
282
- _context.t0 = _context["catch"](13);
283
- this.contentState = _constants.TILE_CONTENT_STATE.FAILED;
284
- throw _context.t0;
285
- case 33:
286
- _context.prev = 33;
287
- requestToken.done();
288
- return _context.finish(33);
289
- case 36:
290
- case "end":
291
- return _context.stop();
292
- }
293
- }, _callee, this, [[13, 29, 33, 36]]);
294
- }));
295
- function loadContent() {
296
- return _loadContent.apply(this, arguments);
297
- }
298
- return loadContent;
299
- }()
300
- }, {
301
- key: "unloadContent",
302
- value: function unloadContent() {
303
- if (this.content && this.content.destroy) {
304
- this.content.destroy();
305
- }
306
- this.content = null;
307
- if (this.header.content && this.header.content.destroy) {
308
- this.header.content.destroy();
309
- }
310
- this.header.content = null;
311
- this.contentState = _constants.TILE_CONTENT_STATE.UNLOADED;
312
- return true;
88
+ destroy() {
89
+ this.header = null;
90
+ }
91
+ isDestroyed() {
92
+ return this.header === null;
93
+ }
94
+ get selected() {
95
+ return this._selectedFrame === this.tileset._frameNumber;
96
+ }
97
+ get isVisible() {
98
+ return this._visible;
99
+ }
100
+ get isVisibleAndInRequestVolume() {
101
+ return this._visible && this._inRequestVolume;
102
+ }
103
+ get hasRenderContent() {
104
+ return !this.hasEmptyContent && !this.hasTilesetContent;
105
+ }
106
+ get hasChildren() {
107
+ return this.children.length > 0 || this.header.children && this.header.children.length > 0;
108
+ }
109
+ get contentReady() {
110
+ return this.contentState === _constants.TILE_CONTENT_STATE.READY || this.hasEmptyContent;
111
+ }
112
+ get contentAvailable() {
113
+ return Boolean(this.contentReady && this.hasRenderContent || this._expiredContent && !this.contentFailed);
114
+ }
115
+ get hasUnloadedContent() {
116
+ return this.hasRenderContent && this.contentUnloaded;
117
+ }
118
+ get contentUnloaded() {
119
+ return this.contentState === _constants.TILE_CONTENT_STATE.UNLOADED;
120
+ }
121
+ get contentExpired() {
122
+ return this.contentState === _constants.TILE_CONTENT_STATE.EXPIRED;
123
+ }
124
+ get contentFailed() {
125
+ return this.contentState === _constants.TILE_CONTENT_STATE.FAILED;
126
+ }
127
+ get distanceToCamera() {
128
+ return this._distanceToCamera;
129
+ }
130
+ get screenSpaceError() {
131
+ return this._screenSpaceError;
132
+ }
133
+ get boundingBox() {
134
+ if (!this._boundingBox) {
135
+ this._boundingBox = (0, _boundingVolume.getCartographicBounds)(this.header.boundingVolume, this.boundingVolume);
313
136
  }
314
- }, {
315
- key: "updateVisibility",
316
- value: function updateVisibility(frameState, viewportIds) {
317
- if (this._frameNumber === frameState.frameNumber) {
318
- return;
319
- }
320
- var parent = this.parent;
321
- var parentVisibilityPlaneMask = parent ? parent._visibilityPlaneMask : _culling.CullingVolume.MASK_INDETERMINATE;
322
- if (this.tileset._traverser.options.updateTransforms) {
323
- var parentTransform = parent ? parent.computedTransform : this.tileset.modelMatrix;
324
- this._updateTransform(parentTransform);
325
- }
326
- this._distanceToCamera = this.distanceToTile(frameState);
327
- this._screenSpaceError = this.getScreenSpaceError(frameState, false);
328
- this._visibilityPlaneMask = this.visibility(frameState, parentVisibilityPlaneMask);
329
- this._visible = this._visibilityPlaneMask !== _culling.CullingVolume.MASK_OUTSIDE;
330
- this._inRequestVolume = this.insideViewerRequestVolume(frameState);
331
- this._frameNumber = frameState.frameNumber;
332
- this.viewportIds = viewportIds;
137
+ return this._boundingBox;
138
+ }
139
+ getScreenSpaceError(frameState, useParentLodMetric) {
140
+ switch (this.tileset.type) {
141
+ case _constants.TILESET_TYPE.I3S:
142
+ return (0, _i3sLod.getProjectedRadius)(this, frameState);
143
+ case _constants.TILESET_TYPE.TILES3D:
144
+ return (0, _tiles3dLod.getTiles3DScreenSpaceError)(this, frameState, useParentLodMetric);
145
+ default:
146
+ throw new Error('Unsupported tileset type');
333
147
  }
334
- }, {
335
- key: "visibility",
336
- value: function visibility(frameState, parentVisibilityPlaneMask) {
337
- var cullingVolume = frameState.cullingVolume;
338
- var boundingVolume = this.boundingVolume;
339
- return cullingVolume.computeVisibilityWithPlaneMask(boundingVolume, parentVisibilityPlaneMask);
148
+ }
149
+ unselect() {
150
+ this._selectedFrame = 0;
151
+ }
152
+ _getGpuMemoryUsageInBytes() {
153
+ return this.content.gpuMemoryUsageInBytes || this.content.byteLength || 0;
154
+ }
155
+ _getPriority() {
156
+ const traverser = this.tileset._traverser;
157
+ const {
158
+ skipLevelOfDetail
159
+ } = traverser.options;
160
+ const maySkipTile = this.refine === _constants.TILE_REFINEMENT.ADD || skipLevelOfDetail;
161
+ if (maySkipTile && !this.isVisible && this._visible !== undefined) {
162
+ return -1;
163
+ }
164
+ if (this.tileset._frameNumber - this._touchedFrame >= 1) {
165
+ return -1;
166
+ }
167
+ if (this.contentState === _constants.TILE_CONTENT_STATE.UNLOADED) {
168
+ return -1;
169
+ }
170
+ const parent = this.parent;
171
+ const useParentScreenSpaceError = parent && (!maySkipTile || this._screenSpaceError === 0.0 || parent.hasTilesetContent);
172
+ const screenSpaceError = useParentScreenSpaceError ? parent._screenSpaceError : this._screenSpaceError;
173
+ const rootScreenSpaceError = traverser.root ? traverser.root._screenSpaceError : 0.0;
174
+ return Math.max(rootScreenSpaceError - screenSpaceError, 0);
175
+ }
176
+ async loadContent() {
177
+ if (this.hasEmptyContent) {
178
+ return false;
340
179
  }
341
- }, {
342
- key: "contentVisibility",
343
- value: function contentVisibility() {
180
+ if (this.content) {
344
181
  return true;
345
182
  }
346
- }, {
347
- key: "distanceToTile",
348
- value: function distanceToTile(frameState) {
349
- var boundingVolume = this.boundingVolume;
350
- return Math.sqrt(Math.max(boundingVolume.distanceSquaredTo(frameState.camera.position), 0));
351
- }
352
- }, {
353
- key: "cameraSpaceZDepth",
354
- value: function cameraSpaceZDepth(_ref) {
355
- var camera = _ref.camera;
356
- var boundingVolume = this.boundingVolume;
357
- scratchVector.subVectors(boundingVolume.center, camera.position);
358
- return camera.direction.dot(scratchVector);
183
+ const expired = this.contentExpired;
184
+ if (expired) {
185
+ this._expireDate = null;
359
186
  }
360
- }, {
361
- key: "insideViewerRequestVolume",
362
- value: function insideViewerRequestVolume(frameState) {
363
- var viewerRequestVolume = this._viewerRequestVolume;
364
- return !viewerRequestVolume || viewerRequestVolume.distanceSquaredTo(frameState.camera.position) <= 0;
365
- }
366
- }, {
367
- key: "updateExpiration",
368
- value: function updateExpiration() {
369
- if (defined(this._expireDate) && this.contentReady && !this.hasEmptyContent) {
370
- var now = Date.now();
371
- if (Date.lessThan(this._expireDate, now)) {
372
- this.contentState = _constants.TILE_CONTENT_STATE.EXPIRED;
373
- this._expiredContent = this.content;
187
+ this.contentState = _constants.TILE_CONTENT_STATE.LOADING;
188
+ const requestToken = await this.tileset._requestScheduler.scheduleRequest(this.id, this._getPriority.bind(this));
189
+ if (!requestToken) {
190
+ this.contentState = _constants.TILE_CONTENT_STATE.UNLOADED;
191
+ return false;
192
+ }
193
+ try {
194
+ const contentUrl = this.tileset.getTileUrl(this.contentUrl);
195
+ const loader = this.tileset.loader;
196
+ const options = {
197
+ ...this.tileset.loadOptions,
198
+ [loader.id]: {
199
+ ...this.tileset.loadOptions[loader.id],
200
+ isTileset: this.type === 'json',
201
+ ...this._getLoaderSpecificOptions(loader.id)
374
202
  }
203
+ };
204
+ this.content = await (0, _core2.load)(contentUrl, loader, options);
205
+ if (this.tileset.options.contentLoader) {
206
+ await this.tileset.options.contentLoader(this);
375
207
  }
376
- }
377
- }, {
378
- key: "extras",
379
- get: function get() {
380
- return this.header.extras;
381
- }
382
- }, {
383
- key: "_initializeLodMetric",
384
- value: function _initializeLodMetric(header) {
385
- if ('lodMetricType' in header) {
386
- this.lodMetricType = header.lodMetricType;
387
- } else {
388
- this.lodMetricType = this.parent && this.parent.lodMetricType || this.tileset.lodMetricType;
389
- console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType");
390
- }
391
- if ('lodMetricValue' in header) {
392
- this.lodMetricValue = header.lodMetricValue;
393
- } else {
394
- this.lodMetricValue = this.parent && this.parent.lodMetricValue || this.tileset.lodMetricValue;
395
- console.warn('3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue');
208
+ if (this._isTileset()) {
209
+ this.tileset._initializeTileHeaders(this.content, this);
396
210
  }
211
+ this.contentState = _constants.TILE_CONTENT_STATE.READY;
212
+ this._onContentLoaded();
213
+ return true;
214
+ } catch (error) {
215
+ this.contentState = _constants.TILE_CONTENT_STATE.FAILED;
216
+ throw error;
217
+ } finally {
218
+ requestToken.done();
397
219
  }
398
- }, {
399
- key: "_initializeTransforms",
400
- value: function _initializeTransforms(tileHeader) {
401
- this.transform = tileHeader.transform ? new _core.Matrix4(tileHeader.transform) : new _core.Matrix4();
402
- var parent = this.parent;
403
- var tileset = this.tileset;
404
- var parentTransform = parent && parent.computedTransform ? parent.computedTransform.clone() : tileset.modelMatrix.clone();
405
- this.computedTransform = new _core.Matrix4(parentTransform).multiplyRight(this.transform);
406
- var parentInitialTransform = parent && parent._initialTransform ? parent._initialTransform.clone() : new _core.Matrix4();
407
- this._initialTransform = new _core.Matrix4(parentInitialTransform).multiplyRight(this.transform);
220
+ }
221
+ unloadContent() {
222
+ if (this.content && this.content.destroy) {
223
+ this.content.destroy();
408
224
  }
409
- }, {
410
- key: "_initializeBoundingVolumes",
411
- value: function _initializeBoundingVolumes(tileHeader) {
412
- this._contentBoundingVolume = null;
413
- this._viewerRequestVolume = null;
414
- this._updateBoundingVolume(tileHeader);
225
+ this.content = null;
226
+ if (this.header.content && this.header.content.destroy) {
227
+ this.header.content.destroy();
415
228
  }
416
- }, {
417
- key: "_initializeContent",
418
- value: function _initializeContent(tileHeader) {
419
- this.content = {
420
- _tileset: this.tileset,
421
- _tile: this
422
- };
423
- this.hasEmptyContent = true;
424
- this.contentState = _constants.TILE_CONTENT_STATE.UNLOADED;
425
- this.hasTilesetContent = false;
426
- if (tileHeader.contentUrl) {
427
- this.content = null;
428
- this.hasEmptyContent = false;
229
+ this.header.content = null;
230
+ this.contentState = _constants.TILE_CONTENT_STATE.UNLOADED;
231
+ return true;
232
+ }
233
+ updateVisibility(frameState, viewportIds) {
234
+ if (this._frameNumber === frameState.frameNumber) {
235
+ return;
236
+ }
237
+ const parent = this.parent;
238
+ const parentVisibilityPlaneMask = parent ? parent._visibilityPlaneMask : _culling.CullingVolume.MASK_INDETERMINATE;
239
+ if (this.tileset._traverser.options.updateTransforms) {
240
+ const parentTransform = parent ? parent.computedTransform : this.tileset.modelMatrix;
241
+ this._updateTransform(parentTransform);
242
+ }
243
+ this._distanceToCamera = this.distanceToTile(frameState);
244
+ this._screenSpaceError = this.getScreenSpaceError(frameState, false);
245
+ this._visibilityPlaneMask = this.visibility(frameState, parentVisibilityPlaneMask);
246
+ this._visible = this._visibilityPlaneMask !== _culling.CullingVolume.MASK_OUTSIDE;
247
+ this._inRequestVolume = this.insideViewerRequestVolume(frameState);
248
+ this._frameNumber = frameState.frameNumber;
249
+ this.viewportIds = viewportIds;
250
+ }
251
+ visibility(frameState, parentVisibilityPlaneMask) {
252
+ const {
253
+ cullingVolume
254
+ } = frameState;
255
+ const {
256
+ boundingVolume
257
+ } = this;
258
+ return cullingVolume.computeVisibilityWithPlaneMask(boundingVolume, parentVisibilityPlaneMask);
259
+ }
260
+ contentVisibility() {
261
+ return true;
262
+ }
263
+ distanceToTile(frameState) {
264
+ const boundingVolume = this.boundingVolume;
265
+ return Math.sqrt(Math.max(boundingVolume.distanceSquaredTo(frameState.camera.position), 0));
266
+ }
267
+ cameraSpaceZDepth(_ref) {
268
+ let {
269
+ camera
270
+ } = _ref;
271
+ const boundingVolume = this.boundingVolume;
272
+ scratchVector.subVectors(boundingVolume.center, camera.position);
273
+ return camera.direction.dot(scratchVector);
274
+ }
275
+ insideViewerRequestVolume(frameState) {
276
+ const viewerRequestVolume = this._viewerRequestVolume;
277
+ return !viewerRequestVolume || viewerRequestVolume.distanceSquaredTo(frameState.camera.position) <= 0;
278
+ }
279
+ updateExpiration() {
280
+ if (defined(this._expireDate) && this.contentReady && !this.hasEmptyContent) {
281
+ const now = Date.now();
282
+ if (Date.lessThan(this._expireDate, now)) {
283
+ this.contentState = _constants.TILE_CONTENT_STATE.EXPIRED;
284
+ this._expiredContent = this.content;
429
285
  }
430
286
  }
431
- }, {
432
- key: "_initializeRenderingState",
433
- value: function _initializeRenderingState(header) {
434
- this.depth = header.level || (this.parent ? this.parent.depth + 1 : 0);
435
- this._shouldRefine = false;
436
- this._distanceToCamera = 0;
437
- this._centerZDepth = 0;
438
- this._screenSpaceError = 0;
439
- this._visibilityPlaneMask = _culling.CullingVolume.MASK_INDETERMINATE;
440
- this._visible = undefined;
441
- this._inRequestVolume = false;
442
- this._stackLength = 0;
443
- this._selectionDepth = 0;
444
- this._frameNumber = 0;
445
- this._touchedFrame = 0;
446
- this._visitedFrame = 0;
447
- this._selectedFrame = 0;
448
- this._requestedFrame = 0;
449
- this._priority = 0.0;
287
+ }
288
+ get extras() {
289
+ return this.header.extras;
290
+ }
291
+ _initializeLodMetric(header) {
292
+ if ('lodMetricType' in header) {
293
+ this.lodMetricType = header.lodMetricType;
294
+ } else {
295
+ this.lodMetricType = this.parent && this.parent.lodMetricType || this.tileset.lodMetricType;
296
+ console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType");
297
+ }
298
+ if ('lodMetricValue' in header) {
299
+ this.lodMetricValue = header.lodMetricValue;
300
+ } else {
301
+ this.lodMetricValue = this.parent && this.parent.lodMetricValue || this.tileset.lodMetricValue;
302
+ console.warn('3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue');
450
303
  }
451
- }, {
452
- key: "_getRefine",
453
- value: function _getRefine(refine) {
454
- return refine || this.parent && this.parent.refine || _constants.TILE_REFINEMENT.REPLACE;
304
+ }
305
+ _initializeTransforms(tileHeader) {
306
+ this.transform = tileHeader.transform ? new _core.Matrix4(tileHeader.transform) : new _core.Matrix4();
307
+ const parent = this.parent;
308
+ const tileset = this.tileset;
309
+ const parentTransform = parent && parent.computedTransform ? parent.computedTransform.clone() : tileset.modelMatrix.clone();
310
+ this.computedTransform = new _core.Matrix4(parentTransform).multiplyRight(this.transform);
311
+ const parentInitialTransform = parent && parent._initialTransform ? parent._initialTransform.clone() : new _core.Matrix4();
312
+ this._initialTransform = new _core.Matrix4(parentInitialTransform).multiplyRight(this.transform);
313
+ }
314
+ _initializeBoundingVolumes(tileHeader) {
315
+ this._contentBoundingVolume = null;
316
+ this._viewerRequestVolume = null;
317
+ this._updateBoundingVolume(tileHeader);
318
+ }
319
+ _initializeContent(tileHeader) {
320
+ this.content = {
321
+ _tileset: this.tileset,
322
+ _tile: this
323
+ };
324
+ this.hasEmptyContent = true;
325
+ this.contentState = _constants.TILE_CONTENT_STATE.UNLOADED;
326
+ this.hasTilesetContent = false;
327
+ if (tileHeader.contentUrl) {
328
+ this.content = null;
329
+ this.hasEmptyContent = false;
455
330
  }
456
- }, {
457
- key: "_isTileset",
458
- value: function _isTileset() {
459
- return this.contentUrl.indexOf('.json') !== -1;
331
+ }
332
+ _initializeRenderingState(header) {
333
+ this.depth = header.level || (this.parent ? this.parent.depth + 1 : 0);
334
+ this._shouldRefine = false;
335
+ this._distanceToCamera = 0;
336
+ this._centerZDepth = 0;
337
+ this._screenSpaceError = 0;
338
+ this._visibilityPlaneMask = _culling.CullingVolume.MASK_INDETERMINATE;
339
+ this._visible = undefined;
340
+ this._inRequestVolume = false;
341
+ this._stackLength = 0;
342
+ this._selectionDepth = 0;
343
+ this._frameNumber = 0;
344
+ this._touchedFrame = 0;
345
+ this._visitedFrame = 0;
346
+ this._selectedFrame = 0;
347
+ this._requestedFrame = 0;
348
+ this._priority = 0.0;
349
+ }
350
+ _getRefine(refine) {
351
+ return refine || this.parent && this.parent.refine || _constants.TILE_REFINEMENT.REPLACE;
352
+ }
353
+ _isTileset() {
354
+ return this.contentUrl.indexOf('.json') !== -1;
355
+ }
356
+ _onContentLoaded() {
357
+ switch (this.content && this.content.type) {
358
+ case 'vctr':
359
+ case 'geom':
360
+ this.tileset._traverser.disableSkipLevelOfDetail = true;
361
+ break;
362
+ default:
363
+ }
364
+ if (this._isTileset()) {
365
+ this.hasTilesetContent = true;
366
+ } else {
367
+ this.gpuMemoryUsageInBytes = this._getGpuMemoryUsageInBytes();
460
368
  }
461
- }, {
462
- key: "_onContentLoaded",
463
- value: function _onContentLoaded() {
464
- switch (this.content && this.content.type) {
465
- case 'vctr':
466
- case 'geom':
467
- this.tileset._traverser.disableSkipLevelOfDetail = true;
468
- break;
469
- default:
470
- }
471
- if (this._isTileset()) {
472
- this.hasTilesetContent = true;
473
- } else {
474
- this.gpuMemoryUsageInBytes = this._getGpuMemoryUsageInBytes();
475
- }
369
+ }
370
+ _updateBoundingVolume(header) {
371
+ this.boundingVolume = (0, _boundingVolume.createBoundingVolume)(header.boundingVolume, this.computedTransform, this.boundingVolume);
372
+ const content = header.content;
373
+ if (!content) {
374
+ return;
476
375
  }
477
- }, {
478
- key: "_updateBoundingVolume",
479
- value: function _updateBoundingVolume(header) {
480
- this.boundingVolume = (0, _boundingVolume.createBoundingVolume)(header.boundingVolume, this.computedTransform, this.boundingVolume);
481
- var content = header.content;
482
- if (!content) {
483
- return;
484
- }
485
- if (content.boundingVolume) {
486
- this._contentBoundingVolume = (0, _boundingVolume.createBoundingVolume)(content.boundingVolume, this.computedTransform, this._contentBoundingVolume);
487
- }
488
- if (header.viewerRequestVolume) {
489
- this._viewerRequestVolume = (0, _boundingVolume.createBoundingVolume)(header.viewerRequestVolume, this.computedTransform, this._viewerRequestVolume);
490
- }
376
+ if (content.boundingVolume) {
377
+ this._contentBoundingVolume = (0, _boundingVolume.createBoundingVolume)(content.boundingVolume, this.computedTransform, this._contentBoundingVolume);
491
378
  }
492
- }, {
493
- key: "_updateTransform",
494
- value: function _updateTransform() {
495
- var parentTransform = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new _core.Matrix4();
496
- var computedTransform = parentTransform.clone().multiplyRight(this.transform);
497
- var didTransformChange = !computedTransform.equals(this.computedTransform);
498
- if (!didTransformChange) {
499
- return;
500
- }
501
- this.computedTransform = computedTransform;
502
- this._updateBoundingVolume(this.header);
379
+ if (header.viewerRequestVolume) {
380
+ this._viewerRequestVolume = (0, _boundingVolume.createBoundingVolume)(header.viewerRequestVolume, this.computedTransform, this._viewerRequestVolume);
503
381
  }
504
- }, {
505
- key: "_getLoaderSpecificOptions",
506
- value: function _getLoaderSpecificOptions(loaderId) {
507
- switch (loaderId) {
508
- case 'i3s':
509
- return _objectSpread(_objectSpread({}, this.tileset.options.i3s), {}, {
510
- _tileOptions: {
511
- attributeUrls: this.header.attributeUrls,
512
- textureUrl: this.header.textureUrl,
513
- textureFormat: this.header.textureFormat,
514
- textureLoaderOptions: this.header.textureLoaderOptions,
515
- materialDefinition: this.header.materialDefinition,
516
- isDracoGeometry: this.header.isDracoGeometry,
517
- mbs: this.header.mbs
518
- },
519
- _tilesetOptions: {
520
- store: this.tileset.tileset.store,
521
- attributeStorageInfo: this.tileset.tileset.attributeStorageInfo,
522
- fields: this.tileset.tileset.fields
523
- },
524
- isTileHeader: false
525
- });
526
- case '3d-tiles':
527
- case 'cesium-ion':
528
- default:
529
- return (0, _dTilesOptions.get3dTilesOptions)(this.tileset.tileset);
530
- }
382
+ }
383
+ _updateTransform() {
384
+ let parentTransform = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new _core.Matrix4();
385
+ const computedTransform = parentTransform.clone().multiplyRight(this.transform);
386
+ const didTransformChange = !computedTransform.equals(this.computedTransform);
387
+ if (!didTransformChange) {
388
+ return;
389
+ }
390
+ this.computedTransform = computedTransform;
391
+ this._updateBoundingVolume(this.header);
392
+ }
393
+ _getLoaderSpecificOptions(loaderId) {
394
+ switch (loaderId) {
395
+ case 'i3s':
396
+ return {
397
+ ...this.tileset.options.i3s,
398
+ _tileOptions: {
399
+ attributeUrls: this.header.attributeUrls,
400
+ textureUrl: this.header.textureUrl,
401
+ textureFormat: this.header.textureFormat,
402
+ textureLoaderOptions: this.header.textureLoaderOptions,
403
+ materialDefinition: this.header.materialDefinition,
404
+ isDracoGeometry: this.header.isDracoGeometry,
405
+ mbs: this.header.mbs
406
+ },
407
+ _tilesetOptions: {
408
+ store: this.tileset.tileset.store,
409
+ attributeStorageInfo: this.tileset.tileset.attributeStorageInfo,
410
+ fields: this.tileset.tileset.fields
411
+ },
412
+ isTileHeader: false
413
+ };
414
+ case '3d-tiles':
415
+ case 'cesium-ion':
416
+ default:
417
+ return (0, _dTilesOptions.get3dTilesOptions)(this.tileset.tileset);
531
418
  }
532
- }]);
533
- return Tile3D;
534
- }();
419
+ }
420
+ }
535
421
  exports.Tile3D = Tile3D;
536
422
  //# sourceMappingURL=tile-3d.js.map