@loaders.gl/tiles 4.1.0-alpha.1 → 4.1.0-alpha.11
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/constants.d.ts.map +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/dist.dev.js +29 -10
- package/dist/index.cjs +39 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/tileset/format-3d-tiles/tileset-3d-traverser.d.ts.map +1 -1
- package/dist/tileset/format-3d-tiles/tileset-3d-traverser.js.map +1 -1
- package/dist/tileset/helpers/i3s-lod.d.ts.map +1 -1
- package/dist/tileset/helpers/i3s-lod.js.map +1 -1
- package/dist/tileset/helpers/tiles-3d-lod.d.ts.map +1 -1
- package/dist/tileset/helpers/tiles-3d-lod.js.map +1 -1
- package/dist/tileset/helpers/transform-utils.d.ts.map +1 -1
- package/dist/tileset/helpers/transform-utils.js.map +1 -1
- package/dist/tileset/helpers/zoom.d.ts.map +1 -1
- package/dist/tileset/helpers/zoom.js.map +1 -1
- package/dist/tileset/tile-3d.d.ts.map +1 -1
- package/dist/tileset/tile-3d.js.map +1 -1
- package/dist/tileset/tileset-3d.d.ts +15 -0
- package/dist/tileset/tileset-3d.d.ts.map +1 -1
- package/dist/tileset/tileset-3d.js +21 -0
- package/dist/tileset/tileset-3d.js.map +1 -1
- package/dist/tileset/tileset-cache.d.ts.map +1 -1
- package/dist/tileset/tileset-cache.js.map +1 -1
- package/dist/tileset/tileset-traverser.d.ts +0 -1
- package/dist/tileset/tileset-traverser.d.ts.map +1 -1
- package/dist/tileset/tileset-traverser.js +8 -10
- package/dist/tileset/tileset-traverser.js.map +1 -1
- package/dist/utils/doubly-linked-list-node.d.ts.map +1 -1
- package/dist/utils/doubly-linked-list-node.js.map +1 -1
- package/package.json +6 -6
- package/src/constants.ts +2 -1
- package/src/index.ts +2 -1
- package/src/tileset/format-3d-tiles/tileset-3d-traverser.ts +2 -1
- package/src/tileset/helpers/i3s-lod.ts +2 -1
- package/src/tileset/helpers/tiles-3d-lod.ts +2 -1
- package/src/tileset/helpers/transform-utils.ts +2 -1
- package/src/tileset/helpers/zoom.ts +2 -1
- package/src/tileset/tile-3d.ts +2 -1
- package/src/tileset/tileset-3d.ts +46 -2
- package/src/tileset/tileset-cache.ts +2 -1
- package/src/tileset/tileset-traverser.ts +15 -19
- package/src/utils/doubly-linked-list-node.ts +2 -1
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,gBAAgB,GACxB,UAAU,GACV,SAAS,GACT,YAAY,GACZ,OAAO,GACP,SAAS,GACT,QAAQ,CAAC;AAEb,eAAO,MAAM,kBAAkB;;;;;;;CAO9B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,SAAS,CAAC;AAE/C,oBAAY,eAAe;IACzB,GAAG,IAAI,CAAE,gFAAgF;IACzF,OAAO,IAAI;CACZ;AAED,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,YAAY,GAAG,YAAY,GAAG,MAAM,CAAC;AAEtE,oBAAY,SAAS;IACnB,KAAK,UAAU;IACf,UAAU,eAAe;IACzB,UAAU,eAAe;IACzB,IAAI,SAAS;CACd;AAED,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,SAAS,CAAC;AAE5C,oBAAY,YAAY;IACtB,GAAG,QAAQ;IACX,OAAO,YAAY;CACpB;AAED,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG,oBAAoB,CAAC;AAEpE,oBAAY,eAAe;IACzB,eAAe,mBAAmB;IAClC,oBAAoB,uBAAuB;CAC5C;AAGD,MAAM,MAAM,sBAAsB,GAAG,cAAc,GAAG,kBAAkB,GAAG,mBAAmB,CAAC;AAE/F,eAAO,MAAM,wBAAwB;;;;CAIpC,CAAC"}
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["TILE_CONTENT_STATE","UNLOADED","LOADING","PROCESSING","READY","EXPIRED","FAILED","TILE_REFINEMENT","TILE_TYPE","TILESET_TYPE","LOD_METRIC_TYPE","TILE3D_OPTIMIZATION_HINT","NOT_COMPUTED","USE_OPTIMIZATION","SKIP_OPTIMIZATION"],"sources":["../src/constants.ts"],"sourcesContent":["// loaders.gl
|
|
1
|
+
{"version":3,"file":"constants.js","names":["TILE_CONTENT_STATE","UNLOADED","LOADING","PROCESSING","READY","EXPIRED","FAILED","TILE_REFINEMENT","TILE_TYPE","TILESET_TYPE","LOD_METRIC_TYPE","TILE3D_OPTIMIZATION_HINT","NOT_COMPUTED","USE_OPTIMIZATION","SKIP_OPTIMIZATION"],"sources":["../src/constants.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nexport type TileContentState =\n | 'unloaded' // Has never been requested\n | 'loading' // Is waiting on a pending request\n | 'processing' // Request received. Contents are being processed for rendering. Depending on the content, it might make its own requests for external data.\n | 'ready' // Ready to render.\n | 'expired' // Is expired and will be unloaded once new content is loaded.\n | 'failed'; // Request failed.\n\nexport const TILE_CONTENT_STATE = {\n UNLOADED: 0, // Has never been requested\n LOADING: 1, // Is waiting on a pending request\n PROCESSING: 2, // Request received. Contents are being processed for rendering. Depending on the content, it might make its own requests for external data.\n READY: 3, // Ready to render.\n EXPIRED: 4, // Is expired and will be unloaded once new content is loaded.\n FAILED: 5 // Request failed.\n};\n\nexport type TileRefinement = 'add' | 'replace';\n\nexport enum TILE_REFINEMENT {\n ADD = 1, // Render tile and, if screen space error exceeded, also refine to its children.\n REPLACE = 2 // Render tile or, if screen space error exceeded, refine to its descendants instead.\n}\n\nexport type TileType = 'empty' | 'scenegraph' | 'pointcloud' | 'mesh';\n\nexport enum TILE_TYPE {\n EMPTY = 'empty',\n SCENEGRAPH = 'scenegraph',\n POINTCLOUD = 'pointcloud',\n MESH = 'mesh'\n}\n\nexport type TilesetType = 'I3S' | 'TILES3D';\n\nexport enum TILESET_TYPE {\n I3S = 'I3S',\n TILES3D = 'TILES3D'\n}\n\nexport type LODMetricType = 'geometricError' | 'maxScreenThreshold';\n\nexport enum LOD_METRIC_TYPE {\n GEOMETRIC_ERROR = 'geometricError',\n MAX_SCREEN_THRESHOLD = 'maxScreenThreshold'\n}\n\n// Cesium 3D Tiles Specific\nexport type Tile3DOptimizationHint = 'NOT_COMPUTED' | 'USE_OPTIMIZATION' | 'SKIP_OPTIMIZATION';\n\nexport const TILE3D_OPTIMIZATION_HINT = {\n NOT_COMPUTED: -1,\n USE_OPTIMIZATION: 1,\n SKIP_OPTIMIZATION: 0\n};\n"],"mappings":"AAYA,OAAO,MAAMA,kBAAkB,GAAG;EAChCC,QAAQ,EAAE,CAAC;EACXC,OAAO,EAAE,CAAC;EACVC,UAAU,EAAE,CAAC;EACbC,KAAK,EAAE,CAAC;EACRC,OAAO,EAAE,CAAC;EACVC,MAAM,EAAE;AACV,CAAC;AAID,WAAYC,eAAe,aAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA;AAO3B,WAAYC,SAAS,aAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAAA,OAATA,SAAS;AAAA;AASrB,WAAYC,YAAY,aAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAA,OAAZA,YAAY;AAAA;AAOxB,WAAYC,eAAe,aAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA;AAQ3B,OAAO,MAAMC,wBAAwB,GAAG;EACtCC,YAAY,EAAE,CAAC,CAAC;EAChBC,gBAAgB,EAAE,CAAC;EACnBC,iBAAiB,EAAE;AACrB,CAAC"}
|
package/dist/dist.dev.js
CHANGED
|
@@ -6368,7 +6368,6 @@ var __exports__ = (() => {
|
|
|
6368
6368
|
var DEFAULT_PROPS2 = {
|
|
6369
6369
|
loadSiblings: false,
|
|
6370
6370
|
skipLevelOfDetail: false,
|
|
6371
|
-
maximumScreenSpaceError: 2,
|
|
6372
6371
|
updateTransforms: true,
|
|
6373
6372
|
onTraversalEnd: () => {
|
|
6374
6373
|
},
|
|
@@ -6541,7 +6540,7 @@ var __exports__ = (() => {
|
|
|
6541
6540
|
if (useParentMetric) {
|
|
6542
6541
|
screenSpaceError = tile.getScreenSpaceError(frameState, true);
|
|
6543
6542
|
}
|
|
6544
|
-
return screenSpaceError >
|
|
6543
|
+
return screenSpaceError > tile.tileset.memoryAdjustedScreenSpaceError;
|
|
6545
6544
|
}
|
|
6546
6545
|
updateTileVisibility(tile, frameState) {
|
|
6547
6546
|
const viewportIds = [];
|
|
@@ -6572,24 +6571,23 @@ var __exports__ = (() => {
|
|
|
6572
6571
|
let allDescendantsLoaded = true;
|
|
6573
6572
|
const stack = this._emptyTraversalStack;
|
|
6574
6573
|
stack.push(root);
|
|
6575
|
-
while (stack.length > 0
|
|
6574
|
+
while (stack.length > 0) {
|
|
6576
6575
|
const tile = stack.pop();
|
|
6576
|
+
const traverse = !tile.hasRenderContent && this.canTraverse(tile, frameState, false, false);
|
|
6577
|
+
const emptyLeaf = !tile.hasRenderContent && tile.children.length === 0;
|
|
6578
|
+
if (!traverse && !tile.contentAvailable && !emptyLeaf) {
|
|
6579
|
+
allDescendantsLoaded = false;
|
|
6580
|
+
}
|
|
6577
6581
|
this.updateTile(tile, frameState);
|
|
6578
6582
|
if (!tile.isVisibleAndInRequestVolume) {
|
|
6579
6583
|
this.loadTile(tile, frameState);
|
|
6584
|
+
this.touchTile(tile, frameState);
|
|
6580
6585
|
}
|
|
6581
|
-
this.touchTile(tile, frameState);
|
|
6582
|
-
const traverse = !tile.hasRenderContent && this.canTraverse(tile, frameState, false, true);
|
|
6583
6586
|
if (traverse) {
|
|
6584
6587
|
const children = tile.children;
|
|
6585
6588
|
for (const child of children) {
|
|
6586
|
-
if (stack.find(child)) {
|
|
6587
|
-
stack.delete(child);
|
|
6588
|
-
}
|
|
6589
6589
|
stack.push(child);
|
|
6590
6590
|
}
|
|
6591
|
-
} else if (!tile.contentAvailable && !tile.hasEmptyContent) {
|
|
6592
|
-
allDescendantsLoaded = false;
|
|
6593
6591
|
}
|
|
6594
6592
|
}
|
|
6595
6593
|
return allDescendantsLoaded;
|
|
@@ -7200,6 +7198,7 @@ var __exports__ = (() => {
|
|
|
7200
7198
|
throttleRequests: true,
|
|
7201
7199
|
maxRequests: 64,
|
|
7202
7200
|
maximumMemoryUsage: 32,
|
|
7201
|
+
memoryCacheOverflow: 1,
|
|
7203
7202
|
maximumTilesSelected: 0,
|
|
7204
7203
|
debounceTime: 0,
|
|
7205
7204
|
onTileLoad: () => {
|
|
@@ -7212,6 +7211,7 @@ var __exports__ = (() => {
|
|
|
7212
7211
|
contentLoader: void 0,
|
|
7213
7212
|
viewDistanceScale: 1,
|
|
7214
7213
|
maximumScreenSpaceError: 8,
|
|
7214
|
+
memoryAdjustedScreenSpaceError: false,
|
|
7215
7215
|
loadTiles: true,
|
|
7216
7216
|
updateTransforms: true,
|
|
7217
7217
|
viewportTraversersMap: null,
|
|
@@ -7232,6 +7232,7 @@ var __exports__ = (() => {
|
|
|
7232
7232
|
var TILES_LOAD_FAILED = "Failed Tile Loads";
|
|
7233
7233
|
var POINTS_COUNT = "Points/Vertices";
|
|
7234
7234
|
var TILES_GPU_MEMORY = "Tile Memory Use";
|
|
7235
|
+
var MAXIMUM_SSE = "Maximum Screen Space Error";
|
|
7235
7236
|
var Tileset3D = class {
|
|
7236
7237
|
root = null;
|
|
7237
7238
|
roots = {};
|
|
@@ -7253,6 +7254,9 @@ var __exports__ = (() => {
|
|
|
7253
7254
|
dynamicScreenSpaceErrorComputedDensity = 0;
|
|
7254
7255
|
maximumMemoryUsage = 32;
|
|
7255
7256
|
gpuMemoryUsageInBytes = 0;
|
|
7257
|
+
memoryAdjustedScreenSpaceError = 0;
|
|
7258
|
+
_cacheBytes = 0;
|
|
7259
|
+
_cacheOverflowBytes = 0;
|
|
7256
7260
|
_frameNumber = 0;
|
|
7257
7261
|
_queryParams = {};
|
|
7258
7262
|
_extensionsUsed = [];
|
|
@@ -7288,6 +7292,9 @@ var __exports__ = (() => {
|
|
|
7288
7292
|
throttleRequests: this.options.throttleRequests,
|
|
7289
7293
|
maxRequests: this.options.maxRequests
|
|
7290
7294
|
});
|
|
7295
|
+
this.memoryAdjustedScreenSpaceError = this.options.maximumScreenSpaceError;
|
|
7296
|
+
this._cacheBytes = this.options.maximumMemoryUsage * 1024 * 1024;
|
|
7297
|
+
this._cacheOverflowBytes = this.options.memoryCacheOverflow * 1024 * 1024;
|
|
7291
7298
|
this.stats = new Stats({
|
|
7292
7299
|
id: this.url
|
|
7293
7300
|
});
|
|
@@ -7359,6 +7366,13 @@ var __exports__ = (() => {
|
|
|
7359
7366
|
}
|
|
7360
7367
|
return this.updatePromise;
|
|
7361
7368
|
}
|
|
7369
|
+
adjustScreenSpaceError() {
|
|
7370
|
+
if (this.gpuMemoryUsageInBytes < this._cacheBytes) {
|
|
7371
|
+
this.memoryAdjustedScreenSpaceError = Math.max(this.memoryAdjustedScreenSpaceError / 1.02, this.options.maximumScreenSpaceError);
|
|
7372
|
+
} else if (this.gpuMemoryUsageInBytes > this._cacheBytes + this._cacheOverflowBytes) {
|
|
7373
|
+
this.memoryAdjustedScreenSpaceError *= 1.02;
|
|
7374
|
+
}
|
|
7375
|
+
}
|
|
7362
7376
|
doUpdate(viewports) {
|
|
7363
7377
|
if ("loadTiles" in this.options && !this.options.loadTiles) {
|
|
7364
7378
|
return;
|
|
@@ -7479,6 +7493,7 @@ var __exports__ = (() => {
|
|
|
7479
7493
|
this.stats.get(TILES_IN_VIEW).count = this.selectedTiles.length;
|
|
7480
7494
|
this.stats.get(TILES_RENDERABLE).count = tilesRenderable;
|
|
7481
7495
|
this.stats.get(POINTS_COUNT).count = pointsRenderable;
|
|
7496
|
+
this.stats.get(MAXIMUM_SSE).count = this.memoryAdjustedScreenSpaceError;
|
|
7482
7497
|
}
|
|
7483
7498
|
async _initializeTileSet(tilesetJson) {
|
|
7484
7499
|
if (this.type === TILESET_TYPE.I3S) {
|
|
@@ -7556,6 +7571,7 @@ var __exports__ = (() => {
|
|
|
7556
7571
|
this.stats.get(TILES_LOAD_FAILED);
|
|
7557
7572
|
this.stats.get(POINTS_COUNT);
|
|
7558
7573
|
this.stats.get(TILES_GPU_MEMORY, "memory");
|
|
7574
|
+
this.stats.get(MAXIMUM_SSE);
|
|
7559
7575
|
}
|
|
7560
7576
|
_initializeTileHeaders(tilesetJson, parentTileHeader) {
|
|
7561
7577
|
const rootTile = new Tile3D(this, tilesetJson.root, parentTileHeader);
|
|
@@ -7688,6 +7704,9 @@ var __exports__ = (() => {
|
|
|
7688
7704
|
this.stats.get(TILES_IN_MEMORY).incrementCount();
|
|
7689
7705
|
this.gpuMemoryUsageInBytes += tile.gpuMemoryUsageInBytes || 0;
|
|
7690
7706
|
this.stats.get(TILES_GPU_MEMORY).count = this.gpuMemoryUsageInBytes;
|
|
7707
|
+
if (this.options.memoryAdjustedScreenSpaceError) {
|
|
7708
|
+
this.adjustScreenSpaceError();
|
|
7709
|
+
}
|
|
7691
7710
|
}
|
|
7692
7711
|
_unloadTile(tile) {
|
|
7693
7712
|
this.gpuMemoryUsageInBytes -= tile.gpuMemoryUsageInBytes || 0;
|
package/dist/index.cjs
CHANGED
|
@@ -892,7 +892,6 @@ var ManagedArray = class {
|
|
|
892
892
|
var DEFAULT_PROPS = {
|
|
893
893
|
loadSiblings: false,
|
|
894
894
|
skipLevelOfDetail: false,
|
|
895
|
-
maximumScreenSpaceError: 2,
|
|
896
895
|
updateTransforms: true,
|
|
897
896
|
onTraversalEnd: () => {
|
|
898
897
|
},
|
|
@@ -1089,7 +1088,7 @@ var TilesetTraverser = class {
|
|
|
1089
1088
|
if (useParentMetric) {
|
|
1090
1089
|
screenSpaceError = tile.getScreenSpaceError(frameState, true);
|
|
1091
1090
|
}
|
|
1092
|
-
return screenSpaceError >
|
|
1091
|
+
return screenSpaceError > tile.tileset.memoryAdjustedScreenSpaceError;
|
|
1093
1092
|
}
|
|
1094
1093
|
updateTileVisibility(tile, frameState) {
|
|
1095
1094
|
const viewportIds = [];
|
|
@@ -1123,24 +1122,23 @@ var TilesetTraverser = class {
|
|
|
1123
1122
|
let allDescendantsLoaded = true;
|
|
1124
1123
|
const stack = this._emptyTraversalStack;
|
|
1125
1124
|
stack.push(root);
|
|
1126
|
-
while (stack.length > 0
|
|
1125
|
+
while (stack.length > 0) {
|
|
1127
1126
|
const tile = stack.pop();
|
|
1127
|
+
const traverse = !tile.hasRenderContent && this.canTraverse(tile, frameState, false, false);
|
|
1128
|
+
const emptyLeaf = !tile.hasRenderContent && tile.children.length === 0;
|
|
1129
|
+
if (!traverse && !tile.contentAvailable && !emptyLeaf) {
|
|
1130
|
+
allDescendantsLoaded = false;
|
|
1131
|
+
}
|
|
1128
1132
|
this.updateTile(tile, frameState);
|
|
1129
1133
|
if (!tile.isVisibleAndInRequestVolume) {
|
|
1130
1134
|
this.loadTile(tile, frameState);
|
|
1135
|
+
this.touchTile(tile, frameState);
|
|
1131
1136
|
}
|
|
1132
|
-
this.touchTile(tile, frameState);
|
|
1133
|
-
const traverse = !tile.hasRenderContent && this.canTraverse(tile, frameState, false, true);
|
|
1134
1137
|
if (traverse) {
|
|
1135
1138
|
const children = tile.children;
|
|
1136
1139
|
for (const child of children) {
|
|
1137
|
-
if (stack.find(child)) {
|
|
1138
|
-
stack.delete(child);
|
|
1139
|
-
}
|
|
1140
1140
|
stack.push(child);
|
|
1141
1141
|
}
|
|
1142
|
-
} else if (!tile.contentAvailable && !tile.hasEmptyContent) {
|
|
1143
|
-
allDescendantsLoaded = false;
|
|
1144
1142
|
}
|
|
1145
1143
|
}
|
|
1146
1144
|
return allDescendantsLoaded;
|
|
@@ -1909,7 +1907,9 @@ var DEFAULT_PROPS2 = {
|
|
|
1909
1907
|
modelMatrix: new import_core10.Matrix4(),
|
|
1910
1908
|
throttleRequests: true,
|
|
1911
1909
|
maxRequests: 64,
|
|
1910
|
+
/** Default memory values optimized for viewing mesh-based 3D Tiles on both mobile and desktop devices */
|
|
1912
1911
|
maximumMemoryUsage: 32,
|
|
1912
|
+
memoryCacheOverflow: 1,
|
|
1913
1913
|
maximumTilesSelected: 0,
|
|
1914
1914
|
debounceTime: 0,
|
|
1915
1915
|
onTileLoad: () => {
|
|
@@ -1922,6 +1922,7 @@ var DEFAULT_PROPS2 = {
|
|
|
1922
1922
|
contentLoader: void 0,
|
|
1923
1923
|
viewDistanceScale: 1,
|
|
1924
1924
|
maximumScreenSpaceError: 8,
|
|
1925
|
+
memoryAdjustedScreenSpaceError: false,
|
|
1925
1926
|
loadTiles: true,
|
|
1926
1927
|
updateTransforms: true,
|
|
1927
1928
|
viewportTraversersMap: null,
|
|
@@ -1940,6 +1941,7 @@ var TILES_UNLOADED = "Tiles Unloaded";
|
|
|
1940
1941
|
var TILES_LOAD_FAILED = "Failed Tile Loads";
|
|
1941
1942
|
var POINTS_COUNT = "Points/Vertices";
|
|
1942
1943
|
var TILES_GPU_MEMORY = "Tile Memory Use";
|
|
1944
|
+
var MAXIMUM_SSE = "Maximum Screen Space Error";
|
|
1943
1945
|
var Tileset3D = class {
|
|
1944
1946
|
/**
|
|
1945
1947
|
* Create a new Tileset3D
|
|
@@ -1974,6 +1976,15 @@ var Tileset3D = class {
|
|
|
1974
1976
|
this.maximumMemoryUsage = 32;
|
|
1975
1977
|
/** The total amount of GPU memory in bytes used by the tileset. */
|
|
1976
1978
|
this.gpuMemoryUsageInBytes = 0;
|
|
1979
|
+
/**
|
|
1980
|
+
* If loading the level of detail required by maximumScreenSpaceError
|
|
1981
|
+
* results in the memory usage exceeding maximumMemoryUsage (GPU), level of detail refinement
|
|
1982
|
+
* will instead use this (larger) adjusted screen space error to achieve the
|
|
1983
|
+
* best possible visual quality within the available memory.
|
|
1984
|
+
*/
|
|
1985
|
+
this.memoryAdjustedScreenSpaceError = 0;
|
|
1986
|
+
this._cacheBytes = 0;
|
|
1987
|
+
this._cacheOverflowBytes = 0;
|
|
1977
1988
|
/** Update tracker. increase in each update cycle. */
|
|
1978
1989
|
this._frameNumber = 0;
|
|
1979
1990
|
this._queryParams = {};
|
|
@@ -2010,6 +2021,9 @@ var Tileset3D = class {
|
|
|
2010
2021
|
throttleRequests: this.options.throttleRequests,
|
|
2011
2022
|
maxRequests: this.options.maxRequests
|
|
2012
2023
|
});
|
|
2024
|
+
this.memoryAdjustedScreenSpaceError = this.options.maximumScreenSpaceError;
|
|
2025
|
+
this._cacheBytes = this.options.maximumMemoryUsage * 1024 * 1024;
|
|
2026
|
+
this._cacheOverflowBytes = this.options.memoryCacheOverflow * 1024 * 1024;
|
|
2013
2027
|
this.stats = new import_stats.Stats({ id: this.url });
|
|
2014
2028
|
this._initializeStats();
|
|
2015
2029
|
this.tilesetInitializationPromise = this._initializeTileSet(tileset);
|
|
@@ -2098,6 +2112,16 @@ var Tileset3D = class {
|
|
|
2098
2112
|
}
|
|
2099
2113
|
return this.updatePromise;
|
|
2100
2114
|
}
|
|
2115
|
+
adjustScreenSpaceError() {
|
|
2116
|
+
if (this.gpuMemoryUsageInBytes < this._cacheBytes) {
|
|
2117
|
+
this.memoryAdjustedScreenSpaceError = Math.max(
|
|
2118
|
+
this.memoryAdjustedScreenSpaceError / 1.02,
|
|
2119
|
+
this.options.maximumScreenSpaceError
|
|
2120
|
+
);
|
|
2121
|
+
} else if (this.gpuMemoryUsageInBytes > this._cacheBytes + this._cacheOverflowBytes) {
|
|
2122
|
+
this.memoryAdjustedScreenSpaceError *= 1.02;
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2101
2125
|
/**
|
|
2102
2126
|
* Update visible tiles relying on a list of viewports
|
|
2103
2127
|
* @param viewports viewports
|
|
@@ -2235,6 +2259,7 @@ var Tileset3D = class {
|
|
|
2235
2259
|
this.stats.get(TILES_IN_VIEW).count = this.selectedTiles.length;
|
|
2236
2260
|
this.stats.get(TILES_RENDERABLE).count = tilesRenderable;
|
|
2237
2261
|
this.stats.get(POINTS_COUNT).count = pointsRenderable;
|
|
2262
|
+
this.stats.get(MAXIMUM_SSE).count = this.memoryAdjustedScreenSpaceError;
|
|
2238
2263
|
}
|
|
2239
2264
|
async _initializeTileSet(tilesetJson) {
|
|
2240
2265
|
if (this.type === "I3S" /* I3S */) {
|
|
@@ -2320,6 +2345,7 @@ var Tileset3D = class {
|
|
|
2320
2345
|
this.stats.get(TILES_LOAD_FAILED);
|
|
2321
2346
|
this.stats.get(POINTS_COUNT);
|
|
2322
2347
|
this.stats.get(TILES_GPU_MEMORY, "memory");
|
|
2348
|
+
this.stats.get(MAXIMUM_SSE);
|
|
2323
2349
|
}
|
|
2324
2350
|
// Installs the main tileset JSON file or a tileset JSON file referenced from a tile.
|
|
2325
2351
|
// eslint-disable-next-line max-statements
|
|
@@ -2459,6 +2485,9 @@ var Tileset3D = class {
|
|
|
2459
2485
|
this.stats.get(TILES_IN_MEMORY).incrementCount();
|
|
2460
2486
|
this.gpuMemoryUsageInBytes += tile.gpuMemoryUsageInBytes || 0;
|
|
2461
2487
|
this.stats.get(TILES_GPU_MEMORY).count = this.gpuMemoryUsageInBytes;
|
|
2488
|
+
if (this.options.memoryAdjustedScreenSpaceError) {
|
|
2489
|
+
this.adjustScreenSpaceError();
|
|
2490
|
+
}
|
|
2462
2491
|
}
|
|
2463
2492
|
_unloadTile(tile) {
|
|
2464
2493
|
this.gpuMemoryUsageInBytes -= tile.gpuMemoryUsageInBytes || 0;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,YAAY,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAC,gBAAgB,EAAC,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAC,oBAAoB,EAAC,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAC,uBAAuB,EAAC,MAAM,mCAAmC,CAAC;AAE1E,OAAO,EAAC,aAAa,EAAC,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,SAAS,EACT,YAAY,EACZ,eAAe,EAChB,MAAM,aAAa,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Tileset3D","Tile3D","TilesetTraverser","TilesetCache","createBoundingVolume","calculateTransformProps","getFrameState","getLodStatus","TILE_CONTENT_STATE","TILE_REFINEMENT","TILE_TYPE","TILESET_TYPE","LOD_METRIC_TYPE"],"sources":["../src/index.ts"],"sourcesContent":["// loaders.gl
|
|
1
|
+
{"version":3,"file":"index.js","names":["Tileset3D","Tile3D","TilesetTraverser","TilesetCache","createBoundingVolume","calculateTransformProps","getFrameState","getLodStatus","TILE_CONTENT_STATE","TILE_REFINEMENT","TILE_TYPE","TILESET_TYPE","LOD_METRIC_TYPE"],"sources":["../src/index.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nexport type {Tileset3DProps} from './tileset/tileset-3d';\nexport {Tileset3D} from './tileset/tileset-3d';\nexport {Tile3D} from './tileset/tile-3d';\n\nexport {TilesetTraverser} from './tileset/tileset-traverser';\nexport {TilesetCache} from './tileset/tileset-cache';\n\nexport {createBoundingVolume} from './tileset/helpers/bounding-volume';\nexport {calculateTransformProps} from './tileset/helpers/transform-utils';\n\nexport {getFrameState} from './tileset/helpers/frame-state';\nexport {getLodStatus} from './tileset/helpers/i3s-lod';\n\nexport {\n TILE_CONTENT_STATE,\n TILE_REFINEMENT,\n TILE_TYPE,\n TILESET_TYPE,\n LOD_METRIC_TYPE\n} from './constants';\n"],"mappings":"SAKQA,SAAS;AAAA,SACTC,MAAM;AAAA,SAENC,gBAAgB;AAAA,SAChBC,YAAY;AAAA,SAEZC,oBAAoB;AAAA,SACpBC,uBAAuB;AAAA,SAEvBC,aAAa;AAAA,SACbC,YAAY;AAAA,SAGlBC,kBAAkB,EAClBC,eAAe,EACfC,SAAS,EACTC,YAAY,EACZC,eAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tileset-3d-traverser.d.ts","sourceRoot":"","sources":["../../../src/tileset/format-3d-tiles/tileset-3d-traverser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tileset-3d-traverser.d.ts","sourceRoot":"","sources":["../../../src/tileset/format-3d-tiles/tileset-3d-traverser.ts"],"names":[],"mappings":"AAQA,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAEtD,qBAAa,kBAAmB,SAAQ,gBAAgB;IACtD,uBAAuB,CAAC,CAAC,KAAA,EAAE,CAAC,KAAA;IAO5B,oBAAoB,CAAC,IAAI,KAAA,EAAE,UAAU,KAAA;IAmCrC,0BAA0B,CAAC,IAAI,KAAA,EAAE,UAAU,KAAA;CAS5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tileset-3d-traverser.js","names":["TILE3D_OPTIMIZATION_HINT","TILE_REFINEMENT","TilesetTraverser","Tileset3DTraverser","compareDistanceToCamera","a","b","_distanceToCamera","_centerZDepth","updateTileVisibility","tile","frameState","isVisibleAndInRequestVolume","hasChildren","children","length","hasTilesetContent","firstChild","_visible","meetsScreenSpaceErrorEarly","replace","refine","REPLACE","useOptimization","_optimChildrenWithinParent","USE_OPTIMIZATION","anyChildrenVisible","parent","ADD","shouldRefine"],"sources":["../../../src/tileset/format-3d-tiles/tileset-3d-traverser.ts"],"sourcesContent":["// loaders.gl
|
|
1
|
+
{"version":3,"file":"tileset-3d-traverser.js","names":["TILE3D_OPTIMIZATION_HINT","TILE_REFINEMENT","TilesetTraverser","Tileset3DTraverser","compareDistanceToCamera","a","b","_distanceToCamera","_centerZDepth","updateTileVisibility","tile","frameState","isVisibleAndInRequestVolume","hasChildren","children","length","hasTilesetContent","firstChild","_visible","meetsScreenSpaceErrorEarly","replace","refine","REPLACE","useOptimization","_optimChildrenWithinParent","USE_OPTIMIZATION","anyChildrenVisible","parent","ADD","shouldRefine"],"sources":["../../../src/tileset/format-3d-tiles/tileset-3d-traverser.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\nimport {TILE3D_OPTIMIZATION_HINT, TILE_REFINEMENT} from '../../constants';\nimport {TilesetTraverser} from '../tileset-traverser';\n\nexport class Tileset3DTraverser extends TilesetTraverser {\n compareDistanceToCamera(a, b) {\n // Sort by farthest child first since this is going on a stack\n return b._distanceToCamera === 0 && a._distanceToCamera === 0\n ? b._centerZDepth - a._centerZDepth\n : b._distanceToCamera - a._distanceToCamera;\n }\n\n updateTileVisibility(tile, frameState) {\n super.updateTileVisibility(tile, frameState);\n\n // Optimization - if none of the tile's children are visible then this tile isn't visible\n if (!tile.isVisibleAndInRequestVolume) {\n return;\n }\n\n const hasChildren = tile.children.length > 0;\n if (tile.hasTilesetContent && hasChildren) {\n // Use the root tile's visibility instead of this tile's visibility.\n // The root tile may be culled by the children bounds optimization in which\n // case this tile should also be culled.\n const firstChild = tile.children[0];\n this.updateTileVisibility(firstChild, frameState);\n tile._visible = firstChild._visible;\n return;\n }\n\n if (this.meetsScreenSpaceErrorEarly(tile, frameState)) {\n tile._visible = false;\n return;\n }\n\n const replace = tile.refine === TILE_REFINEMENT.REPLACE;\n const useOptimization =\n tile._optimChildrenWithinParent === TILE3D_OPTIMIZATION_HINT.USE_OPTIMIZATION;\n if (replace && useOptimization && hasChildren) {\n if (!this.anyChildrenVisible(tile, frameState)) {\n tile._visible = false;\n return;\n }\n }\n }\n\n meetsScreenSpaceErrorEarly(tile, frameState) {\n const {parent} = tile;\n if (!parent || parent.hasTilesetContent || parent.refine !== TILE_REFINEMENT.ADD) {\n return false;\n }\n\n // Use parent's geometric error with child's box to see if the tile already meet the SSE\n return !this.shouldRefine(tile, frameState, true);\n }\n}\n"],"mappings":"SAOQA,wBAAwB,EAAEC,eAAe;AAAA,SACzCC,gBAAgB;AAExB,OAAO,MAAMC,kBAAkB,SAASD,gBAAgB,CAAC;EACvDE,uBAAuBA,CAACC,CAAC,EAAEC,CAAC,EAAE;IAE5B,OAAOA,CAAC,CAACC,iBAAiB,KAAK,CAAC,IAAIF,CAAC,CAACE,iBAAiB,KAAK,CAAC,GACzDD,CAAC,CAACE,aAAa,GAAGH,CAAC,CAACG,aAAa,GACjCF,CAAC,CAACC,iBAAiB,GAAGF,CAAC,CAACE,iBAAiB;EAC/C;EAEAE,oBAAoBA,CAACC,IAAI,EAAEC,UAAU,EAAE;IACrC,KAAK,CAACF,oBAAoB,CAACC,IAAI,EAAEC,UAAU,CAAC;IAG5C,IAAI,CAACD,IAAI,CAACE,2BAA2B,EAAE;MACrC;IACF;IAEA,MAAMC,WAAW,GAAGH,IAAI,CAACI,QAAQ,CAACC,MAAM,GAAG,CAAC;IAC5C,IAAIL,IAAI,CAACM,iBAAiB,IAAIH,WAAW,EAAE;MAIzC,MAAMI,UAAU,GAAGP,IAAI,CAACI,QAAQ,CAAC,CAAC,CAAC;MACnC,IAAI,CAACL,oBAAoB,CAACQ,UAAU,EAAEN,UAAU,CAAC;MACjDD,IAAI,CAACQ,QAAQ,GAAGD,UAAU,CAACC,QAAQ;MACnC;IACF;IAEA,IAAI,IAAI,CAACC,0BAA0B,CAACT,IAAI,EAAEC,UAAU,CAAC,EAAE;MACrDD,IAAI,CAACQ,QAAQ,GAAG,KAAK;MACrB;IACF;IAEA,MAAME,OAAO,GAAGV,IAAI,CAACW,MAAM,KAAKpB,eAAe,CAACqB,OAAO;IACvD,MAAMC,eAAe,GACnBb,IAAI,CAACc,0BAA0B,KAAKxB,wBAAwB,CAACyB,gBAAgB;IAC/E,IAAIL,OAAO,IAAIG,eAAe,IAAIV,WAAW,EAAE;MAC7C,IAAI,CAAC,IAAI,CAACa,kBAAkB,CAAChB,IAAI,EAAEC,UAAU,CAAC,EAAE;QAC9CD,IAAI,CAACQ,QAAQ,GAAG,KAAK;QACrB;MACF;IACF;EACF;EAEAC,0BAA0BA,CAACT,IAAI,EAAEC,UAAU,EAAE;IAC3C,MAAM;MAACgB;IAAM,CAAC,GAAGjB,IAAI;IACrB,IAAI,CAACiB,MAAM,IAAIA,MAAM,CAACX,iBAAiB,IAAIW,MAAM,CAACN,MAAM,KAAKpB,eAAe,CAAC2B,GAAG,EAAE;MAChF,OAAO,KAAK;IACd;IAGA,OAAO,CAAC,IAAI,CAACC,YAAY,CAACnB,IAAI,EAAEC,UAAU,EAAE,IAAI,CAAC;EACnD;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i3s-lod.d.ts","sourceRoot":"","sources":["../../../src/tileset/helpers/i3s-lod.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"i3s-lod.d.ts","sourceRoot":"","sources":["../../../src/tileset/helpers/i3s-lod.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,MAAM,EAAC,MAAM,YAAY,CAAC;AAClC,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAUzC;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAczF;AAED;;;;;GAKG;AAEH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,MAAM,CA6C/E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i3s-lod.js","names":["Matrix4","Vector3","Ellipsoid","cameraPositionCartesian","toEye","cameraPositionEnu","extraVertexEnu","projectedOriginVector","enuToCartesianMatrix","cartesianToEnuMatrix","getLodStatus","tile","frameState","lodMetricValue","isNaN","screenSize","getProjectedRadius","header","children","topDownViewport","viewport","mbsLat","mbs","mbsLon","mbsZ","mbsR","mbsCenterCartesian","boundingVolume","center","cameraPositionCartographic","unprojectPosition","cameraPosition","WGS84","cartographicToCartesian","copy","subtract","normalize","eastNorthUpToFixedFrame","invert","transform","projection","Math","sqrt","extraZ","extraVertexCartesian","extraVectorCartesian","radiusVector","cross","scale","sphereMbsBorderVertexCartesian","add","sphereMbsBorderVertexCartographic","cartesianToCartographic","projectedOrigin","project","projectedMbsBorderVertex","projectedRadius","magnitude"],"sources":["../../../src/tileset/helpers/i3s-lod.ts"],"sourcesContent":["// loaders.gl
|
|
1
|
+
{"version":3,"file":"i3s-lod.js","names":["Matrix4","Vector3","Ellipsoid","cameraPositionCartesian","toEye","cameraPositionEnu","extraVertexEnu","projectedOriginVector","enuToCartesianMatrix","cartesianToEnuMatrix","getLodStatus","tile","frameState","lodMetricValue","isNaN","screenSize","getProjectedRadius","header","children","topDownViewport","viewport","mbsLat","mbs","mbsLon","mbsZ","mbsR","mbsCenterCartesian","boundingVolume","center","cameraPositionCartographic","unprojectPosition","cameraPosition","WGS84","cartographicToCartesian","copy","subtract","normalize","eastNorthUpToFixedFrame","invert","transform","projection","Math","sqrt","extraZ","extraVertexCartesian","extraVectorCartesian","radiusVector","cross","scale","sphereMbsBorderVertexCartesian","add","sphereMbsBorderVertexCartographic","cartesianToCartographic","projectedOrigin","project","projectedMbsBorderVertex","projectedRadius","magnitude"],"sources":["../../../src/tileset/helpers/i3s-lod.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Matrix4, Vector3} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {Tile3D} from '../tile-3d';\nimport {FrameState} from './frame-state';\n\nconst cameraPositionCartesian = new Vector3();\nconst toEye = new Vector3();\nconst cameraPositionEnu = new Vector3();\nconst extraVertexEnu = new Vector3();\nconst projectedOriginVector = new Vector3();\nconst enuToCartesianMatrix = new Matrix4();\nconst cartesianToEnuMatrix = new Matrix4();\n\n/**\n * For the maxScreenThreshold error metric, maxError means that you should replace the node with it's children\n as soon as the nodes bounding sphere has a screen radius larger than maxError pixels.\n In this sense a value of 0 means you should always load it's children,\n or if it's a leaf node, you should always display it.\n * @param tile \n * @param frameState \n * @returns \n */\nexport function getLodStatus(tile: Tile3D, frameState: FrameState): 'DIG' | 'OUT' | 'DRAW' {\n if (tile.lodMetricValue === 0 || isNaN(tile.lodMetricValue)) {\n return 'DIG';\n }\n const screenSize = 2 * getProjectedRadius(tile, frameState);\n if (screenSize < 2) {\n return 'OUT';\n }\n if (!tile.header.children || screenSize <= tile.lodMetricValue) {\n return 'DRAW';\n } else if (tile.header.children) {\n return 'DIG';\n }\n return 'OUT';\n}\n\n/**\n * Calculate size of MBS radius projected on the screen plane\n * @param tile\n * @param frameState\n * @returns\n */\n// eslint-disable-next-line max-statements\nexport function getProjectedRadius(tile: Tile3D, frameState: FrameState): number {\n const {topDownViewport: viewport} = frameState;\n const mbsLat = tile.header.mbs[1];\n const mbsLon = tile.header.mbs[0];\n const mbsZ = tile.header.mbs[2];\n const mbsR = tile.header.mbs[3];\n const mbsCenterCartesian = [...tile.boundingVolume.center];\n const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);\n Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, cameraPositionCartesian);\n\n // ---------------------------\n // Calculate mbs border vertex\n // ---------------------------\n toEye.copy(cameraPositionCartesian).subtract(mbsCenterCartesian).normalize();\n // Add extra vector to form plane\n Ellipsoid.WGS84.eastNorthUpToFixedFrame(mbsCenterCartesian, enuToCartesianMatrix);\n cartesianToEnuMatrix.copy(enuToCartesianMatrix).invert();\n cameraPositionEnu.copy(cameraPositionCartesian).transform(cartesianToEnuMatrix);\n // Mean Proportionals in Right Triangles - Altitude rule\n // https://mathbitsnotebook.com/Geometry/RightTriangles/RTmeanRight.html\n const projection = Math.sqrt(\n cameraPositionEnu[0] * cameraPositionEnu[0] + cameraPositionEnu[1] * cameraPositionEnu[1]\n );\n const extraZ = (projection * projection) / cameraPositionEnu[2];\n extraVertexEnu.copy([cameraPositionEnu[0], cameraPositionEnu[1], extraZ]);\n const extraVertexCartesian = extraVertexEnu.transform(enuToCartesianMatrix);\n const extraVectorCartesian = extraVertexCartesian.subtract(mbsCenterCartesian).normalize();\n // We need radius vector orthogonal to toEye vector\n const radiusVector = toEye.cross(extraVectorCartesian).normalize().scale(mbsR);\n const sphereMbsBorderVertexCartesian = radiusVector.add(mbsCenterCartesian);\n const sphereMbsBorderVertexCartographic = Ellipsoid.WGS84.cartesianToCartographic(\n sphereMbsBorderVertexCartesian\n );\n // ---------------------------\n\n // Project center vertex and border vertex and calculate projected radius of MBS\n const projectedOrigin = viewport.project([mbsLon, mbsLat, mbsZ]);\n const projectedMbsBorderVertex = viewport.project(\n sphereMbsBorderVertexCartographic as [number, number, number]\n );\n const projectedRadius = projectedOriginVector\n .copy(projectedOrigin)\n .subtract(projectedMbsBorderVertex)\n .magnitude();\n return projectedRadius;\n}\n"],"mappings":"AAIA,SAAQA,OAAO,EAAEC,OAAO,QAAO,eAAe;AAC9C,SAAQC,SAAS,QAAO,qBAAqB;AAI7C,MAAMC,uBAAuB,GAAG,IAAIF,OAAO,CAAC,CAAC;AAC7C,MAAMG,KAAK,GAAG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KAAK,CAACF,oBAAoB,CAAC,CAACT,SAAS,CAAC,CAAC,CAACY,KAAK,CAACvB,IAAI,CAAC;EAC9E,MAAMwB,8BAA8B,GAAGH,YAAY,CAACI,GAAG,CAACxB,kBAAkB,CAAC;EAC3E,MAAMyB,iCAAiC,GAAGjD,SAAS,CAAC8B,KAAK,CAACoB,uBAAuB,CAC/EH,8BACF,CAAC;EAID,MAAMI,eAAe,GAAGjC,QAAQ,CAACkC,OAAO,CAAC,CAAC/B,MAAM,EAAEF,MAAM,EAAEG,IAAI,CAAC,CAAC;EAChE,MAAM+B,wBAAwB,GAAGnC,QAAQ,CAACkC,OAAO,CAC/CH,iCACF,CAAC;EACD,MAAMK,eAAe,GAAGjD,qBAAqB,CAC1C2B,IAAI,CAACmB,eAAe,CAAC,CACrBlB,QAAQ,CAACoB,wBAAwB,CAAC,CAClCE,SAAS,CAAC,CAAC;EACd,OAAOD,eAAe;AACxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiles-3d-lod.d.ts","sourceRoot":"","sources":["../../../src/tileset/helpers/tiles-3d-lod.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tiles-3d-lod.d.ts","sourceRoot":"","sources":["../../../src/tileset/helpers/tiles-3d-lod.ts"],"names":[],"mappings":"AAsBA,wBAAgB,gCAAgC,CAAC,IAAI,KAAA,EAAE,EAAC,MAAM,EAAE,aAAa,EAAC;;;CAAA,EAAE,OAAO,KAAK,UAqF3F;AAED,wBAAgB,GAAG,CAAC,gBAAgB,KAAA,EAAE,OAAO,KAAA,UAG5C;AAED,wBAAgB,0BAA0B,CAAC,OAAO,KAAA,EAAE,gBAAgB,KAAA,UAUnE;AAED,wBAAgB,0BAA0B,CAAC,IAAI,KAAA,EAAE,UAAU,KAAA,EAAE,kBAAkB,KAAA,UAsB9E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiles-3d-lod.js","names":["Matrix4","Vector3","clamp","scratchPositionNormal","scratchCartographic","scratchMatrix","scratchCenter","scratchPosition","scratchDirection","calculateDynamicScreenSpaceError","root","_ref","camera","mapProjection","options","arguments","length","undefined","dynamicScreenSpaceErrorHeightFalloff","dynamicScreenSpaceErrorDensity","up","direction","height","minimumHeight","maximumHeight","tileBoundingVolume","contentBoundingVolume","TileBoundingRegion","Cartesian3","normalize","positionWC","directionWC","positionCartographic","transformLocal","inverseTransformation","computedTransform","ellipsoid","boundingVolume","centerLocal","multiplyByPoint","center","magnitude","minimumRadius","centerCartographic","Cartographic","fromCartesian","positionLocal","UNIT_Z","multiplyByPointAsVector","z","TileOrientedBoundingBox","boxHeight","_header","box","TileBoundingSphere","radius","heightFalloff","heightClose","heightFar","t","dot","Math","abs","horizonFactor","fog","distanceToCamera","density","scalar","exp","getDynamicScreenSpaceError","tileset","dynamicScreenSpaceError","dynamicScreenSpaceErrorComputedDensity","factor","dynamicScreenSpaceErrorFactor","dynamicError","getTiles3DScreenSpaceError","tile","frameState","useParentLodMetric","parentLodMetricValue","parent","lodMetricValue","distance","max","_distanceToCamera","sseDenominator","viewDistanceScale","error"],"sources":["../../../src/tileset/helpers/tiles-3d-lod.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n// TODO - Dynamic screen space error provides an optimization when looking at\n// tilesets from above\n\n/* eslint-disable */\n// @ts-nocheck\nimport {Matrix4, Vector3, clamp} from '@math.gl/core';\n\nconst scratchPositionNormal = new Vector3();\nconst scratchCartographic = new Vector3();\nconst scratchMatrix = new Matrix4();\nconst scratchCenter = new Vector3();\nconst scratchPosition = new Vector3();\nconst scratchDirection = new Vector3();\n\n// eslint-disable-next-line max-statements, complexity\nexport function calculateDynamicScreenSpaceError(root, {camera, mapProjection}, options = {}) {\n const {dynamicScreenSpaceErrorHeightFalloff = 0.25, dynamicScreenSpaceErrorDensity = 0.00278} =\n options;\n\n let up;\n let direction;\n let height;\n let minimumHeight;\n let maximumHeight;\n\n const tileBoundingVolume = root.contentBoundingVolume;\n\n if (tileBoundingVolume instanceof TileBoundingRegion) {\n up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);\n direction = camera.directionWC;\n height = camera.positionCartographic.height;\n minimumHeight = tileBoundingVolume.minimumHeight;\n maximumHeight = tileBoundingVolume.maximumHeight;\n } else {\n // Transform camera position and direction into the local coordinate system of the tileset\n const transformLocal = Matrix4.inverseTransformation(root.computedTransform, scratchMatrix);\n const ellipsoid = mapProjection.ellipsoid;\n const boundingVolume = tileBoundingVolume.boundingVolume;\n const centerLocal = Matrix4.multiplyByPoint(\n transformLocal,\n boundingVolume.center,\n scratchCenter\n );\n if (Cartesian3.magnitude(centerLocal) > ellipsoid.minimumRadius) {\n // The tileset is defined in WGS84. Approximate the minimum and maximum height.\n const centerCartographic = Cartographic.fromCartesian(\n centerLocal,\n ellipsoid,\n scratchCartographic\n );\n up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);\n direction = camera.directionWC;\n height = camera.positionCartographic.height;\n minimumHeight = 0.0;\n maximumHeight = centerCartographic.height * 2.0;\n } else {\n // The tileset is defined in local coordinates (z-up)\n const positionLocal = Matrix4.multiplyByPoint(\n transformLocal,\n camera.positionWC,\n scratchPosition\n );\n up = Cartesian3.UNIT_Z;\n direction = Matrix4.multiplyByPointAsVector(\n transformLocal,\n camera.directionWC,\n scratchDirection\n );\n direction = Cartesian3.normalize(direction, direction);\n height = positionLocal.z;\n if (tileBoundingVolume instanceof TileOrientedBoundingBox) {\n // Assuming z-up, the last component stores the half-height of the box\n const boxHeight = root._header.boundingVolume.box[11];\n minimumHeight = centerLocal.z - boxHeight;\n maximumHeight = centerLocal.z + boxHeight;\n } else if (tileBoundingVolume instanceof TileBoundingSphere) {\n const radius = boundingVolume.radius;\n minimumHeight = centerLocal.z - radius;\n maximumHeight = centerLocal.z + radius;\n }\n }\n }\n\n // The range where the density starts to lessen. Start at the quarter height of the tileset.\n const heightFalloff = dynamicScreenSpaceErrorHeightFalloff;\n const heightClose = minimumHeight + (maximumHeight - minimumHeight) * heightFalloff;\n const heightFar = maximumHeight;\n\n const t = clamp((height - heightClose) / (heightFar - heightClose), 0.0, 1.0);\n\n // Increase density as the camera tilts towards the horizon\n const dot = Math.abs(Cartesian3.dot(direction, up));\n\n let horizonFactor = 1.0 - dot;\n\n // Weaken the horizon factor as the camera height increases, implying the camera is further away from the tileset.\n // The goal is to increase density for the \"street view\", not when viewing the tileset from a distance.\n horizonFactor = horizonFactor * (1.0 - t);\n\n return dynamicScreenSpaceErrorDensity * horizonFactor;\n}\n\nexport function fog(distanceToCamera, density) {\n const scalar = distanceToCamera * density;\n return 1.0 - Math.exp(-(scalar * scalar));\n}\n\nexport function getDynamicScreenSpaceError(tileset, distanceToCamera) {\n if (tileset.dynamicScreenSpaceError && tileset.dynamicScreenSpaceErrorComputedDensity) {\n const density = tileset.dynamicScreenSpaceErrorComputedDensity;\n const factor = tileset.dynamicScreenSpaceErrorFactor;\n // TODO: Refined screen space error that minimizes tiles in non-first-person\n const dynamicError = fog(distanceToCamera, density) * factor;\n return dynamicError;\n }\n\n return 0;\n}\n\nexport function getTiles3DScreenSpaceError(tile, frameState, useParentLodMetric) {\n const tileset = tile.tileset;\n const parentLodMetricValue = (tile.parent && tile.parent.lodMetricValue) || tile.lodMetricValue;\n const lodMetricValue = useParentLodMetric ? parentLodMetricValue : tile.lodMetricValue;\n\n // Leaf tiles do not have any error so save the computation\n if (lodMetricValue === 0.0) {\n return 0.0;\n }\n\n // TODO: Orthographic Frustum needs special treatment?\n // this._getOrthograhicScreenSpaceError();\n\n // Avoid divide by zero when viewer is inside the tile\n const distance = Math.max(tile._distanceToCamera, 1e-7);\n const {height, sseDenominator} = frameState;\n const {viewDistanceScale} = tileset.options;\n let error = (lodMetricValue * height * (viewDistanceScale || 1.0)) / (distance * sseDenominator);\n\n error -= getDynamicScreenSpaceError(t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C9D,MAAMC,MAAM,GAAGH,OAAO,CAACI,6BAA6B;IAEpD,MAAMC,YAAY,GAAGX,GAAG,CAACC,gBAAgB,EAAEC,OAAO,CAAC,GAAGO,MAAM;IAC5D,OAAOE,YAAY;EACrB;EAEA,OAAO,CAAC;AACV;AAEA,OAAO,SAASC,0BAA0BA,CAACC,IAAI,EAAEC,UAAU,EAAEC,kBAAkB,EAAE;EAC/E,MAAMT,OAAO,GAAGO,IAAI,CAACP,OAAO;EAC5B,MAAMU,oBAAoB,GAAIH,IAAI,CAACI,MAAM,IAAIJ,IAAI,CAACI,MAAM,CAACC,cAAc,IAAKL,IAAI,CAACK,cAAc;EAC/F,MAAMA,cAAc,GAAGH,kBAAkB,GAAGC,oBAAoB,GAAGH,IAAI,CAACK,cAAc;EAGtF,IAAIA,cAAc,KAAK,GAAG,EAAE;IAC1B,OAAO,GAAG;EACZ;EAMA,MAAMC,QAAQ,GAAGtB,IAAI,CAACuB,GAAG,CAACP,IAAI,CAACQ,iBAAiB,EAAE,IAAI,CAAC;EACvD,MAAM;IAAC/D,MAAM;IAAEgE;EAAc,CAAC,GAAGR,UAAU;EAC3C,MAAM;IAACS;EAAiB,CAAC,GAAGjB,OAAO,CAACxD,OAAO;EAC3C,IAAI0E,KAAK,GAAIN,cAAc,GAAG5D,MAAM,IAAIiE,iBAAiB,IAAI,GAAG,CAAC,IAAKJ,QAAQ,GAAGG,cAAc,CAAC;EAEhGE,KAAK,IAAInB,0BAA0B,CAACC,OAAO,EAAEa,QAAQ,CAAC;EAEtD,OAAOK,KAAK;AACd"}
|
|
1
|
+
{"version":3,"file":"tiles-3d-lod.js","names":["Matrix4","Vector3","clamp","scratchPositionNormal","scratchCartographic","scratchMatrix","scratchCenter","scratchPosition","scratchDirection","calculateDynamicScreenSpaceError","root","_ref","camera","mapProjection","options","arguments","length","undefined","dynamicScreenSpaceErrorHeightFalloff","dynamicScreenSpaceErrorDensity","up","direction","height","minimumHeight","maximumHeight","tileBoundingVolume","contentBoundingVolume","TileBoundingRegion","Cartesian3","normalize","positionWC","directionWC","positionCartographic","transformLocal","inverseTransformation","computedTransform","ellipsoid","boundingVolume","centerLocal","multiplyByPoint","center","magnitude","minimumRadius","centerCartographic","Cartographic","fromCartesian","positionLocal","UNIT_Z","multiplyByPointAsVector","z","TileOrientedBoundingBox","boxHeight","_header","box","TileBoundingSphere","radius","heightFalloff","heightClose","heightFar","t","dot","Math","abs","horizonFactor","fog","distanceToCamera","density","scalar","exp","getDynamicScreenSpaceError","tileset","dynamicScreenSpaceError","dynamicScreenSpaceErrorComputedDensity","factor","dynamicScreenSpaceErrorFactor","dynamicError","getTiles3DScreenSpaceError","tile","frameState","useParentLodMetric","parentLodMetricValue","parent","lodMetricValue","distance","max","_distanceToCamera","sseDenominator","viewDistanceScale","error"],"sources":["../../../src/tileset/helpers/tiles-3d-lod.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n// TODO - Dynamic screen space error provides an optimization when looking at\n// tilesets from above\n\n/* eslint-disable */\n// @ts-nocheck\nimport {Matrix4, Vector3, clamp} from '@math.gl/core';\n\nconst scratchPositionNormal = new Vector3();\nconst scratchCartographic = new Vector3();\nconst scratchMatrix = new Matrix4();\nconst scratchCenter = new Vector3();\nconst scratchPosition = new Vector3();\nconst scratchDirection = new Vector3();\n\n// eslint-disable-next-line max-statements, complexity\nexport function calculateDynamicScreenSpaceError(root, {camera, mapProjection}, options = {}) {\n const {dynamicScreenSpaceErrorHeightFalloff = 0.25, dynamicScreenSpaceErrorDensity = 0.00278} =\n options;\n\n let up;\n let direction;\n let height;\n let minimumHeight;\n let maximumHeight;\n\n const tileBoundingVolume = root.contentBoundingVolume;\n\n if (tileBoundingVolume instanceof TileBoundingRegion) {\n up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);\n direction = camera.directionWC;\n height = camera.positionCartographic.height;\n minimumHeight = tileBoundingVolume.minimumHeight;\n maximumHeight = tileBoundingVolume.maximumHeight;\n } else {\n // Transform camera position and direction into the local coordinate system of the tileset\n const transformLocal = Matrix4.inverseTransformation(root.computedTransform, scratchMatrix);\n const ellipsoid = mapProjection.ellipsoid;\n const boundingVolume = tileBoundingVolume.boundingVolume;\n const centerLocal = Matrix4.multiplyByPoint(\n transformLocal,\n boundingVolume.center,\n scratchCenter\n );\n if (Cartesian3.magnitude(centerLocal) > ellipsoid.minimumRadius) {\n // The tileset is defined in WGS84. Approximate the minimum and maximum height.\n const centerCartographic = Cartographic.fromCartesian(\n centerLocal,\n ellipsoid,\n scratchCartographic\n );\n up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);\n direction = camera.directionWC;\n height = camera.positionCartographic.height;\n minimumHeight = 0.0;\n maximumHeight = centerCartographic.height * 2.0;\n } else {\n // The tileset is defined in local coordinates (z-up)\n const positionLocal = Matrix4.multiplyByPoint(\n transformLocal,\n camera.positionWC,\n scratchPosition\n );\n up = Cartesian3.UNIT_Z;\n direction = Matrix4.multiplyByPointAsVector(\n transformLocal,\n camera.directionWC,\n scratchDirection\n );\n direction = Cartesian3.normalize(direction, direction);\n height = positionLocal.z;\n if (tileBoundingVolume instanceof TileOrientedBoundingBox) {\n // Assuming z-up, the last component stores the half-height of the box\n const boxHeight = root._header.boundingVolume.box[11];\n minimumHeight = centerLocal.z - boxHeight;\n maximumHeight = centerLocal.z + boxHeight;\n } else if (tileBoundingVolume instanceof TileBoundingSphere) {\n const radius = boundingVolume.radius;\n minimumHeight = centerLocal.z - radius;\n maximumHeight = centerLocal.z + radius;\n }\n }\n }\n\n // The range where the density starts to lessen. Start at the quarter height of the tileset.\n const heightFalloff = dynamicScreenSpaceErrorHeightFalloff;\n const heightClose = minimumHeight + (maximumHeight - minimumHeight) * heightFalloff;\n const heightFar = maximumHeight;\n\n const t = clamp((height - heightClose) / (heightFar - heightClose), 0.0, 1.0);\n\n // Increase density as the camera tilts towards the horizon\n const dot = Math.abs(Cartesian3.dot(direction, up));\n\n let horizonFactor = 1.0 - dot;\n\n // Weaken the horizon factor as the camera height increases, implying the camera is further away from the tileset.\n // The goal is to increase density for the \"street view\", not when viewing the tileset from a distance.\n horizonFactor = horizonFactor * (1.0 - t);\n\n return dynamicScreenSpaceErrorDensity * horizonFactor;\n}\n\nexport function fog(distanceToCamera, density) {\n const scalar = distanceToCamera * density;\n return 1.0 - Math.exp(-(scalar * scalar));\n}\n\nexport function getDynamicScreenSpaceError(tileset, distanceToCamera) {\n if (tileset.dynamicScreenSpaceError && tileset.dynamicScreenSpaceErrorComputedDensity) {\n const density = tileset.dynamicScreenSpaceErrorComputedDensity;\n const factor = tileset.dynamicScreenSpaceErrorFactor;\n // TODO: Refined screen space error that minimizes tiles in non-first-person\n const dynamicError = fog(distanceToCamera, density) * factor;\n return dynamicError;\n }\n\n return 0;\n}\n\nexport function getTiles3DScreenSpaceError(tile, frameState, useParentLodMetric) {\n const tileset = tile.tileset;\n const parentLodMetricValue = (tile.parent && tile.parent.lodMetricValue) || tile.lodMetricValue;\n const lodMetricValue = useParentLodMetric ? parentLodMetricValue : tile.lodMetricValue;\n\n // Leaf tiles do not have any error so save the computation\n if (lodMetricValue === 0.0) {\n return 0.0;\n }\n\n // TODO: Orthographic Frustum needs special treatment?\n // this._getOrthograhicScreenSpaceError();\n\n // Avoid divide by zero when viewer is inside the tile\n const distance = Math.max(tile._distanceToCamera, 1e-7);\n const {height, sseDenominator} = frameState;\n const {viewDistanceScale} = tileset.options;\n let error = (lodMetricValue * height * (viewDistanceScale || 1.0)) / (distance * sseDenominator);\n\n error -= getDynamicScreenSpaceError(tileset, distance);\n\n return error;\n}\n"],"mappings":"AAYA,SAAQA,OAAO,EAAEC,OAAO,EAAEC,KAAK,QAAO,eAAe;AAErD,MAAMC,qBAAqB,GAAG,IAAIF,OAAO,CAAC,CAAC;AAC3C,MAAMG,mBAAmB,GAAG,IAAIH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AEA,OAAO,SAASC,0BAA0BA,CAACC,IAAI,EAAEC,UAAU,EAAEC,kBAAkB,EAAE;EAC/E,MAAMT,OAAO,GAAGO,IAAI,CAACP,OAAO;EAC5B,MAAMU,oBAAoB,GAAIH,IAAI,CAACI,MAAM,IAAIJ,IAAI,CAACI,MAAM,CAACC,cAAc,IAAKL,IAAI,CAACK,cAAc;EAC/F,MAAMA,cAAc,GAAGH,kBAAkB,GAAGC,oBAAoB,GAAGH,IAAI,CAACK,cAAc;EAGtF,IAAIA,cAAc,KAAK,GAAG,EAAE;IAC1B,OAAO,GAAG;EACZ;EAMA,MAAMC,QAAQ,GAAGtB,IAAI,CAACuB,GAAG,CAACP,IAAI,CAACQ,iBAAiB,EAAE,IAAI,CAAC;EACvD,MAAM;IAAC/D,MAAM;IAAEgE;EAAc,CAAC,GAAGR,UAAU;EAC3C,MAAM;IAACS;EAAiB,CAAC,GAAGjB,OAAO,CAACxD,OAAO;EAC3C,IAAI0E,KAAK,GAAIN,cAAc,GAAG5D,MAAM,IAAIiE,iBAAiB,IAAI,GAAG,CAAC,IAAKJ,QAAQ,GAAGG,cAAc,CAAC;EAEhGE,KAAK,IAAInB,0BAA0B,CAACC,OAAO,EAAEa,QAAQ,CAAC;EAEtD,OAAOK,KAAK;AACd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-utils.d.ts","sourceRoot":"","sources":["../../../src/tileset/helpers/transform-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transform-utils.d.ts","sourceRoot":"","sources":["../../../src/tileset/helpers/transform-utils.ts"],"names":[],"mappings":"AAQA,wBAAgB,uBAAuB,CAAC,UAAU,KAAA,EAAE,IAAI,KAAA,QA4DvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-utils.js","names":["Ellipsoid","Matrix4","Vector3","assert","calculateTransformProps","tileHeader","tile","rtcCenter","gltfUpAxis","computedTransform","boundingVolume","center","modelMatrix","translate","rotationY","rotateX","Math","PI","multiplyRight","rotationX","rotateY","isQuantized","quantizedVolumeOffset","scale","quantizedVolumeScale","cartesianOrigin","cartesianModelMatrix","cartographicOrigin","WGS84","cartesianToCartographic","fromFixedFrameMatrix","eastNorthUpToFixedFrame","toFixedFrameMatrix","invert","cartographicModelMatrix","coordinateSystem"],"sources":["../../../src/tileset/helpers/transform-utils.ts"],"sourcesContent":["// loaders.gl
|
|
1
|
+
{"version":3,"file":"transform-utils.js","names":["Ellipsoid","Matrix4","Vector3","assert","calculateTransformProps","tileHeader","tile","rtcCenter","gltfUpAxis","computedTransform","boundingVolume","center","modelMatrix","translate","rotationY","rotateX","Math","PI","multiplyRight","rotationX","rotateY","isQuantized","quantizedVolumeOffset","scale","quantizedVolumeScale","cartesianOrigin","cartesianModelMatrix","cartographicOrigin","WGS84","cartesianToCartographic","fromFixedFrameMatrix","eastNorthUpToFixedFrame","toFixedFrameMatrix","invert","cartographicModelMatrix","coordinateSystem"],"sources":["../../../src/tileset/helpers/transform-utils.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {Matrix4, Vector3} from '@math.gl/core';\nimport {assert} from '@loaders.gl/loader-utils';\n\nexport function calculateTransformProps(tileHeader, tile) {\n assert(tileHeader);\n assert(tile);\n\n const {rtcCenter, gltfUpAxis} = tile;\n const {\n computedTransform,\n boundingVolume: {center}\n } = tileHeader;\n\n let modelMatrix = new Matrix4(computedTransform);\n\n // Translate if appropriate\n if (rtcCenter) {\n modelMatrix.translate(rtcCenter);\n }\n\n // glTF models need to be rotated from Y to Z up\n // https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#y-up-to-z-up\n switch (gltfUpAxis) {\n case 'Z':\n break;\n case 'Y':\n const rotationY = new Matrix4().rotateX(Math.PI / 2);\n modelMatrix = modelMatrix.multiplyRight(rotationY);\n break;\n case 'X':\n const rotationX = new Matrix4().rotateY(-Math.PI / 2);\n modelMatrix = modelMatrix.multiplyRight(rotationX);\n break;\n default:\n break;\n }\n\n // Scale/offset positions if normalized integers\n if (tile.isQuantized) {\n modelMatrix.translate(tile.quantizedVolumeOffset).scale(tile.quantizedVolumeScale);\n }\n\n // Option 1: Cartesian matrix and origin\n const cartesianOrigin = new Vector3(center);\n\n tile.cartesianModelMatrix = modelMatrix;\n tile.cartesianOrigin = cartesianOrigin;\n\n // Option 2: Cartographic matrix and origin\n const cartographicOrigin = Ellipsoid.WGS84.cartesianToCartographic(\n cartesianOrigin,\n new Vector3()\n );\n const fromFixedFrameMatrix = Ellipsoid.WGS84.eastNorthUpToFixedFrame(cartesianOrigin);\n const toFixedFrameMatrix = fromFixedFrameMatrix.invert();\n\n tile.cartographicModelMatrix = toFixedFrameMatrix.multiplyRight(modelMatrix);\n tile.cartographicOrigin = cartographicOrigin;\n\n // Deprecated, drop\n if (!tile.coordinateSystem) {\n tile.modelMatrix = tile.cartographicModelMatrix;\n }\n}\n"],"mappings":"AAIA,SAAQA,SAAS,QAAO,qBAAqB;AAC7C,SAAQC,OAAO,EAAEC,OAAO,QAAO,eAAe;AAC9C,SAAQC,MAAM,QAAO,0BAA0B;AAE/C,OAAO,SAASC,uBAAuBA,CAACC,UAAU,EAAEC,IAAI,EAAE;EACxDH,MAAM,CAACE,UAAU,CAAC;EAClBF,MAAM,CAACG,IAAI,CAAC;EAEZ,MAAM;IAACC,SAAS;IAAEC;EAAU,CAAC,GAAGF,IAAI;EACpC,MAAM;IACJG,iBAAiB;IACjBC,cAAc,EAAE;MAACC;IAAM;EACzB,CAAC,GAAGN,UAAU;EAEd,IAAIO,WAAW,GAAG,IAAIX,OAAO,CAACQ,iBAAiB,CAAC;EAGhD,IAAIF,SAAS,EAAE;IACbK,WAAW,CAACC,SAAS,CAACN,SAAS,CAAC;EAClC;EAIA,QAAQC,UAAU;IAChB,KAAK,GAAG;MACN;IACF,KAAK,GAAG;MACN,MAAMM,SAAS,GAAG,IA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om.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zoom.d.ts","sourceRoot":"","sources":["../../../src/tileset/helpers/zoom.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AACtC,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AAErE,OAAO,EAAC,iBAAiB,EAAC,MAAM,aAAa,CAAC;AAQ9C;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,cAAc,EAAE,cAAc,GAAG,mBAAmB,GAAG,iBAAiB,EACxE,mBAAmB,EAAE,OAAO,UAwB7B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE;IACV,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,EACD,mBAAmB,EAAE,OAAO,EAC5B,eAAe,EAAE,OAAO,UAYzB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EACxC,mBAAmB,EAAE,OAAO,EAC5B,eAAe,EAAE,OAAO,UAQzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zoom.js","names":["Vector3","BoundingSphere","OrientedBoundingBox","Ellipsoid","WGS84_RADIUS_X","WGS84_RADIUS_Y","WGS84_RADIUS_Z","scratchVector","getZoomFromBoundingVolume","boundingVolume","cartorgraphicCenter","halfAxes","obbSize","getObbSize","Math","log2","radius","width","height","zoomX","zoomY","getZoomFromFullExtent","fullExtent","cartesianCenter","WGS84","cartographicToCartesian","xmax","ymax","zmax","extentSize","sqrt","pow","getZoomFromExtent","extent","xmin","ymin","zmin","getColumn","axeY","axeZ","farthestVertex","add","size","len"],"sources":["../../../src/tileset/helpers/zoom.ts"],"sourcesContent":["// loaders.gl
|
|
1
|
+
{"version":3,"file":"zoom.js","names":["Vector3","BoundingSphere","OrientedBoundingBox","Ellipsoid","WGS84_RADIUS_X","WGS84_RADIUS_Y","WGS84_RADIUS_Z","scratchVector","getZoomFromBoundingVolume","boundingVolume","cartorgraphicCenter","halfAxes","obbSize","getObbSize","Math","log2","radius","width","height","zoomX","zoomY","getZoomFromFullExtent","fullExtent","cartesianCenter","WGS84","cartographicToCartesian","xmax","ymax","zmax","extentSize","sqrt","pow","getZoomFromExtent","extent","xmin","ymin","zmin","getColumn","axeY","axeZ","farthestVertex","add","size","len"],"sources":["../../../src/tileset/helpers/zoom.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {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 Ellipsoid.WGS84.cartographicToCartesian(\n [fullExtent.xmax, fullExtent.ymax, fullExtent.zmax],\n scratchVector\n );\n const extentSize = Math.sqrt(\n Math.pow(scratchVector[0] - cartesianCenter[0], 2) +\n Math.pow(scratchVector[1] - cartesianCenter[1], 2) +\n Math.pow(scratchVector[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"],"mappings":"AAIA,SAAQA,OAAO,QAAO,eAAe;AACrC,SAAQC,cAAc,EAAEC,mBAAmB,QAAO,kBAAkB;AACpE,SAAQC,SAAS,QAAO,qBAAqB;AAG7C,MAAMC,cAAc,GAAG,SAAS;AAChC,MAAMC,cAAc,GAAG,SAAS;AAChC,MAAMC,cAAc,GAAG,kBAAkB;AAEzC,MAAMC,aAAa,GAAG,IAAIP,OAAO,CAAC,CAAC;AAQnC,OAAO,SAASQ,yBAAyBA,CACvCC,cAAwE,EACxEC,mBAA4B,EAC5B;EACA,IAAID,cAAc,YAAYP,mBAAmB,EAAE;IAEjD,MAAM;MAACS;IAAQ,CAAC,GAAGF,cAAc;IACjC,MAAMG,OAAO,GAAGC,UAAU,CAACF,QAAQ,CAAC;IAGpC,OAAOG,IAAI,CAACC,IAAI,CAACT,cAAc,IAAIM,OAAO,GAAGF,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;EACvE,CAAC,MAAM,IAAID,cAAc,YAAYR,cAAc,EAAE;IAEnD,MAAM;MAACe;IAAM,CAAC,GAAGP,cAAc;IAE/B,OAAOK,IAAI,CAACC,IAAI,CAACT,cAAc,IAAIU,MAAM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AI,EAAEC,IAAI,EAAET,IAAI,EAAEC,IAAI,CAAC,GAAGM,MAAM;EACvC,OAAOZ,qBAAqB,CAC1B;IAACa,IAAI;IAAER,IAAI;IAAES,IAAI;IAAER,IAAI;IAAES,IAAI,EAAE,CAAC;IAAER,IAAI,EAAE;EAAC,CAAC,EAC1ClB,mBAAmB,EACnBa,eACF,CAAC;AACH;AAEA,SAASV,UAAUA,CAACF,QAAQ,EAAE;EAC5BA,QAAQ,CAAC0B,SAAS,CAAC,CAAC,EAAE9B,aAAa,CAAC;EACpC,MAAM+B,IAAI,GAAG3B,QAAQ,CAAC0B,SAAS,CAAC,CAAC,CAAC;EAClC,MAAME,IAAI,GAAG5B,QAAQ,CAAC0B,SAAS,CAAC,CAAC,CAAC;EAClC,MAAMG,cAAc,GAAGjC,aAAa,CAACkC,GAAG,CAACH,IAAI,CAAC,CAACG,GAAG,CAACF,IAAI,CAAC;EACxD,MAAMG,IAAI,GAAGF,cAAc,CAACG,GAAG,CAAC,CAAC;EACjC,OAAOD,IAAI;AACb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tile-3d.d.ts","sourceRoot":"","sources":["../../src/tileset/tile-3d.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tile-3d.d.ts","sourceRoot":"","sources":["../../src/tileset/tile-3d.ts"],"names":[],"mappings":"AAOA,OAAO,EAAU,OAAO,EAAC,MAAM,eAAe,CAAC;AAM/C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,kCAAkC,CAAC;AAG3E,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAGL,kBAAkB,EACnB,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;AAQrD;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAA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