@loaders.gl/tiles 3.0.13 → 3.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.es5.min.js +1 -1
- package/dist/dist.es5.min.js.map +1 -1
- package/dist/dist.min.js +1 -1
- package/dist/dist.min.js.map +1 -1
- package/dist/es5/bundle.js +2 -2
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/constants.js +6 -6
- package/dist/es5/constants.js.map +1 -1
- package/dist/es5/index.js +12 -12
- package/dist/es5/tileset/helpers/bounding-volume.js +37 -25
- package/dist/es5/tileset/helpers/bounding-volume.js.map +1 -1
- package/dist/es5/tileset/helpers/frame-state.js +25 -29
- package/dist/es5/tileset/helpers/frame-state.js.map +1 -1
- package/dist/es5/tileset/helpers/i3s-lod.js +66 -51
- package/dist/es5/tileset/helpers/i3s-lod.js.map +1 -1
- package/dist/es5/tileset/helpers/tiles-3d-lod.js +47 -51
- package/dist/es5/tileset/helpers/tiles-3d-lod.js.map +1 -1
- package/dist/es5/tileset/helpers/transform-utils.js +11 -17
- package/dist/es5/tileset/helpers/transform-utils.js.map +1 -1
- package/dist/es5/tileset/helpers/zoom.js +15 -17
- package/dist/es5/tileset/helpers/zoom.js.map +1 -1
- package/dist/es5/tileset/tile-3d.js +421 -328
- package/dist/es5/tileset/tile-3d.js.map +1 -1
- package/dist/es5/tileset/tileset-3d.js +563 -381
- package/dist/es5/tileset/tileset-3d.js.map +1 -1
- package/dist/es5/tileset/tileset-cache.js +63 -50
- package/dist/es5/tileset/tileset-cache.js.map +1 -1
- package/dist/es5/tileset/traversers/i3s-tile-manager.js +44 -32
- package/dist/es5/tileset/traversers/i3s-tile-manager.js.map +1 -1
- package/dist/es5/tileset/traversers/i3s-tileset-traverser.js +143 -53
- package/dist/es5/tileset/traversers/i3s-tileset-traverser.js.map +1 -1
- package/dist/es5/tileset/traversers/tileset-3d-traverser.js +62 -34
- package/dist/es5/tileset/traversers/tileset-3d-traverser.js.map +1 -1
- package/dist/es5/tileset/traversers/tileset-traverser.js +282 -209
- package/dist/es5/tileset/traversers/tileset-traverser.js.map +1 -1
- package/dist/es5/utils/doubly-linked-list-node.js +9 -7
- package/dist/es5/utils/doubly-linked-list-node.js.map +1 -1
- package/dist/es5/utils/doubly-linked-list.js +76 -64
- package/dist/es5/utils/doubly-linked-list.js.map +1 -1
- package/dist/es5/utils/managed-array.js +108 -86
- package/dist/es5/utils/managed-array.js.map +1 -1
- package/package.json +5 -5
package/dist/es5/bundle.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var moduleExports = require('./index');
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
var _global = typeof window === 'undefined' ? global : window;
|
|
6
6
|
|
|
7
7
|
_global.loaders = _global.loaders || {};
|
|
8
8
|
module.exports = Object.assign(_global.loaders, moduleExports);
|
package/dist/es5/bundle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","_global","window","global","loaders","module","exports","Object","assign"],"mappings":";;AACA,
|
|
1
|
+
{"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","_global","window","global","loaders","module","exports","Object","assign"],"mappings":";;AACA,IAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACA,IAAMC,OAAO,GAAG,OAAOC,MAAP,KAAkB,WAAlB,GAAgCC,MAAhC,GAAyCD,MAAzD;;AACAD,OAAO,CAACG,OAAR,GAAkBH,OAAO,CAACG,OAAR,IAAmB,EAArC;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcP,OAAO,CAACG,OAAtB,EAA+BL,aAA/B,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nconst _global = typeof window === 'undefined' ? global : window;\n_global.loaders = _global.loaders || {};\nmodule.exports = Object.assign(_global.loaders, moduleExports);\n"],"file":"bundle.js"}
|
package/dist/es5/constants.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
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
|
-
|
|
7
|
+
var TILE_CONTENT_STATE = {
|
|
8
8
|
UNLOADED: 0,
|
|
9
9
|
LOADING: 1,
|
|
10
10
|
PROCESSING: 2,
|
|
@@ -13,29 +13,29 @@ const TILE_CONTENT_STATE = {
|
|
|
13
13
|
FAILED: 5
|
|
14
14
|
};
|
|
15
15
|
exports.TILE_CONTENT_STATE = TILE_CONTENT_STATE;
|
|
16
|
-
|
|
16
|
+
var TILE_REFINEMENT = {
|
|
17
17
|
ADD: 1,
|
|
18
18
|
REPLACE: 2
|
|
19
19
|
};
|
|
20
20
|
exports.TILE_REFINEMENT = TILE_REFINEMENT;
|
|
21
|
-
|
|
21
|
+
var TILE_TYPE = {
|
|
22
22
|
EMPTY: 'empty',
|
|
23
23
|
SCENEGRAPH: 'scenegraph',
|
|
24
24
|
POINTCLOUD: 'pointcloud',
|
|
25
25
|
MESH: 'mesh'
|
|
26
26
|
};
|
|
27
27
|
exports.TILE_TYPE = TILE_TYPE;
|
|
28
|
-
|
|
28
|
+
var TILESET_TYPE = {
|
|
29
29
|
I3S: 'I3S',
|
|
30
30
|
TILES3D: 'TILES3D'
|
|
31
31
|
};
|
|
32
32
|
exports.TILESET_TYPE = TILESET_TYPE;
|
|
33
|
-
|
|
33
|
+
var LOD_METRIC_TYPE = {
|
|
34
34
|
GEOMETRIC_ERROR: 'geometricError',
|
|
35
35
|
MAX_SCREEN_THRESHOLD: 'maxScreenThreshold'
|
|
36
36
|
};
|
|
37
37
|
exports.LOD_METRIC_TYPE = LOD_METRIC_TYPE;
|
|
38
|
-
|
|
38
|
+
var TILE3D_OPTIMIZATION_HINT = {
|
|
39
39
|
NOT_COMPUTED: -1,
|
|
40
40
|
USE_OPTIMIZATION: 1,
|
|
41
41
|
SKIP_OPTIMIZATION: 0
|
|
@@ -1 +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,
|
|
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,IAAMA,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,IAAMC,eAAe,GAAG;AAC7BC,EAAAA,GAAG,EAAE,CADwB;AAE7BC,EAAAA,OAAO,EAAE;AAFoB,CAAxB;;AAKA,IAAMC,SAAS,GAAG;AACvBC,EAAAA,KAAK,EAAE,OADgB;AAEvBC,EAAAA,UAAU,EAAE,YAFW;AAGvBC,EAAAA,UAAU,EAAE,YAHW;AAIvBC,EAAAA,IAAI,EAAE;AAJiB,CAAlB;;AAOA,IAAMC,YAAY,GAAG;AAC1BC,EAAAA,GAAG,EAAE,KADqB;AAE1BC,EAAAA,OAAO,EAAE;AAFiB,CAArB;;AAKA,IAAMC,eAAe,GAAG;AAC7BC,EAAAA,eAAe,EAAE,gBADY;AAE7BC,EAAAA,oBAAoB,EAAE;AAFO,CAAxB;;AAMA,IAAMC,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"}
|
package/dist/es5/index.js
CHANGED
|
@@ -7,73 +7,73 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
Object.defineProperty(exports, "Tileset3D", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () {
|
|
10
|
+
get: function get() {
|
|
11
11
|
return _tileset3d.default;
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "Tile3D", {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function () {
|
|
16
|
+
get: function get() {
|
|
17
17
|
return _tile3d.default;
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "TilesetTraverser", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () {
|
|
22
|
+
get: function get() {
|
|
23
23
|
return _tilesetTraverser.default;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
Object.defineProperty(exports, "TilesetCache", {
|
|
27
27
|
enumerable: true,
|
|
28
|
-
get: function () {
|
|
28
|
+
get: function get() {
|
|
29
29
|
return _tilesetCache.default;
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
32
|
Object.defineProperty(exports, "createBoundingVolume", {
|
|
33
33
|
enumerable: true,
|
|
34
|
-
get: function () {
|
|
34
|
+
get: function get() {
|
|
35
35
|
return _boundingVolume.createBoundingVolume;
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
Object.defineProperty(exports, "calculateTransformProps", {
|
|
39
39
|
enumerable: true,
|
|
40
|
-
get: function () {
|
|
40
|
+
get: function get() {
|
|
41
41
|
return _transformUtils.calculateTransformProps;
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
44
|
Object.defineProperty(exports, "getFrameState", {
|
|
45
45
|
enumerable: true,
|
|
46
|
-
get: function () {
|
|
46
|
+
get: function get() {
|
|
47
47
|
return _frameState.getFrameState;
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
Object.defineProperty(exports, "TILE_CONTENT_STATE", {
|
|
51
51
|
enumerable: true,
|
|
52
|
-
get: function () {
|
|
52
|
+
get: function get() {
|
|
53
53
|
return _constants.TILE_CONTENT_STATE;
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
Object.defineProperty(exports, "TILE_REFINEMENT", {
|
|
57
57
|
enumerable: true,
|
|
58
|
-
get: function () {
|
|
58
|
+
get: function get() {
|
|
59
59
|
return _constants.TILE_REFINEMENT;
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
Object.defineProperty(exports, "TILE_TYPE", {
|
|
63
63
|
enumerable: true,
|
|
64
|
-
get: function () {
|
|
64
|
+
get: function get() {
|
|
65
65
|
return _constants.TILE_TYPE;
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
68
|
Object.defineProperty(exports, "TILESET_TYPE", {
|
|
69
69
|
enumerable: true,
|
|
70
|
-
get: function () {
|
|
70
|
+
get: function get() {
|
|
71
71
|
return _constants.TILESET_TYPE;
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
74
|
Object.defineProperty(exports, "LOD_METRIC_TYPE", {
|
|
75
75
|
enumerable: true,
|
|
76
|
-
get: function () {
|
|
76
|
+
get: function get() {
|
|
77
77
|
return _constants.LOD_METRIC_TYPE;
|
|
78
78
|
}
|
|
79
79
|
});
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.createBoundingVolume = createBoundingVolume;
|
|
7
9
|
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
+
|
|
8
14
|
var _core = require("@math.gl/core");
|
|
9
15
|
|
|
10
16
|
var _culling = require("@math.gl/culling");
|
|
@@ -17,9 +23,9 @@ function defined(x) {
|
|
|
17
23
|
return x !== undefined && x !== null;
|
|
18
24
|
}
|
|
19
25
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
var scratchScale = new _core.Vector3();
|
|
27
|
+
var scratchNorthWest = new _core.Vector3();
|
|
28
|
+
var scratchSouthEast = new _core.Vector3();
|
|
23
29
|
|
|
24
30
|
function createBoundingVolume(boundingVolumeHeader, transform, result) {
|
|
25
31
|
(0, _loaderUtils.assert)(boundingVolumeHeader, '3D Tile: boundingVolume must be defined');
|
|
@@ -29,14 +35,20 @@ function createBoundingVolume(boundingVolumeHeader, transform, result) {
|
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
if (boundingVolumeHeader.region) {
|
|
32
|
-
|
|
38
|
+
var _boundingVolumeHeader = (0, _slicedToArray2.default)(boundingVolumeHeader.region, 6),
|
|
39
|
+
west = _boundingVolumeHeader[0],
|
|
40
|
+
south = _boundingVolumeHeader[1],
|
|
41
|
+
east = _boundingVolumeHeader[2],
|
|
42
|
+
north = _boundingVolumeHeader[3],
|
|
43
|
+
minHeight = _boundingVolumeHeader[4],
|
|
44
|
+
maxHeight = _boundingVolumeHeader[5];
|
|
33
45
|
|
|
34
|
-
|
|
46
|
+
var northWest = _geospatial.Ellipsoid.WGS84.cartographicToCartesian([(0, _core.degrees)(west), (0, _core.degrees)(north), minHeight], scratchNorthWest);
|
|
35
47
|
|
|
36
|
-
|
|
48
|
+
var southEast = _geospatial.Ellipsoid.WGS84.cartographicToCartesian([(0, _core.degrees)(east), (0, _core.degrees)(south), maxHeight], scratchSouthEast);
|
|
37
49
|
|
|
38
|
-
|
|
39
|
-
|
|
50
|
+
var centerInCartesian = new _core.Vector3().addVectors(northWest, southEast).multiplyScalar(0.5);
|
|
51
|
+
var radius = new _core.Vector3().subVectors(northWest, southEast).len() / 2.0;
|
|
40
52
|
return createSphere([centerInCartesian[0], centerInCartesian[1], centerInCartesian[2], radius], new _core.Matrix4());
|
|
41
53
|
}
|
|
42
54
|
|
|
@@ -48,32 +60,32 @@ function createBoundingVolume(boundingVolumeHeader, transform, result) {
|
|
|
48
60
|
}
|
|
49
61
|
|
|
50
62
|
function createBox(box, transform, result) {
|
|
51
|
-
|
|
63
|
+
var center = new _core.Vector3(box[0], box[1], box[2]);
|
|
52
64
|
transform.transform(center, center);
|
|
53
|
-
|
|
65
|
+
var origin = [];
|
|
54
66
|
|
|
55
67
|
if (box.length === 10) {
|
|
56
|
-
|
|
57
|
-
|
|
68
|
+
var halfSize = box.slice(3, 6);
|
|
69
|
+
var quaternion = new _core.Quaternion();
|
|
58
70
|
quaternion.fromArray(box, 6);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
71
|
+
var x = new _core.Vector3([1, 0, 0]);
|
|
72
|
+
var y = new _core.Vector3([0, 1, 0]);
|
|
73
|
+
var z = new _core.Vector3([0, 0, 1]);
|
|
62
74
|
x.transformByQuaternion(quaternion);
|
|
63
75
|
x.scale(halfSize[0]);
|
|
64
76
|
y.transformByQuaternion(quaternion);
|
|
65
77
|
y.scale(halfSize[1]);
|
|
66
78
|
z.transformByQuaternion(quaternion);
|
|
67
79
|
z.scale(halfSize[2]);
|
|
68
|
-
origin = [
|
|
80
|
+
origin = [].concat((0, _toConsumableArray2.default)(x.toArray()), (0, _toConsumableArray2.default)(y.toArray()), (0, _toConsumableArray2.default)(z.toArray()));
|
|
69
81
|
} else {
|
|
70
|
-
origin = [
|
|
82
|
+
origin = [].concat((0, _toConsumableArray2.default)(box.slice(3, 6)), (0, _toConsumableArray2.default)(box.slice(6, 9)), (0, _toConsumableArray2.default)(box.slice(9, 12)));
|
|
71
83
|
}
|
|
72
84
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
85
|
+
var xAxis = transform.transformAsVector(origin.slice(0, 3));
|
|
86
|
+
var yAxis = transform.transformAsVector(origin.slice(3, 6));
|
|
87
|
+
var zAxis = transform.transformAsVector(origin.slice(6, 9));
|
|
88
|
+
var halfAxes = new _core.Matrix3([xAxis[0], xAxis[1], xAxis[2], yAxis[0], yAxis[1], yAxis[2], zAxis[0], zAxis[1], zAxis[2]]);
|
|
77
89
|
|
|
78
90
|
if (defined(result)) {
|
|
79
91
|
result.center = center;
|
|
@@ -85,11 +97,11 @@ function createBox(box, transform, result) {
|
|
|
85
97
|
}
|
|
86
98
|
|
|
87
99
|
function createSphere(sphere, transform, result) {
|
|
88
|
-
|
|
100
|
+
var center = new _core.Vector3(sphere[0], sphere[1], sphere[2]);
|
|
89
101
|
transform.transform(center, center);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
102
|
+
var scale = transform.getScale(scratchScale);
|
|
103
|
+
var uniformScale = Math.max(Math.max(scale[0], scale[1]), scale[2]);
|
|
104
|
+
var radius = sphere[3] * uniformScale;
|
|
93
105
|
|
|
94
106
|
if (defined(result)) {
|
|
95
107
|
result.center = center;
|
|
@@ -1 +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,gBAA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K,CAAC,CAAD,CARsB,EAS3BA,KAAK,CAAC,CAAD,CATsB,CAAZ,CAAjB;;AAYA,MAAInD,OAAO,CAACU,MAAD,CAAX,EAAqB;AACnBA,IAAAA,MAAM,CAACyB,MAAP,GAAgBA,MAAhB;AACAzB,IAAAA,MAAM,CAAC0C,QAAP,GAAkBA,QAAlB;AACA,WAAO1C,MAAP;AACD;;AAED,SAAO,IAAI4C,4BAAJ,CAAwBnB,MAAxB,EAAgCiB,QAAhC,CAAP;AACD;;AAyDD,SAASrB,YAAT,CAAsBE,MAAtB,EAA8BxB,SAA9B,EAAyCC,MAAzC,EAAkD;AAEhD,QAAMyB,MAAM,GAAG,IAAI/B,aAAJ,CAAY6B,MAAM,CAAC,CAAD,CAAlB,EAAuBA,MAAM,CAAC,CAAD,CAA7B,EAAkCA,MAAM,CAAC,CAAD,CAAxC,CAAf;AACAxB,EAAAA,SAAS,CAACA,SAAV,CAAoB0B,MAApB,EAA4BA,MAA5B;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"}
|
|
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,IAAME,YAAY,GAAG,IAAIC,aAAJ,EAArB;AACA,IAAMC,gBAAgB,GAAG,IAAID,aAAJ,EAAzB;AACA,IAAME,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,6DAAyDL,oBAAoB,CAACK,MAA9E;AAAA,QAAOC,I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J,CAAY6B,MAAM,CAAC,CAAD,CAAlB,EAAuBA,MAAM,CAAC,CAAD,CAA7B,EAAkCA,MAAM,CAAC,CAAD,CAAxC,CAAf;AACAxB,EAAAA,SAAS,CAACA,SAAV,CAAoB0B,MAApB,EAA4BA,MAA5B;AACA,MAAMW,KAAK,GAAGrC,SAAS,CAAC8C,QAAV,CAAmBpD,YAAnB,CAAd;AAEA,MAAMqD,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,MAAMlB,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"}
|
|
@@ -11,31 +11,27 @@ var _culling = require("@math.gl/culling");
|
|
|
11
11
|
|
|
12
12
|
var _geospatial = require("@math.gl/geospatial");
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
var scratchVector = new _core.Vector3();
|
|
15
|
+
var scratchPosition = new _core.Vector3();
|
|
16
|
+
var cullingVolume = new _culling.CullingVolume([new _culling.Plane(), new _culling.Plane(), new _culling.Plane(), new _culling.Plane(), new _culling.Plane(), new _culling.Plane()]);
|
|
17
17
|
|
|
18
18
|
function getFrameState(viewport, frameNumber) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const {
|
|
25
|
-
metersPerUnit
|
|
26
|
-
} = viewport.distanceScales;
|
|
27
|
-
const viewportCenterCartographic = [viewport.longitude, viewport.latitude, 0];
|
|
19
|
+
var cameraDirection = viewport.cameraDirection,
|
|
20
|
+
cameraUp = viewport.cameraUp,
|
|
21
|
+
height = viewport.height;
|
|
22
|
+
var metersPerUnit = viewport.distanceScales.metersPerUnit;
|
|
23
|
+
var viewportCenterCartographic = [viewport.longitude, viewport.latitude, 0];
|
|
28
24
|
|
|
29
|
-
|
|
25
|
+
var viewportCenterCartesian = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(viewportCenterCartographic, new _core.Vector3());
|
|
30
26
|
|
|
31
|
-
|
|
27
|
+
var enuToFixedTransform = _geospatial.Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);
|
|
32
28
|
|
|
33
|
-
|
|
29
|
+
var cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
|
|
34
30
|
|
|
35
|
-
|
|
31
|
+
var cameraPositionCartesian = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new _core.Vector3());
|
|
36
32
|
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
var cameraDirectionCartesian = new _core.Vector3(enuToFixedTransform.transformAsVector(new _core.Vector3(cameraDirection).scale(metersPerUnit))).normalize();
|
|
34
|
+
var cameraUpCartesian = new _core.Vector3(enuToFixedTransform.transformAsVector(new _core.Vector3(cameraUp).scale(metersPerUnit))).normalize();
|
|
39
35
|
commonSpacePlanesToWGS84(viewport, viewportCenterCartesian);
|
|
40
36
|
return {
|
|
41
37
|
camera: {
|
|
@@ -43,25 +39,25 @@ function getFrameState(viewport, frameNumber) {
|
|
|
43
39
|
direction: cameraDirectionCartesian,
|
|
44
40
|
up: cameraUpCartesian
|
|
45
41
|
},
|
|
46
|
-
viewport,
|
|
47
|
-
height,
|
|
48
|
-
cullingVolume,
|
|
49
|
-
frameNumber,
|
|
42
|
+
viewport: viewport,
|
|
43
|
+
height: height,
|
|
44
|
+
cullingVolume: cullingVolume,
|
|
45
|
+
frameNumber: frameNumber,
|
|
50
46
|
sseDenominator: 1.15
|
|
51
47
|
};
|
|
52
48
|
}
|
|
53
49
|
|
|
54
50
|
function commonSpacePlanesToWGS84(viewport, viewportCenterCartesian) {
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
var frustumPlanes = viewport.getFrustumPlanes();
|
|
52
|
+
var i = 0;
|
|
57
53
|
|
|
58
|
-
for (
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
for (var dir in frustumPlanes) {
|
|
55
|
+
var plane = frustumPlanes[dir];
|
|
56
|
+
var distanceToCenter = plane.normal.dot(viewport.center);
|
|
61
57
|
scratchPosition.copy(plane.normal).scale(plane.distance - distanceToCenter).add(viewport.center);
|
|
62
|
-
|
|
58
|
+
var cartographicPos = viewport.unprojectPosition(scratchPosition);
|
|
63
59
|
|
|
64
|
-
|
|
60
|
+
var cartesianPos = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, new _core.Vector3());
|
|
65
61
|
|
|
66
62
|
cullingVolume.planes[i++].fromPointNormal(cartesianPos, scratchVector.copy(viewportCenterCartesian).subtract(cartesianPos));
|
|
67
63
|
}
|
|
@@ -1 +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,
|
|
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,IAAMA,aAAa,GAAG,IAAIC,aAAJ,EAAtB;AACA,IAAMC,eAAe,GAAG,IAAID,aAAJ,EAAxB;AACA,IAAME,aAAa,GAAG,IAAIC,sBAAJ,CAAkB,CACtC,IAAIC,cAAJ,EADsC,EAEtC,IAAIA,cAAJ,EAFsC,EAGtC,IAAIA,cAAJ,EAHsC,EAItC,IAAIA,cAAJ,EAJsC,EAKtC,IAAIA,cAAJ,EALsC,EAMtC,IAAIA,cAAJ,EANsC,CAAlB,CAAtB;;AAWO,SAASC,aAAT,CAAuBC,QAAvB,EAAiCC,WAAjC,EAAkE;AAEvE,MAAOC,eAAP,GAA4CF,QAA5C,CAAOE,eAAP;AAAA,MAAwBC,QAAxB,GAA4CH,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QAAQ,EAARA,QANK;AAOLI,IAAAA,MAAM,EAANA,MAPK;AAQLR,IAAAA,aAAa,EAAbA,aARK;AASLK,IAAAA,WAAW,EAAXA,WATK;AAUL6B,IAAAA,cAAc,EAAE;AAVX,GAAP;AAYD;;AAED,SAASL,wBAAT,CAAkCzB,QAAlC,EAA4CU,uBAA5C,EAAqE;AAEnE,MAAMqB,aAAa,GAAG/B,QAAQ,CAACgC,gBAAT,EAAtB;AACA,MAAIC,CAAC,GAAG,CAAR;;AACA,OAAK,IAAMC,GAAX,IAAkBH,aAAlB,EAAiC;AAC/B,QAAMI,KAAK,GAAGJ,aAAa,CAACG,GAAD,CAA3B;AACA,QAAME,gBAAgB,GAAGD,KAAK,CAACE,MAAN,CAAaC,GAAb,CAAiBtC,QAAQ,CAACuC,MAA1B,CAAzB;AACA5C,IAAAA,eAAe,CACZ6C,IADH,CACQL,KAAK,CAACE,MADd,EAEGf,KAFH,CAESa,KAAK,CAACM,QAAN,GAAiBL,gBAF1B,EAGGM,GAHH,CAGO1C,QAAQ,CAACuC,MAHhB;AAIA,QAAMI,eAAe,GAAG3C,QAAQ,CAACiB,iBAAT,CAA2BtB,eAA3B,CAAxB;;AAEA,QAAMiD,YAAY,GAAGjC,sBAAUC,KAAV,CAAgBC,uBAAhB,CAAwC8B,eAAxC,EAAyD,IAAIjD,aAAJ,EAAzD,CAArB;;AAEAE,IAAAA,aAAa,CAACiD,MAAd,CAAqBZ,CAAC,EAAtB,EAA0Ba,eAA1B,CACEF,YADF,EAGEnD,aAAa,CAAC+C,IAAd,CAAmB9B,uBAAnB,EAA4CqC,QAA5C,CAAqDH,YAArD,CAHF;AAKD;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"}
|
|
@@ -1,37 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.lodJudge = lodJudge;
|
|
7
9
|
exports.getI3ScreenSize = getI3ScreenSize;
|
|
8
10
|
|
|
11
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
+
|
|
9
13
|
var _core = require("@math.gl/core");
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
var WGS84_RADIUS_X = 6378137.0;
|
|
16
|
+
var qualityFactor = Math.PI / 2;
|
|
13
17
|
|
|
14
18
|
function lodJudge(tile, frameState) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const visibleHeight = height * 0.5 + mbsR / WGS84_RADIUS_X;
|
|
34
|
-
const visibleWidth = width * 0.5 + mbsR / WGS84_RADIUS_X;
|
|
19
|
+
var viewport = frameState.viewport;
|
|
20
|
+
var metersPerPixel = viewport.metersPerPixel;
|
|
21
|
+
var mbsLat = tile.header.mbs[1];
|
|
22
|
+
var mbsLon = tile.header.mbs[0];
|
|
23
|
+
var mbsZ = tile.header.mbs[2];
|
|
24
|
+
var mbsR = tile.header.mbs[3];
|
|
25
|
+
var height = viewport.height,
|
|
26
|
+
width = viewport.width,
|
|
27
|
+
latitude = viewport.latitude,
|
|
28
|
+
longitude = viewport.longitude;
|
|
29
|
+
var viewportCenter = [longitude, latitude];
|
|
30
|
+
var mbsCenter = [mbsLon, mbsLat, mbsZ];
|
|
31
|
+
var mbsLatProjected = [longitude, mbsLat];
|
|
32
|
+
var mbsLonProjected = [mbsLon, latitude];
|
|
33
|
+
var diagonalInMeters = Math.sqrt(height * height + width * width) * metersPerPixel[0];
|
|
34
|
+
var distanceInMeters = getDistanceFromLatLon(viewportCenter, mbsCenter);
|
|
35
|
+
var visibleHeight = height * 0.5 + mbsR / WGS84_RADIUS_X;
|
|
36
|
+
var visibleWidth = width * 0.5 + mbsR / WGS84_RADIUS_X;
|
|
35
37
|
|
|
36
38
|
if (distanceInMeters > diagonalInMeters + mbsR / WGS84_RADIUS_X) {
|
|
37
39
|
return 'OUT';
|
|
@@ -49,7 +51,7 @@ function lodJudge(tile, frameState) {
|
|
|
49
51
|
return 'DIG';
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
|
|
54
|
+
var screenSize = getI3ScreenSize(tile, frameState);
|
|
53
55
|
screenSize *= qualityFactor;
|
|
54
56
|
|
|
55
57
|
if (screenSize < 0.5) {
|
|
@@ -65,11 +67,16 @@ function lodJudge(tile, frameState) {
|
|
|
65
67
|
return 'OUT';
|
|
66
68
|
}
|
|
67
69
|
|
|
68
|
-
function projectVertexToSphere(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
function projectVertexToSphere(_ref) {
|
|
71
|
+
var _ref2 = (0, _slicedToArray2.default)(_ref, 3),
|
|
72
|
+
x = _ref2[0],
|
|
73
|
+
y = _ref2[1],
|
|
74
|
+
z = _ref2[2];
|
|
75
|
+
|
|
76
|
+
var azim = (0, _core.toRadians)(x);
|
|
77
|
+
var incl = (0, _core.toRadians)(y);
|
|
78
|
+
var radius = 1.0 + z / WGS84_RADIUS_X;
|
|
79
|
+
var radCosInc = radius * Math.cos(incl);
|
|
73
80
|
x = radCosInc * Math.cos(azim);
|
|
74
81
|
y = radCosInc * Math.sin(azim);
|
|
75
82
|
z = radius * Math.sin(incl);
|
|
@@ -77,42 +84,50 @@ function projectVertexToSphere([x, y, z]) {
|
|
|
77
84
|
}
|
|
78
85
|
|
|
79
86
|
function getDistanceFromLatLon(observer, center) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
var _observer = (0, _slicedToArray2.default)(observer, 3),
|
|
88
|
+
observerLon = _observer[0],
|
|
89
|
+
observerLat = _observer[1],
|
|
90
|
+
_observer$ = _observer[2],
|
|
91
|
+
observerZ = _observer$ === void 0 ? 0.0 : _observer$;
|
|
92
|
+
|
|
93
|
+
var _center = (0, _slicedToArray2.default)(center, 3),
|
|
94
|
+
centerLon = _center[0],
|
|
95
|
+
centerLat = _center[1],
|
|
96
|
+
_center$ = _center[2],
|
|
97
|
+
centerZ = _center$ === void 0 ? 0.0 : _center$;
|
|
98
|
+
|
|
99
|
+
var projectedCenter = projectVertexToSphere([centerLon, centerLat, centerZ]);
|
|
100
|
+
var projectedObserver = projectVertexToSphere([observerLon, observerLat, observerZ]);
|
|
101
|
+
var dx = projectedObserver[0] - projectedCenter[0];
|
|
102
|
+
var dy = projectedObserver[1] - projectedCenter[1];
|
|
103
|
+
var dz = projectedObserver[2] - projectedCenter[2];
|
|
87
104
|
return dx * dx + dy * dy + dz * dz;
|
|
88
105
|
}
|
|
89
106
|
|
|
90
107
|
function getI3ScreenSize(tile, frameState) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
108
|
+
var viewport = frameState.viewport;
|
|
109
|
+
var mbsLat = tile.header.mbs[1];
|
|
110
|
+
var mbsLon = tile.header.mbs[0];
|
|
111
|
+
var mbsZ = tile.header.mbs[2];
|
|
112
|
+
var mbsR = tile.header.mbs[3];
|
|
113
|
+
var mbsCenter = [mbsLon, mbsLat, mbsZ];
|
|
114
|
+
var cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
|
|
115
|
+
var dSquared = getDistanceFromLatLon(cameraPositionCartographic, mbsCenter);
|
|
116
|
+
var mbsRNormalized = mbsR / WGS84_RADIUS_X;
|
|
117
|
+
var d = dSquared - mbsRNormalized * mbsRNormalized;
|
|
118
|
+
var fltMax = 3.4028235e38;
|
|
102
119
|
|
|
103
120
|
if (d <= 0.0) {
|
|
104
121
|
return 0.5 * fltMax;
|
|
105
122
|
}
|
|
106
123
|
|
|
107
|
-
|
|
124
|
+
var screenSizeFactor = getTanOfHalfVFAngle(frameState) * mbsRNormalized / Math.sqrt(d) * 300;
|
|
108
125
|
return screenSizeFactor;
|
|
109
126
|
}
|
|
110
127
|
|
|
111
128
|
function getTanOfHalfVFAngle(frameState) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
} = frameState.viewport;
|
|
115
|
-
const t = projectionMatrix[5];
|
|
129
|
+
var projectionMatrix = frameState.viewport.projectionMatrix;
|
|
130
|
+
var t = projectionMatrix[5];
|
|
116
131
|
return t;
|
|
117
132
|
}
|
|
118
133
|
//# sourceMappingURL=i3s-lod.js.map
|