@loaders.gl/tiles 3.0.13 → 3.0.14
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.
- package/dist/dist.es5.min.js +1 -1
- package/dist/dist.es5.min.js.map +1 -1
- package/dist/dist.min.js +1 -1
- package/dist/dist.min.js.map +1 -1
- package/dist/es5/bundle.js +2 -2
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/constants.js +6 -6
- package/dist/es5/constants.js.map +1 -1
- package/dist/es5/index.js +12 -12
- package/dist/es5/tileset/helpers/bounding-volume.js +37 -25
- package/dist/es5/tileset/helpers/bounding-volume.js.map +1 -1
- package/dist/es5/tileset/helpers/frame-state.js +25 -29
- package/dist/es5/tileset/helpers/frame-state.js.map +1 -1
- package/dist/es5/tileset/helpers/i3s-lod.js +66 -51
- package/dist/es5/tileset/helpers/i3s-lod.js.map +1 -1
- package/dist/es5/tileset/helpers/tiles-3d-lod.js +47 -51
- package/dist/es5/tileset/helpers/tiles-3d-lod.js.map +1 -1
- package/dist/es5/tileset/helpers/transform-utils.js +11 -17
- package/dist/es5/tileset/helpers/transform-utils.js.map +1 -1
- package/dist/es5/tileset/helpers/zoom.js +15 -17
- package/dist/es5/tileset/helpers/zoom.js.map +1 -1
- package/dist/es5/tileset/tile-3d.js +421 -328
- package/dist/es5/tileset/tile-3d.js.map +1 -1
- package/dist/es5/tileset/tileset-3d.js +563 -381
- package/dist/es5/tileset/tileset-3d.js.map +1 -1
- package/dist/es5/tileset/tileset-cache.js +63 -50
- package/dist/es5/tileset/tileset-cache.js.map +1 -1
- package/dist/es5/tileset/traversers/i3s-tile-manager.js +44 -32
- package/dist/es5/tileset/traversers/i3s-tile-manager.js.map +1 -1
- package/dist/es5/tileset/traversers/i3s-tileset-traverser.js +143 -53
- package/dist/es5/tileset/traversers/i3s-tileset-traverser.js.map +1 -1
- package/dist/es5/tileset/traversers/tileset-3d-traverser.js +62 -34
- package/dist/es5/tileset/traversers/tileset-3d-traverser.js.map +1 -1
- package/dist/es5/tileset/traversers/tileset-traverser.js +282 -209
- package/dist/es5/tileset/traversers/tileset-traverser.js.map +1 -1
- package/dist/es5/utils/doubly-linked-list-node.js +9 -7
- package/dist/es5/utils/doubly-linked-list-node.js.map +1 -1
- package/dist/es5/utils/doubly-linked-list.js +76 -64
- package/dist/es5/utils/doubly-linked-list.js.map +1 -1
- package/dist/es5/utils/managed-array.js +108 -86
- package/dist/es5/utils/managed-array.js.map +1 -1
- package/package.json +5 -5
|
@@ -7,6 +7,14 @@ 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
|
+
|
|
10
18
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
19
|
|
|
12
20
|
var _core = require("@math.gl/core");
|
|
@@ -27,14 +35,20 @@ var _dTilesOptions = require("./helpers/3d-tiles-options");
|
|
|
27
35
|
|
|
28
36
|
var _tilesetTraverser = _interopRequireDefault(require("./traversers/tileset-traverser"));
|
|
29
37
|
|
|
30
|
-
|
|
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();
|
|
31
43
|
|
|
32
44
|
function defined(x) {
|
|
33
45
|
return x !== undefined && x !== null;
|
|
34
46
|
}
|
|
35
47
|
|
|
36
|
-
|
|
37
|
-
|
|
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);
|
|
38
52
|
(0, _defineProperty2.default)(this, "tileset", void 0);
|
|
39
53
|
(0, _defineProperty2.default)(this, "header", void 0);
|
|
40
54
|
(0, _defineProperty2.default)(this, "id", void 0);
|
|
@@ -136,375 +150,454 @@ class TileHeader {
|
|
|
136
150
|
Object.seal(this);
|
|
137
151
|
}
|
|
138
152
|
|
|
139
|
-
|
|
140
|
-
|
|
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');
|
|
153
|
+
(0, _createClass2.default)(TileHeader, [{
|
|
154
|
+
key: "destroy",
|
|
155
|
+
value: function destroy() {
|
|
156
|
+
this.header = null;
|
|
201
157
|
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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;
|
|
158
|
+
}, {
|
|
159
|
+
key: "isDestroyed",
|
|
160
|
+
value: function isDestroyed() {
|
|
161
|
+
return this.header === null;
|
|
213
162
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
163
|
+
}, {
|
|
164
|
+
key: "selected",
|
|
165
|
+
get: function get() {
|
|
166
|
+
return this._selectedFrame === this.tileset._frameNumber;
|
|
217
167
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
168
|
+
}, {
|
|
169
|
+
key: "isVisible",
|
|
170
|
+
get: function get() {
|
|
171
|
+
return this._visible;
|
|
221
172
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const rootScreenSpaceError = traverser.root ? traverser.root._screenSpaceError : 0.0;
|
|
227
|
-
return Math.max(rootScreenSpaceError - screenSpaceError, 0);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
async loadContent() {
|
|
231
|
-
if (this.hasEmptyContent) {
|
|
232
|
-
return false;
|
|
173
|
+
}, {
|
|
174
|
+
key: "isVisibleAndInRequestVolume",
|
|
175
|
+
get: function get() {
|
|
176
|
+
return this._visible && this._inRequestVolume;
|
|
233
177
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
178
|
+
}, {
|
|
179
|
+
key: "hasRenderContent",
|
|
180
|
+
get: function get() {
|
|
181
|
+
return !this.hasEmptyContent && !this.hasTilesetContent;
|
|
237
182
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
this._expireDate = null;
|
|
183
|
+
}, {
|
|
184
|
+
key: "hasChildren",
|
|
185
|
+
get: function get() {
|
|
186
|
+
return this.children.length > 0 || this.header.children && this.header.children.length > 0;
|
|
243
187
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
if (!requestToken) {
|
|
249
|
-
this.contentState = _constants.TILE_CONTENT_STATE.UNLOADED;
|
|
250
|
-
return false;
|
|
188
|
+
}, {
|
|
189
|
+
key: "contentReady",
|
|
190
|
+
get: function get() {
|
|
191
|
+
return this.contentState === _constants.TILE_CONTENT_STATE.READY || this.hasEmptyContent;
|
|
251
192
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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);
|
|
263
|
-
|
|
264
|
-
if (this.tileset.options.contentLoader) {
|
|
265
|
-
await this.tileset.options.contentLoader(this);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (this._isTileset()) {
|
|
269
|
-
this.tileset._initializeTileHeaders(this.content, this);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
this.contentState = _constants.TILE_CONTENT_STATE.READY;
|
|
273
|
-
|
|
274
|
-
this._onContentLoaded();
|
|
275
|
-
|
|
276
|
-
return true;
|
|
277
|
-
} catch (error) {
|
|
278
|
-
this.contentState = _constants.TILE_CONTENT_STATE.FAILED;
|
|
279
|
-
throw error;
|
|
280
|
-
} finally {
|
|
281
|
-
requestToken.done();
|
|
193
|
+
}, {
|
|
194
|
+
key: "contentAvailable",
|
|
195
|
+
get: function get() {
|
|
196
|
+
return Boolean(this.contentReady && this.hasRenderContent || this._expiredContent && !this.contentFailed);
|
|
282
197
|
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
this.content.destroy();
|
|
198
|
+
}, {
|
|
199
|
+
key: "hasUnloadedContent",
|
|
200
|
+
get: function get() {
|
|
201
|
+
return this.hasRenderContent && this.contentUnloaded;
|
|
288
202
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
this.header.content.destroy();
|
|
203
|
+
}, {
|
|
204
|
+
key: "contentUnloaded",
|
|
205
|
+
get: function get() {
|
|
206
|
+
return this.contentState === _constants.TILE_CONTENT_STATE.UNLOADED;
|
|
294
207
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
updateVisibility(frameState, viewportIds) {
|
|
302
|
-
if (this._frameNumber === frameState.frameNumber) {
|
|
303
|
-
return;
|
|
208
|
+
}, {
|
|
209
|
+
key: "contentExpired",
|
|
210
|
+
get: function get() {
|
|
211
|
+
return this.contentState === _constants.TILE_CONTENT_STATE.EXPIRED;
|
|
304
212
|
}
|
|
213
|
+
}, {
|
|
214
|
+
key: "contentFailed",
|
|
215
|
+
get: function get() {
|
|
216
|
+
return this.contentState === _constants.TILE_CONTENT_STATE.FAILED;
|
|
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
|
+
}
|
|
231
|
+
}
|
|
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
|
+
}
|
|
305
242
|
|
|
306
|
-
|
|
307
|
-
|
|
243
|
+
if (this.tileset._frameNumber - this._touchedFrame >= 1) {
|
|
244
|
+
return -1;
|
|
245
|
+
}
|
|
308
246
|
|
|
309
|
-
|
|
310
|
-
|
|
247
|
+
if (this.contentState === _constants.TILE_CONTENT_STATE.UNLOADED) {
|
|
248
|
+
return -1;
|
|
249
|
+
}
|
|
311
250
|
|
|
312
|
-
this.
|
|
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);
|
|
313
256
|
}
|
|
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
|
+
}
|
|
314
357
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
358
|
+
return loadContent;
|
|
359
|
+
}()
|
|
360
|
+
}, {
|
|
361
|
+
key: "unloadContent",
|
|
362
|
+
value: function unloadContent() {
|
|
363
|
+
if (this.content && this.content.destroy) {
|
|
364
|
+
this.content.destroy();
|
|
365
|
+
}
|
|
323
366
|
|
|
324
|
-
|
|
325
|
-
const {
|
|
326
|
-
cullingVolume
|
|
327
|
-
} = frameState;
|
|
328
|
-
const {
|
|
329
|
-
boundingVolume
|
|
330
|
-
} = this;
|
|
331
|
-
return cullingVolume.computeVisibilityWithPlaneMask(boundingVolume, parentVisibilityPlaneMask);
|
|
332
|
-
}
|
|
367
|
+
this.content = null;
|
|
333
368
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
369
|
+
if (this.header.content && this.header.content.destroy) {
|
|
370
|
+
this.header.content.destroy();
|
|
371
|
+
}
|
|
337
372
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
373
|
+
this.header.content = null;
|
|
374
|
+
this.contentState = _constants.TILE_CONTENT_STATE.UNLOADED;
|
|
375
|
+
return true;
|
|
376
|
+
}
|
|
377
|
+
}, {
|
|
378
|
+
key: "updateVisibility",
|
|
379
|
+
value: function updateVisibility(frameState, viewportIds) {
|
|
380
|
+
if (this._frameNumber === frameState.frameNumber) {
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
342
383
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}) {
|
|
346
|
-
const boundingVolume = this.boundingVolume;
|
|
347
|
-
scratchVector.subVectors(boundingVolume.center, camera.position);
|
|
348
|
-
return camera.direction.dot(scratchVector);
|
|
349
|
-
}
|
|
384
|
+
var parent = this.parent;
|
|
385
|
+
var parentVisibilityPlaneMask = parent ? parent._visibilityPlaneMask : _culling.CullingVolume.MASK_INDETERMINATE;
|
|
350
386
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
return !viewerRequestVolume || viewerRequestVolume.distanceSquaredTo(frameState.camera.position) <= 0;
|
|
354
|
-
}
|
|
387
|
+
if (this.tileset._traverser.options.updateTransforms) {
|
|
388
|
+
var parentTransform = parent ? parent.computedTransform : this.tileset.modelMatrix;
|
|
355
389
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
const now = Date.now();
|
|
390
|
+
this._updateTransform(parentTransform);
|
|
391
|
+
}
|
|
359
392
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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() {
|
|
411
|
+
return true;
|
|
412
|
+
}
|
|
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);
|
|
426
|
+
}
|
|
427
|
+
}, {
|
|
428
|
+
key: "insideViewerRequestVolume",
|
|
429
|
+
value: function insideViewerRequestVolume(frameState) {
|
|
430
|
+
var viewerRequestVolume = this._viewerRequestVolume;
|
|
431
|
+
return !viewerRequestVolume || viewerRequestVolume.distanceSquaredTo(frameState.camera.position) <= 0;
|
|
432
|
+
}
|
|
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
|
+
}
|
|
363
443
|
}
|
|
364
444
|
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
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");
|
|
445
|
+
}, {
|
|
446
|
+
key: "extras",
|
|
447
|
+
get: function get() {
|
|
448
|
+
return this.header.extras;
|
|
377
449
|
}
|
|
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
|
+
}
|
|
378
459
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
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');
|
|
465
|
+
}
|
|
384
466
|
}
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
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;
|
|
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);
|
|
416
477
|
}
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
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
|
-
}
|
|
478
|
+
}, {
|
|
479
|
+
key: "_initializeBoundingVolumes",
|
|
480
|
+
value: function _initializeBoundingVolumes(tileHeader) {
|
|
481
|
+
this._contentBoundingVolume = null;
|
|
482
|
+
this._viewerRequestVolume = null;
|
|
445
483
|
|
|
446
|
-
|
|
447
|
-
switch (this.content && this.content.type) {
|
|
448
|
-
case 'vctr':
|
|
449
|
-
case 'geom':
|
|
450
|
-
this.tileset._traverser.disableSkipLevelOfDetail = true;
|
|
451
|
-
break;
|
|
452
|
-
|
|
453
|
-
default:
|
|
484
|
+
this._updateBoundingVolume(tileHeader);
|
|
454
485
|
}
|
|
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;
|
|
455
496
|
|
|
456
|
-
|
|
457
|
-
|
|
497
|
+
if (tileHeader.contentUrl) {
|
|
498
|
+
this.content = null;
|
|
499
|
+
this.hasEmptyContent = false;
|
|
500
|
+
}
|
|
458
501
|
}
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
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;
|
|
467
521
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
522
|
+
}, {
|
|
523
|
+
key: "_getRefine",
|
|
524
|
+
value: function _getRefine(refine) {
|
|
525
|
+
return refine || this.parent && this.parent.refine || _constants.TILE_REFINEMENT.REPLACE;
|
|
471
526
|
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
527
|
+
}, {
|
|
528
|
+
key: "_isTileset",
|
|
529
|
+
value: function _isTileset() {
|
|
530
|
+
return this.contentUrl.indexOf('.json') !== -1;
|
|
475
531
|
}
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
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
|
+
}
|
|
481
543
|
|
|
482
|
-
|
|
483
|
-
|
|
544
|
+
if (this._isTileset()) {
|
|
545
|
+
this.hasTilesetContent = true;
|
|
546
|
+
}
|
|
484
547
|
}
|
|
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
|
+
}
|
|
485
557
|
|
|
486
|
-
|
|
558
|
+
if (content.boundingVolume) {
|
|
559
|
+
this._contentBoundingVolume = (0, _boundingVolume.createBoundingVolume)(content.boundingVolume, this.computedTransform, this._contentBoundingVolume);
|
|
560
|
+
}
|
|
487
561
|
|
|
488
|
-
|
|
489
|
-
|
|
562
|
+
if (header.viewerRequestVolume) {
|
|
563
|
+
this._viewerRequestVolume = (0, _boundingVolume.createBoundingVolume)(header.viewerRequestVolume, this.computedTransform, this._viewerRequestVolume);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
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
|
+
}
|
|
490
576
|
|
|
491
|
-
|
|
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
|
-
};
|
|
577
|
+
this.computedTransform = computedTransform;
|
|
499
578
|
|
|
500
|
-
|
|
501
|
-
case 'cesium-ion':
|
|
502
|
-
default:
|
|
503
|
-
return (0, _dTilesOptions.get3dTilesOptions)(this.tileset.tileset);
|
|
579
|
+
this._updateBoundingVolume(this.header);
|
|
504
580
|
}
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
|
|
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
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}]);
|
|
599
|
+
return TileHeader;
|
|
600
|
+
}();
|
|
508
601
|
|
|
509
602
|
exports.default = TileHeader;
|
|
510
603
|
//# sourceMappingURL=tile-3d.js.map
|