@loaders.gl/tiles 3.2.0-alpha.1 → 3.2.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.min.js +102 -16
- package/dist/es5/tileset/helpers/zoom.js +32 -0
- package/dist/es5/tileset/helpers/zoom.js.map +1 -1
- package/dist/es5/tileset/tileset-3d.js +119 -41
- package/dist/es5/tileset/tileset-3d.js.map +1 -1
- package/dist/es5/tileset/traversers/i3s-frame-counter.js +45 -0
- package/dist/es5/tileset/traversers/i3s-frame-counter.js.map +1 -0
- package/dist/es5/tileset/traversers/i3s-tile-manager.js +17 -0
- package/dist/es5/tileset/traversers/i3s-tile-manager.js.map +1 -1
- package/dist/es5/tileset/traversers/i3s-tileset-traverser.js +6 -1
- package/dist/es5/tileset/traversers/i3s-tileset-traverser.js.map +1 -1
- package/dist/es5/tileset/traversers/tileset-traverser.js +13 -1
- package/dist/es5/tileset/traversers/tileset-traverser.js.map +1 -1
- package/dist/esm/tileset/helpers/zoom.js +17 -0
- package/dist/esm/tileset/helpers/zoom.js.map +1 -1
- package/dist/esm/tileset/tileset-3d.js +60 -14
- package/dist/esm/tileset/tileset-3d.js.map +1 -1
- package/dist/esm/tileset/traversers/i3s-frame-counter.js +23 -0
- package/dist/esm/tileset/traversers/i3s-frame-counter.js.map +1 -0
- package/dist/esm/tileset/traversers/i3s-tile-manager.js +15 -0
- package/dist/esm/tileset/traversers/i3s-tile-manager.js.map +1 -1
- package/dist/esm/tileset/traversers/i3s-tileset-traverser.js +5 -1
- package/dist/esm/tileset/traversers/i3s-tileset-traverser.js.map +1 -1
- package/dist/esm/tileset/traversers/tileset-traverser.js +14 -1
- package/dist/esm/tileset/traversers/tileset-traverser.js.map +1 -1
- package/dist/tileset/helpers/zoom.d.ts +35 -0
- package/dist/tileset/helpers/zoom.d.ts.map +1 -1
- package/dist/tileset/helpers/zoom.js +41 -1
- package/dist/tileset/tileset-3d.d.ts +17 -3
- package/dist/tileset/tileset-3d.d.ts.map +1 -1
- package/dist/tileset/tileset-3d.js +60 -19
- package/dist/tileset/traversers/i3s-frame-counter.d.ts +24 -0
- package/dist/tileset/traversers/i3s-frame-counter.d.ts.map +1 -0
- package/dist/tileset/traversers/i3s-frame-counter.js +37 -0
- package/dist/tileset/traversers/i3s-tile-manager.d.ts +10 -2
- package/dist/tileset/traversers/i3s-tile-manager.d.ts.map +1 -1
- package/dist/tileset/traversers/i3s-tile-manager.js +24 -0
- package/dist/tileset/traversers/i3s-tileset-traverser.d.ts +9 -2
- package/dist/tileset/traversers/i3s-tileset-traverser.d.ts.map +1 -1
- package/dist/tileset/traversers/i3s-tileset-traverser.js +10 -1
- package/dist/tileset/traversers/tileset-traverser.d.ts +5 -1
- package/dist/tileset/traversers/tileset-traverser.d.ts.map +1 -1
- package/dist/tileset/traversers/tileset-traverser.js +10 -1
- package/package.json +5 -5
- package/src/tileset/helpers/zoom.ts +64 -0
- package/src/tileset/tileset-3d.ts +72 -19
- package/src/tileset/traversers/i3s-frame-counter.ts +35 -0
- package/src/tileset/traversers/i3s-tile-manager.ts +26 -2
- package/src/tileset/traversers/i3s-tileset-traverser.ts +16 -3
- package/src/tileset/traversers/tileset-traverser.ts +13 -2
package/dist/dist.min.js
CHANGED
|
@@ -3672,7 +3672,7 @@
|
|
|
3672
3672
|
this.worker = isBrowser2 ? this._createBrowserWorker() : this._createNodeWorker();
|
|
3673
3673
|
}
|
|
3674
3674
|
static isSupported() {
|
|
3675
|
-
return typeof Worker !== "undefined" && isBrowser2;
|
|
3675
|
+
return typeof Worker !== "undefined" && isBrowser2 || typeof Worker2 !== void 0;
|
|
3676
3676
|
}
|
|
3677
3677
|
destroy() {
|
|
3678
3678
|
this.onMessage = NOOP;
|
|
@@ -5145,6 +5145,15 @@
|
|
|
5145
5145
|
}
|
|
5146
5146
|
return 1;
|
|
5147
5147
|
}
|
|
5148
|
+
function getZoomFromFullExtent(fullExtent, cartorgraphicCenter, cartesianCenter) {
|
|
5149
|
+
const extentVertex = Ellipsoid.WGS84.cartographicToCartesian([fullExtent.xmax, fullExtent.ymax, fullExtent.zmax], new Vector3());
|
|
5150
|
+
const extentSize = Math.sqrt(Math.pow(extentVertex[0] - cartesianCenter[0], 2) + Math.pow(extentVertex[1] - cartesianCenter[1], 2) + Math.pow(extentVertex[2] - cartesianCenter[2], 2));
|
|
5151
|
+
return Math.log2(WGS84_RADIUS_Z2 / (extentSize + cartorgraphicCenter[2]));
|
|
5152
|
+
}
|
|
5153
|
+
function getZoomFromExtent(extent, cartorgraphicCenter, cartesianCenter) {
|
|
5154
|
+
const [xmin, ymin, xmax, ymax] = extent;
|
|
5155
|
+
return getZoomFromFullExtent({ xmin, xmax, ymin, ymax, zmin: 0, zmax: 0 }, cartorgraphicCenter, cartesianCenter);
|
|
5156
|
+
}
|
|
5148
5157
|
function getObbSize(halfAxes) {
|
|
5149
5158
|
halfAxes.getColumn(0, scratchVector8);
|
|
5150
5159
|
const axeY = halfAxes.getColumn(1);
|
|
@@ -5158,6 +5167,7 @@
|
|
|
5158
5167
|
"src/tileset/helpers/zoom.ts"() {
|
|
5159
5168
|
init_esm();
|
|
5160
5169
|
init_esm4();
|
|
5170
|
+
init_esm2();
|
|
5161
5171
|
WGS84_RADIUS_X2 = 6378137;
|
|
5162
5172
|
WGS84_RADIUS_Y2 = 6378137;
|
|
5163
5173
|
WGS84_RADIUS_Z2 = 6356752314245179e-9;
|
|
@@ -5304,7 +5314,7 @@
|
|
|
5304
5314
|
text += ` ${await response.text()}`;
|
|
5305
5315
|
}
|
|
5306
5316
|
message += text;
|
|
5307
|
-
message = message.length > 60 ? `${message.slice(60)}...` : message;
|
|
5317
|
+
message = message.length > 60 ? `${message.slice(0, 60)}...` : message;
|
|
5308
5318
|
} catch (error) {
|
|
5309
5319
|
}
|
|
5310
5320
|
return message;
|
|
@@ -7714,6 +7724,8 @@
|
|
|
7714
7724
|
};
|
|
7715
7725
|
TilesetTraverser = class {
|
|
7716
7726
|
constructor(options) {
|
|
7727
|
+
this.lastUpdate = new Date().getTime();
|
|
7728
|
+
this.updateDebounceTime = 1e3;
|
|
7717
7729
|
this.options = { ...DEFAULT_PROPS3, ...options };
|
|
7718
7730
|
this._traversalStack = new ManagedArray();
|
|
7719
7731
|
this._emptyTraversalStack = new ManagedArray();
|
|
@@ -7723,6 +7735,9 @@
|
|
|
7723
7735
|
this.requestedTiles = {};
|
|
7724
7736
|
this.emptyTiles = {};
|
|
7725
7737
|
}
|
|
7738
|
+
get traversalFinished() {
|
|
7739
|
+
return true;
|
|
7740
|
+
}
|
|
7726
7741
|
traverse(root, frameState, options) {
|
|
7727
7742
|
this.root = root;
|
|
7728
7743
|
this.options = { ...this.options, ...options };
|
|
@@ -7770,7 +7785,11 @@
|
|
|
7770
7785
|
this.touchTile(tile, frameState);
|
|
7771
7786
|
tile._shouldRefine = shouldRefine && parentRefines;
|
|
7772
7787
|
}
|
|
7773
|
-
|
|
7788
|
+
const newTime = new Date().getTime();
|
|
7789
|
+
if (this.traversalFinished || newTime - this.lastUpdate > this.updateDebounceTime) {
|
|
7790
|
+
this.lastUpdate = newTime;
|
|
7791
|
+
this.options.onTraversalEnd(frameState);
|
|
7792
|
+
}
|
|
7774
7793
|
}
|
|
7775
7794
|
updateChildTiles(tile, frameState) {
|
|
7776
7795
|
const children = tile.children;
|
|
@@ -8327,10 +8346,35 @@
|
|
|
8327
8346
|
}
|
|
8328
8347
|
});
|
|
8329
8348
|
|
|
8349
|
+
// src/tileset/traversers/i3s-frame-counter.ts
|
|
8350
|
+
var I3SPendingTilesRegister;
|
|
8351
|
+
var init_i3s_frame_counter = __esm({
|
|
8352
|
+
"src/tileset/traversers/i3s-frame-counter.ts"() {
|
|
8353
|
+
I3SPendingTilesRegister = class {
|
|
8354
|
+
constructor() {
|
|
8355
|
+
this.frameNumberMap = new Map();
|
|
8356
|
+
}
|
|
8357
|
+
register(frameNumber) {
|
|
8358
|
+
const oldCount = this.frameNumberMap.get(frameNumber) || 0;
|
|
8359
|
+
this.frameNumberMap.set(frameNumber, (oldCount || 0) + 1);
|
|
8360
|
+
}
|
|
8361
|
+
deregister(frameNumber) {
|
|
8362
|
+
const oldCount = this.frameNumberMap.get(frameNumber) || 1;
|
|
8363
|
+
this.frameNumberMap.set(frameNumber, (oldCount || 0) - 1);
|
|
8364
|
+
}
|
|
8365
|
+
isZero(frameNumber) {
|
|
8366
|
+
const count = this.frameNumberMap.get(frameNumber) || 0;
|
|
8367
|
+
return count === 0;
|
|
8368
|
+
}
|
|
8369
|
+
};
|
|
8370
|
+
}
|
|
8371
|
+
});
|
|
8372
|
+
|
|
8330
8373
|
// src/tileset/traversers/i3s-tile-manager.ts
|
|
8331
8374
|
var STATUS, I3STileManager;
|
|
8332
8375
|
var init_i3s_tile_manager = __esm({
|
|
8333
8376
|
"src/tileset/traversers/i3s-tile-manager.ts"() {
|
|
8377
|
+
init_i3s_frame_counter();
|
|
8334
8378
|
STATUS = {
|
|
8335
8379
|
REQUESTED: "REQUESTED",
|
|
8336
8380
|
COMPLETED: "COMPLETED",
|
|
@@ -8338,28 +8382,38 @@
|
|
|
8338
8382
|
};
|
|
8339
8383
|
I3STileManager = class {
|
|
8340
8384
|
constructor() {
|
|
8385
|
+
this.pendingTilesRegister = new I3SPendingTilesRegister();
|
|
8341
8386
|
this._statusMap = {};
|
|
8342
8387
|
}
|
|
8343
8388
|
add(request, key, callback, frameState) {
|
|
8344
8389
|
if (!this._statusMap[key]) {
|
|
8390
|
+
const { frameNumber } = frameState;
|
|
8345
8391
|
this._statusMap[key] = { request, callback, key, frameState, status: STATUS.REQUESTED };
|
|
8392
|
+
this.pendingTilesRegister.register(frameNumber);
|
|
8346
8393
|
request().then((data) => {
|
|
8347
8394
|
this._statusMap[key].status = STATUS.COMPLETED;
|
|
8395
|
+
this.pendingTilesRegister.deregister(frameNumber);
|
|
8348
8396
|
this._statusMap[key].callback(data, frameState);
|
|
8349
8397
|
}).catch((error) => {
|
|
8350
8398
|
this._statusMap[key].status = STATUS.ERROR;
|
|
8399
|
+
this.pendingTilesRegister.deregister(frameNumber);
|
|
8351
8400
|
callback(error);
|
|
8352
8401
|
});
|
|
8353
8402
|
}
|
|
8354
8403
|
}
|
|
8355
8404
|
update(key, frameState) {
|
|
8356
8405
|
if (this._statusMap[key]) {
|
|
8406
|
+
this.pendingTilesRegister.deregister(this._statusMap[key].frameState.frameNumber);
|
|
8407
|
+
this.pendingTilesRegister.register(frameState.frameNumber);
|
|
8357
8408
|
this._statusMap[key].frameState = frameState;
|
|
8358
8409
|
}
|
|
8359
8410
|
}
|
|
8360
8411
|
find(key) {
|
|
8361
8412
|
return this._statusMap[key];
|
|
8362
8413
|
}
|
|
8414
|
+
hasPendingTiles(frameNumber) {
|
|
8415
|
+
return !this.pendingTilesRegister.isZero(frameNumber);
|
|
8416
|
+
}
|
|
8363
8417
|
};
|
|
8364
8418
|
}
|
|
8365
8419
|
});
|
|
@@ -8374,6 +8428,9 @@
|
|
|
8374
8428
|
init_tile_3d();
|
|
8375
8429
|
init_i3s_tile_manager();
|
|
8376
8430
|
I3STilesetTraverser = class extends TilesetTraverser {
|
|
8431
|
+
get traversalFinished() {
|
|
8432
|
+
return !this._tileManager.hasPendingTiles(this._frameNumber || 0);
|
|
8433
|
+
}
|
|
8377
8434
|
constructor(options) {
|
|
8378
8435
|
super(options);
|
|
8379
8436
|
this._tileManager = new I3STileManager();
|
|
@@ -8424,7 +8481,7 @@
|
|
|
8424
8481
|
tile.children.push(childTile);
|
|
8425
8482
|
const frameState = this._tileManager.find(childTile.id).frameState;
|
|
8426
8483
|
this.updateTile(childTile, frameState);
|
|
8427
|
-
if (this._frameNumber === frameState.frameNumber) {
|
|
8484
|
+
if (this._frameNumber === frameState.frameNumber && (this.traversalFinished || new Date().getTime() - this.lastUpdate > this.updateDebounceTime)) {
|
|
8428
8485
|
this.executeTraversal(childTile, frameState);
|
|
8429
8486
|
}
|
|
8430
8487
|
}
|
|
@@ -8550,7 +8607,7 @@
|
|
|
8550
8607
|
this.asset = {};
|
|
8551
8608
|
this.credits = {};
|
|
8552
8609
|
this.description = this.options.description || "";
|
|
8553
|
-
this._initializeTileSet(json);
|
|
8610
|
+
this.tilesetInitializationPromise = this._initializeTileSet(json);
|
|
8554
8611
|
}
|
|
8555
8612
|
destroy() {
|
|
8556
8613
|
this._destroy();
|
|
@@ -8587,14 +8644,17 @@
|
|
|
8587
8644
|
return Boolean(this._extensionsUsed && this._extensionsUsed.indexOf(extensionName) > -1);
|
|
8588
8645
|
}
|
|
8589
8646
|
update(viewports = null) {
|
|
8590
|
-
|
|
8591
|
-
viewports
|
|
8592
|
-
|
|
8593
|
-
|
|
8594
|
-
|
|
8595
|
-
|
|
8647
|
+
this.tilesetInitializationPromise.then(() => {
|
|
8648
|
+
if (!viewports && this.lastUpdatedVieports) {
|
|
8649
|
+
viewports = this.lastUpdatedVieports;
|
|
8650
|
+
} else {
|
|
8651
|
+
this.lastUpdatedVieports = viewports;
|
|
8652
|
+
}
|
|
8653
|
+
this.doUpdate(viewports);
|
|
8654
|
+
});
|
|
8596
8655
|
}
|
|
8597
8656
|
async selectTiles(viewports = null) {
|
|
8657
|
+
await this.tilesetInitializationPromise;
|
|
8598
8658
|
if (viewports) {
|
|
8599
8659
|
this.lastUpdatedVieports = viewports;
|
|
8600
8660
|
}
|
|
@@ -8726,17 +8786,43 @@
|
|
|
8726
8786
|
this.stats.get(TILES_RENDERABLE).count = tilesRenderable;
|
|
8727
8787
|
this.stats.get(POINTS_COUNT).count = pointsRenderable;
|
|
8728
8788
|
}
|
|
8729
|
-
_initializeTileSet(tilesetJson) {
|
|
8789
|
+
async _initializeTileSet(tilesetJson) {
|
|
8790
|
+
if (this.type === TILESET_TYPE.I3S) {
|
|
8791
|
+
this.calculateViewPropsI3S();
|
|
8792
|
+
tilesetJson.root = await tilesetJson.root;
|
|
8793
|
+
}
|
|
8730
8794
|
this.root = this._initializeTileHeaders(tilesetJson, null);
|
|
8731
8795
|
if (this.type === TILESET_TYPE.TILES3D) {
|
|
8732
|
-
this.
|
|
8796
|
+
this._initializeTiles3DTileset(tilesetJson);
|
|
8797
|
+
this.calculateViewPropsTiles3D();
|
|
8733
8798
|
}
|
|
8734
8799
|
if (this.type === TILESET_TYPE.I3S) {
|
|
8735
8800
|
this._initializeI3STileset();
|
|
8736
8801
|
}
|
|
8737
|
-
this._calculateViewProps();
|
|
8738
8802
|
}
|
|
8739
|
-
|
|
8803
|
+
calculateViewPropsI3S() {
|
|
8804
|
+
const fullExtent = this.tileset.fullExtent;
|
|
8805
|
+
if (fullExtent) {
|
|
8806
|
+
const { xmin, xmax, ymin, ymax, zmin, zmax } = fullExtent;
|
|
8807
|
+
this.cartographicCenter = new Vector3(xmin + (xmax - xmin) / 2, ymin + (ymax - ymin) / 2, zmin + (zmax - zmin) / 2);
|
|
8808
|
+
this.cartesianCenter = Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter, new Vector3());
|
|
8809
|
+
this.zoom = getZoomFromFullExtent(fullExtent, this.cartographicCenter, this.cartesianCenter);
|
|
8810
|
+
return;
|
|
8811
|
+
}
|
|
8812
|
+
const extent = this.tileset.store?.extent;
|
|
8813
|
+
if (extent) {
|
|
8814
|
+
const [xmin, ymin, xmax, ymax] = extent;
|
|
8815
|
+
this.cartographicCenter = new Vector3(xmin + (xmax - xmin) / 2, ymin + (ymax - ymin) / 2, 0);
|
|
8816
|
+
this.cartesianCenter = Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter, new Vector3());
|
|
8817
|
+
this.zoom = getZoomFromExtent(extent, this.cartographicCenter, this.cartesianCenter);
|
|
8818
|
+
return;
|
|
8819
|
+
}
|
|
8820
|
+
console.warn("Extent is not defined in the tileset header");
|
|
8821
|
+
this.cartographicCenter = new Vector3();
|
|
8822
|
+
this.zoom = 1;
|
|
8823
|
+
return;
|
|
8824
|
+
}
|
|
8825
|
+
calculateViewPropsTiles3D() {
|
|
8740
8826
|
const root = this.root;
|
|
8741
8827
|
assert2(root);
|
|
8742
8828
|
const { center } = root.boundingVolume;
|
|
@@ -8894,7 +8980,7 @@
|
|
|
8894
8980
|
this._unloadTile(tile);
|
|
8895
8981
|
tile.destroy();
|
|
8896
8982
|
}
|
|
8897
|
-
|
|
8983
|
+
_initializeTiles3DTileset(tilesetJson) {
|
|
8898
8984
|
this.asset = tilesetJson.asset;
|
|
8899
8985
|
if (!this.asset) {
|
|
8900
8986
|
throw new Error("Tileset must have an asset property.");
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.getZoomFromBoundingVolume = getZoomFromBoundingVolume;
|
|
9
|
+
exports.getZoomFromFullExtent = getZoomFromFullExtent;
|
|
10
|
+
exports.getZoomFromExtent = getZoomFromExtent;
|
|
11
|
+
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
7
13
|
|
|
8
14
|
var _core = require("@math.gl/core");
|
|
9
15
|
|
|
10
16
|
var _culling = require("@math.gl/culling");
|
|
11
17
|
|
|
18
|
+
var _geospatial = require("@math.gl/geospatial");
|
|
19
|
+
|
|
12
20
|
var WGS84_RADIUS_X = 6378137.0;
|
|
13
21
|
var WGS84_RADIUS_Y = 6378137.0;
|
|
14
22
|
var WGS84_RADIUS_Z = 6356752.3142451793;
|
|
@@ -33,6 +41,30 @@ function getZoomFromBoundingVolume(boundingVolume, cartorgraphicCenter) {
|
|
|
33
41
|
return 1;
|
|
34
42
|
}
|
|
35
43
|
|
|
44
|
+
function getZoomFromFullExtent(fullExtent, cartorgraphicCenter, cartesianCenter) {
|
|
45
|
+
var extentVertex = _geospatial.Ellipsoid.WGS84.cartographicToCartesian([fullExtent.xmax, fullExtent.ymax, fullExtent.zmax], new _core.Vector3());
|
|
46
|
+
|
|
47
|
+
var extentSize = Math.sqrt(Math.pow(extentVertex[0] - cartesianCenter[0], 2) + Math.pow(extentVertex[1] - cartesianCenter[1], 2) + Math.pow(extentVertex[2] - cartesianCenter[2], 2));
|
|
48
|
+
return Math.log2(WGS84_RADIUS_Z / (extentSize + cartorgraphicCenter[2]));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function getZoomFromExtent(extent, cartorgraphicCenter, cartesianCenter) {
|
|
52
|
+
var _extent = (0, _slicedToArray2.default)(extent, 4),
|
|
53
|
+
xmin = _extent[0],
|
|
54
|
+
ymin = _extent[1],
|
|
55
|
+
xmax = _extent[2],
|
|
56
|
+
ymax = _extent[3];
|
|
57
|
+
|
|
58
|
+
return getZoomFromFullExtent({
|
|
59
|
+
xmin: xmin,
|
|
60
|
+
xmax: xmax,
|
|
61
|
+
ymin: ymin,
|
|
62
|
+
ymax: ymax,
|
|
63
|
+
zmin: 0,
|
|
64
|
+
zmax: 0
|
|
65
|
+
}, cartorgraphicCenter, cartesianCenter);
|
|
66
|
+
}
|
|
67
|
+
|
|
36
68
|
function getObbSize(halfAxes) {
|
|
37
69
|
halfAxes.getColumn(0, scratchVector);
|
|
38
70
|
var axeY = halfAxes.getColumn(1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/tileset/helpers/zoom.ts"],"names":["WGS84_RADIUS_X","WGS84_RADIUS_Y","WGS84_RADIUS_Z","scratchVector","Vector3","getZoomFromBoundingVolume","boundingVolume","cartorgraphicCenter","OrientedBoundingBox","halfAxes","obbSize","getObbSize","Math","log2","BoundingSphere","radius","width","height","zoomX","zoomY","getColumn","axeY","axeZ","farthestVertex","add","size","len"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/tileset/helpers/zoom.ts"],"names":["WGS84_RADIUS_X","WGS84_RADIUS_Y","WGS84_RADIUS_Z","scratchVector","Vector3","getZoomFromBoundingVolume","boundingVolume","cartorgraphicCenter","OrientedBoundingBox","halfAxes","obbSize","getObbSize","Math","log2","BoundingSphere","radius","width","height","zoomX","zoomY","getZoomFromFullExtent","fullExtent","cartesianCenter","extentVertex","Ellipsoid","WGS84","cartographicToCartesian","xmax","ymax","zmax","extentSize","sqrt","pow","getZoomFromExtent","extent","xmin","ymin","zmin","getColumn","axeY","axeZ","farthestVertex","add","size","len"],"mappings":"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","sourcesContent":["import {Vector3} from '@math.gl/core';\nimport {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {BoundingRectangle} from '../../types';\n\nconst WGS84_RADIUS_X = 6378137.0;\nconst WGS84_RADIUS_Y = 6378137.0;\nconst WGS84_RADIUS_Z = 6356752.3142451793;\n\nconst scratchVector = new Vector3();\n\n/**\n * Calculate appropriate zoom value for a particular boundingVolume\n * @param boundingVolume - the instance of bounding volume\n * @param cartorgraphicCenter - cartographic center of the bounding volume\n * @returns {number} - zoom value\n */\nexport function getZoomFromBoundingVolume(\n boundingVolume: BoundingSphere | OrientedBoundingBox | BoundingRectangle,\n cartorgraphicCenter: Vector3\n) {\n if (boundingVolume instanceof OrientedBoundingBox) {\n // OrientedBoundingBox\n const {halfAxes} = boundingVolume;\n const obbSize = getObbSize(halfAxes);\n // Use WGS84_RADIUS_Z to allign with BoundingSphere algorithm\n // Add the tile elevation value for correct zooming to elevated tiles\n return Math.log2(WGS84_RADIUS_Z / (obbSize + cartorgraphicCenter[2]));\n } else if (boundingVolume instanceof BoundingSphere) {\n // BoundingSphere\n const {radius} = boundingVolume;\n // Add the tile elevation value for correct zooming to elevated tiles\n return Math.log2(WGS84_RADIUS_Z / (radius + cartorgraphicCenter[2]));\n } else if (boundingVolume.width && boundingVolume.height) {\n // BoundingRectangle\n const {width, height} = boundingVolume;\n const zoomX = Math.log2(WGS84_RADIUS_X / width);\n const zoomY = Math.log2(WGS84_RADIUS_Y / height);\n\n return (zoomX + zoomY) / 2;\n }\n\n return 1;\n}\n\n/**\n * Calculate initial zoom for the tileset from 3D `fullExtent` defined in\n * the tileset metadata\n * @param fullExtent - 3D extent of the tileset\n * @param fullExtent.xmin - minimal longitude in decimal degrees\n * @param fullExtent.xmax - maximal longitude in decimal degrees\n * @param fullExtent.ymin - minimal latitude in decimal degrees\n * @param fullExtent.ymax - maximal latitude in decimal degrees\n * @param fullExtent.zmin - minimal elevation in meters\n * @param fullExtent.zmax - maximal elevation in meters\n * @param cartorgraphicCenter - tileset center in cartographic coordinate system\n * @param cartesianCenter - tileset center in cartesian coordinate system\n * @returns - initial zoom for the tileset\n */\nexport function getZoomFromFullExtent(\n fullExtent: {\n xmin: number;\n xmax: number;\n ymin: number;\n ymax: number;\n zmin: number;\n zmax: number;\n },\n cartorgraphicCenter: Vector3,\n cartesianCenter: Vector3\n) {\n const extentVertex = Ellipsoid.WGS84.cartographicToCartesian(\n [fullExtent.xmax, fullExtent.ymax, fullExtent.zmax],\n new Vector3()\n );\n const extentSize = Math.sqrt(\n Math.pow(extentVertex[0] - cartesianCenter[0], 2) +\n Math.pow(extentVertex[1] - cartesianCenter[1], 2) +\n Math.pow(extentVertex[2] - cartesianCenter[2], 2)\n );\n return Math.log2(WGS84_RADIUS_Z / (extentSize + cartorgraphicCenter[2]));\n}\n\n/**\n * Calculate initial zoom for the tileset from 2D `extent` defined in\n * the tileset metadata\n * @param extent - 2D extent of the tileset. It is array of 4 elements [xmin, ymin, xmax, ymax]\n * @param extent[0] - minimal longitude in decimal degrees\n * @param extent[1] - minimal latitude in decimal degrees\n * @param extent[2] - maximal longitude in decimal degrees\n * @param extent[3] - maximal latitude in decimal degrees\n * @param cartorgraphicCenter - tileset center in cartographic coordinate system\n * @param cartesianCenter - tileset center in cartesian coordinate system\n * @returns - initial zoom for the tileset\n */\nexport function getZoomFromExtent(\n extent: [number, number, number, number],\n cartorgraphicCenter: Vector3,\n cartesianCenter: Vector3\n) {\n const [xmin, ymin, xmax, ymax] = extent;\n return getZoomFromFullExtent(\n {xmin, xmax, ymin, ymax, zmin: 0, zmax: 0},\n cartorgraphicCenter,\n cartesianCenter\n );\n}\n\nfunction getObbSize(halfAxes) {\n halfAxes.getColumn(0, scratchVector);\n const axeY = halfAxes.getColumn(1);\n const axeZ = halfAxes.getColumn(2);\n const farthestVertex = scratchVector.add(axeY).add(axeZ);\n const size = farthestVertex.len();\n return size;\n}\n"],"file":"zoom.js"}
|
|
@@ -122,6 +122,7 @@ var Tileset3D = function () {
|
|
|
122
122
|
(0, _defineProperty2.default)(this, "geometricError", void 0);
|
|
123
123
|
(0, _defineProperty2.default)(this, "selectedTiles", void 0);
|
|
124
124
|
(0, _defineProperty2.default)(this, "updatePromise", null);
|
|
125
|
+
(0, _defineProperty2.default)(this, "tilesetInitializationPromise", void 0);
|
|
125
126
|
(0, _defineProperty2.default)(this, "cartographicCenter", void 0);
|
|
126
127
|
(0, _defineProperty2.default)(this, "cartesianCenter", void 0);
|
|
127
128
|
(0, _defineProperty2.default)(this, "zoom", void 0);
|
|
@@ -193,8 +194,7 @@ var Tileset3D = function () {
|
|
|
193
194
|
this.asset = {};
|
|
194
195
|
this.credits = {};
|
|
195
196
|
this.description = this.options.description || '';
|
|
196
|
-
|
|
197
|
-
this._initializeTileSet(json);
|
|
197
|
+
this.tilesetInitializationPromise = this._initializeTileSet(json);
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
(0, _createClass2.default)(Tileset3D, [{
|
|
@@ -255,21 +255,24 @@ var Tileset3D = function () {
|
|
|
255
255
|
}, {
|
|
256
256
|
key: "update",
|
|
257
257
|
value: function update() {
|
|
258
|
-
var
|
|
258
|
+
var _this = this;
|
|
259
259
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
260
|
+
var viewports = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
261
|
+
this.tilesetInitializationPromise.then(function () {
|
|
262
|
+
if (!viewports && _this.lastUpdatedVieports) {
|
|
263
|
+
viewports = _this.lastUpdatedVieports;
|
|
264
|
+
} else {
|
|
265
|
+
_this.lastUpdatedVieports = viewports;
|
|
266
|
+
}
|
|
265
267
|
|
|
266
|
-
|
|
268
|
+
_this.doUpdate(viewports);
|
|
269
|
+
});
|
|
267
270
|
}
|
|
268
271
|
}, {
|
|
269
272
|
key: "selectTiles",
|
|
270
273
|
value: function () {
|
|
271
274
|
var _selectTiles = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee() {
|
|
272
|
-
var
|
|
275
|
+
var _this2 = this;
|
|
273
276
|
|
|
274
277
|
var viewports,
|
|
275
278
|
_args = arguments;
|
|
@@ -278,7 +281,10 @@ var Tileset3D = function () {
|
|
|
278
281
|
switch (_context.prev = _context.next) {
|
|
279
282
|
case 0:
|
|
280
283
|
viewports = _args.length > 0 && _args[0] !== undefined ? _args[0] : null;
|
|
284
|
+
_context.next = 3;
|
|
285
|
+
return this.tilesetInitializationPromise;
|
|
281
286
|
|
|
287
|
+
case 3:
|
|
282
288
|
if (viewports) {
|
|
283
289
|
this.lastUpdatedVieports = viewports;
|
|
284
290
|
}
|
|
@@ -286,17 +292,17 @@ var Tileset3D = function () {
|
|
|
286
292
|
if (!this.updatePromise) {
|
|
287
293
|
this.updatePromise = new Promise(function (resolve) {
|
|
288
294
|
setTimeout(function () {
|
|
289
|
-
|
|
295
|
+
_this2.doUpdate(_this2.lastUpdatedVieports);
|
|
290
296
|
|
|
291
|
-
resolve(
|
|
292
|
-
|
|
293
|
-
},
|
|
297
|
+
resolve(_this2._frameNumber);
|
|
298
|
+
_this2.updatePromise = null;
|
|
299
|
+
}, _this2.options.debounceTime);
|
|
294
300
|
});
|
|
295
301
|
}
|
|
296
302
|
|
|
297
303
|
return _context.abrupt("return", this.updatePromise);
|
|
298
304
|
|
|
299
|
-
case
|
|
305
|
+
case 6:
|
|
300
306
|
case "end":
|
|
301
307
|
return _context.stop();
|
|
302
308
|
}
|
|
@@ -559,22 +565,94 @@ var Tileset3D = function () {
|
|
|
559
565
|
}
|
|
560
566
|
}, {
|
|
561
567
|
key: "_initializeTileSet",
|
|
562
|
-
value: function
|
|
563
|
-
|
|
568
|
+
value: function () {
|
|
569
|
+
var _initializeTileSet2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(tilesetJson) {
|
|
570
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
571
|
+
while (1) {
|
|
572
|
+
switch (_context2.prev = _context2.next) {
|
|
573
|
+
case 0:
|
|
574
|
+
if (!(this.type === _constants.TILESET_TYPE.I3S)) {
|
|
575
|
+
_context2.next = 5;
|
|
576
|
+
break;
|
|
577
|
+
}
|
|
564
578
|
|
|
565
|
-
|
|
566
|
-
|
|
579
|
+
this.calculateViewPropsI3S();
|
|
580
|
+
_context2.next = 4;
|
|
581
|
+
return tilesetJson.root;
|
|
582
|
+
|
|
583
|
+
case 4:
|
|
584
|
+
tilesetJson.root = _context2.sent;
|
|
585
|
+
|
|
586
|
+
case 5:
|
|
587
|
+
this.root = this._initializeTileHeaders(tilesetJson, null);
|
|
588
|
+
|
|
589
|
+
if (this.type === _constants.TILESET_TYPE.TILES3D) {
|
|
590
|
+
this._initializeTiles3DTileset(tilesetJson);
|
|
591
|
+
|
|
592
|
+
this.calculateViewPropsTiles3D();
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
if (this.type === _constants.TILESET_TYPE.I3S) {
|
|
596
|
+
this._initializeI3STileset();
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
case 8:
|
|
600
|
+
case "end":
|
|
601
|
+
return _context2.stop();
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}, _callee2, this);
|
|
605
|
+
}));
|
|
606
|
+
|
|
607
|
+
function _initializeTileSet(_x) {
|
|
608
|
+
return _initializeTileSet2.apply(this, arguments);
|
|
567
609
|
}
|
|
568
610
|
|
|
569
|
-
|
|
570
|
-
|
|
611
|
+
return _initializeTileSet;
|
|
612
|
+
}()
|
|
613
|
+
}, {
|
|
614
|
+
key: "calculateViewPropsI3S",
|
|
615
|
+
value: function calculateViewPropsI3S() {
|
|
616
|
+
var _this$tileset$store;
|
|
617
|
+
|
|
618
|
+
var fullExtent = this.tileset.fullExtent;
|
|
619
|
+
|
|
620
|
+
if (fullExtent) {
|
|
621
|
+
var xmin = fullExtent.xmin,
|
|
622
|
+
xmax = fullExtent.xmax,
|
|
623
|
+
ymin = fullExtent.ymin,
|
|
624
|
+
ymax = fullExtent.ymax,
|
|
625
|
+
zmin = fullExtent.zmin,
|
|
626
|
+
zmax = fullExtent.zmax;
|
|
627
|
+
this.cartographicCenter = new _core.Vector3(xmin + (xmax - xmin) / 2, ymin + (ymax - ymin) / 2, zmin + (zmax - zmin) / 2);
|
|
628
|
+
this.cartesianCenter = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter, new _core.Vector3());
|
|
629
|
+
this.zoom = (0, _zoom.getZoomFromFullExtent)(fullExtent, this.cartographicCenter, this.cartesianCenter);
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
var extent = (_this$tileset$store = this.tileset.store) === null || _this$tileset$store === void 0 ? void 0 : _this$tileset$store.extent;
|
|
634
|
+
|
|
635
|
+
if (extent) {
|
|
636
|
+
var _extent = (0, _slicedToArray2.default)(extent, 4),
|
|
637
|
+
_xmin = _extent[0],
|
|
638
|
+
_ymin = _extent[1],
|
|
639
|
+
_xmax = _extent[2],
|
|
640
|
+
_ymax = _extent[3];
|
|
641
|
+
|
|
642
|
+
this.cartographicCenter = new _core.Vector3(_xmin + (_xmax - _xmin) / 2, _ymin + (_ymax - _ymin) / 2, 0);
|
|
643
|
+
this.cartesianCenter = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter, new _core.Vector3());
|
|
644
|
+
this.zoom = (0, _zoom.getZoomFromExtent)(extent, this.cartographicCenter, this.cartesianCenter);
|
|
645
|
+
return;
|
|
571
646
|
}
|
|
572
647
|
|
|
573
|
-
|
|
648
|
+
console.warn('Extent is not defined in the tileset header');
|
|
649
|
+
this.cartographicCenter = new _core.Vector3();
|
|
650
|
+
this.zoom = 1;
|
|
651
|
+
return;
|
|
574
652
|
}
|
|
575
653
|
}, {
|
|
576
|
-
key: "
|
|
577
|
-
value: function
|
|
654
|
+
key: "calculateViewPropsTiles3D",
|
|
655
|
+
value: function calculateViewPropsTiles3D() {
|
|
578
656
|
var root = this.root;
|
|
579
657
|
(0, _loaderUtils.assert)(root);
|
|
580
658
|
var center = root.boundingVolume.center;
|
|
@@ -679,48 +757,48 @@ var Tileset3D = function () {
|
|
|
679
757
|
}, {
|
|
680
758
|
key: "_loadTile",
|
|
681
759
|
value: function () {
|
|
682
|
-
var _loadTile2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function
|
|
760
|
+
var _loadTile2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(tile) {
|
|
683
761
|
var loaded;
|
|
684
|
-
return _regenerator.default.wrap(function
|
|
762
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
685
763
|
while (1) {
|
|
686
|
-
switch (
|
|
764
|
+
switch (_context3.prev = _context3.next) {
|
|
687
765
|
case 0:
|
|
688
|
-
|
|
766
|
+
_context3.prev = 0;
|
|
689
767
|
|
|
690
768
|
this._onStartTileLoading();
|
|
691
769
|
|
|
692
|
-
|
|
770
|
+
_context3.next = 4;
|
|
693
771
|
return tile.loadContent();
|
|
694
772
|
|
|
695
773
|
case 4:
|
|
696
|
-
loaded =
|
|
697
|
-
|
|
774
|
+
loaded = _context3.sent;
|
|
775
|
+
_context3.next = 10;
|
|
698
776
|
break;
|
|
699
777
|
|
|
700
778
|
case 7:
|
|
701
|
-
|
|
702
|
-
|
|
779
|
+
_context3.prev = 7;
|
|
780
|
+
_context3.t0 = _context3["catch"](0);
|
|
703
781
|
|
|
704
|
-
this._onTileLoadError(tile,
|
|
782
|
+
this._onTileLoadError(tile, _context3.t0);
|
|
705
783
|
|
|
706
784
|
case 10:
|
|
707
|
-
|
|
785
|
+
_context3.prev = 10;
|
|
708
786
|
|
|
709
787
|
this._onEndTileLoading();
|
|
710
788
|
|
|
711
789
|
this._onTileLoad(tile, loaded);
|
|
712
790
|
|
|
713
|
-
return
|
|
791
|
+
return _context3.finish(10);
|
|
714
792
|
|
|
715
793
|
case 14:
|
|
716
794
|
case "end":
|
|
717
|
-
return
|
|
795
|
+
return _context3.stop();
|
|
718
796
|
}
|
|
719
797
|
}
|
|
720
|
-
},
|
|
798
|
+
}, _callee3, this, [[0, 7, 10, 14]]);
|
|
721
799
|
}));
|
|
722
800
|
|
|
723
|
-
function _loadTile(
|
|
801
|
+
function _loadTile(_x2) {
|
|
724
802
|
return _loadTile2.apply(this, arguments);
|
|
725
803
|
}
|
|
726
804
|
|
|
@@ -859,8 +937,8 @@ var Tileset3D = function () {
|
|
|
859
937
|
tile.destroy();
|
|
860
938
|
}
|
|
861
939
|
}, {
|
|
862
|
-
key: "
|
|
863
|
-
value: function
|
|
940
|
+
key: "_initializeTiles3DTileset",
|
|
941
|
+
value: function _initializeTiles3DTileset(tilesetJson) {
|
|
864
942
|
this.asset = tilesetJson.asset;
|
|
865
943
|
|
|
866
944
|
if (!this.asset) {
|