@loaders.gl/tiles 3.1.0-alpha.3 → 3.1.0-beta.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/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +8135 -4
- package/dist/constants.d.ts +32 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +29 -26
- package/dist/es5/bundle.js +7 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/constants.js +44 -0
- package/dist/es5/constants.js.map +1 -0
- package/dist/es5/index.js +104 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/tileset/helpers/3d-tiles-options.js +13 -0
- package/dist/es5/tileset/helpers/3d-tiles-options.js.map +1 -0
- package/dist/es5/tileset/helpers/bounding-volume.js +102 -0
- package/dist/es5/tileset/helpers/bounding-volume.js.map +1 -0
- package/dist/es5/tileset/helpers/frame-state.js +69 -0
- package/dist/es5/tileset/helpers/frame-state.js.map +1 -0
- package/dist/es5/tileset/helpers/i3s-lod.js +84 -0
- package/dist/es5/tileset/helpers/i3s-lod.js.map +1 -0
- package/dist/es5/tileset/helpers/tiles-3d-lod.js +123 -0
- package/dist/es5/tileset/helpers/tiles-3d-lod.js.map +1 -0
- package/dist/es5/tileset/helpers/transform-utils.js +71 -0
- package/dist/es5/tileset/helpers/transform-utils.js.map +1 -0
- package/dist/es5/tileset/helpers/zoom.js +45 -0
- package/dist/es5/tileset/helpers/zoom.js.map +1 -0
- package/dist/es5/tileset/tile-3d.js +510 -0
- package/dist/es5/tileset/tile-3d.js.map +1 -0
- package/dist/es5/tileset/tileset-3d.js +656 -0
- package/dist/es5/tileset/tileset-3d.js.map +1 -0
- package/dist/es5/tileset/tileset-cache.js +88 -0
- package/dist/es5/tileset/tileset-cache.js.map +1 -0
- package/dist/es5/tileset/traversers/i3s-tile-manager.js +57 -0
- package/dist/es5/tileset/traversers/i3s-tile-manager.js.map +1 -0
- package/dist/es5/tileset/traversers/i3s-tileset-traverser.js +95 -0
- package/dist/es5/tileset/traversers/i3s-tileset-traverser.js.map +1 -0
- package/dist/es5/tileset/traversers/tileset-3d-traverser.js +66 -0
- package/dist/es5/tileset/traversers/tileset-3d-traverser.js.map +1 -0
- package/dist/es5/tileset/traversers/tileset-traverser.js +304 -0
- package/dist/es5/tileset/traversers/tileset-traverser.js.map +1 -0
- package/dist/es5/utils/doubly-linked-list-node.js +25 -0
- package/dist/es5/utils/doubly-linked-list-node.js.map +1 -0
- package/dist/es5/utils/doubly-linked-list.js +92 -0
- package/dist/es5/utils/doubly-linked-list.js.map +1 -0
- package/dist/es5/utils/managed-array.js +127 -0
- package/dist/es5/utils/managed-array.js.map +1 -0
- package/dist/esm/bundle.js +5 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/constants.js +32 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/tileset/helpers/3d-tiles-options.js +6 -0
- package/dist/esm/tileset/helpers/3d-tiles-options.js.map +1 -0
- package/dist/esm/tileset/helpers/bounding-volume.js +88 -0
- package/dist/esm/tileset/helpers/bounding-volume.js.map +1 -0
- package/dist/esm/tileset/helpers/frame-state.js +51 -0
- package/dist/esm/tileset/helpers/frame-state.js.map +1 -0
- package/dist/esm/tileset/helpers/i3s-lod.js +67 -0
- package/dist/esm/tileset/helpers/i3s-lod.js.map +1 -0
- package/dist/esm/tileset/helpers/tiles-3d-lod.js +105 -0
- package/dist/esm/tileset/helpers/tiles-3d-lod.js.map +1 -0
- package/dist/esm/tileset/helpers/transform-utils.js +58 -0
- package/dist/esm/tileset/helpers/transform-utils.js.map +1 -0
- package/dist/esm/tileset/helpers/zoom.js +36 -0
- package/dist/esm/tileset/helpers/zoom.js.map +1 -0
- package/dist/esm/tileset/tile-3d.js +534 -0
- package/dist/esm/tileset/tile-3d.js.map +1 -0
- package/dist/esm/tileset/tileset-3d.js +674 -0
- package/dist/esm/tileset/tileset-3d.js.map +1 -0
- package/dist/esm/tileset/tileset-cache.js +79 -0
- package/dist/esm/tileset/tileset-cache.js.map +1 -0
- package/dist/esm/tileset/traversers/i3s-tile-manager.js +45 -0
- package/dist/esm/tileset/traversers/i3s-tile-manager.js.map +1 -0
- package/dist/esm/tileset/traversers/i3s-tileset-traverser.js +80 -0
- package/dist/esm/tileset/traversers/i3s-tileset-traverser.js.map +1 -0
- package/dist/esm/tileset/traversers/tileset-3d-traverser.js +53 -0
- package/dist/esm/tileset/traversers/tileset-3d-traverser.js.map +1 -0
- package/dist/esm/tileset/traversers/tileset-traverser.js +296 -0
- package/dist/esm/tileset/traversers/tileset-traverser.js.map +1 -0
- package/dist/esm/utils/doubly-linked-list-node.js +16 -0
- package/dist/esm/utils/doubly-linked-list-node.js.map +1 -0
- package/dist/esm/utils/doubly-linked-list.js +81 -0
- package/dist/esm/utils/doubly-linked-list.js.map +1 -0
- package/dist/esm/utils/managed-array.js +117 -0
- package/dist/esm/utils/managed-array.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -9
- package/dist/tileset/helpers/3d-tiles-options.d.ts +4 -0
- package/dist/tileset/helpers/3d-tiles-options.d.ts.map +1 -0
- package/dist/tileset/helpers/3d-tiles-options.js +8 -5
- package/dist/tileset/helpers/bounding-volume.d.ts +9 -0
- package/dist/tileset/helpers/bounding-volume.d.ts.map +1 -0
- package/dist/tileset/helpers/bounding-volume.js +159 -70
- package/dist/tileset/helpers/frame-state.d.ts +17 -0
- package/dist/tileset/helpers/frame-state.d.ts.map +1 -0
- package/dist/tileset/helpers/frame-state.js +67 -48
- package/dist/tileset/helpers/i3s-lod.d.ts +20 -0
- package/dist/tileset/helpers/i3s-lod.d.ts.map +1 -0
- package/dist/tileset/helpers/i3s-lod.js +80 -105
- package/dist/tileset/helpers/tiles-3d-lod.d.ts +8 -0
- package/dist/tileset/helpers/tiles-3d-lod.d.ts.map +1 -0
- package/dist/tileset/helpers/tiles-3d-lod.js +111 -100
- package/dist/tileset/helpers/transform-utils.d.ts +2 -0
- package/dist/tileset/helpers/transform-utils.d.ts.map +1 -0
- package/dist/tileset/helpers/transform-utils.js +50 -53
- package/dist/tileset/helpers/zoom.d.ts +7 -0
- package/dist/tileset/helpers/zoom.d.ts.map +1 -0
- package/dist/tileset/helpers/zoom.js +36 -30
- package/dist/tileset/tile-3d.d.ts +174 -0
- package/dist/tileset/tile-3d.d.ts.map +1 -0
- package/dist/tileset/tile-3d.js +550 -530
- package/dist/tileset/tileset-3d.d.ts +172 -0
- package/dist/tileset/tileset-3d.d.ts.map +1 -0
- package/dist/tileset/tileset-3d.js +576 -649
- package/dist/tileset/tileset-cache.d.ts +18 -0
- package/dist/tileset/tileset-cache.d.ts.map +1 -0
- package/dist/tileset/tileset-cache.js +71 -71
- package/dist/tileset/traversers/i3s-tile-manager.d.ts +8 -0
- package/dist/tileset/traversers/i3s-tile-manager.d.ts.map +1 -0
- package/dist/tileset/traversers/i3s-tile-manager.js +31 -40
- package/dist/tileset/traversers/i3s-tileset-traverser.d.ts +18 -0
- package/dist/tileset/traversers/i3s-tileset-traverser.d.ts.map +1 -0
- package/dist/tileset/traversers/i3s-tileset-traverser.js +81 -76
- package/dist/tileset/traversers/tileset-3d-traverser.d.ts +7 -0
- package/dist/tileset/traversers/tileset-3d-traverser.d.ts.map +1 -0
- package/dist/tileset/traversers/tileset-3d-traverser.js +51 -49
- package/dist/tileset/traversers/tileset-traverser.d.ts +52 -0
- package/dist/tileset/traversers/tileset-traverser.d.ts.map +1 -0
- package/dist/tileset/traversers/tileset-traverser.js +274 -276
- package/dist/utils/doubly-linked-list-node.d.ts +12 -0
- package/dist/utils/doubly-linked-list-node.d.ts.map +1 -0
- package/dist/utils/doubly-linked-list-node.js +16 -8
- package/dist/utils/doubly-linked-list.d.ts +31 -0
- package/dist/utils/doubly-linked-list.d.ts.map +1 -0
- package/dist/utils/doubly-linked-list.js +94 -72
- package/dist/utils/managed-array.d.ts +85 -0
- package/dist/utils/managed-array.d.ts.map +1 -0
- package/dist/utils/managed-array.js +143 -103
- package/package.json +11 -9
- package/src/index.ts +1 -0
- package/src/tileset/helpers/i3s-lod.ts +72 -96
- package/src/tileset/helpers/transform-utils.ts +3 -1
- package/src/tileset/tile-3d.ts +2 -2
- package/src/tileset/tileset-cache.ts +2 -0
- package/src/tileset/traversers/i3s-tileset-traverser.ts +2 -3
- package/src/utils/{doubly-linked-list-node.js → doubly-linked-list-node.ts} +4 -0
- package/src/utils/{doubly-linked-list.js → doubly-linked-list.ts} +3 -5
- package/src/utils/{managed-array.js → managed-array.ts} +4 -1
- package/dist/bundle.js.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/dist.min.js +0 -2
- package/dist/dist.min.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/tileset/helpers/3d-tiles-options.js.map +0 -1
- package/dist/tileset/helpers/bounding-volume.js.map +0 -1
- package/dist/tileset/helpers/frame-state.js.map +0 -1
- package/dist/tileset/helpers/i3s-lod.js.map +0 -1
- package/dist/tileset/helpers/tiles-3d-lod.js.map +0 -1
- package/dist/tileset/helpers/transform-utils.js.map +0 -1
- package/dist/tileset/helpers/zoom.js.map +0 -1
- package/dist/tileset/tile-3d.js.map +0 -1
- package/dist/tileset/tileset-3d.js.map +0 -1
- package/dist/tileset/tileset-cache.js.map +0 -1
- package/dist/tileset/traversers/i3s-tile-manager.js.map +0 -1
- package/dist/tileset/traversers/i3s-tileset-traverser.js.map +0 -1
- package/dist/tileset/traversers/tileset-3d-traverser.js.map +0 -1
- package/dist/tileset/traversers/tileset-traverser.js.map +0 -1
- package/dist/utils/doubly-linked-list-node.js.map +0 -1
- package/dist/utils/doubly-linked-list.js.map +0 -1
- package/dist/utils/managed-array.js.map +0 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare const TILE_CONTENT_STATE: {
|
|
2
|
+
UNLOADED: number;
|
|
3
|
+
LOADING: number;
|
|
4
|
+
PROCESSING: number;
|
|
5
|
+
READY: number;
|
|
6
|
+
EXPIRED: number;
|
|
7
|
+
FAILED: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const TILE_REFINEMENT: {
|
|
10
|
+
ADD: number;
|
|
11
|
+
REPLACE: number;
|
|
12
|
+
};
|
|
13
|
+
export declare const TILE_TYPE: {
|
|
14
|
+
EMPTY: string;
|
|
15
|
+
SCENEGRAPH: string;
|
|
16
|
+
POINTCLOUD: string;
|
|
17
|
+
MESH: string;
|
|
18
|
+
};
|
|
19
|
+
export declare const TILESET_TYPE: {
|
|
20
|
+
I3S: string;
|
|
21
|
+
TILES3D: string;
|
|
22
|
+
};
|
|
23
|
+
export declare const LOD_METRIC_TYPE: {
|
|
24
|
+
GEOMETRIC_ERROR: string;
|
|
25
|
+
MAX_SCREEN_THRESHOLD: string;
|
|
26
|
+
};
|
|
27
|
+
export declare const TILE3D_OPTIMIZATION_HINT: {
|
|
28
|
+
NOT_COMPUTED: number;
|
|
29
|
+
USE_OPTIMIZATION: number;
|
|
30
|
+
SKIP_OPTIMIZATION: number;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB;;;;;;;CAO9B,CAAC;AAEF,eAAO,MAAM,eAAe;;;CAG3B,CAAC;AAEF,eAAO,MAAM,SAAS;;;;;CAKrB,CAAC;AAEF,eAAO,MAAM,YAAY;;;CAGxB,CAAC;AAEF,eAAO,MAAM,eAAe;;;CAG3B,CAAC;AAGF,eAAO,MAAM,wBAAwB;;;;CAIpC,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -1,32 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TILE3D_OPTIMIZATION_HINT = exports.LOD_METRIC_TYPE = exports.TILESET_TYPE = exports.TILE_TYPE = exports.TILE_REFINEMENT = exports.TILE_CONTENT_STATE = void 0;
|
|
4
|
+
exports.TILE_CONTENT_STATE = {
|
|
5
|
+
UNLOADED: 0,
|
|
6
|
+
LOADING: 1,
|
|
7
|
+
PROCESSING: 2,
|
|
8
|
+
READY: 3,
|
|
9
|
+
EXPIRED: 4,
|
|
10
|
+
FAILED: 5 // Request failed.
|
|
8
11
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
exports.TILE_REFINEMENT = {
|
|
13
|
+
ADD: 1,
|
|
14
|
+
REPLACE: 2 // Render tile or, if screen space error exceeded, refine to its descendants instead.
|
|
12
15
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
exports.TILE_TYPE = {
|
|
17
|
+
EMPTY: 'empty',
|
|
18
|
+
SCENEGRAPH: 'scenegraph',
|
|
19
|
+
POINTCLOUD: 'pointcloud',
|
|
20
|
+
MESH: 'mesh'
|
|
18
21
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
exports.TILESET_TYPE = {
|
|
23
|
+
I3S: 'I3S',
|
|
24
|
+
TILES3D: 'TILES3D'
|
|
22
25
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
exports.LOD_METRIC_TYPE = {
|
|
27
|
+
GEOMETRIC_ERROR: 'geometricError',
|
|
28
|
+
MAX_SCREEN_THRESHOLD: 'maxScreenThreshold'
|
|
26
29
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
// Cesium 3D Tiles Specific
|
|
31
|
+
exports.TILE3D_OPTIMIZATION_HINT = {
|
|
32
|
+
NOT_COMPUTED: -1,
|
|
33
|
+
USE_OPTIMIZATION: 1,
|
|
34
|
+
SKIP_OPTIMIZATION: 0
|
|
31
35
|
};
|
|
32
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":";;AACA,MAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,OAAX,GAAqBD,UAAU,CAACC,OAAX,IAAsB,EAA3C;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,OAAzB,EAAkCH,aAAlC,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"file":"bundle.js"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TILE3D_OPTIMIZATION_HINT = exports.LOD_METRIC_TYPE = exports.TILESET_TYPE = exports.TILE_TYPE = exports.TILE_REFINEMENT = exports.TILE_CONTENT_STATE = void 0;
|
|
7
|
+
const TILE_CONTENT_STATE = {
|
|
8
|
+
UNLOADED: 0,
|
|
9
|
+
LOADING: 1,
|
|
10
|
+
PROCESSING: 2,
|
|
11
|
+
READY: 3,
|
|
12
|
+
EXPIRED: 4,
|
|
13
|
+
FAILED: 5
|
|
14
|
+
};
|
|
15
|
+
exports.TILE_CONTENT_STATE = TILE_CONTENT_STATE;
|
|
16
|
+
const TILE_REFINEMENT = {
|
|
17
|
+
ADD: 1,
|
|
18
|
+
REPLACE: 2
|
|
19
|
+
};
|
|
20
|
+
exports.TILE_REFINEMENT = TILE_REFINEMENT;
|
|
21
|
+
const TILE_TYPE = {
|
|
22
|
+
EMPTY: 'empty',
|
|
23
|
+
SCENEGRAPH: 'scenegraph',
|
|
24
|
+
POINTCLOUD: 'pointcloud',
|
|
25
|
+
MESH: 'mesh'
|
|
26
|
+
};
|
|
27
|
+
exports.TILE_TYPE = TILE_TYPE;
|
|
28
|
+
const TILESET_TYPE = {
|
|
29
|
+
I3S: 'I3S',
|
|
30
|
+
TILES3D: 'TILES3D'
|
|
31
|
+
};
|
|
32
|
+
exports.TILESET_TYPE = TILESET_TYPE;
|
|
33
|
+
const LOD_METRIC_TYPE = {
|
|
34
|
+
GEOMETRIC_ERROR: 'geometricError',
|
|
35
|
+
MAX_SCREEN_THRESHOLD: 'maxScreenThreshold'
|
|
36
|
+
};
|
|
37
|
+
exports.LOD_METRIC_TYPE = LOD_METRIC_TYPE;
|
|
38
|
+
const TILE3D_OPTIMIZATION_HINT = {
|
|
39
|
+
NOT_COMPUTED: -1,
|
|
40
|
+
USE_OPTIMIZATION: 1,
|
|
41
|
+
SKIP_OPTIMIZATION: 0
|
|
42
|
+
};
|
|
43
|
+
exports.TILE3D_OPTIMIZATION_HINT = TILE3D_OPTIMIZATION_HINT;
|
|
44
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/constants.ts"],"names":["TILE_CONTENT_STATE","UNLOADED","LOADING","PROCESSING","READY","EXPIRED","FAILED","TILE_REFINEMENT","ADD","REPLACE","TILE_TYPE","EMPTY","SCENEGRAPH","POINTCLOUD","MESH","TILESET_TYPE","I3S","TILES3D","LOD_METRIC_TYPE","GEOMETRIC_ERROR","MAX_SCREEN_THRESHOLD","TILE3D_OPTIMIZATION_HINT","NOT_COMPUTED","USE_OPTIMIZATION","SKIP_OPTIMIZATION"],"mappings":";;;;;;AAAO,MAAMA,kBAAkB,GAAG;AAChCC,EAAAA,QAAQ,EAAE,CADsB;AAEhCC,EAAAA,OAAO,EAAE,CAFuB;AAGhCC,EAAAA,UAAU,EAAE,CAHoB;AAIhCC,EAAAA,KAAK,EAAE,CAJyB;AAKhCC,EAAAA,OAAO,EAAE,CALuB;AAMhCC,EAAAA,MAAM,EAAE;AANwB,CAA3B;;AASA,MAAMC,eAAe,GAAG;AAC7BC,EAAAA,GAAG,EAAE,CADwB;AAE7BC,EAAAA,OAAO,EAAE;AAFoB,CAAxB;;AAKA,MAAMC,SAAS,GAAG;AACvBC,EAAAA,KAAK,EAAE,OADgB;AAEvBC,EAAAA,UAAU,EAAE,YAFW;AAGvBC,EAAAA,UAAU,EAAE,YAHW;AAIvBC,EAAAA,IAAI,EAAE;AAJiB,CAAlB;;AAOA,MAAMC,YAAY,GAAG;AAC1BC,EAAAA,GAAG,EAAE,KADqB;AAE1BC,EAAAA,OAAO,EAAE;AAFiB,CAArB;;AAKA,MAAMC,eAAe,GAAG;AAC7BC,EAAAA,eAAe,EAAE,gBADY;AAE7BC,EAAAA,oBAAoB,EAAE;AAFO,CAAxB;;AAMA,MAAMC,wBAAwB,GAAG;AACtCC,EAAAA,YAAY,EAAE,CAAC,CADuB;AAEtCC,EAAAA,gBAAgB,EAAE,CAFoB;AAGtCC,EAAAA,iBAAiB,EAAE;AAHmB,CAAjC","sourcesContent":["export 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 const 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 const TILE_TYPE = {\n EMPTY: 'empty',\n SCENEGRAPH: 'scenegraph',\n POINTCLOUD: 'pointcloud',\n MESH: 'mesh'\n};\n\nexport const TILESET_TYPE = {\n I3S: 'I3S',\n TILES3D: 'TILES3D'\n};\n\nexport const LOD_METRIC_TYPE = {\n GEOMETRIC_ERROR: 'geometricError',\n MAX_SCREEN_THRESHOLD: 'maxScreenThreshold'\n};\n\n// Cesium 3D Tiles Specific\nexport const TILE3D_OPTIMIZATION_HINT = {\n NOT_COMPUTED: -1,\n USE_OPTIMIZATION: 1,\n SKIP_OPTIMIZATION: 0\n};\n"],"file":"constants.js"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "Tileset3D", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () {
|
|
11
|
+
return _tileset3d.default;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "Tile3D", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () {
|
|
17
|
+
return _tile3d.default;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "TilesetTraverser", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () {
|
|
23
|
+
return _tilesetTraverser.default;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "TilesetCache", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () {
|
|
29
|
+
return _tilesetCache.default;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports, "createBoundingVolume", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _boundingVolume.createBoundingVolume;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(exports, "calculateTransformProps", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () {
|
|
41
|
+
return _transformUtils.calculateTransformProps;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(exports, "getFrameState", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function () {
|
|
47
|
+
return _frameState.getFrameState;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(exports, "getLodStatus", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function () {
|
|
53
|
+
return _i3sLod.getLodStatus;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(exports, "TILE_CONTENT_STATE", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function () {
|
|
59
|
+
return _constants.TILE_CONTENT_STATE;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(exports, "TILE_REFINEMENT", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
get: function () {
|
|
65
|
+
return _constants.TILE_REFINEMENT;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(exports, "TILE_TYPE", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function () {
|
|
71
|
+
return _constants.TILE_TYPE;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(exports, "TILESET_TYPE", {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
get: function () {
|
|
77
|
+
return _constants.TILESET_TYPE;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(exports, "LOD_METRIC_TYPE", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
get: function () {
|
|
83
|
+
return _constants.LOD_METRIC_TYPE;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
var _tileset3d = _interopRequireDefault(require("./tileset/tileset-3d"));
|
|
88
|
+
|
|
89
|
+
var _tile3d = _interopRequireDefault(require("./tileset/tile-3d"));
|
|
90
|
+
|
|
91
|
+
var _tilesetTraverser = _interopRequireDefault(require("./tileset/traversers/tileset-traverser"));
|
|
92
|
+
|
|
93
|
+
var _tilesetCache = _interopRequireDefault(require("./tileset/tileset-cache"));
|
|
94
|
+
|
|
95
|
+
var _boundingVolume = require("./tileset/helpers/bounding-volume");
|
|
96
|
+
|
|
97
|
+
var _transformUtils = require("./tileset/helpers/transform-utils");
|
|
98
|
+
|
|
99
|
+
var _frameState = require("./tileset/helpers/frame-state");
|
|
100
|
+
|
|
101
|
+
var _i3sLod = require("./tileset/helpers/i3s-lod");
|
|
102
|
+
|
|
103
|
+
var _constants = require("./constants");
|
|
104
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AAEA","sourcesContent":["export type {Tileset3DProps} from './tileset/tileset-3d';\nexport {default as Tileset3D} from './tileset/tileset-3d';\nexport {default as Tile3D} from './tileset/tile-3d';\n\nexport {default as TilesetTraverser} from './tileset/traversers/tileset-traverser';\nexport {default as 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"],"file":"index.js"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.get3dTilesOptions = get3dTilesOptions;
|
|
7
|
+
|
|
8
|
+
function get3dTilesOptions(tileset) {
|
|
9
|
+
return {
|
|
10
|
+
assetGltfUpAxis: tileset.asset && tileset.asset.gltfUpAxis || 'Y'
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=3d-tiles-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/tileset/helpers/3d-tiles-options.ts"],"names":["get3dTilesOptions","tileset","assetGltfUpAxis","asset","gltfUpAxis"],"mappings":";;;;;;;AAAO,SAASA,iBAAT,CAA2BC,OAA3B,EAAoC;AACzC,SAAO;AACLC,IAAAA,eAAe,EAAGD,OAAO,CAACE,KAAR,IAAiBF,OAAO,CAACE,KAAR,CAAcC,UAAhC,IAA+C;AAD3D,GAAP;AAGD","sourcesContent":["export function get3dTilesOptions(tileset) {\n return {\n assetGltfUpAxis: (tileset.asset && tileset.asset.gltfUpAxis) || 'Y'\n };\n}\n"],"file":"3d-tiles-options.js"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createBoundingVolume = createBoundingVolume;
|
|
7
|
+
|
|
8
|
+
var _core = require("@math.gl/core");
|
|
9
|
+
|
|
10
|
+
var _culling = require("@math.gl/culling");
|
|
11
|
+
|
|
12
|
+
var _geospatial = require("@math.gl/geospatial");
|
|
13
|
+
|
|
14
|
+
var _loaderUtils = require("@loaders.gl/loader-utils");
|
|
15
|
+
|
|
16
|
+
function defined(x) {
|
|
17
|
+
return x !== undefined && x !== null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const scratchScale = new _core.Vector3();
|
|
21
|
+
const scratchNorthWest = new _core.Vector3();
|
|
22
|
+
const scratchSouthEast = new _core.Vector3();
|
|
23
|
+
|
|
24
|
+
function createBoundingVolume(boundingVolumeHeader, transform, result) {
|
|
25
|
+
(0, _loaderUtils.assert)(boundingVolumeHeader, '3D Tile: boundingVolume must be defined');
|
|
26
|
+
|
|
27
|
+
if (boundingVolumeHeader.box) {
|
|
28
|
+
return createBox(boundingVolumeHeader.box, transform, result);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (boundingVolumeHeader.region) {
|
|
32
|
+
const [west, south, east, north, minHeight, maxHeight] = boundingVolumeHeader.region;
|
|
33
|
+
|
|
34
|
+
const northWest = _geospatial.Ellipsoid.WGS84.cartographicToCartesian([(0, _core.degrees)(west), (0, _core.degrees)(north), minHeight], scratchNorthWest);
|
|
35
|
+
|
|
36
|
+
const southEast = _geospatial.Ellipsoid.WGS84.cartographicToCartesian([(0, _core.degrees)(east), (0, _core.degrees)(south), maxHeight], scratchSouthEast);
|
|
37
|
+
|
|
38
|
+
const centerInCartesian = new _core.Vector3().addVectors(northWest, southEast).multiplyScalar(0.5);
|
|
39
|
+
const radius = new _core.Vector3().subVectors(northWest, southEast).len() / 2.0;
|
|
40
|
+
return createSphere([centerInCartesian[0], centerInCartesian[1], centerInCartesian[2], radius], new _core.Matrix4());
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (boundingVolumeHeader.sphere) {
|
|
44
|
+
return createSphere(boundingVolumeHeader.sphere, transform, result);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
throw new Error('3D Tile: boundingVolume must contain a sphere, region, or box');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function createBox(box, transform, result) {
|
|
51
|
+
const center = new _core.Vector3(box[0], box[1], box[2]);
|
|
52
|
+
transform.transform(center, center);
|
|
53
|
+
let origin = [];
|
|
54
|
+
|
|
55
|
+
if (box.length === 10) {
|
|
56
|
+
const halfSize = box.slice(3, 6);
|
|
57
|
+
const quaternion = new _core.Quaternion();
|
|
58
|
+
quaternion.fromArray(box, 6);
|
|
59
|
+
const x = new _core.Vector3([1, 0, 0]);
|
|
60
|
+
const y = new _core.Vector3([0, 1, 0]);
|
|
61
|
+
const z = new _core.Vector3([0, 0, 1]);
|
|
62
|
+
x.transformByQuaternion(quaternion);
|
|
63
|
+
x.scale(halfSize[0]);
|
|
64
|
+
y.transformByQuaternion(quaternion);
|
|
65
|
+
y.scale(halfSize[1]);
|
|
66
|
+
z.transformByQuaternion(quaternion);
|
|
67
|
+
z.scale(halfSize[2]);
|
|
68
|
+
origin = [...x.toArray(), ...y.toArray(), ...z.toArray()];
|
|
69
|
+
} else {
|
|
70
|
+
origin = [...box.slice(3, 6), ...box.slice(6, 9), ...box.slice(9, 12)];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const xAxis = transform.transformAsVector(origin.slice(0, 3));
|
|
74
|
+
const yAxis = transform.transformAsVector(origin.slice(3, 6));
|
|
75
|
+
const zAxis = transform.transformAsVector(origin.slice(6, 9));
|
|
76
|
+
const halfAxes = new _core.Matrix3([xAxis[0], xAxis[1], xAxis[2], yAxis[0], yAxis[1], yAxis[2], zAxis[0], zAxis[1], zAxis[2]]);
|
|
77
|
+
|
|
78
|
+
if (defined(result)) {
|
|
79
|
+
result.center = center;
|
|
80
|
+
result.halfAxes = halfAxes;
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return new _culling.OrientedBoundingBox(center, halfAxes);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function createSphere(sphere, transform, result) {
|
|
88
|
+
const center = new _core.Vector3(sphere[0], sphere[1], sphere[2]);
|
|
89
|
+
transform.transform(center, center);
|
|
90
|
+
const scale = transform.getScale(scratchScale);
|
|
91
|
+
const uniformScale = Math.max(Math.max(scale[0], scale[1]), scale[2]);
|
|
92
|
+
const radius = sphere[3] * uniformScale;
|
|
93
|
+
|
|
94
|
+
if (defined(result)) {
|
|
95
|
+
result.center = center;
|
|
96
|
+
result.radius = radius;
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return new _culling.BoundingSphere(center, radius);
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=bounding-volume.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/tileset/helpers/bounding-volume.ts"],"names":["defined","x","undefined","scratchScale","Vector3","scratchNorthWest","scratchSouthEast","createBoundingVolume","boundingVolumeHeader","transform","result","box","createBox","region","west","south","east","north","minHeight","maxHeight","northWest","Ellipsoid","WGS84","cartographicToCartesian","southEast","centerInCartesian","addVectors","multiplyScalar","radius","subVectors","len","createSphere","Matrix4","sphere","Error","center","origin","length","halfSize","slice","quaternion","Quaternion","fromArray","y","z","transformByQuaternion","scale","toArray","xAxis","transformAsVector","yAxis","zAxis","halfAxes","Matrix3","OrientedBoundingBox","getScale","uniformScale","Math","max","BoundingSphere"],"mappings":";;;;;;;AAIA;;AACA;;AACA;;AACA;;AAIA,SAASA,OAAT,CAAiBC,CAAjB,EAAoB;AAClB,SAAOA,CAAC,KAAKC,SAAN,IAAmBD,CAAC,KAAK,IAAhC;AACD;;AAGD,MAAME,YAAY,GAAG,IAAIC,aAAJ,EAArB;AACA,MAAMC,gBAAgB,GAAG,IAAID,aAAJ,EAAzB;AACA,MAAME,gBAAgB,GAAG,IAAIF,aAAJ,EAAzB;;AAYO,SAASG,oBAAT,CAA8BC,oBAA9B,EAAoDC,SAApD,EAA+DC,MAA/D,EAAuE;AAC5E,2BAAOF,oBAAP,EAA6B,yCAA7B;;AAIA,MAAIA,oBAAoB,CAACG,GAAzB,EAA8B;AAC5B,WAAOC,SAAS,CAACJ,oBAAoB,CAACG,GAAtB,EAA2BF,SAA3B,EAAsCC,MAAtC,CAAhB;AACD;;AACD,MAAIF,oBAAoB,CAACK,MAAzB,EAAiC;AAI/B,UAAM,CAACC,IAAD,EAAOC,KAAP,EAAcC,IAAd,EAAoBC,KAApB,EAA2BC,SAA3B,EAAsCC,SAAtC,IAAmDX,oBAAoB,CAACK,MAA9E;;AAEA,UAAMO,SAAS,GAAGC,sBAAUC,KAAV,CAAgBC,uBAAhB,CAChB,CAAC,mBAAQT,IAAR,CAAD,EAAgB,mBAAQG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AACA,QAAMW,KAAK,GAAGrC,SAAS,CAAC8C,QAAV,CAAmBpD,YAAnB,CAAd;AAEA,QAAMqD,YAAY,GAAGC,IAAI,CAACC,GAAL,CAASD,IAAI,CAACC,GAAL,CAASZ,KAAK,CAAC,CAAD,CAAd,EAAmBA,KAAK,CAAC,CAAD,CAAxB,CAAT,EAAuCA,KAAK,CAAC,CAAD,CAA5C,CAArB;AACA,QAAMlB,MAAM,GAAGK,MAAM,CAAC,CAAD,CAAN,GAAYuB,YAA3B;;AAEA,MAAIxD,OAAO,CAACU,MAAD,CAAX,EAAqB;AACnBA,IAAAA,MAAM,CAACyB,MAAP,GAAgBA,MAAhB;AACAzB,IAAAA,MAAM,CAACkB,MAAP,GAAgBA,MAAhB;AACA,WAAOlB,MAAP;AACD;;AAED,SAAO,IAAIiD,uBAAJ,CAAmBxB,MAAnB,EAA2BP,MAA3B,CAAP;AACD","sourcesContent":["// 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/* eslint-disable */\nimport {Quaternion, Vector3, Matrix3, Matrix4, degrees} from '@math.gl/core';\nimport {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {assert} from '@loaders.gl/loader-utils';\n\n// const scratchProjectedBoundingSphere = new BoundingSphere();\n\nfunction defined(x) {\n return x !== undefined && x !== null;\n}\n\n// const scratchMatrix = new Matrix3();\nconst scratchScale = new Vector3();\nconst scratchNorthWest = new Vector3();\nconst scratchSouthEast = new Vector3();\n// const scratchRectangle = new Rectangle();\n// const scratchOrientedBoundingBox = new OrientedBoundingBox();\n// const scratchTransform = new Matrix4();\n\n/**\n * Create a bounding volume from the tile's bounding volume header.\n * @param {Object} boundingVolumeHeader The tile's bounding volume header.\n * @param {Matrix4} transform The transform to apply to the bounding volume.\n * @param [result] The object onto which to store the result.\n * @returns The modified result parameter or a new TileBoundingVolume instance if none was provided.\n */\nexport function createBoundingVolume(boundingVolumeHeader, transform, result) {\n assert(boundingVolumeHeader, '3D Tile: boundingVolume must be defined');\n\n // boundingVolume schema:\n // https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/schema/boundingVolume.schema.json\n if (boundingVolumeHeader.box) {\n return createBox(boundingVolumeHeader.box, transform, result);\n }\n if (boundingVolumeHeader.region) {\n // [west, south, east, north, minimum height, maximum height]\n // Latitudes and longitudes are in the WGS 84 datum as defined in EPSG 4979 and are in radians.\n // Heights are in meters above (or below) the WGS 84 ellipsoid.\n const [west, south, east, north, minHeight, maxHeight] = boundingVolumeHeader.region;\n\n const northWest = Ellipsoid.WGS84.cartographicToCartesian(\n [degrees(west), degrees(north), minHeight],\n scratchNorthWest\n );\n const southEast = Ellipsoid.WGS84.cartographicToCartesian(\n [degrees(east), degrees(south), maxHeight],\n scratchSouthEast\n );\n const centerInCartesian = new Vector3().addVectors(northWest, southEast).multiplyScalar(0.5);\n const radius = new Vector3().subVectors(northWest, southEast).len() / 2.0;\n\n // TODO improve region boundingVolume\n // for now, create a sphere as the boundingVolume instead of box\n return createSphere(\n [centerInCartesian[0], centerInCartesian[1], centerInCartesian[2], radius],\n new Matrix4()\n );\n }\n\n if (boundingVolumeHeader.sphere) {\n return createSphere(boundingVolumeHeader.sphere, transform, result);\n }\n\n throw new Error('3D Tile: boundingVolume must contain a sphere, region, or box');\n}\n\nfunction createBox(box, transform, result) {\n // https://math.gl/modules/culling/docs/api-reference/oriented-bounding-box\n // 1. A half-axes based representation.\n // box: An array of 12 numbers that define an oriented bounding box.\n // The first three elements define the x, y, and z values for the center of the box.\n // The next three elements (with indices 3, 4, and 5) define the x axis direction and half-length.\n // The next three elements (indices 6, 7, and 8) define the y axis direction and half-length.\n // The last three elements (indices 9, 10, and 11) define the z axis direction and half-length.\n // 2. A half-size-quaternion based representation.\n // box: An array of 10 numbers that define an oriented bounding box.\n // The first three elements define the x, y, and z values for the center of the box in a right-handed 3-axis (x, y, z) Cartesian coordinate system where the z-axis is up.\n // The next three elements (with indices 3, 4, and 5) define the halfSize.\n // The last four elements (indices 6, 7, 8 and 10) define the quaternion.\n const center = new Vector3(box[0], box[1], box[2]);\n transform.transform(center, center);\n let origin: number[] = [];\n if (box.length === 10) {\n const halfSize = box.slice(3, 6);\n const quaternion = new Quaternion();\n quaternion.fromArray(box, 6);\n const x = new Vector3([1, 0, 0]);\n const y = new Vector3([0, 1, 0]);\n const z = new Vector3([0, 0, 1]);\n x.transformByQuaternion(quaternion);\n x.scale(halfSize[0]);\n y.transformByQuaternion(quaternion);\n y.scale(halfSize[1]);\n z.transformByQuaternion(quaternion);\n z.scale(halfSize[2]);\n origin = [...x.toArray(), ...y.toArray(), ...z.toArray()];\n } else {\n origin = [...box.slice(3, 6), ...box.slice(6, 9), ...box.slice(9, 12)];\n }\n const xAxis = transform.transformAsVector(origin.slice(0, 3));\n const yAxis = transform.transformAsVector(origin.slice(3, 6));\n const zAxis = transform.transformAsVector(origin.slice(6, 9));\n const halfAxes = new Matrix3([\n xAxis[0],\n xAxis[1],\n xAxis[2],\n yAxis[0],\n yAxis[1],\n yAxis[2],\n zAxis[0],\n zAxis[1],\n zAxis[2]\n ]);\n\n if (defined(result)) {\n result.center = center;\n result.halfAxes = halfAxes;\n return result;\n }\n\n return new OrientedBoundingBox(center, halfAxes);\n}\n\n/*\nfunction createBoxFromTransformedRegion(region, transform, initialTransform, result) {\n const rectangle = Rectangle.unpack(region, 0, scratchRectangle);\n const minimumHeight = region[4];\n const maximumHeight = region[5];\n\n const orientedBoundingBox = OrientedBoundingBox.fromRectangle(\n rectangle,\n minimumHeight,\n maximumHeight,\n Ellipsoid.WGS84,\n scratchOrientedBoundingBox\n );\n const center = orientedBoundingBox.center;\n const halfAxes = orientedBoundingBox.halfAxes;\n\n // A region bounding volume is not transformed by the transform in the tileset JSON,\n // but may be transformed by additional transforms applied in Cesium.\n // This is why the transform is calculated as the difference between the initial transform and the current transform.\n transform = Matrix4.multiplyTransformation(\n transform,\n Matrix4.inverseTransformation(initialTransform, scratchTransform),\n scratchTransform\n );\n center = Matrix4.multiplyByPoint(transform, center, center);\n const rotationScale = Matrix4.getRotation(transform, scratchMatrix);\n halfAxes = Matrix3.multiply(rotationScale, halfAxes, halfAxes);\n\n if (defined(result) && result instanceof TileOrientedBoundingBox) {\n result.update(center, halfAxes);\n return result;\n }\n\n return new TileOrientedBoundingBox(center, halfAxes);\n}\n\nfunction createRegion(region, transform, initialTransform, result) {\n if (!Matrix4.equalsEpsilon(transform, initialTransform, CesiumMath.EPSILON8)) {\n return createBoxFromTransformedRegion(region, transform, initialTransform, result);\n }\n\n if (defined(result)) {\n return result;\n }\n\n const rectangleRegion = Rectangle.unpack(region, 0, scratchRectangle);\n\n return new TileBoundingRegion({\n rectangle: rectangleRegion,\n minimumHeight: region[4],\n maximumHeight: region[5]\n });\n}\n*/\n\nfunction createSphere(sphere, transform, result?) {\n // Find the transformed center\n const center = new Vector3(sphere[0], sphere[1], sphere[2]);\n transform.transform(center, center);\n const scale = transform.getScale(scratchScale);\n\n const uniformScale = Math.max(Math.max(scale[0], scale[1]), scale[2]);\n const radius = sphere[3] * uniformScale;\n\n if (defined(result)) {\n result.center = center;\n result.radius = radius;\n return result;\n }\n\n return new BoundingSphere(center, radius);\n}\n"],"file":"bounding-volume.js"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getFrameState = getFrameState;
|
|
7
|
+
|
|
8
|
+
var _core = require("@math.gl/core");
|
|
9
|
+
|
|
10
|
+
var _culling = require("@math.gl/culling");
|
|
11
|
+
|
|
12
|
+
var _geospatial = require("@math.gl/geospatial");
|
|
13
|
+
|
|
14
|
+
const scratchVector = new _core.Vector3();
|
|
15
|
+
const scratchPosition = new _core.Vector3();
|
|
16
|
+
const cullingVolume = new _culling.CullingVolume([new _culling.Plane(), new _culling.Plane(), new _culling.Plane(), new _culling.Plane(), new _culling.Plane(), new _culling.Plane()]);
|
|
17
|
+
|
|
18
|
+
function getFrameState(viewport, frameNumber) {
|
|
19
|
+
const {
|
|
20
|
+
cameraDirection,
|
|
21
|
+
cameraUp,
|
|
22
|
+
height
|
|
23
|
+
} = viewport;
|
|
24
|
+
const {
|
|
25
|
+
metersPerUnit
|
|
26
|
+
} = viewport.distanceScales;
|
|
27
|
+
const viewportCenterCartographic = [viewport.longitude, viewport.latitude, 0];
|
|
28
|
+
|
|
29
|
+
const viewportCenterCartesian = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(viewportCenterCartographic, new _core.Vector3());
|
|
30
|
+
|
|
31
|
+
const enuToFixedTransform = _geospatial.Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);
|
|
32
|
+
|
|
33
|
+
const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
|
|
34
|
+
|
|
35
|
+
const cameraPositionCartesian = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new _core.Vector3());
|
|
36
|
+
|
|
37
|
+
const cameraDirectionCartesian = new _core.Vector3(enuToFixedTransform.transformAsVector(new _core.Vector3(cameraDirection).scale(metersPerUnit))).normalize();
|
|
38
|
+
const cameraUpCartesian = new _core.Vector3(enuToFixedTransform.transformAsVector(new _core.Vector3(cameraUp).scale(metersPerUnit))).normalize();
|
|
39
|
+
commonSpacePlanesToWGS84(viewport, viewportCenterCartesian);
|
|
40
|
+
return {
|
|
41
|
+
camera: {
|
|
42
|
+
position: cameraPositionCartesian,
|
|
43
|
+
direction: cameraDirectionCartesian,
|
|
44
|
+
up: cameraUpCartesian
|
|
45
|
+
},
|
|
46
|
+
viewport,
|
|
47
|
+
height,
|
|
48
|
+
cullingVolume,
|
|
49
|
+
frameNumber,
|
|
50
|
+
sseDenominator: 1.15
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function commonSpacePlanesToWGS84(viewport, viewportCenterCartesian) {
|
|
55
|
+
const frustumPlanes = viewport.getFrustumPlanes();
|
|
56
|
+
let i = 0;
|
|
57
|
+
|
|
58
|
+
for (const dir in frustumPlanes) {
|
|
59
|
+
const plane = frustumPlanes[dir];
|
|
60
|
+
const distanceToCenter = plane.normal.dot(viewport.center);
|
|
61
|
+
scratchPosition.copy(plane.normal).scale(plane.distance - distanceToCenter).add(viewport.center);
|
|
62
|
+
const cartographicPos = viewport.unprojectPosition(scratchPosition);
|
|
63
|
+
|
|
64
|
+
const cartesianPos = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, new _core.Vector3());
|
|
65
|
+
|
|
66
|
+
cullingVolume.planes[i++].fromPointNormal(cartesianPos, scratchVector.copy(viewportCenterCartesian).subtract(cartesianPos));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=frame-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/tileset/helpers/frame-state.ts"],"names":["scratchVector","Vector3","scratchPosition","cullingVolume","CullingVolume","Plane","getFrameState","viewport","frameNumber","cameraDirection","cameraUp","height","metersPerUnit","distanceScales","viewportCenterCartographic","longitude","latitude","viewportCenterCartesian","Ellipsoid","WGS84","cartographicToCartesian","enuToFixedTransform","eastNorthUpToFixedFrame","cameraPositionCartographic","unprojectPosition","cameraPosition","cameraPositionCartesian","cameraDirectionCartesian","transformAsVector","scale","normalize","cameraUpCartesian","commonSpacePlanesToWGS84","camera","position","direction","up","sseDenominator","frustumPlanes","getFrustumPlanes","i","dir","plane","distanceToCenter","normal","dot","center","copy","distance","add","cartographicPos","cartesianPos","planes","fromPointNormal","subtract"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAeA,MAAMA,aAAa,GAAG,IAAIC,aAAJ,EAAtB;AACA,MAAMC,eAAe,GAAG,IAAID,aAAJ,EAAxB;AACA,MAAME,aAAa,GAAG,IAAIC,sBAAJ,CAA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D;AACF","sourcesContent":["import {Vector3} from '@math.gl/core';\nimport {CullingVolume, Plane} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\n\nexport type FrameState = {\n camera: {\n position: number[];\n direction: number[];\n up: number[];\n };\n viewport: {[key: string]: any};\n height: number;\n cullingVolume: CullingVolume;\n frameNumber: number; // TODO: This can be the same between updates, what number is unique for between updates?\n sseDenominator: number; // Assumes fovy = 60 degrees\n};\n\nconst scratchVector = new Vector3();\nconst scratchPosition = new Vector3();\nconst cullingVolume = new CullingVolume([\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane()\n]);\n\n// Extracts a frame state appropriate for tile culling from a deck.gl viewport\n// TODO - this could likely be generalized and merged back into deck.gl for other culling scenarios\nexport function getFrameState(viewport, frameNumber: number): FrameState {\n // Traverse and and request. Update _selectedTiles so that we know what to render.\n const {cameraDirection, cameraUp, height} = viewport;\n const {metersPerUnit} = viewport.distanceScales;\n\n const viewportCenterCartographic = [viewport.longitude, viewport.latitude, 0];\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() breaks on raw array, create a Vector.\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() takes a cartesian, is that intuitive?\n const viewportCenterCartesian = Ellipsoid.WGS84.cartographicToCartesian(\n viewportCenterCartographic,\n new Vector3()\n );\n const enuToFixedTransform = Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);\n\n const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);\n const cameraPositionCartesian = Ellipsoid.WGS84.cartographicToCartesian(\n cameraPositionCartographic,\n new Vector3()\n );\n\n // These should still be normalized as the transform has scale 1 (goes from meters to meters)\n const cameraDirectionCartesian = new Vector3(\n // @ts-ignore\n enuToFixedTransform.transformAsVector(new Vector3(cameraDirection).scale(metersPerUnit))\n ).normalize();\n const cameraUpCartesian = new Vector3(\n // @ts-ignore\n enuToFixedTransform.transformAsVector(new Vector3(cameraUp).scale(metersPerUnit))\n ).normalize();\n\n commonSpacePlanesToWGS84(viewport, viewportCenterCartesian);\n\n // TODO: make a file/class for frameState and document what needs to be attached to this so that traversal can function\n return {\n camera: {\n position: cameraPositionCartesian,\n direction: cameraDirectionCartesian,\n up: cameraUpCartesian\n },\n viewport,\n height,\n cullingVolume,\n frameNumber, // TODO: This can be the same between updates, what number is unique for between updates?\n sseDenominator: 1.15 // Assumes fovy = 60 degrees\n };\n}\n\nfunction commonSpacePlanesToWGS84(viewport, viewportCenterCartesian) {\n // Extract frustum planes based on current view.\n const frustumPlanes = viewport.getFrustumPlanes();\n let i = 0;\n for (const dir in frustumPlanes) {\n const plane = frustumPlanes[dir];\n const distanceToCenter = plane.normal.dot(viewport.center);\n scratchPosition\n .copy(plane.normal)\n .scale(plane.distance - distanceToCenter)\n .add(viewport.center);\n const cartographicPos = viewport.unprojectPosition(scratchPosition);\n\n const cartesianPos = Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, new Vector3());\n\n cullingVolume.planes[i++].fromPointNormal(\n cartesianPos,\n // Want the normal to point into the frustum since that's what culling expects\n scratchVector.copy(viewportCenterCartesian).subtract(cartesianPos)\n );\n }\n}\n"],"file":"frame-state.js"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getLodStatus = getLodStatus;
|
|
7
|
+
exports.getProjectedRadius = getProjectedRadius;
|
|
8
|
+
|
|
9
|
+
var _core = require("@math.gl/core");
|
|
10
|
+
|
|
11
|
+
var _geospatial = require("@math.gl/geospatial");
|
|
12
|
+
|
|
13
|
+
function getLodStatus(tile, frameState) {
|
|
14
|
+
if (tile.lodMetricValue === 0 || isNaN(tile.lodMetricValue)) {
|
|
15
|
+
return 'DIG';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const screenSize = 2 * getProjectedRadius(tile, frameState);
|
|
19
|
+
|
|
20
|
+
if (screenSize < 2) {
|
|
21
|
+
return 'OUT';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!tile.header.children || screenSize <= tile.lodMetricValue) {
|
|
25
|
+
return 'DRAW';
|
|
26
|
+
} else if (tile.header.children) {
|
|
27
|
+
return 'DIG';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return 'OUT';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getProjectedRadius(tile, frameState) {
|
|
34
|
+
const originalViewport = frameState.viewport;
|
|
35
|
+
const ViewportClass = originalViewport.constructor;
|
|
36
|
+
const {
|
|
37
|
+
longitude,
|
|
38
|
+
latitude,
|
|
39
|
+
height,
|
|
40
|
+
width,
|
|
41
|
+
bearing,
|
|
42
|
+
zoom
|
|
43
|
+
} = originalViewport;
|
|
44
|
+
const viewport = new ViewportClass({
|
|
45
|
+
longitude,
|
|
46
|
+
latitude,
|
|
47
|
+
height,
|
|
48
|
+
width,
|
|
49
|
+
bearing,
|
|
50
|
+
zoom,
|
|
51
|
+
pitch: 0
|
|
52
|
+
});
|
|
53
|
+
const mbsLat = tile.header.mbs[1];
|
|
54
|
+
const mbsLon = tile.header.mbs[0];
|
|
55
|
+
const mbsZ = tile.header.mbs[2];
|
|
56
|
+
const mbsR = tile.header.mbs[3];
|
|
57
|
+
const mbsCenterCartesian = [...tile.boundingVolume.center];
|
|
58
|
+
const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
|
|
59
|
+
|
|
60
|
+
const cameraPositionCartesian = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new _core.Vector3());
|
|
61
|
+
|
|
62
|
+
const toEye = new _core.Vector3(cameraPositionCartesian).subtract(mbsCenterCartesian).normalize();
|
|
63
|
+
const enuToCartesianMatrix = new _core.Matrix4();
|
|
64
|
+
|
|
65
|
+
_geospatial.Ellipsoid.WGS84.eastNorthUpToFixedFrame(mbsCenterCartesian, enuToCartesianMatrix);
|
|
66
|
+
|
|
67
|
+
const cartesianToEnuMatrix = new _core.Matrix4(enuToCartesianMatrix).invert();
|
|
68
|
+
const cameraPositionEnu = new _core.Vector3(cameraPositionCartesian).transform(cartesianToEnuMatrix);
|
|
69
|
+
const projection = Math.sqrt(cameraPositionEnu[0] * cameraPositionEnu[0] + cameraPositionEnu[1] * cameraPositionEnu[1]);
|
|
70
|
+
const extraZ = projection * projection / cameraPositionEnu[2];
|
|
71
|
+
const extraVertexEnu = new _core.Vector3([cameraPositionEnu[0], cameraPositionEnu[1], extraZ]);
|
|
72
|
+
const extraVertexCartesian = extraVertexEnu.transform(enuToCartesianMatrix);
|
|
73
|
+
const extraVectorCartesian = new _core.Vector3(extraVertexCartesian).subtract(mbsCenterCartesian).normalize();
|
|
74
|
+
const radiusVector = toEye.cross(extraVectorCartesian).normalize().scale(mbsR);
|
|
75
|
+
const sphereMbsBorderVertexCartesian = new _core.Vector3(mbsCenterCartesian).add(radiusVector);
|
|
76
|
+
|
|
77
|
+
const sphereMbsBorderVertexCartographic = _geospatial.Ellipsoid.WGS84.cartesianToCartographic(sphereMbsBorderVertexCartesian);
|
|
78
|
+
|
|
79
|
+
const projectedOrigin = viewport.project([mbsLon, mbsLat, mbsZ]);
|
|
80
|
+
const projectedMbsBorderVertex = viewport.project(sphereMbsBorderVertexCartographic);
|
|
81
|
+
const projectedRadius = new _core.Vector3(projectedOrigin).subtract(projectedMbsBorderVertex).magnitude();
|
|
82
|
+
return projectedRadius;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=i3s-lod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/tileset/helpers/i3s-lod.ts"],"names":["getLodStatus","tile","frameState","lodMetricValue","isNaN","screenSize","getProjectedRadius","header","children","originalViewport","viewport","ViewportClass","constructor","longitude","latitude","height","width","bearing","zoom","pitch","mbsLat","mbs","mbsLon","mbsZ","mbsR","mbsCenterCartesian","boundingVolume","center","cameraPositionCartographic","unprojectPosition","cameraPosition","cameraPositionCartesian","Ellipsoid","WGS84","cartographicToCartesian","Vector3","toEye","subtract","normalize","enuToCartesianMatrix","Matrix4","eastNorthUpToFixedFrame","cartesianToEnuMatrix","invert","cameraPositionEnu","transform","projection","Math","sqrt","extraZ","extraVertexEnu","extraVertexCartesian","extraVectorCartesian","radiusVector","cross","scale","sphereMbsBorderVertexCartesian","add","sphereMbsBorderVertexCartographic","cartesianToCartographic","projectedOrigin","project","projectedMbsBorderVertex","projectedRadius","magnitude"],"mappings":";;;;;;;;AAAA;;AACA;;AAaO,SAASA,YAAT,CAAsBC,IAAtB,EAAoCC,UAApC,EAAoF;AACzF,MAAID,IAAI,CAACE,cAAL,KAAwB,CAAxB,IAA6BC,KAAK,CAACH,IAAI,CAACE,cAAN,CAAtC,EAA6D;AAC3D,WAAO,KAAP;AACD;;AACD,QAAME,UAAU,GAAG,IAAIC,kBAAkB,CAACL,IAAD,EAAOC,UAAP,CAAzC;;AACA,MAAIG,UAAU,GAAG,CAAjB,EAAoB;AAClB,WAAO,KAAP;AACD;;AACD,MAAI,CAACJ,IAAI,CAACM,MAAL,CAAYC,QAAb,IAAyBH,UAAU,IAAIJ,IAAI,CAACE,cAAhD,EAAgE;AAC9D,WAAO,MAAP;AACD,GAFD,MAEO,IAAIF,IAAI,CAACM,MAAL,CAAYC,QAAhB,EAA0B;AAC/B,WAAO,KAAP;AACD;;AACD,SAAO,KAAP;AACD;;AASM,SAASF,kBAAT,CAA4BL,IAA5B,EAA0CC,UAA1C,EAA0E;AAC/E,QAAMO,gBAAgB,GAAGP,UAAU,CAACQ,QAApC;AACA,QAAMC,aAAa,GAAGF,gBAAgB,CAACG,WAAvC;AACA,QAAM;AAACC,IAAAA,SAAD;AAAYC,IAAAA,QAAZ;AAAsBC,IAAAA,MAAtB;AAA8BC,IAAAA,KAA9B;AAAqCC,IAAAA,OAArC;AAA8CC,IAAAA;AAA9C,MAAsDT,gBAA5D;AAEA,QAAMC,QAAQ,GAAG,IAAIC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';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport Tile3D from '../tile-3d';\nimport {FrameState} from './frame-state';\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 originalViewport = frameState.viewport;\n const ViewportClass = originalViewport.constructor;\n const {longitude, latitude, height, width, bearing, zoom} = originalViewport;\n // @ts-ignore\n const viewport = new ViewportClass({longitude, latitude, height, width, bearing, zoom, pitch: 0});\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 const cameraPositionCartesian = Ellipsoid.WGS84.cartographicToCartesian(\n cameraPositionCartographic,\n new Vector3()\n );\n\n // ---------------------------\n // Calculate mbs border vertex\n // ---------------------------\n const toEye = new Vector3(cameraPositionCartesian).subtract(mbsCenterCartesian).normalize();\n // Add extra vector to form plane\n const enuToCartesianMatrix = new Matrix4();\n Ellipsoid.WGS84.eastNorthUpToFixedFrame(mbsCenterCartesian, enuToCartesianMatrix);\n const cartesianToEnuMatrix = new Matrix4(enuToCartesianMatrix).invert();\n const cameraPositionEnu = new Vector3(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 const extraVertexEnu = new Vector3([cameraPositionEnu[0], cameraPositionEnu[1], extraZ]);\n const extraVertexCartesian = extraVertexEnu.transform(enuToCartesianMatrix);\n const extraVectorCartesian = new Vector3(extraVertexCartesian)\n .subtract(mbsCenterCartesian)\n .normalize();\n // We need radius vector orthogonal to toEye vector\n const radiusVector = toEye.cross(extraVectorCartesian).normalize().scale(mbsR);\n const sphereMbsBorderVertexCartesian = new Vector3(mbsCenterCartesian).add(radiusVector);\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(sphereMbsBorderVertexCartographic);\n const projectedRadius = new Vector3(projectedOrigin)\n .subtract(projectedMbsBorderVertex)\n .magnitude();\n return projectedRadius;\n}\n"],"file":"i3s-lod.js"}
|