@loaders.gl/tiles 4.0.0-beta.2 → 4.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.js.map +1 -0
- package/dist/dist.dev.js +8162 -0
- package/dist/index.cjs +2537 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/{esm/tileset → tileset}/format-3d-tiles/tileset-3d-traverser.js +2 -2
- package/dist/tileset/format-3d-tiles/tileset-3d-traverser.js.map +1 -0
- package/dist/{esm/tileset → tileset}/format-i3s/i3s-pending-tiles-register.js +1 -2
- package/dist/tileset/format-i3s/i3s-pending-tiles-register.js.map +1 -0
- package/dist/{esm/tileset → tileset}/format-i3s/i3s-tile-manager.js +3 -4
- package/dist/tileset/format-i3s/i3s-tile-manager.js.map +1 -0
- package/dist/{esm/tileset → tileset}/format-i3s/i3s-tileset-traverser.js +7 -8
- package/dist/tileset/format-i3s/i3s-tileset-traverser.js.map +1 -0
- package/dist/tileset/helpers/3d-tiles-options.js.map +1 -0
- package/dist/tileset/helpers/bounding-volume.d.ts +1 -1
- package/dist/tileset/helpers/bounding-volume.d.ts.map +1 -1
- package/dist/{esm/tileset → tileset}/helpers/bounding-volume.js +16 -6
- package/dist/tileset/helpers/bounding-volume.js.map +1 -0
- package/dist/tileset/helpers/frame-state.js.map +1 -0
- package/dist/tileset/helpers/i3s-lod.js.map +1 -0
- package/dist/tileset/helpers/tiles-3d-lod.js.map +1 -0
- package/dist/tileset/helpers/transform-utils.js.map +1 -0
- package/dist/{esm/tileset → tileset}/helpers/zoom.js +2 -2
- package/dist/tileset/helpers/zoom.js.map +1 -0
- package/dist/tileset/tile-3d.d.ts.map +1 -1
- package/dist/{esm/tileset → tileset}/tile-3d.js +55 -56
- package/dist/tileset/tile-3d.js.map +1 -0
- package/dist/tileset/tileset-3d.d.ts.map +1 -1
- package/dist/{esm/tileset → tileset}/tileset-3d.js +64 -62
- package/dist/tileset/tileset-3d.js.map +1 -0
- package/dist/{esm/tileset → tileset}/tileset-cache.js +4 -5
- package/dist/tileset/tileset-cache.js.map +1 -0
- package/dist/{esm/tileset → tileset}/tileset-traverser.js +12 -13
- package/dist/tileset/tileset-traverser.js.map +1 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/doubly-linked-list-node.js +11 -0
- package/dist/utils/doubly-linked-list-node.js.map +1 -0
- package/dist/{esm/utils → utils}/doubly-linked-list.js +4 -5
- package/dist/utils/doubly-linked-list.js.map +1 -0
- package/dist/{esm/utils → utils}/managed-array.js +3 -4
- package/dist/utils/managed-array.js.map +1 -0
- package/package.json +20 -12
- package/src/tileset/helpers/bounding-volume.ts +53 -24
- package/src/tileset/helpers/zoom.ts +5 -5
- package/src/tileset/tile-3d.ts +1 -1
- package/src/tileset/tileset-3d.ts +6 -9
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/dist.min.js +0 -9231
- package/dist/es5/bundle.js +0 -6
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/constants.js +0 -48
- package/dist/es5/constants.js.map +0 -1
- package/dist/es5/index.js +0 -93
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/tileset/format-3d-tiles/tileset-3d-traverser.js +0 -70
- package/dist/es5/tileset/format-3d-tiles/tileset-3d-traverser.js.map +0 -1
- package/dist/es5/tileset/format-i3s/i3s-pending-tiles-register.js +0 -45
- package/dist/es5/tileset/format-i3s/i3s-pending-tiles-register.js.map +0 -1
- package/dist/es5/tileset/format-i3s/i3s-tile-manager.js +0 -84
- package/dist/es5/tileset/format-i3s/i3s-tile-manager.js.map +0 -1
- package/dist/es5/tileset/format-i3s/i3s-tileset-traverser.js +0 -143
- package/dist/es5/tileset/format-i3s/i3s-tileset-traverser.js.map +0 -1
- package/dist/es5/tileset/helpers/3d-tiles-options.js +0 -12
- package/dist/es5/tileset/helpers/3d-tiles-options.js.map +0 -1
- package/dist/es5/tileset/helpers/bounding-volume.js +0 -176
- package/dist/es5/tileset/helpers/bounding-volume.js.map +0 -1
- package/dist/es5/tileset/helpers/frame-state.js +0 -129
- package/dist/es5/tileset/helpers/frame-state.js.map +0 -1
- package/dist/es5/tileset/helpers/i3s-lod.js +0 -60
- package/dist/es5/tileset/helpers/i3s-lod.js.map +0 -1
- package/dist/es5/tileset/helpers/tiles-3d-lod.js +0 -103
- package/dist/es5/tileset/helpers/tiles-3d-lod.js.map +0 -1
- package/dist/es5/tileset/helpers/transform-utils.js +0 -50
- package/dist/es5/tileset/helpers/transform-utils.js.map +0 -1
- package/dist/es5/tileset/helpers/zoom.js +0 -63
- package/dist/es5/tileset/helpers/zoom.js.map +0 -1
- package/dist/es5/tileset/tile-3d.js +0 -536
- package/dist/es5/tileset/tile-3d.js.map +0 -1
- package/dist/es5/tileset/tileset-3d.js +0 -859
- package/dist/es5/tileset/tileset-3d.js.map +0 -1
- package/dist/es5/tileset/tileset-cache.js +0 -82
- package/dist/es5/tileset/tileset-cache.js.map +0 -1
- package/dist/es5/tileset/tileset-traverser.js +0 -321
- package/dist/es5/tileset/tileset-traverser.js.map +0 -1
- package/dist/es5/types.js +0 -2
- package/dist/es5/types.js.map +0 -1
- package/dist/es5/utils/doubly-linked-list-node.js +0 -21
- package/dist/es5/utils/doubly-linked-list-node.js.map +0 -1
- package/dist/es5/utils/doubly-linked-list.js +0 -88
- package/dist/es5/utils/doubly-linked-list.js.map +0 -1
- package/dist/es5/utils/managed-array.js +0 -126
- package/dist/es5/utils/managed-array.js.map +0 -1
- package/dist/esm/bundle.js +0 -4
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/constants.js.map +0 -1
- package/dist/esm/index.js +0 -10
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/tileset/format-3d-tiles/tileset-3d-traverser.js.map +0 -1
- package/dist/esm/tileset/format-i3s/i3s-pending-tiles-register.js.map +0 -1
- package/dist/esm/tileset/format-i3s/i3s-tile-manager.js.map +0 -1
- package/dist/esm/tileset/format-i3s/i3s-tileset-traverser.js.map +0 -1
- package/dist/esm/tileset/helpers/3d-tiles-options.js.map +0 -1
- package/dist/esm/tileset/helpers/bounding-volume.js.map +0 -1
- package/dist/esm/tileset/helpers/frame-state.js.map +0 -1
- package/dist/esm/tileset/helpers/i3s-lod.js.map +0 -1
- package/dist/esm/tileset/helpers/tiles-3d-lod.js.map +0 -1
- package/dist/esm/tileset/helpers/transform-utils.js.map +0 -1
- package/dist/esm/tileset/helpers/zoom.js.map +0 -1
- package/dist/esm/tileset/tile-3d.js.map +0 -1
- package/dist/esm/tileset/tileset-3d.js.map +0 -1
- package/dist/esm/tileset/tileset-cache.js.map +0 -1
- package/dist/esm/tileset/tileset-traverser.js.map +0 -1
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/utils/doubly-linked-list-node.js +0 -12
- package/dist/esm/utils/doubly-linked-list-node.js.map +0 -1
- package/dist/esm/utils/doubly-linked-list.js.map +0 -1
- package/dist/esm/utils/managed-array.js.map +0 -1
- package/src/bundle.ts +0 -4
- /package/dist/{esm/constants.js → constants.js} +0 -0
- /package/dist/{esm/tileset → tileset}/helpers/3d-tiles-options.js +0 -0
- /package/dist/{esm/tileset → tileset}/helpers/frame-state.js +0 -0
- /package/dist/{esm/tileset → tileset}/helpers/i3s-lod.js +0 -0
- /package/dist/{esm/tileset → tileset}/helpers/tiles-3d-lod.js +0 -0
- /package/dist/{esm/tileset → tileset}/helpers/transform-utils.js +0 -0
- /package/dist/{esm/types.js → types.js} +0 -0
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createBoundingVolume = createBoundingVolume;
|
|
8
|
-
exports.getCartographicBounds = getCartographicBounds;
|
|
9
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
-
var _core = require("@math.gl/core");
|
|
12
|
-
var _culling = require("@math.gl/culling");
|
|
13
|
-
var _geospatial = require("@math.gl/geospatial");
|
|
14
|
-
var _loaderUtils = require("@loaders.gl/loader-utils");
|
|
15
|
-
function defined(x) {
|
|
16
|
-
return x !== undefined && x !== null;
|
|
17
|
-
}
|
|
18
|
-
var scratchPoint = new _core.Vector3();
|
|
19
|
-
var scratchScale = new _core.Vector3();
|
|
20
|
-
var scratchNorthWest = new _core.Vector3();
|
|
21
|
-
var scratchSouthEast = new _core.Vector3();
|
|
22
|
-
function createBoundingVolume(boundingVolumeHeader, transform, result) {
|
|
23
|
-
(0, _loaderUtils.assert)(boundingVolumeHeader, '3D Tile: boundingVolume must be defined');
|
|
24
|
-
if (boundingVolumeHeader.box) {
|
|
25
|
-
return createBox(boundingVolumeHeader.box, transform, result);
|
|
26
|
-
}
|
|
27
|
-
if (boundingVolumeHeader.region) {
|
|
28
|
-
var _boundingVolumeHeader = (0, _slicedToArray2.default)(boundingVolumeHeader.region, 6),
|
|
29
|
-
west = _boundingVolumeHeader[0],
|
|
30
|
-
south = _boundingVolumeHeader[1],
|
|
31
|
-
east = _boundingVolumeHeader[2],
|
|
32
|
-
north = _boundingVolumeHeader[3],
|
|
33
|
-
minHeight = _boundingVolumeHeader[4],
|
|
34
|
-
maxHeight = _boundingVolumeHeader[5];
|
|
35
|
-
var northWest = _geospatial.Ellipsoid.WGS84.cartographicToCartesian([(0, _core.degrees)(west), (0, _core.degrees)(north), minHeight], scratchNorthWest);
|
|
36
|
-
var southEast = _geospatial.Ellipsoid.WGS84.cartographicToCartesian([(0, _core.degrees)(east), (0, _core.degrees)(south), maxHeight], scratchSouthEast);
|
|
37
|
-
var centerInCartesian = new _core.Vector3().addVectors(northWest, southEast).multiplyScalar(0.5);
|
|
38
|
-
var radius = new _core.Vector3().subVectors(northWest, southEast).len() / 2.0;
|
|
39
|
-
return createSphere([centerInCartesian[0], centerInCartesian[1], centerInCartesian[2], radius], new _core.Matrix4());
|
|
40
|
-
}
|
|
41
|
-
if (boundingVolumeHeader.sphere) {
|
|
42
|
-
return createSphere(boundingVolumeHeader.sphere, transform, result);
|
|
43
|
-
}
|
|
44
|
-
throw new Error('3D Tile: boundingVolume must contain a sphere, region, or box');
|
|
45
|
-
}
|
|
46
|
-
function getCartographicBounds(boundingVolumeHeader, boundingVolume) {
|
|
47
|
-
if (boundingVolumeHeader.box) {
|
|
48
|
-
return orientedBoundingBoxToCartographicBounds(boundingVolume);
|
|
49
|
-
}
|
|
50
|
-
if (boundingVolumeHeader.region) {
|
|
51
|
-
var _boundingVolumeHeader2 = (0, _slicedToArray2.default)(boundingVolumeHeader.region, 6),
|
|
52
|
-
west = _boundingVolumeHeader2[0],
|
|
53
|
-
south = _boundingVolumeHeader2[1],
|
|
54
|
-
east = _boundingVolumeHeader2[2],
|
|
55
|
-
north = _boundingVolumeHeader2[3],
|
|
56
|
-
minHeight = _boundingVolumeHeader2[4],
|
|
57
|
-
maxHeight = _boundingVolumeHeader2[5];
|
|
58
|
-
return [[(0, _core.degrees)(west), (0, _core.degrees)(south), minHeight], [(0, _core.degrees)(east), (0, _core.degrees)(north), maxHeight]];
|
|
59
|
-
}
|
|
60
|
-
if (boundingVolumeHeader.sphere) {
|
|
61
|
-
return boundingSphereToCartographicBounds(boundingVolume);
|
|
62
|
-
}
|
|
63
|
-
throw new Error('Unkown boundingVolume type');
|
|
64
|
-
}
|
|
65
|
-
function createBox(box, transform, result) {
|
|
66
|
-
var center = new _core.Vector3(box[0], box[1], box[2]);
|
|
67
|
-
transform.transform(center, center);
|
|
68
|
-
var origin = [];
|
|
69
|
-
if (box.length === 10) {
|
|
70
|
-
var halfSize = box.slice(3, 6);
|
|
71
|
-
var quaternion = new _core.Quaternion();
|
|
72
|
-
quaternion.fromArray(box, 6);
|
|
73
|
-
var x = new _core.Vector3([1, 0, 0]);
|
|
74
|
-
var y = new _core.Vector3([0, 1, 0]);
|
|
75
|
-
var z = new _core.Vector3([0, 0, 1]);
|
|
76
|
-
x.transformByQuaternion(quaternion);
|
|
77
|
-
x.scale(halfSize[0]);
|
|
78
|
-
y.transformByQuaternion(quaternion);
|
|
79
|
-
y.scale(halfSize[1]);
|
|
80
|
-
z.transformByQuaternion(quaternion);
|
|
81
|
-
z.scale(halfSize[2]);
|
|
82
|
-
origin = [].concat((0, _toConsumableArray2.default)(x.toArray()), (0, _toConsumableArray2.default)(y.toArray()), (0, _toConsumableArray2.default)(z.toArray()));
|
|
83
|
-
} else {
|
|
84
|
-
origin = [].concat((0, _toConsumableArray2.default)(box.slice(3, 6)), (0, _toConsumableArray2.default)(box.slice(6, 9)), (0, _toConsumableArray2.default)(box.slice(9, 12)));
|
|
85
|
-
}
|
|
86
|
-
var xAxis = transform.transformAsVector(origin.slice(0, 3));
|
|
87
|
-
var yAxis = transform.transformAsVector(origin.slice(3, 6));
|
|
88
|
-
var zAxis = transform.transformAsVector(origin.slice(6, 9));
|
|
89
|
-
var halfAxes = new _core.Matrix3([xAxis[0], xAxis[1], xAxis[2], yAxis[0], yAxis[1], yAxis[2], zAxis[0], zAxis[1], zAxis[2]]);
|
|
90
|
-
if (defined(result)) {
|
|
91
|
-
result.center = center;
|
|
92
|
-
result.halfAxes = halfAxes;
|
|
93
|
-
return result;
|
|
94
|
-
}
|
|
95
|
-
return new _culling.OrientedBoundingBox(center, halfAxes);
|
|
96
|
-
}
|
|
97
|
-
function createSphere(sphere, transform, result) {
|
|
98
|
-
var center = new _core.Vector3(sphere[0], sphere[1], sphere[2]);
|
|
99
|
-
transform.transform(center, center);
|
|
100
|
-
var scale = transform.getScale(scratchScale);
|
|
101
|
-
var uniformScale = Math.max(Math.max(scale[0], scale[1]), scale[2]);
|
|
102
|
-
var radius = sphere[3] * uniformScale;
|
|
103
|
-
if (defined(result)) {
|
|
104
|
-
result.center = center;
|
|
105
|
-
result.radius = radius;
|
|
106
|
-
return result;
|
|
107
|
-
}
|
|
108
|
-
return new _culling.BoundingSphere(center, radius);
|
|
109
|
-
}
|
|
110
|
-
function orientedBoundingBoxToCartographicBounds(boundingVolume) {
|
|
111
|
-
var result = emptyCartographicBounds();
|
|
112
|
-
var _ref = boundingVolume,
|
|
113
|
-
halfAxes = _ref.halfAxes;
|
|
114
|
-
var xAxis = new _core.Vector3(halfAxes.getColumn(0));
|
|
115
|
-
var yAxis = new _core.Vector3(halfAxes.getColumn(1));
|
|
116
|
-
var zAxis = new _core.Vector3(halfAxes.getColumn(2));
|
|
117
|
-
for (var x = 0; x < 2; x++) {
|
|
118
|
-
for (var y = 0; y < 2; y++) {
|
|
119
|
-
for (var z = 0; z < 2; z++) {
|
|
120
|
-
scratchPoint.copy(boundingVolume.center);
|
|
121
|
-
scratchPoint.add(xAxis);
|
|
122
|
-
scratchPoint.add(yAxis);
|
|
123
|
-
scratchPoint.add(zAxis);
|
|
124
|
-
addToCartographicBounds(result, scratchPoint);
|
|
125
|
-
zAxis.negate();
|
|
126
|
-
}
|
|
127
|
-
yAxis.negate();
|
|
128
|
-
}
|
|
129
|
-
xAxis.negate();
|
|
130
|
-
}
|
|
131
|
-
return result;
|
|
132
|
-
}
|
|
133
|
-
function boundingSphereToCartographicBounds(boundingVolume) {
|
|
134
|
-
var result = emptyCartographicBounds();
|
|
135
|
-
var _ref2 = boundingVolume,
|
|
136
|
-
center = _ref2.center,
|
|
137
|
-
radius = _ref2.radius;
|
|
138
|
-
var point = _geospatial.Ellipsoid.WGS84.scaleToGeodeticSurface(center, scratchPoint);
|
|
139
|
-
var zAxis;
|
|
140
|
-
if (point) {
|
|
141
|
-
zAxis = _geospatial.Ellipsoid.WGS84.geodeticSurfaceNormal(point);
|
|
142
|
-
} else {
|
|
143
|
-
zAxis = new _core.Vector3(0, 0, 1);
|
|
144
|
-
}
|
|
145
|
-
var xAxis = new _core.Vector3(zAxis[2], -zAxis[1], 0);
|
|
146
|
-
if (xAxis.len() > 0) {
|
|
147
|
-
xAxis.normalize();
|
|
148
|
-
} else {
|
|
149
|
-
xAxis = new _core.Vector3(0, 1, 0);
|
|
150
|
-
}
|
|
151
|
-
var yAxis = xAxis.clone().cross(zAxis);
|
|
152
|
-
for (var _i = 0, _arr = [xAxis, yAxis, zAxis]; _i < _arr.length; _i++) {
|
|
153
|
-
var axis = _arr[_i];
|
|
154
|
-
scratchScale.copy(axis).scale(radius);
|
|
155
|
-
for (var dir = 0; dir < 2; dir++) {
|
|
156
|
-
scratchPoint.copy(center);
|
|
157
|
-
scratchPoint.add(scratchScale);
|
|
158
|
-
addToCartographicBounds(result, scratchPoint);
|
|
159
|
-
scratchScale.negate();
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return result;
|
|
163
|
-
}
|
|
164
|
-
function emptyCartographicBounds() {
|
|
165
|
-
return [[Infinity, Infinity, Infinity], [-Infinity, -Infinity, -Infinity]];
|
|
166
|
-
}
|
|
167
|
-
function addToCartographicBounds(target, cartesian) {
|
|
168
|
-
_geospatial.Ellipsoid.WGS84.cartesianToCartographic(cartesian, scratchPoint);
|
|
169
|
-
target[0][0] = Math.min(target[0][0], scratchPoint[0]);
|
|
170
|
-
target[0][1] = Math.min(target[0][1], scratchPoint[1]);
|
|
171
|
-
target[0][2] = Math.min(target[0][2], scratchPoint[2]);
|
|
172
|
-
target[1][0] = Math.max(target[1][0], scratchPoint[0]);
|
|
173
|
-
target[1][1] = Math.max(target[1][1], scratchPoint[1]);
|
|
174
|
-
target[1][2] = Math.max(target[1][2], scratchPoint[2]);
|
|
175
|
-
}
|
|
176
|
-
//# sourceMappingURL=bounding-volume.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bounding-volume.js","names":["_core","require","_culling","_geospatial","_loaderUtils","defined","x","undefined","scratchPoint","Vector3","scratchScale","scratchNorthWest","scratchSouthEast","createBoundingVolume","boundingVolumeHeader","transform","result","assert","box","createBox","region","_boundingVolumeHeader","_slicedToArray2","default","west","south","east","north","minHeight","maxHeight","northWest","Ellipsoid","WGS84","cartographicToCartesian","degrees","southEast","centerInCartesian","addVectors","multiplyScalar","radius","subVectors","len","createSphere","Matrix4","sphere","Error","getCartographicBounds","boundingVolume","orientedBoundingBoxToCartographicBounds","_boundingVolumeHeader2","boundingSphereToCartographicBounds","center","origin","length","halfSize","slice","quaternion","Quaternion","fromArray","y","z","transformByQuaternion","scale","concat","_toConsumableArray2","toArray","xAxis","transformAsVector","yAxis","zAxis","halfAxes","Matrix3","OrientedBoundingBox","getScale","uniformScale","Math","max","BoundingSphere","emptyCartographicBounds","_ref","getColumn","copy","add","addToCartographicBounds","negate","_ref2","point","scaleToGeodeticSurface","geodeticSurfaceNormal","normalize","clone","cross","_i","_arr","axis","dir","Infinity","target","cartesian","cartesianToCartographic","min"],"sources":["../../../../src/tileset/helpers/bounding-volume.ts"],"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 scratchPoint = new Vector3();\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\n/** [min, max] each in [longitude, latitude, altitude] */\nexport type CartographicBounds = [min: number[], max: number[]];\n\n/**\n * Calculate the cartographic bounding box the tile's bounding volume.\n * @param {Object} boundingVolumeHeader The tile's bounding volume header.\n * @param {BoundingVolume} boundingVolume The bounding volume.\n * @returns {CartographicBounds}\n */\nexport function getCartographicBounds(\n boundingVolumeHeader,\n boundingVolume: OrientedBoundingBox | BoundingSphere\n): CartographicBounds {\n // boundingVolume schema:\n // https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/schema/boundingVolume.schema.json\n if (boundingVolumeHeader.box) {\n return orientedBoundingBoxToCartographicBounds(boundingVolume as OrientedBoundingBox);\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 return [\n [degrees(west), degrees(south), minHeight],\n [degrees(east), degrees(north), maxHeight]\n ];\n }\n\n if (boundingVolumeHeader.sphere) {\n return boundingSphereToCartographicBounds(boundingVolume as BoundingSphere);\n }\n\n throw new Error('Unkown boundingVolume type');\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\n/**\n * Convert a bounding volume defined by OrientedBoundingBox to cartographic bounds\n * @returns {CartographicBounds}\n */\nfunction orientedBoundingBoxToCartographicBounds(\n boundingVolume: OrientedBoundingBox\n): CartographicBounds {\n const result = emptyCartographicBounds();\n\n const {halfAxes} = boundingVolume as OrientedBoundingBox;\n const xAxis = new Vector3(halfAxes.getColumn(0));\n const yAxis = new Vector3(halfAxes.getColumn(1));\n const zAxis = new Vector3(halfAxes.getColumn(2));\n\n // Test all 8 corners of the box\n for (let x = 0; x < 2; x++) {\n for (let y = 0; y < 2; y++) {\n for (let z = 0; z < 2; z++) {\n scratchPoint.copy(boundingVolume.center);\n scratchPoint.add(xAxis);\n scratchPoint.add(yAxis);\n scratchPoint.add(zAxis);\n\n addToCartographicBounds(result, scratchPoint);\n zAxis.negate();\n }\n yAxis.negate();\n }\n xAxis.negate();\n }\n return result;\n}\n\n/**\n * Convert a bounding volume defined by BoundingSphere to cartographic bounds\n * @returns {CartographicBounds}\n */\nfunction boundingSphereToCartographicBounds(boundingVolume: BoundingSphere): CartographicBounds {\n const result = emptyCartographicBounds();\n\n const {center, radius} = boundingVolume as BoundingSphere;\n const point = Ellipsoid.WGS84.scaleToGeodeticSurface(center, scratchPoint);\n\n let zAxis: Vector3;\n if (point) {\n zAxis = Ellipsoid.WGS84.geodeticSurfaceNormal(point) as Vector3;\n } else {\n zAxis = new Vector3(0, 0, 1);\n }\n let xAxis = new Vector3(zAxis[2], -zAxis[1], 0);\n if (xAxis.len() > 0) {\n xAxis.normalize();\n } else {\n xAxis = new Vector3(0, 1, 0);\n }\n const yAxis = xAxis.clone().cross(zAxis);\n\n // Test 6 end points of the 3 axes\n for (const axis of [xAxis, yAxis, zAxis]) {\n scratchScale.copy(axis).scale(radius);\n for (let dir = 0; dir < 2; dir++) {\n scratchPoint.copy(center);\n scratchPoint.add(scratchScale);\n addToCartographicBounds(result, scratchPoint);\n // Flip the axis\n scratchScale.negate();\n }\n }\n return result;\n}\n\n/**\n * Create a new cartographic bounds that contains no points\n * @returns {CartographicBounds}\n */\nfunction emptyCartographicBounds(): CartographicBounds {\n return [\n [Infinity, Infinity, Infinity],\n [-Infinity, -Infinity, -Infinity]\n ];\n}\n\n/**\n * Add a point to the target cartographic bounds\n * @param {CartographicBounds} target\n * @param {Vector3} cartesian coordinates of the point to add\n */\nfunction addToCartographicBounds(target: CartographicBounds, cartesian: Readonly<Vector3>) {\n Ellipsoid.WGS84.cartesianToCartographic(cartesian, scratchPoint);\n target[0][0] = Math.min(target[0][0], scratchPoint[0]);\n target[0][1] = Math.min(target[0][1], scratchPoint[1]);\n target[0][2] = Math.min(target[0][2], scratchPoint[2]);\n\n target[1][0] = Math.max(target[1][0], scratchPoint[0]);\n target[1][1] = Math.max(target[1][1], scratchPoint[1]);\n target[1][2] = Math.max(target[1][2], scratchPoint[2]);\n}\n"],"mappings":";;;;;;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAIA,SAASI,OAAOA,CAACC,CAAC,EAAE;EAClB,OAAOA,CAAC,KAAKC,SAAS,IAAID,CAAC,KAAK,IAAI;AACtC;AAGA,IAAME,YAAY,GAAG,IAAIC,aAAO,CAAC,CAAC;AAClC,IAAMC,YAAY,GAAG,IAAID,aAAO,CAAC,CAAC;AAClC,IAAME,gBAAgB,GAAG,IAAIF,aAA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interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.getFrameState = getFrameState;
|
|
8
|
-
exports.limitSelectedTiles = limitSelectedTiles;
|
|
9
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
-
var _core = require("@math.gl/core");
|
|
11
|
-
var _culling = require("@math.gl/culling");
|
|
12
|
-
var _geospatial = require("@math.gl/geospatial");
|
|
13
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
14
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
15
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
16
|
-
var scratchVector = new _core.Vector3();
|
|
17
|
-
var scratchPosition = new _core.Vector3();
|
|
18
|
-
var cullingVolume = new _culling.CullingVolume([new _culling.Plane(), new _culling.Plane(), new _culling.Plane(), new _culling.Plane(), new _culling.Plane(), new _culling.Plane()]);
|
|
19
|
-
function getFrameState(viewport, frameNumber) {
|
|
20
|
-
var cameraDirection = viewport.cameraDirection,
|
|
21
|
-
cameraUp = viewport.cameraUp,
|
|
22
|
-
height = viewport.height;
|
|
23
|
-
var metersPerUnit = viewport.distanceScales.metersPerUnit;
|
|
24
|
-
var viewportCenterCartesian = worldToCartesian(viewport, viewport.center);
|
|
25
|
-
var enuToFixedTransform = _geospatial.Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);
|
|
26
|
-
var cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
|
|
27
|
-
var cameraPositionCartesian = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new _core.Vector3());
|
|
28
|
-
var cameraDirectionCartesian = new _core.Vector3(enuToFixedTransform.transformAsVector(new _core.Vector3(cameraDirection).scale(metersPerUnit))).normalize();
|
|
29
|
-
var cameraUpCartesian = new _core.Vector3(enuToFixedTransform.transformAsVector(new _core.Vector3(cameraUp).scale(metersPerUnit))).normalize();
|
|
30
|
-
commonSpacePlanesToWGS84(viewport);
|
|
31
|
-
var ViewportClass = viewport.constructor;
|
|
32
|
-
var longitude = viewport.longitude,
|
|
33
|
-
latitude = viewport.latitude,
|
|
34
|
-
width = viewport.width,
|
|
35
|
-
bearing = viewport.bearing,
|
|
36
|
-
zoom = viewport.zoom;
|
|
37
|
-
var topDownViewport = new ViewportClass({
|
|
38
|
-
longitude: longitude,
|
|
39
|
-
latitude: latitude,
|
|
40
|
-
height: height,
|
|
41
|
-
width: width,
|
|
42
|
-
bearing: bearing,
|
|
43
|
-
zoom: zoom,
|
|
44
|
-
pitch: 0
|
|
45
|
-
});
|
|
46
|
-
return {
|
|
47
|
-
camera: {
|
|
48
|
-
position: cameraPositionCartesian,
|
|
49
|
-
direction: cameraDirectionCartesian,
|
|
50
|
-
up: cameraUpCartesian
|
|
51
|
-
},
|
|
52
|
-
viewport: viewport,
|
|
53
|
-
topDownViewport: topDownViewport,
|
|
54
|
-
height: height,
|
|
55
|
-
cullingVolume: cullingVolume,
|
|
56
|
-
frameNumber: frameNumber,
|
|
57
|
-
sseDenominator: 1.15
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function limitSelectedTiles(tiles, frameState, maximumTilesSelected) {
|
|
61
|
-
if (maximumTilesSelected === 0 || tiles.length <= maximumTilesSelected) {
|
|
62
|
-
return [tiles, []];
|
|
63
|
-
}
|
|
64
|
-
var tuples = [];
|
|
65
|
-
var _frameState$viewport = frameState.viewport,
|
|
66
|
-
viewportLongitude = _frameState$viewport.longitude,
|
|
67
|
-
viewportLatitude = _frameState$viewport.latitude;
|
|
68
|
-
var _iterator = _createForOfIteratorHelper(tiles.entries()),
|
|
69
|
-
_step;
|
|
70
|
-
try {
|
|
71
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
72
|
-
var _step$value = (0, _slicedToArray2.default)(_step.value, 2),
|
|
73
|
-
index = _step$value[0],
|
|
74
|
-
tile = _step$value[1];
|
|
75
|
-
var _tile$header$mbs = (0, _slicedToArray2.default)(tile.header.mbs, 2),
|
|
76
|
-
longitude = _tile$header$mbs[0],
|
|
77
|
-
latitude = _tile$header$mbs[1];
|
|
78
|
-
var deltaLon = Math.abs(viewportLongitude - longitude);
|
|
79
|
-
var deltaLat = Math.abs(viewportLatitude - latitude);
|
|
80
|
-
var distance = Math.sqrt(deltaLat * deltaLat + deltaLon * deltaLon);
|
|
81
|
-
tuples.push([index, distance]);
|
|
82
|
-
}
|
|
83
|
-
} catch (err) {
|
|
84
|
-
_iterator.e(err);
|
|
85
|
-
} finally {
|
|
86
|
-
_iterator.f();
|
|
87
|
-
}
|
|
88
|
-
var tuplesSorted = tuples.sort(function (a, b) {
|
|
89
|
-
return a[1] - b[1];
|
|
90
|
-
});
|
|
91
|
-
var selectedTiles = [];
|
|
92
|
-
for (var i = 0; i < maximumTilesSelected; i++) {
|
|
93
|
-
selectedTiles.push(tiles[tuplesSorted[i][0]]);
|
|
94
|
-
}
|
|
95
|
-
var unselectedTiles = [];
|
|
96
|
-
for (var _i = maximumTilesSelected; _i < tuplesSorted.length; _i++) {
|
|
97
|
-
unselectedTiles.push(tiles[tuplesSorted[_i][0]]);
|
|
98
|
-
}
|
|
99
|
-
return [selectedTiles, unselectedTiles];
|
|
100
|
-
}
|
|
101
|
-
function commonSpacePlanesToWGS84(viewport) {
|
|
102
|
-
var frustumPlanes = viewport.getFrustumPlanes();
|
|
103
|
-
var nearCenterCommon = closestPointOnPlane(frustumPlanes.near, viewport.cameraPosition);
|
|
104
|
-
var nearCenterCartesian = worldToCartesian(viewport, nearCenterCommon);
|
|
105
|
-
var cameraCartesian = worldToCartesian(viewport, viewport.cameraPosition, scratchPosition);
|
|
106
|
-
var i = 0;
|
|
107
|
-
cullingVolume.planes[i++].fromPointNormal(nearCenterCartesian, scratchVector.copy(nearCenterCartesian).subtract(cameraCartesian));
|
|
108
|
-
for (var dir in frustumPlanes) {
|
|
109
|
-
if (dir === 'near') {
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
var plane = frustumPlanes[dir];
|
|
113
|
-
var posCommon = closestPointOnPlane(plane, nearCenterCommon, scratchPosition);
|
|
114
|
-
var cartesianPos = worldToCartesian(viewport, posCommon, scratchPosition);
|
|
115
|
-
cullingVolume.planes[i++].fromPointNormal(cartesianPos, scratchVector.copy(nearCenterCartesian).subtract(cartesianPos));
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
function closestPointOnPlane(plane, refPoint) {
|
|
119
|
-
var out = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new _core.Vector3();
|
|
120
|
-
var distanceToRef = plane.normal.dot(refPoint);
|
|
121
|
-
out.copy(plane.normal).scale(plane.distance - distanceToRef).add(refPoint);
|
|
122
|
-
return out;
|
|
123
|
-
}
|
|
124
|
-
function worldToCartesian(viewport, point) {
|
|
125
|
-
var out = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new _core.Vector3();
|
|
126
|
-
var cartographicPos = viewport.unprojectPosition(point);
|
|
127
|
-
return _geospatial.Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, out);
|
|
128
|
-
}
|
|
129
|
-
//# sourceMappingURL=frame-state.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"frame-state.js","names":["_core","require","_culling","_geospatial","_createForOfIteratorHelper","o","allowArrayLike","it","Symbol","iterator","Array","isArray","_unsupportedIterableToArray","length","i","F","s","n","done","value","e","_e","f","TypeError","normalCompletion","didErr","err","call","step","next","_e2","return","minLen","_arrayLikeToArray","Object","prototype","toString","slice","constructor","name","from","test","arr","len","arr2","scratchVector","Vector3","scratchPosition","cullingVolume","CullingVolume","Plane","getFrameState","viewport","frameNumber","cameraDirection","cameraUp","height","metersPerUnit","distanceScales","viewportCenterCartesian","worldToCartesian","center","enuToFixedTransform","Ellipsoid","WGS84","eastNorthUpToFixedFrame","cameraPositionCartographic","unprojectPosition","cameraPosition","cameraPositionCartesian","cartographicToCartesian","cameraDirectionCartesian","transformAsVector","scale","normalize","cameraUpCartesian","commonSpacePlanesToWGS84","ViewportClass","longitude","latitude","width","bearing","zoom","topDownViewport","pitch","camera","position","direction","up","sseDenominator","limitSelectedTiles","tiles","frameState","maximumTilesSelected","tuples","_frameState$viewport","viewportLongitude","viewportLatitude","_iterator","entries","_step","_step$value","_slicedToArray2","default","index","tile","_tile$header$mbs","header","mbs","deltaLon","Math","abs","deltaLat","distance","sqrt","push","tuplesSorted","sort","a","b","selectedTiles","unselectedTiles","frustumPlanes","getFrustumPlanes","nearCenterCommon","closestPointOnPlane","near","nearCenterCartesian","cameraCartesian","planes","fromPointNormal","copy","subtract","dir","plane","posCommon","cartesianPos","refPoint","out","arguments","undefined","distanceToRef","normal","dot","add","point","cartographicPos"],"sources":["../../../../src/tileset/helpers/frame-state.ts"],"sourcesContent":["import {Tile3D} from '@loaders.gl/tiles';\nimport {Vector3} from '@math.gl/core';\nimport {CullingVolume, Plane} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {GeospatialViewport, Viewport} from '../../types';\n\nexport type FrameState = {\n camera: {\n position: number[];\n direction: number[];\n up: number[];\n };\n viewport: GeospatialViewport;\n topDownViewport: GeospatialViewport; // Use it to calculate projected radius for a tile\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: GeospatialViewport, frameNumber: number): FrameState {\n // Traverse and and request. Update _selectedTiles so that we know what to render.\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 // TODO - Ellipsoid.eastNorthUpToFixedFrame() breaks on raw array, create a Vector.\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() takes a cartesian, is that intuitive?\n const viewportCenterCartesian = worldToCartesian(viewport, viewport.center);\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);\n\n const ViewportClass = viewport.constructor;\n const {longitude, latitude, width, bearing, zoom} = viewport;\n // @ts-ignore\n const topDownViewport = new ViewportClass({\n longitude,\n latitude,\n height,\n width,\n bearing,\n zoom,\n pitch: 0\n });\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 topDownViewport,\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\n/**\n * Limit `tiles` array length with `maximumTilesSelected` number.\n * The criteria for this filtering is distance of a tile center\n * to the `frameState.viewport`'s longitude and latitude\n * @param tiles - tiles array to filter\n * @param frameState - frameState to calculate distances\n * @param maximumTilesSelected - maximal amount of tiles in the output array\n * @returns new tiles array\n */\nexport function limitSelectedTiles(\n tiles: Tile3D[],\n frameState: FrameState,\n maximumTilesSelected: number\n): [Tile3D[], Tile3D[]] {\n if (maximumTilesSelected === 0 || tiles.length <= maximumTilesSelected) {\n return [tiles, []];\n }\n // Accumulate distances in couples array: [tileIndex: number, distanceToViewport: number]\n const tuples: [number, number][] = [];\n const {longitude: viewportLongitude, latitude: viewportLatitude} = frameState.viewport;\n for (const [index, tile] of tiles.entries()) {\n const [longitude, latitude] = tile.header.mbs;\n const deltaLon = Math.abs(viewportLongitude - longitude);\n const deltaLat = Math.abs(viewportLatitude - latitude);\n const distance = Math.sqrt(deltaLat * deltaLat + deltaLon * deltaLon);\n tuples.push([index, distance]);\n }\n const tuplesSorted = tuples.sort((a, b) => a[1] - b[1]);\n const selectedTiles: Tile3D[] = [];\n for (let i = 0; i < maximumTilesSelected; i++) {\n selectedTiles.push(tiles[tuplesSorted[i][0]]);\n }\n const unselectedTiles: Tile3D[] = [];\n for (let i = maximumTilesSelected; i < tuplesSorted.length; i++) {\n unselectedTiles.push(tiles[tuplesSorted[i][0]]);\n }\n\n return [selectedTiles, unselectedTiles];\n}\n\nfunction commonSpacePlanesToWGS84(viewport) {\n // Extract frustum planes based on current view.\n const frustumPlanes = viewport.getFrustumPlanes();\n\n // Get the near/far plane centers\n const nearCenterCommon = closestPointOnPlane(frustumPlanes.near, viewport.cameraPosition);\n const nearCenterCartesian = worldToCartesian(viewport, nearCenterCommon);\n const cameraCartesian = worldToCartesian(viewport, viewport.cameraPosition, scratchPosition);\n\n let i = 0;\n cullingVolume.planes[i++].fromPointNormal(\n nearCenterCartesian,\n scratchVector.copy(nearCenterCartesian).subtract(cameraCartesian)\n );\n\n for (const dir in frustumPlanes) {\n if (dir === 'near') {\n continue; // eslint-disable-line no-continue\n }\n const plane = frustumPlanes[dir];\n const posCommon = closestPointOnPlane(plane, nearCenterCommon, scratchPosition);\n const cartesianPos = worldToCartesian(viewport, posCommon, scratchPosition);\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(nearCenterCartesian).subtract(cartesianPos)\n );\n }\n}\n\nfunction closestPointOnPlane(\n plane: {distance: number; normal: Vector3},\n refPoint: [number, number, number] | Vector3,\n out: Vector3 = new Vector3()\n): Vector3 {\n const distanceToRef = plane.normal.dot(refPoint);\n out\n .copy(plane.normal)\n .scale(plane.distance - distanceToRef)\n .add(refPoint);\n return out;\n}\n\nfunction worldToCartesian(\n viewport: Viewport,\n point: number[] | Vector3,\n out: Vector3 = new Vector3()\n): Vector3 {\n const cartographicPos = viewport.unprojectPosition(point);\n return Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, out);\n}\n"],"mappings":";;;;;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GA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G,CACAP,IAAI,CAACG,KAAK,CAACQ,MAAM,CAAC,CAClBrE,KAAK,CAAC6D,KAAK,CAACrB,QAAQ,GAAG4B,aAAa,CAAC,CACrCG,GAAG,CAACP,QAAQ,CAAC;EAChB,OAAOC,GAAG;AACZ;AAEA,SAAS9E,gBAAgBA,CACvBR,QAAkB,EAClB6F,KAAyB,EAEhB;EAAA,IADTP,GAAY,GAAAC,SAAA,CAAA9H,MAAA,QAAA8H,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAG,IAAI7F,aAAO,CAAC,CAAC;EAE5B,IAAMoG,eAAe,GAAG9F,QAAQ,CAACe,iBAAiB,CAAC8E,KAAK,CAAC;EACzD,OAAOlF,qBAAS,CAACC,KAAK,CAACM,uBAAuB,CAAC4E,eAAe,EAAER,GAAG,CAAC;AACtE"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.getLodStatus = getLodStatus;
|
|
8
|
-
exports.getProjectedRadius = getProjectedRadius;
|
|
9
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
-
var _core = require("@math.gl/core");
|
|
11
|
-
var _geospatial = require("@math.gl/geospatial");
|
|
12
|
-
var cameraPositionCartesian = new _core.Vector3();
|
|
13
|
-
var toEye = new _core.Vector3();
|
|
14
|
-
var cameraPositionEnu = new _core.Vector3();
|
|
15
|
-
var extraVertexEnu = new _core.Vector3();
|
|
16
|
-
var projectedOriginVector = new _core.Vector3();
|
|
17
|
-
var enuToCartesianMatrix = new _core.Matrix4();
|
|
18
|
-
var cartesianToEnuMatrix = new _core.Matrix4();
|
|
19
|
-
function getLodStatus(tile, frameState) {
|
|
20
|
-
if (tile.lodMetricValue === 0 || isNaN(tile.lodMetricValue)) {
|
|
21
|
-
return 'DIG';
|
|
22
|
-
}
|
|
23
|
-
var screenSize = 2 * getProjectedRadius(tile, frameState);
|
|
24
|
-
if (screenSize < 2) {
|
|
25
|
-
return 'OUT';
|
|
26
|
-
}
|
|
27
|
-
if (!tile.header.children || screenSize <= tile.lodMetricValue) {
|
|
28
|
-
return 'DRAW';
|
|
29
|
-
} else if (tile.header.children) {
|
|
30
|
-
return 'DIG';
|
|
31
|
-
}
|
|
32
|
-
return 'OUT';
|
|
33
|
-
}
|
|
34
|
-
function getProjectedRadius(tile, frameState) {
|
|
35
|
-
var viewport = frameState.topDownViewport;
|
|
36
|
-
var mbsLat = tile.header.mbs[1];
|
|
37
|
-
var mbsLon = tile.header.mbs[0];
|
|
38
|
-
var mbsZ = tile.header.mbs[2];
|
|
39
|
-
var mbsR = tile.header.mbs[3];
|
|
40
|
-
var mbsCenterCartesian = (0, _toConsumableArray2.default)(tile.boundingVolume.center);
|
|
41
|
-
var cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
|
|
42
|
-
_geospatial.Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, cameraPositionCartesian);
|
|
43
|
-
toEye.copy(cameraPositionCartesian).subtract(mbsCenterCartesian).normalize();
|
|
44
|
-
_geospatial.Ellipsoid.WGS84.eastNorthUpToFixedFrame(mbsCenterCartesian, enuToCartesianMatrix);
|
|
45
|
-
cartesianToEnuMatrix.copy(enuToCartesianMatrix).invert();
|
|
46
|
-
cameraPositionEnu.copy(cameraPositionCartesian).transform(cartesianToEnuMatrix);
|
|
47
|
-
var projection = Math.sqrt(cameraPositionEnu[0] * cameraPositionEnu[0] + cameraPositionEnu[1] * cameraPositionEnu[1]);
|
|
48
|
-
var extraZ = projection * projection / cameraPositionEnu[2];
|
|
49
|
-
extraVertexEnu.copy([cameraPositionEnu[0], cameraPositionEnu[1], extraZ]);
|
|
50
|
-
var extraVertexCartesian = extraVertexEnu.transform(enuToCartesianMatrix);
|
|
51
|
-
var extraVectorCartesian = extraVertexCartesian.subtract(mbsCenterCartesian).normalize();
|
|
52
|
-
var radiusVector = toEye.cross(extraVectorCartesian).normalize().scale(mbsR);
|
|
53
|
-
var sphereMbsBorderVertexCartesian = radiusVector.add(mbsCenterCartesian);
|
|
54
|
-
var sphereMbsBorderVertexCartographic = _geospatial.Ellipsoid.WGS84.cartesianToCartographic(sphereMbsBorderVertexCartesian);
|
|
55
|
-
var projectedOrigin = viewport.project([mbsLon, mbsLat, mbsZ]);
|
|
56
|
-
var projectedMbsBorderVertex = viewport.project(sphereMbsBorderVertexCartographic);
|
|
57
|
-
var projectedRadius = projectedOriginVector.copy(projectedOrigin).subtract(projectedMbsBorderVertex).magnitude();
|
|
58
|
-
return projectedRadius;
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=i3s-lod.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"i3s-lod.js","names":["_core","require","_geospatial","cameraPositionCartesian","Vector3","toEye","cameraPositionEnu","extraVertexEnu","projectedOriginVector","enuToCartesianMatrix","Matrix4","cartesianToEnuMatrix","getLodStatus","tile","frameState","lodMetricValue","isNaN","screenSize","getProjectedRadius","header","children","viewport","topDownViewport","mbsLat","mbs","mbsLon","mbsZ","mbsR","mbsCenterCartesian","_toConsumableArray2","default","boundingVolume","center","cameraPositionCartographic","unprojectPosition","cameraPosition","Ellipsoid","WGS84","cartographicToCartesian","copy","subtract","normalize","eastNorthUpToFixedFrame","invert","transform","projection","Math","sqrt","extraZ","extraVertexCartesian","extraVectorCartesian","radiusVector","cross","scale","sphereMbsBorderVertexCartesian","add","sphereMbsBorderVertexCartographic","cartesianToCartographic","projectedOrigin","project","projectedMbsBorderVertex","projectedRadius","magnitude"],"sources":["../../../../src/tileset/helpers/i3s-lod.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {Matrix4, Vector3} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {Tile3D} from '../tile-3d';\nimport {FrameState} from './frame-state';\n\nconst cameraPositionCartesian = new Vector3();\nconst toEye = new Vector3();\nconst cameraPositionEnu = new Vector3();\nconst extraVertexEnu = new Vector3();\nconst projectedOriginVector = new Vector3();\nconst enuToCartesianMatrix = new Matrix4();\nconst cartesianToEnuMatrix = new Matrix4();\n\n/**\n * For the maxScreenThreshold error metric, maxError means that you should replace the node with it's children\n as soon as the nodes bounding sphere has a screen radius larger than maxError pixels.\n In this sense a value of 0 means you should always load it's children,\n or if it's a leaf node, you should always display it.\n * @param tile \n * @param frameState \n * @returns \n */\nexport function getLodStatus(tile: Tile3D, frameState: FrameState): 'DIG' | 'OUT' | 'DRAW' {\n if (tile.lodMetricValue === 0 || isNaN(tile.lodMetricValue)) {\n return 'DIG';\n }\n const screenSize = 2 * getProjectedRadius(tile, frameState);\n if (screenSize < 2) {\n return 'OUT';\n }\n if (!tile.header.children || screenSize <= tile.lodMetricValue) {\n return 'DRAW';\n } else if (tile.header.children) {\n return 'DIG';\n }\n return 'OUT';\n}\n\n/**\n * Calculate size of MBS radius projected on the screen plane\n * @param tile\n * @param frameState\n * @returns\n */\n// eslint-disable-next-line max-statements\nexport function getProjectedRadius(tile: Tile3D, frameState: FrameState): number {\n const {topDownViewport: viewport} = frameState;\n const mbsLat = tile.header.mbs[1];\n const mbsLon = tile.header.mbs[0];\n const mbsZ = tile.header.mbs[2];\n const mbsR = tile.header.mbs[3];\n const mbsCenterCartesian = [...tile.boundingVolume.center];\n const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);\n Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, cameraPositionCartesian);\n\n // ---------------------------\n // Calculate mbs border vertex\n // ---------------------------\n toEye.copy(cameraPositionCartesian).subtract(mbsCenterCartesian).normalize();\n // Add extra vector to form plane\n Ellipsoid.WGS84.eastNorthUpToFixedFrame(mbsCenterCartesian, enuToCartesianMatrix);\n cartesianToEnuMatrix.copy(enuToCartesianMatrix).invert();\n cameraPositionEnu.copy(cameraPositionCartesian).transform(cartesianToEnuMatrix);\n // Mean Proportionals in Right Triangles - Altitude rule\n // https://mathbitsnotebook.com/Geometry/RightTriangles/RTmeanRight.html\n const projection = Math.sqrt(\n cameraPositionEnu[0] * cameraPositionEnu[0] + cameraPositionEnu[1] * cameraPositionEnu[1]\n );\n const extraZ = (projection * projection) / cameraPositionEnu[2];\n extraVertexEnu.copy([cameraPositionEnu[0], cameraPositionEnu[1], extraZ]);\n const extraVertexCartesian = extraVertexEnu.transform(enuToCartesianMatrix);\n const extraVectorCartesian = extraVertexCartesian.subtract(mbsCenterCartesian).normalize();\n // We need radius vector orthogonal to toEye vector\n const radiusVector = toEye.cross(extraVectorCartesian).normalize().scale(mbsR);\n const sphereMbsBorderVertexCartesian = radiusVector.add(mbsCenterCartesian);\n const sphereMbsBorderVertexCartographic = Ellipsoid.WGS84.cartesianToCartographic(\n sphereMbsBorderVertexCartesian\n );\n // ---------------------------\n\n // Project center vertex and border vertex and calculate projected radius of MBS\n const projectedOrigin = viewport.project([mbsLon, mbsLat, mbsZ]);\n const projectedMbsBorderVertex = viewport.project(\n sphereMbsBorderVertexCartographic as [number, number, number]\n );\n const projectedRadius = projectedOriginVector\n .copy(projectedOrigin)\n .subtract(projectedMbsBorderVertex)\n .magnitude();\n return projectedRadius;\n}\n"],"mappings":";;;;;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAIA,IAAME,uBAAuB,GAAG,IAAIC,aAAO,CAAC,CAAC;AAC7C,IAAMC,KAAK,GAAG,IAAID,aAAO,CAAC,CAAC;AAC3B,IAAME,iBAAiB,GAAG,IAAIF,aAAO,CAAC,CAAC;AACvC,IAAMG,cAAc,GAAG,IAAIH,aAAO,CAAC,CAAC;AACpC,IAAMI,qBAAqB,GAAG,IAAIJ,aAAO,CAAC,CAAC;AAC3C,IAAMK,oBAAoB,GAAG,IAAIC,aAAO,CAAC,CAAC;AAC1C,IAAMC,oBAAoB,G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AACsC,OAAO,CAAC,CAAClC,MAAM,EAAEF,MAAM,EAAEG,IAAI,CAAC,CAAC;EAChE,IAAMkC,wBAAwB,GAAGvC,QAAQ,CAACsC,OAAO,CAC/CH,iCACF,CAAC;EACD,IAAMK,eAAe,GAAGrD,qBAAqB,CAC1C+B,IAAI,CAACmB,eAAe,CAAC,CACrBlB,QAAQ,CAACoB,wBAAwB,CAAC,CAClCE,SAAS,CAAC,CAAC;EACd,OAAOD,eAAe;AACxB"}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.calculateDynamicScreenSpaceError = calculateDynamicScreenSpaceError;
|
|
7
|
-
exports.fog = fog;
|
|
8
|
-
exports.getDynamicScreenSpaceError = getDynamicScreenSpaceError;
|
|
9
|
-
exports.getTiles3DScreenSpaceError = getTiles3DScreenSpaceError;
|
|
10
|
-
var _core = require("@math.gl/core");
|
|
11
|
-
var scratchPositionNormal = new _core.Vector3();
|
|
12
|
-
var scratchCartographic = new _core.Vector3();
|
|
13
|
-
var scratchMatrix = new _core.Matrix4();
|
|
14
|
-
var scratchCenter = new _core.Vector3();
|
|
15
|
-
var scratchPosition = new _core.Vector3();
|
|
16
|
-
var scratchDirection = new _core.Vector3();
|
|
17
|
-
function calculateDynamicScreenSpaceError(root, _ref) {
|
|
18
|
-
var camera = _ref.camera,
|
|
19
|
-
mapProjection = _ref.mapProjection;
|
|
20
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
21
|
-
var _options$dynamicScree = options.dynamicScreenSpaceErrorHeightFalloff,
|
|
22
|
-
dynamicScreenSpaceErrorHeightFalloff = _options$dynamicScree === void 0 ? 0.25 : _options$dynamicScree,
|
|
23
|
-
_options$dynamicScree2 = options.dynamicScreenSpaceErrorDensity,
|
|
24
|
-
dynamicScreenSpaceErrorDensity = _options$dynamicScree2 === void 0 ? 0.00278 : _options$dynamicScree2;
|
|
25
|
-
var up;
|
|
26
|
-
var direction;
|
|
27
|
-
var height;
|
|
28
|
-
var minimumHeight;
|
|
29
|
-
var maximumHeight;
|
|
30
|
-
var tileBoundingVolume = root.contentBoundingVolume;
|
|
31
|
-
if (tileBoundingVolume instanceof TileBoundingRegion) {
|
|
32
|
-
up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);
|
|
33
|
-
direction = camera.directionWC;
|
|
34
|
-
height = camera.positionCartographic.height;
|
|
35
|
-
minimumHeight = tileBoundingVolume.minimumHeight;
|
|
36
|
-
maximumHeight = tileBoundingVolume.maximumHeight;
|
|
37
|
-
} else {
|
|
38
|
-
var transformLocal = _core.Matrix4.inverseTransformation(root.computedTransform, scratchMatrix);
|
|
39
|
-
var ellipsoid = mapProjection.ellipsoid;
|
|
40
|
-
var boundingVolume = tileBoundingVolume.boundingVolume;
|
|
41
|
-
var centerLocal = _core.Matrix4.multiplyByPoint(transformLocal, boundingVolume.center, scratchCenter);
|
|
42
|
-
if (Cartesian3.magnitude(centerLocal) > ellipsoid.minimumRadius) {
|
|
43
|
-
var centerCartographic = Cartographic.fromCartesian(centerLocal, ellipsoid, scratchCartographic);
|
|
44
|
-
up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);
|
|
45
|
-
direction = camera.directionWC;
|
|
46
|
-
height = camera.positionCartographic.height;
|
|
47
|
-
minimumHeight = 0.0;
|
|
48
|
-
maximumHeight = centerCartographic.height * 2.0;
|
|
49
|
-
} else {
|
|
50
|
-
var positionLocal = _core.Matrix4.multiplyByPoint(transformLocal, camera.positionWC, scratchPosition);
|
|
51
|
-
up = Cartesian3.UNIT_Z;
|
|
52
|
-
direction = _core.Matrix4.multiplyByPointAsVector(transformLocal, camera.directionWC, scratchDirection);
|
|
53
|
-
direction = Cartesian3.normalize(direction, direction);
|
|
54
|
-
height = positionLocal.z;
|
|
55
|
-
if (tileBoundingVolume instanceof TileOrientedBoundingBox) {
|
|
56
|
-
var boxHeight = root._header.boundingVolume.box[11];
|
|
57
|
-
minimumHeight = centerLocal.z - boxHeight;
|
|
58
|
-
maximumHeight = centerLocal.z + boxHeight;
|
|
59
|
-
} else if (tileBoundingVolume instanceof TileBoundingSphere) {
|
|
60
|
-
var radius = boundingVolume.radius;
|
|
61
|
-
minimumHeight = centerLocal.z - radius;
|
|
62
|
-
maximumHeight = centerLocal.z + radius;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
var heightFalloff = dynamicScreenSpaceErrorHeightFalloff;
|
|
67
|
-
var heightClose = minimumHeight + (maximumHeight - minimumHeight) * heightFalloff;
|
|
68
|
-
var heightFar = maximumHeight;
|
|
69
|
-
var t = (0, _core.clamp)((height - heightClose) / (heightFar - heightClose), 0.0, 1.0);
|
|
70
|
-
var dot = Math.abs(Cartesian3.dot(direction, up));
|
|
71
|
-
var horizonFactor = 1.0 - dot;
|
|
72
|
-
horizonFactor = horizonFactor * (1.0 - t);
|
|
73
|
-
return dynamicScreenSpaceErrorDensity * horizonFactor;
|
|
74
|
-
}
|
|
75
|
-
function fog(distanceToCamera, density) {
|
|
76
|
-
var scalar = distanceToCamera * density;
|
|
77
|
-
return 1.0 - Math.exp(-(scalar * scalar));
|
|
78
|
-
}
|
|
79
|
-
function getDynamicScreenSpaceError(tileset, distanceToCamera) {
|
|
80
|
-
if (tileset.dynamicScreenSpaceError && tileset.dynamicScreenSpaceErrorComputedDensity) {
|
|
81
|
-
var density = tileset.dynamicScreenSpaceErrorComputedDensity;
|
|
82
|
-
var factor = tileset.dynamicScreenSpaceErrorFactor;
|
|
83
|
-
var dynamicError = fog(distanceToCamera, density) * factor;
|
|
84
|
-
return dynamicError;
|
|
85
|
-
}
|
|
86
|
-
return 0;
|
|
87
|
-
}
|
|
88
|
-
function getTiles3DScreenSpaceError(tile, frameState, useParentLodMetric) {
|
|
89
|
-
var tileset = tile.tileset;
|
|
90
|
-
var parentLodMetricValue = tile.parent && tile.parent.lodMetricValue || tile.lodMetricValue;
|
|
91
|
-
var lodMetricValue = useParentLodMetric ? parentLodMetricValue : tile.lodMetricValue;
|
|
92
|
-
if (lodMetricValue === 0.0) {
|
|
93
|
-
return 0.0;
|
|
94
|
-
}
|
|
95
|
-
var distance = Math.max(tile._distanceToCamera, 1e-7);
|
|
96
|
-
var height = frameState.height,
|
|
97
|
-
sseDenominator = frameState.sseDenominator;
|
|
98
|
-
var viewDistanceScale = tileset.options.viewDistanceScale;
|
|
99
|
-
var error = lodMetricValue * height * (viewDistanceScale || 1.0) / (distance * sseDenominator);
|
|
100
|
-
error -= getDynamicScreenSpaceError(tileset, distance);
|
|
101
|
-
return error;
|
|
102
|
-
}
|
|
103
|
-
//# sourceMappingURL=tiles-3d-lod.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tiles-3d-lod.js","names":["_core","require","scratchPositionNormal","Vector3","scratchCartographic","scratchMatrix","Matrix4","scratchCenter","scratchPosition","scratchDirection","calculateDynamicScreenSpaceError","root","_ref","camera","mapProjection","options","arguments","length","undefined","_options$dynamicScree","dynamicScreenSpaceErrorHeightFalloff","_options$dynamicScree2","dynamicScreenSpaceErrorDensity","up","direction","height","minimumHeight","maximumHeight","tileBoundingVolume","contentBoundingVolume","TileBoundingRegion","Cartesian3","normalize","positionWC","directionWC","positionCartographic","transformLocal","inverseTransformation","computedTransform","ellipsoid","boundingVolume","centerLocal","multiplyByPoint","center","magnitude","minimumRadius","centerCartographic","Cartographic","fromCartesian","positionLocal","UNIT_Z","multiplyByPointAsVector","z","TileOrientedBoundingBox","boxHeight","_header","box","TileBoundingSphere","radius","heightFalloff","heightClose","heightFar","t","clamp","dot","Math","abs","horizonFactor","fog","distanceToCamera","density","scalar","exp","getDynamicScreenSpaceError","tileset","dynamicScreenSpaceError","dynamicScreenSpaceErrorComputedDensity","factor","dynamicScreenSpaceErrorFactor","dynamicError","getTiles3DScreenSpaceError","tile","frameState","useParentLodMetric","parentLodMetricValue","parent","lodMetricValue","distance","max","_distanceToCamera","sseDenominator","viewDistanceScale","error"],"sources":["../../../../src/tileset/helpers/tiles-3d-lod.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n// TODO - Dynamic screen space error provides an optimization when looking at\n// tilesets from above\n\n/* eslint-disable */\n// @ts-nocheck\nimport {Matrix4, Vector3, clamp} from '@math.gl/core';\n\nconst scratchPositionNormal = new Vector3();\nconst scratchCartographic = new Vector3();\nconst scratchMatrix = new Matrix4();\nconst scratchCenter = new Vector3();\nconst scratchPosition = new Vector3();\nconst scratchDirection = new Vector3();\n\n// eslint-disable-next-line max-statements, complexity\nexport function calculateDynamicScreenSpaceError(root, {camera, mapProjection}, options = {}) {\n const {dynamicScreenSpaceErrorHeightFalloff = 0.25, dynamicScreenSpaceErrorDensity = 0.00278} =\n options;\n\n let up;\n let direction;\n let height;\n let minimumHeight;\n let maximumHeight;\n\n const tileBoundingVolume = root.contentBoundingVolume;\n\n if (tileBoundingVolume instanceof TileBoundingRegion) {\n up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);\n direction = camera.directionWC;\n height = camera.positionCartographic.height;\n minimumHeight = tileBoundingVolume.minimumHeight;\n maximumHeight = tileBoundingVolume.maximumHeight;\n } else {\n // Transform camera position and direction into the local coordinate system of the tileset\n const transformLocal = Matrix4.inverseTransformation(root.computedTransform, scratchMatrix);\n const ellipsoid = mapProjection.ellipsoid;\n const boundingVolume = tileBoundingVolume.boundingVolume;\n const centerLocal = Matrix4.multiplyByPoint(\n transformLocal,\n boundingVolume.center,\n scratchCenter\n );\n if (Cartesian3.magnitude(centerLocal) > ellipsoid.minimumRadius) {\n // The tileset is defined in WGS84. Approximate the minimum and maximum height.\n const centerCartographic = Cartographic.fromCartesian(\n centerLocal,\n ellipsoid,\n scratchCartographic\n );\n up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);\n direction = camera.directionWC;\n height = camera.positionCartographic.height;\n minimumHeight = 0.0;\n maximumHeight = centerCartographic.height * 2.0;\n } else {\n // The tileset is defined in local coordinates (z-up)\n const positionLocal = Matrix4.multiplyByPoint(\n transformLocal,\n camera.positionWC,\n scratchPosition\n );\n up = Cartesian3.UNIT_Z;\n direction = Matrix4.multiplyByPointAsVector(\n transformLocal,\n camera.directionWC,\n scratchDirection\n );\n direction = Cartesian3.normalize(direction, direction);\n height = positionLocal.z;\n if (tileBoundingVolume instanceof TileOrientedBoundingBox) {\n // Assuming z-up, the last component stores the half-height of the box\n const boxHeight = root._header.boundingVolume.box[11];\n minimumHeight = centerLocal.z - boxHeight;\n maximumHeight = centerLocal.z + boxHeight;\n } else if (tileBoundingVolume instanceof TileBoundingSphere) {\n const radius = boundingVolume.radius;\n minimumHeight = centerLocal.z - radius;\n maximumHeight = centerLocal.z + radius;\n }\n }\n }\n\n // The range where the density starts to lessen. Start at the quarter height of the tileset.\n const heightFalloff = dynamicScreenSpaceErrorHeightFalloff;\n const heightClose = minimumHeight + (maximumHeight - minimumHeight) * heightFalloff;\n const heightFar = maximumHeight;\n\n const t = clamp((height - heightClose) / (heightFar - heightClose), 0.0, 1.0);\n\n // Increase density as the camera tilts towards the horizon\n const dot = Math.abs(Cartesian3.dot(direction, up));\n\n let horizonFactor = 1.0 - dot;\n\n // Weaken the horizon factor as the camera height increases, implying the camera is further away from the tileset.\n // The goal is to increase density for the \"street view\", not when viewing the tileset from a distance.\n horizonFactor = horizonFactor * (1.0 - t);\n\n return dynamicScreenSpaceErrorDensity * horizonFactor;\n}\n\nexport function fog(distanceToCamera, density) {\n const scalar = distanceToCamera * density;\n return 1.0 - Math.exp(-(scalar * scalar));\n}\n\nexport function getDynamicScreenSpaceError(tileset, distanceToCamera) {\n if (tileset.dynamicScreenSpaceError && tileset.dynamicScreenSpaceErrorComputedDensity) {\n const density = tileset.dynamicScreenSpaceErrorComputedDensity;\n const factor = tileset.dynamicScreenSpaceErrorFactor;\n // TODO: Refined screen space error that minimizes tiles in non-first-person\n const dynamicError = fog(distanceToCamera, density) * factor;\n return dynamicError;\n }\n\n return 0;\n}\n\nexport function getTiles3DScreenSpaceError(tile, frameState, useParentLodMetric) {\n const tileset = tile.tileset;\n const parentLodMetricValue = (tile.parent && tile.parent.lodMetricValue) || tile.lodMetricValue;\n const lodMetricValue = useParentLodMetric ? parentLodMetricValue : tile.lodMetricValue;\n\n // Leaf tiles do not have any error so save the computation\n if (lodMetricValue === 0.0) {\n return 0.0;\n }\n\n // TODO: Orthographic Frustum needs special treatment?\n // this._getOrthograhicScreenSpaceError();\n\n // Avoid divide by zero when viewer is inside the tile\n const distance = Math.max(tile._distanceToCamera, 1e-7);\n const {height, sseDenominator} = frameState;\n const {viewDistanceScale} = tileset.options;\n let error = (lodMetricValue * height * (viewDistanceScale || 1.0)) / (distance * sseDenominator);\n\n error -= getDynamicScreenSpaceError(tileset, distance);\n\n return error;\n}\n"],"mappings":";;;;;;;;;AAUA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAMC,qBAAqB,GAAG,IAAIC,aAAO,CAAC,CAAC;AAC3C,IAAMC,mBAAmB,GAAG,IAAID,aAAO,CAAC,CAAC;AACzC,IAAME,aAAa,GAAG,IAAIC,aAAO,CAAC,CAAC;AACnC,IAAMC,aAAa,GAAG,IAAIJ,aAAO,CAAC,CAAC;AACnC,IAAMK,eAAe,GAAG,IAAIL,aAAO,CAAC,CAAC;AACrC,IAAMM,gBAAgB,GAAG,IAAIN,aAAO,CAAC,CAAC;AAG/B,SAASO,gCAAgCA,CAACC,IAAI,EAAAC,IAAA,EAAyC;EAAA,IAAtCC,MAAM,GAAAD,IAAA,CAANC,MAAM;IAAEC,aAAa,GAAAF,IAAA,CAAbE,aAAa;EAAA,IAAGC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAC1F,IAAAG,qBAAA,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