@loaders.gl/tiles 4.0.0-alpha.22 → 4.0.0-alpha.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/tiles",
3
- "version": "4.0.0-alpha.22",
3
+ "version": "4.0.0-alpha.24",
4
4
  "description": "Common components for different tiles loaders.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -33,8 +33,8 @@
33
33
  "build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/dist.min.js"
34
34
  },
35
35
  "dependencies": {
36
- "@loaders.gl/loader-utils": "4.0.0-alpha.22",
37
- "@loaders.gl/math": "4.0.0-alpha.22",
36
+ "@loaders.gl/loader-utils": "4.0.0-alpha.24",
37
+ "@loaders.gl/math": "4.0.0-alpha.24",
38
38
  "@math.gl/core": "^3.5.1",
39
39
  "@math.gl/culling": "^3.5.1",
40
40
  "@math.gl/geospatial": "^3.5.1",
@@ -47,5 +47,5 @@
47
47
  "devDependencies": {
48
48
  "@deck.gl/core": "^8.9.0"
49
49
  },
50
- "gitHead": "0da838c506d1275383f2fd3d244d9c72b25397d2"
50
+ "gitHead": "97a8990595c132fb14e3445a8768d9f4cb98ff05"
51
51
  }
package/dist/bundle.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- // @ts-nocheck
3
- const moduleExports = require('./index');
4
- globalThis.loaders = globalThis.loaders || {};
5
- module.exports = Object.assign(globalThis.loaders, moduleExports);
package/dist/constants.js DELETED
@@ -1,39 +0,0 @@
1
- "use strict";
2
- // loaders.gl, MIT license
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.TILE3D_OPTIMIZATION_HINT = exports.LOD_METRIC_TYPE = exports.TILESET_TYPE = exports.TILE_TYPE = exports.TILE_REFINEMENT = exports.TILE_CONTENT_STATE = void 0;
5
- exports.TILE_CONTENT_STATE = {
6
- UNLOADED: 0,
7
- LOADING: 1,
8
- PROCESSING: 2,
9
- READY: 3,
10
- EXPIRED: 4,
11
- FAILED: 5 // Request failed.
12
- };
13
- var TILE_REFINEMENT;
14
- (function (TILE_REFINEMENT) {
15
- TILE_REFINEMENT[TILE_REFINEMENT["ADD"] = 1] = "ADD";
16
- TILE_REFINEMENT[TILE_REFINEMENT["REPLACE"] = 2] = "REPLACE"; // Render tile or, if screen space error exceeded, refine to its descendants instead.
17
- })(TILE_REFINEMENT || (exports.TILE_REFINEMENT = TILE_REFINEMENT = {}));
18
- var TILE_TYPE;
19
- (function (TILE_TYPE) {
20
- TILE_TYPE["EMPTY"] = "empty";
21
- TILE_TYPE["SCENEGRAPH"] = "scenegraph";
22
- TILE_TYPE["POINTCLOUD"] = "pointcloud";
23
- TILE_TYPE["MESH"] = "mesh";
24
- })(TILE_TYPE || (exports.TILE_TYPE = TILE_TYPE = {}));
25
- var TILESET_TYPE;
26
- (function (TILESET_TYPE) {
27
- TILESET_TYPE["I3S"] = "I3S";
28
- TILESET_TYPE["TILES3D"] = "TILES3D";
29
- })(TILESET_TYPE || (exports.TILESET_TYPE = TILESET_TYPE = {}));
30
- var LOD_METRIC_TYPE;
31
- (function (LOD_METRIC_TYPE) {
32
- LOD_METRIC_TYPE["GEOMETRIC_ERROR"] = "geometricError";
33
- LOD_METRIC_TYPE["MAX_SCREEN_THRESHOLD"] = "maxScreenThreshold";
34
- })(LOD_METRIC_TYPE || (exports.LOD_METRIC_TYPE = LOD_METRIC_TYPE = {}));
35
- exports.TILE3D_OPTIMIZATION_HINT = {
36
- NOT_COMPUTED: -1,
37
- USE_OPTIMIZATION: 1,
38
- SKIP_OPTIMIZATION: 0
39
- };
package/dist/index.js DELETED
@@ -1,26 +0,0 @@
1
- "use strict";
2
- // loaders.gl, MIT license
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.LOD_METRIC_TYPE = exports.TILESET_TYPE = exports.TILE_TYPE = exports.TILE_REFINEMENT = exports.TILE_CONTENT_STATE = exports.getLodStatus = exports.getFrameState = exports.calculateTransformProps = exports.createBoundingVolume = exports.TilesetCache = exports.TilesetTraverser = exports.Tile3D = exports.Tileset3D = void 0;
5
- var tileset_3d_1 = require("./tileset/tileset-3d");
6
- Object.defineProperty(exports, "Tileset3D", { enumerable: true, get: function () { return tileset_3d_1.Tileset3D; } });
7
- var tile_3d_1 = require("./tileset/tile-3d");
8
- Object.defineProperty(exports, "Tile3D", { enumerable: true, get: function () { return tile_3d_1.Tile3D; } });
9
- var tileset_traverser_1 = require("./tileset/tileset-traverser");
10
- Object.defineProperty(exports, "TilesetTraverser", { enumerable: true, get: function () { return tileset_traverser_1.TilesetTraverser; } });
11
- var tileset_cache_1 = require("./tileset/tileset-cache");
12
- Object.defineProperty(exports, "TilesetCache", { enumerable: true, get: function () { return tileset_cache_1.TilesetCache; } });
13
- var bounding_volume_1 = require("./tileset/helpers/bounding-volume");
14
- Object.defineProperty(exports, "createBoundingVolume", { enumerable: true, get: function () { return bounding_volume_1.createBoundingVolume; } });
15
- var transform_utils_1 = require("./tileset/helpers/transform-utils");
16
- Object.defineProperty(exports, "calculateTransformProps", { enumerable: true, get: function () { return transform_utils_1.calculateTransformProps; } });
17
- var frame_state_1 = require("./tileset/helpers/frame-state");
18
- Object.defineProperty(exports, "getFrameState", { enumerable: true, get: function () { return frame_state_1.getFrameState; } });
19
- var i3s_lod_1 = require("./tileset/helpers/i3s-lod");
20
- Object.defineProperty(exports, "getLodStatus", { enumerable: true, get: function () { return i3s_lod_1.getLodStatus; } });
21
- var constants_1 = require("./constants");
22
- Object.defineProperty(exports, "TILE_CONTENT_STATE", { enumerable: true, get: function () { return constants_1.TILE_CONTENT_STATE; } });
23
- Object.defineProperty(exports, "TILE_REFINEMENT", { enumerable: true, get: function () { return constants_1.TILE_REFINEMENT; } });
24
- Object.defineProperty(exports, "TILE_TYPE", { enumerable: true, get: function () { return constants_1.TILE_TYPE; } });
25
- Object.defineProperty(exports, "TILESET_TYPE", { enumerable: true, get: function () { return constants_1.TILESET_TYPE; } });
26
- Object.defineProperty(exports, "LOD_METRIC_TYPE", { enumerable: true, get: function () { return constants_1.LOD_METRIC_TYPE; } });
@@ -1,54 +0,0 @@
1
- "use strict";
2
- // loaders.gl, MIT license
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Tileset3DTraverser = void 0;
5
- // This file is derived from the Cesium code base under Apache 2 license
6
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
7
- const constants_1 = require("../../constants");
8
- const tileset_traverser_1 = require("../tileset-traverser");
9
- class Tileset3DTraverser extends tileset_traverser_1.TilesetTraverser {
10
- compareDistanceToCamera(a, b) {
11
- // Sort by farthest child first since this is going on a stack
12
- return b._distanceToCamera === 0 && a._distanceToCamera === 0
13
- ? b._centerZDepth - a._centerZDepth
14
- : b._distanceToCamera - a._distanceToCamera;
15
- }
16
- updateTileVisibility(tile, frameState) {
17
- super.updateTileVisibility(tile, frameState);
18
- // Optimization - if none of the tile's children are visible then this tile isn't visible
19
- if (!tile.isVisibleAndInRequestVolume) {
20
- return;
21
- }
22
- const hasChildren = tile.children.length > 0;
23
- if (tile.hasTilesetContent && hasChildren) {
24
- // Use the root tile's visibility instead of this tile's visibility.
25
- // The root tile may be culled by the children bounds optimization in which
26
- // case this tile should also be culled.
27
- const firstChild = tile.children[0];
28
- this.updateTileVisibility(firstChild, frameState);
29
- tile._visible = firstChild._visible;
30
- return;
31
- }
32
- if (this.meetsScreenSpaceErrorEarly(tile, frameState)) {
33
- tile._visible = false;
34
- return;
35
- }
36
- const replace = tile.refine === constants_1.TILE_REFINEMENT.REPLACE;
37
- const useOptimization = tile._optimChildrenWithinParent === constants_1.TILE3D_OPTIMIZATION_HINT.USE_OPTIMIZATION;
38
- if (replace && useOptimization && hasChildren) {
39
- if (!this.anyChildrenVisible(tile, frameState)) {
40
- tile._visible = false;
41
- return;
42
- }
43
- }
44
- }
45
- meetsScreenSpaceErrorEarly(tile, frameState) {
46
- const { parent } = tile;
47
- if (!parent || parent.hasTilesetContent || parent.refine !== constants_1.TILE_REFINEMENT.ADD) {
48
- return false;
49
- }
50
- // Use parent's geometric error with child's box to see if the tile already meet the SSE
51
- return !this.shouldRefine(tile, frameState, true);
52
- }
53
- }
54
- exports.Tileset3DTraverser = Tileset3DTraverser;
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.I3SPendingTilesRegister = void 0;
4
- /**
5
- * Counter to register pending tile headers for the particular frameNumber
6
- * Until all tiles are loaded we won't call `onTraversalEnd` callback
7
- */
8
- class I3SPendingTilesRegister {
9
- constructor() {
10
- this.frameNumberMap = new Map();
11
- }
12
- /**
13
- * Register a new pending tile header for the particular frameNumber
14
- * @param viewportId
15
- * @param frameNumber
16
- */
17
- register(viewportId, frameNumber) {
18
- const viewportMap = this.frameNumberMap.get(viewportId) || new Map();
19
- const oldCount = viewportMap.get(frameNumber) || 0;
20
- viewportMap.set(frameNumber, oldCount + 1);
21
- this.frameNumberMap.set(viewportId, viewportMap);
22
- }
23
- /**
24
- * Deregister a pending tile header for the particular frameNumber
25
- * @param viewportId
26
- * @param frameNumber
27
- */
28
- deregister(viewportId, frameNumber) {
29
- const viewportMap = this.frameNumberMap.get(viewportId);
30
- if (!viewportMap) {
31
- return;
32
- }
33
- const oldCount = viewportMap.get(frameNumber) || 1;
34
- viewportMap.set(frameNumber, oldCount - 1);
35
- }
36
- /**
37
- * Check is there are no pending tile headers registered for the particular frameNumber
38
- * @param viewportId
39
- * @param frameNumber
40
- * @returns
41
- */
42
- isZero(viewportId, frameNumber) {
43
- const count = this.frameNumberMap.get(viewportId)?.get(frameNumber) || 0;
44
- return count === 0;
45
- }
46
- }
47
- exports.I3SPendingTilesRegister = I3SPendingTilesRegister;
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.I3STileManager = void 0;
4
- const i3s_pending_tiles_register_1 = require("./i3s-pending-tiles-register");
5
- const STATUS = {
6
- REQUESTED: 'REQUESTED',
7
- COMPLETED: 'COMPLETED',
8
- ERROR: 'ERROR'
9
- };
10
- // A helper class to manage tile metadata fetching
11
- class I3STileManager {
12
- constructor() {
13
- this.pendingTilesRegister = new i3s_pending_tiles_register_1.I3SPendingTilesRegister();
14
- this._statusMap = {};
15
- }
16
- /**
17
- * Add request to map
18
- * @param request - node metadata request
19
- * @param key - unique key
20
- * @param callback - callback after request completed
21
- * @param frameState - frameState data
22
- */
23
- add(request, key, callback, frameState) {
24
- if (!this._statusMap[key]) {
25
- const { frameNumber, viewport: { id } } = frameState;
26
- this._statusMap[key] = { request, callback, key, frameState, status: STATUS.REQUESTED };
27
- // Register pending request for the frameNumber
28
- this.pendingTilesRegister.register(id, frameNumber);
29
- request()
30
- .then((data) => {
31
- this._statusMap[key].status = STATUS.COMPLETED;
32
- const { frameNumber: actualFrameNumber, viewport: { id } } = this._statusMap[key].frameState;
33
- // Deregister pending request for the frameNumber
34
- this.pendingTilesRegister.deregister(id, actualFrameNumber);
35
- this._statusMap[key].callback(data, frameState);
36
- })
37
- .catch((error) => {
38
- this._statusMap[key].status = STATUS.ERROR;
39
- const { frameNumber: actualFrameNumber, viewport: { id } } = this._statusMap[key].frameState;
40
- // Deregister pending request for the frameNumber
41
- this.pendingTilesRegister.deregister(id, actualFrameNumber);
42
- callback(error);
43
- });
44
- }
45
- }
46
- /**
47
- * Update request if it is still actual for the new frameState
48
- * @param key - unique key
49
- * @param frameState - frameState data
50
- */
51
- update(key, frameState) {
52
- if (this._statusMap[key]) {
53
- // Deregister pending request for the old frameNumber
54
- const { frameNumber, viewport: { id } } = this._statusMap[key].frameState;
55
- this.pendingTilesRegister.deregister(id, frameNumber);
56
- // Register pending request for the new frameNumber
57
- const { frameNumber: newFrameNumber, viewport: { id: newViewportId } } = frameState;
58
- this.pendingTilesRegister.register(newViewportId, newFrameNumber);
59
- this._statusMap[key].frameState = frameState;
60
- }
61
- }
62
- /**
63
- * Find request in the map
64
- * @param key - unique key
65
- * @returns
66
- */
67
- find(key) {
68
- return this._statusMap[key];
69
- }
70
- /**
71
- * Check it there are pending tile headers for the particular frameNumber
72
- * @param viewportId
73
- * @param frameNumber
74
- * @returns
75
- */
76
- hasPendingTiles(viewportId, frameNumber) {
77
- return !this.pendingTilesRegister.isZero(viewportId, frameNumber);
78
- }
79
- }
80
- exports.I3STileManager = I3STileManager;
@@ -1,92 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.I3STilesetTraverser = void 0;
4
- const core_1 = require("@loaders.gl/core");
5
- const tileset_traverser_1 = require("../tileset-traverser");
6
- const i3s_lod_1 = require("../helpers/i3s-lod");
7
- const tile_3d_1 = require("../tile-3d");
8
- const i3s_tile_manager_1 = require("./i3s-tile-manager");
9
- class I3STilesetTraverser extends tileset_traverser_1.TilesetTraverser {
10
- constructor(options) {
11
- super(options);
12
- this._tileManager = new i3s_tile_manager_1.I3STileManager();
13
- }
14
- /**
15
- * Check if there are no penging tile header requests,
16
- * that means the traversal is finished and we can call
17
- * following-up callbacks.
18
- */
19
- traversalFinished(frameState) {
20
- return !this._tileManager.hasPendingTiles(frameState.viewport.id, this._frameNumber || 0);
21
- }
22
- shouldRefine(tile, frameState) {
23
- tile._lodJudge = (0, i3s_lod_1.getLodStatus)(tile, frameState);
24
- return tile._lodJudge === 'DIG';
25
- }
26
- updateChildTiles(tile, frameState) {
27
- const children = tile.header.children || [];
28
- // children which are already fetched and constructed as Tile3D instances
29
- const childTiles = tile.children;
30
- const tileset = tile.tileset;
31
- for (const child of children) {
32
- const extendedId = `${child.id}-${frameState.viewport.id}`;
33
- // if child tile is not fetched
34
- const childTile = childTiles && childTiles.find((t) => t.id === extendedId);
35
- if (!childTile) {
36
- let request = () => this._loadTile(child.id, tileset);
37
- const cachedRequest = this._tileManager.find(extendedId);
38
- if (!cachedRequest) {
39
- // eslint-disable-next-line max-depth
40
- if (tileset.tileset.nodePages) {
41
- request = () => tileset.tileset.nodePagesTile.formTileFromNodePages(child.id);
42
- }
43
- this._tileManager.add(request, extendedId, (header) => this._onTileLoad(header, tile, extendedId), frameState);
44
- }
45
- else {
46
- // update frameNumber since it is still needed in current frame
47
- this._tileManager.update(extendedId, frameState);
48
- }
49
- }
50
- else if (childTile) {
51
- // if child tile is fetched and available
52
- this.updateTile(childTile, frameState);
53
- }
54
- }
55
- return false;
56
- }
57
- async _loadTile(nodeId, tileset) {
58
- const { loader } = tileset;
59
- const nodeUrl = tileset.getTileUrl(`${tileset.url}/nodes/${nodeId}`);
60
- // load metadata
61
- const options = {
62
- ...tileset.loadOptions,
63
- i3s: {
64
- ...tileset.loadOptions.i3s,
65
- isTileHeader: true
66
- }
67
- };
68
- return await (0, core_1.load)(nodeUrl, loader, options);
69
- }
70
- /**
71
- * The callback to init Tile3D instance after loading the tile JSON
72
- * @param {Object} header - the tile JSON from a dataset
73
- * @param {Tile3D} tile - the parent Tile3D instance
74
- * @param {string} extendedId - optional ID to separate copies of a tile for different viewports.
75
- * const extendedId = `${tile.id}-${frameState.viewport.id}`;
76
- * @return {void}
77
- */
78
- _onTileLoad(header, tile, extendedId) {
79
- // after child tile is fetched
80
- const childTile = new tile_3d_1.Tile3D(tile.tileset, header, tile, extendedId);
81
- tile.children.push(childTile);
82
- const frameState = this._tileManager.find(childTile.id).frameState;
83
- this.updateTile(childTile, frameState);
84
- // after tile fetched, resume traversal if still in current update/traversal frame
85
- if (this._frameNumber === frameState.frameNumber &&
86
- (this.traversalFinished(frameState) ||
87
- new Date().getTime() - this.lastUpdate > this.updateDebounceTime)) {
88
- this.executeTraversal(childTile, frameState);
89
- }
90
- }
91
- }
92
- exports.I3STilesetTraverser = I3STilesetTraverser;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.get3dTilesOptions = void 0;
4
- function get3dTilesOptions(tileset) {
5
- return {
6
- assetGltfUpAxis: (tileset.asset && tileset.asset.gltfUpAxis) || 'Y'
7
- };
8
- }
9
- exports.get3dTilesOptions = get3dTilesOptions;