@openglobus/og 0.10.2 → 0.10.5
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/css/og.css +1 -1
- package/package.json +4 -4
- package/src/og/Extent.js +274 -273
- package/src/og/Globe.js +11 -3
- package/src/og/LonLat.js +148 -147
- package/src/og/camera/PlanetCamera.js +110 -38
- package/src/og/control/EarthNavigation.js +259 -0
- package/src/og/control/MouseNavigation.js +68 -40
- package/src/og/layer/KML.js +157 -0
- package/src/og/quadTree/Node.js +8 -8
- package/src/og/quadTree/quadTree.js +22 -18
- package/src/og/renderer/RendererEvents.js +21 -16
- package/src/og/scene/Planet.js +12 -7
- package/src/og/segment/Segment.js +2 -4
- package/src/og/utils/FontAtlas.js +1 -0
- package/src/og/{segment → utils}/PlainSegmentWorker.js +425 -407
- package/src/og/webgl/Handler.js +866 -845
package/src/og/LonLat.js
CHANGED
|
@@ -19,166 +19,167 @@ const INV_PI_BY_180_HALF_PI = INV_PI_BY_180 * HALF_PI;
|
|
|
19
19
|
* @param {number} [lat] - Latitude.
|
|
20
20
|
* @param {number} [height] - Height over the surface.
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
export class LonLat {
|
|
23
|
+
|
|
24
|
+
constructor(lon, lat, height) {
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Longitude.
|
|
28
|
+
* @public
|
|
29
|
+
* @type {number}
|
|
30
|
+
*/
|
|
31
|
+
this.lon = lon || 0;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Latitude.
|
|
35
|
+
* @public
|
|
36
|
+
* @type {number}
|
|
37
|
+
*/
|
|
38
|
+
this.lat = lat || 0;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Height.
|
|
42
|
+
* @public
|
|
43
|
+
* @type {number}
|
|
44
|
+
*/
|
|
45
|
+
this.height = height || 0;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
isZero() {
|
|
49
|
+
return this.lon === 0.0 && this.lat === 0.0 && this.height === 0.0;
|
|
50
|
+
};
|
|
23
51
|
|
|
24
52
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @
|
|
27
|
-
* @
|
|
53
|
+
* Creates coordinates array.
|
|
54
|
+
* @static
|
|
55
|
+
* @param{Array.<Array<number,number,number>>} arr - Coordinates array data.
|
|
56
|
+
* @return{Array.<og.LonLat>} the same coordinates array but each element is LonLat instance.
|
|
28
57
|
*/
|
|
29
|
-
|
|
58
|
+
static join(arr) {
|
|
59
|
+
var res = [];
|
|
60
|
+
for (var i = 0; i < arr.length; i++) {
|
|
61
|
+
var ai = arr[i];
|
|
62
|
+
res[i] = new LonLat(ai[0], ai[1], ai[2]);
|
|
63
|
+
}
|
|
64
|
+
return res;
|
|
65
|
+
};
|
|
30
66
|
|
|
31
67
|
/**
|
|
32
|
-
*
|
|
33
|
-
* @
|
|
34
|
-
* @
|
|
68
|
+
* Creates an object by coordinate array.
|
|
69
|
+
* @static
|
|
70
|
+
* @param {Array.<number,number,number>} arr - Coordiante array, where first is longitude, second is latitude and third is a height.
|
|
71
|
+
* @returns {og.LonLat} -
|
|
35
72
|
*/
|
|
36
|
-
|
|
73
|
+
static createFromArray(arr) {
|
|
74
|
+
return new LonLat(arr[0], arr[1], arr[2]);
|
|
75
|
+
};
|
|
37
76
|
|
|
38
77
|
/**
|
|
39
|
-
*
|
|
40
|
-
* @
|
|
41
|
-
* @
|
|
78
|
+
* Converts degrees to mercator coordinates.
|
|
79
|
+
* @static
|
|
80
|
+
* @param {number} lon - Degrees longitude.
|
|
81
|
+
* @param {number} lat - Degrees latitude.
|
|
82
|
+
* @param {number} [height] - Height.
|
|
83
|
+
* @returns {og.LonLat} -
|
|
42
84
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Creates coordinates array.
|
|
52
|
-
* @static
|
|
53
|
-
* @param{Array.<Array<number,number,number>>} arr - Coordinates array data.
|
|
54
|
-
* @return{Array.<og.LonLat>} the same coordinates array but each element is LonLat instance.
|
|
55
|
-
*/
|
|
56
|
-
LonLat.join = function (arr) {
|
|
57
|
-
var res = [];
|
|
58
|
-
for (var i = 0; i < arr.length; i++) {
|
|
59
|
-
var ai = arr[i];
|
|
60
|
-
res[i] = new LonLat(ai[0], ai[1], ai[2]);
|
|
61
|
-
}
|
|
62
|
-
return res;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Creates an object by coordinate array.
|
|
67
|
-
* @static
|
|
68
|
-
* @param {Array.<number,number,number>} arr - Coordiante array, where first is longitude, second is latitude and third is a height.
|
|
69
|
-
* @returns {og.LonLat} -
|
|
70
|
-
*/
|
|
71
|
-
LonLat.createFromArray = function (arr) {
|
|
72
|
-
return new LonLat(arr[0], arr[1], arr[2]);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Converts degrees to mercator coordinates.
|
|
77
|
-
* @static
|
|
78
|
-
* @param {number} lon - Degrees longitude.
|
|
79
|
-
* @param {number} lat - Degrees latitude.
|
|
80
|
-
* @param {number} [height] - Height.
|
|
81
|
-
* @returns {og.LonLat} -
|
|
82
|
-
*/
|
|
83
|
-
LonLat.forwardMercator = function (lon, lat, height) {
|
|
84
|
-
return new LonLat(lon * mercator.POLE_BY_180,
|
|
85
|
-
Math.log(Math.tan((90.0 + lat) * PI_BY_360)) * mercator.POLE_BY_PI,
|
|
86
|
-
height);
|
|
87
|
-
};
|
|
85
|
+
static forwardMercator(lon, lat, height) {
|
|
86
|
+
return new LonLat(lon * mercator.POLE_BY_180,
|
|
87
|
+
Math.log(Math.tan((90.0 + lat) * PI_BY_360)) * mercator.POLE_BY_PI,
|
|
88
|
+
height);
|
|
89
|
+
};
|
|
88
90
|
|
|
89
|
-
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
};
|
|
91
|
+
/**
|
|
92
|
+
* Converts mercator to degrees coordinates.
|
|
93
|
+
* @static
|
|
94
|
+
* @param {number} x - Mercator longitude.
|
|
95
|
+
* @param {number} y - Mercator latitude.
|
|
96
|
+
* @param {number} [height] - Height.
|
|
97
|
+
* @returns {og.LonLat} -
|
|
98
|
+
*/
|
|
99
|
+
static inverseMercator(x, y, height) {
|
|
100
|
+
return new LonLat(x * mercator.INV_POLE_BY_180,
|
|
101
|
+
INV_PI_BY_360 * Math.atan(Math.exp(y * mercator.PI_BY_POLE)) - INV_PI_BY_180_HALF_PI,
|
|
102
|
+
height);
|
|
103
|
+
};
|
|
102
104
|
|
|
103
|
-
/**
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
};
|
|
105
|
+
/**
|
|
106
|
+
* Sets coordinates.
|
|
107
|
+
* @public
|
|
108
|
+
* @param {number} [lon] - Longitude.
|
|
109
|
+
* @param {number} [lat] - Latitude.
|
|
110
|
+
* @param {number} [height] - Height.
|
|
111
|
+
* @returns {og.LonLat} -
|
|
112
|
+
*/
|
|
113
|
+
set(lon, lat, height) {
|
|
114
|
+
this.lon = lon || 0;
|
|
115
|
+
this.lat = lat || 0;
|
|
116
|
+
this.height = height || 0;
|
|
117
|
+
return this;
|
|
118
|
+
};
|
|
117
119
|
|
|
118
|
-
/**
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
};
|
|
120
|
+
/**
|
|
121
|
+
* Copy coordinates.
|
|
122
|
+
* @public
|
|
123
|
+
* @param {og.LonLat} [lonLat] - Coordinates to copy.
|
|
124
|
+
* @returns {og.LonLat} -
|
|
125
|
+
*/
|
|
126
|
+
copy(lonLat) {
|
|
127
|
+
this.lon = lonLat.lon;
|
|
128
|
+
this.lat = lonLat.lat;
|
|
129
|
+
this.height = lonLat.height;
|
|
130
|
+
return this;
|
|
131
|
+
};
|
|
130
132
|
|
|
131
|
-
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
};
|
|
133
|
+
/**
|
|
134
|
+
* Clone the coordiante.
|
|
135
|
+
* @public
|
|
136
|
+
* @returns {og.LonLat} -
|
|
137
|
+
*/
|
|
138
|
+
clone() {
|
|
139
|
+
return new LonLat(this.lon, this.lat, this.height);
|
|
140
|
+
};
|
|
139
141
|
|
|
140
|
-
/**
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
};
|
|
142
|
+
/**
|
|
143
|
+
* Converts to mercator coordinates.
|
|
144
|
+
* @public
|
|
145
|
+
* @returns {og.LonLat} -
|
|
146
|
+
*/
|
|
147
|
+
forwardMercator() {
|
|
148
|
+
return LonLat.forwardMercator(this.lon, this.lat, this.height);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
forwardMercatorEPS01() {
|
|
152
|
+
var lat = this.lat;
|
|
153
|
+
if (lat > 89.9) {
|
|
154
|
+
lat = 89.9;
|
|
155
|
+
} else if (lat < -89.9) {
|
|
156
|
+
lat = -89.9;
|
|
157
|
+
}
|
|
158
|
+
return new LonLat(
|
|
159
|
+
this.lon * mercator.POLE_BY_180,
|
|
160
|
+
Math.log(Math.tan((90.0 + lat) * PI_BY_360)) * mercator.POLE_BY_PI);
|
|
161
|
+
};
|
|
160
162
|
|
|
161
|
-
/**
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
};
|
|
163
|
+
/**
|
|
164
|
+
* Converts from mercator coordinates.
|
|
165
|
+
* @public
|
|
166
|
+
* @returns {og.LonLat} -
|
|
167
|
+
*/
|
|
168
|
+
inverseMercator() {
|
|
169
|
+
return LonLat.inverseMercator(this.lon, this.lat, this.height);
|
|
170
|
+
};
|
|
169
171
|
|
|
170
|
-
/**
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
export { LonLat };
|
|
172
|
+
/**
|
|
173
|
+
* Compares coordinates.
|
|
174
|
+
* @public
|
|
175
|
+
* @param {og.LonLat} b - Coordinate to compare with.
|
|
176
|
+
* @returns {boolean} -
|
|
177
|
+
*/
|
|
178
|
+
equal(b) {
|
|
179
|
+
if (b.height) {
|
|
180
|
+
return this.lon === b.lon && this.lat === b.lat && this.height === b.height;
|
|
181
|
+
} else {
|
|
182
|
+
return this.lon === b.lon && this.lat === b.lat;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
}
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
* @module og/camera/PlanetCamera
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import * as math from
|
|
8
|
-
import * as mercator from
|
|
9
|
-
import { Camera } from
|
|
10
|
-
import { Vec3 } from
|
|
11
|
-
import { Key } from
|
|
12
|
-
import { LonLat } from
|
|
13
|
-
import { Ray } from
|
|
14
|
-
import { Quat } from
|
|
15
|
-
import { Mat4 } from
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
import * as math from "../math.js";
|
|
8
|
+
import * as mercator from "../mercator.js";
|
|
9
|
+
import { Camera } from "./Camera.js";
|
|
10
|
+
import { Vec3 } from "../math/Vec3.js";
|
|
11
|
+
import { Key } from "../Lock.js";
|
|
12
|
+
import { LonLat } from "../LonLat.js";
|
|
13
|
+
import { Ray } from "../math/Ray.js";
|
|
14
|
+
import { Quat } from "../math/Quat.js";
|
|
15
|
+
import { Mat4 } from "../math/Mat4.js";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Planet camera.
|
|
@@ -24,17 +24,28 @@ import { Mat4 } from '../math/Mat4.js';
|
|
|
24
24
|
* @param {number} [options.viewAngle=37] - Camera angle of view. Default is 35.0
|
|
25
25
|
* @param {number} [options.near] - Camera near plane distance. Default is 1.0
|
|
26
26
|
* @param {number} [options.far] - Camera far plane distance. Deafult is og.math.MAX
|
|
27
|
-
* @param {number} [options.minAltitude] - Minimal altitude for the camera. Deafult is
|
|
27
|
+
* @param {number} [options.minAltitude] - Minimal altitude for the camera. Deafult is 1
|
|
28
|
+
* @param {number} [options.maxAltitude] - Maximal altitude for the camera. Deafult is 20000000
|
|
28
29
|
* @param {og.Vec3} [options.eye] - Camera eye position. Default (0,0,0)
|
|
29
30
|
* @param {og.Vec3} [options.look] - Camera look position. Default (0,0,0)
|
|
30
31
|
* @param {og.Vec3} [options.up] - Camera eye position. Default (0,1,0)
|
|
31
32
|
*/
|
|
32
33
|
class PlanetCamera extends Camera {
|
|
33
34
|
constructor(planet, options) {
|
|
34
|
-
super(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
super(
|
|
36
|
+
planet.renderer,
|
|
37
|
+
Object.assign(
|
|
38
|
+
{},
|
|
39
|
+
{
|
|
40
|
+
frustums: /*[[100, 10000000]]*/ [
|
|
41
|
+
[1, 100 + 0.075],
|
|
42
|
+
[100, 1000 + 0.075],
|
|
43
|
+
[1000, 1e6 + 10000],
|
|
44
|
+
[1e6, 1e9]
|
|
45
|
+
] //[[1, 1e3 + 100], [1e3, 1e6 + 10000], [1e6, 1e9]]*/
|
|
46
|
+
},
|
|
47
|
+
options
|
|
48
|
+
)
|
|
38
49
|
);
|
|
39
50
|
/**
|
|
40
51
|
* Assigned camera's planet.
|
|
@@ -50,6 +61,13 @@ class PlanetCamera extends Camera {
|
|
|
50
61
|
*/
|
|
51
62
|
this.minAltitude = options.minAltitude || 1;
|
|
52
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Maximal alltitude that camera can reach over the globe.
|
|
66
|
+
* @public
|
|
67
|
+
* @type {number}
|
|
68
|
+
*/
|
|
69
|
+
this.maxAltitude = options.maxAltitude || 20000000;
|
|
70
|
+
|
|
53
71
|
/**
|
|
54
72
|
* Current geographical degree position.
|
|
55
73
|
* @protected
|
|
@@ -112,6 +130,13 @@ class PlanetCamera extends Camera {
|
|
|
112
130
|
*/
|
|
113
131
|
update() {
|
|
114
132
|
this.events.stopPropagation();
|
|
133
|
+
|
|
134
|
+
let maxAlt = this.maxAltitude + this.planet.ellipsoid._a;
|
|
135
|
+
|
|
136
|
+
if (this.eye.length() > maxAlt) {
|
|
137
|
+
this.eye.copy(this.eye.normal().scale(maxAlt));
|
|
138
|
+
}
|
|
139
|
+
|
|
115
140
|
super.update();
|
|
116
141
|
this.updateGeodeticPosition();
|
|
117
142
|
this.eyeNorm = this.eye.normal();
|
|
@@ -191,7 +216,6 @@ class PlanetCamera extends Camera {
|
|
|
191
216
|
* @returns {og.Vec3}
|
|
192
217
|
*/
|
|
193
218
|
getExtentPosition(extent, height) {
|
|
194
|
-
|
|
195
219
|
var north = extent.getNorth();
|
|
196
220
|
var south = extent.getSouth();
|
|
197
221
|
var east = extent.getEast();
|
|
@@ -275,8 +299,15 @@ class PlanetCamera extends Camera {
|
|
|
275
299
|
* @param {cameraCallback} [startCallback] - Callback that calls befor the flying begins.
|
|
276
300
|
*/
|
|
277
301
|
flyExtent(extent, height, up, ampl, completeCallback, startCallback, frameCallback) {
|
|
278
|
-
this.flyCartesian(
|
|
279
|
-
|
|
302
|
+
this.flyCartesian(
|
|
303
|
+
this.getExtentPosition(extent, height),
|
|
304
|
+
Vec3.ZERO,
|
|
305
|
+
up,
|
|
306
|
+
ampl,
|
|
307
|
+
completeCallback,
|
|
308
|
+
startCallback,
|
|
309
|
+
frameCallback
|
|
310
|
+
);
|
|
280
311
|
}
|
|
281
312
|
|
|
282
313
|
viewDistance(cartesian, distance = 10000.0) {
|
|
@@ -293,7 +324,14 @@ class PlanetCamera extends Camera {
|
|
|
293
324
|
this.update();
|
|
294
325
|
}
|
|
295
326
|
|
|
296
|
-
flyDistance(
|
|
327
|
+
flyDistance(
|
|
328
|
+
cartesian,
|
|
329
|
+
distance = 10000.0,
|
|
330
|
+
ampl = 0.0,
|
|
331
|
+
completeCallback,
|
|
332
|
+
startCallback,
|
|
333
|
+
frameCallback
|
|
334
|
+
) {
|
|
297
335
|
let p0 = this.eye.add(this.getForward().scaleTo(distance));
|
|
298
336
|
let _rot = Quat.getRotationBetweenVectors(p0.normal(), cartesian.normal());
|
|
299
337
|
if (_rot.isZero()) {
|
|
@@ -302,7 +340,15 @@ class PlanetCamera extends Camera {
|
|
|
302
340
|
} else {
|
|
303
341
|
let newPos = cartesian.add(_rot.mulVec3(this.getBackward()).scale(distance)),
|
|
304
342
|
newUp = _rot.mulVec3(this.getUp());
|
|
305
|
-
this.flyCartesian(
|
|
343
|
+
this.flyCartesian(
|
|
344
|
+
newPos,
|
|
345
|
+
cartesian,
|
|
346
|
+
newUp,
|
|
347
|
+
ampl,
|
|
348
|
+
completeCallback,
|
|
349
|
+
startCallback,
|
|
350
|
+
frameCallback
|
|
351
|
+
);
|
|
306
352
|
}
|
|
307
353
|
}
|
|
308
354
|
|
|
@@ -317,7 +363,6 @@ class PlanetCamera extends Camera {
|
|
|
317
363
|
* @param {cameraCallback} [startCallback] - Callback that calls befor the flying begins.
|
|
318
364
|
*/
|
|
319
365
|
flyCartesian(cartesian, look, up, ampl = 1.0, completeCallback, startCallback, frameCallback) {
|
|
320
|
-
|
|
321
366
|
this.stopFlying();
|
|
322
367
|
|
|
323
368
|
this._completeCallback = completeCallback;
|
|
@@ -333,13 +378,17 @@ class PlanetCamera extends Camera {
|
|
|
333
378
|
look = this.planet.ellipsoid.lonLatToCartesian(look);
|
|
334
379
|
}
|
|
335
380
|
|
|
336
|
-
var ground_a = this.planet.ellipsoid.lonLatToCartesian(
|
|
381
|
+
var ground_a = this.planet.ellipsoid.lonLatToCartesian(
|
|
382
|
+
new LonLat(this._lonLat.lon, this._lonLat.lat)
|
|
383
|
+
);
|
|
337
384
|
var v_a = this._v,
|
|
338
385
|
n_a = this._n;
|
|
339
386
|
|
|
340
387
|
var lonlat_b = this.planet.ellipsoid.cartesianToLonLat(cartesian);
|
|
341
388
|
var up_b = up || Vec3.UP;
|
|
342
|
-
var ground_b = this.planet.ellipsoid.lonLatToCartesian(
|
|
389
|
+
var ground_b = this.planet.ellipsoid.lonLatToCartesian(
|
|
390
|
+
new LonLat(lonlat_b.lon, lonlat_b.lat, 0)
|
|
391
|
+
);
|
|
343
392
|
var eye_b = cartesian;
|
|
344
393
|
var n_b = Vec3.sub(eye_b, look);
|
|
345
394
|
var u_b = up_b.cross(n_b);
|
|
@@ -350,7 +399,7 @@ class PlanetCamera extends Camera {
|
|
|
350
399
|
var an = ground_a.normal();
|
|
351
400
|
var bn = ground_b.normal();
|
|
352
401
|
var anbn = 1.0 - an.dot(bn);
|
|
353
|
-
var hM_a = ampl * math.SQRT_HALF * Math.sqrt(
|
|
402
|
+
var hM_a = ampl * math.SQRT_HALF * Math.sqrt(anbn > 0.0 ? anbn : 0.0);
|
|
354
403
|
|
|
355
404
|
var maxHeight = 6639613;
|
|
356
405
|
var currMaxHeight = Math.max(this._lonLat.height, lonlat_b.height);
|
|
@@ -370,7 +419,11 @@ class PlanetCamera extends Camera {
|
|
|
370
419
|
var g_i = ground_a.smerp(ground_b, d).normalize();
|
|
371
420
|
var ground_i = this.planet.getRayIntersectionEllipsoid(new Ray(zero, g_i));
|
|
372
421
|
var t = 1 - d;
|
|
373
|
-
var height_i =
|
|
422
|
+
var height_i =
|
|
423
|
+
this._lonLat.height * d * d * d +
|
|
424
|
+
max_h * 3 * d * d * t +
|
|
425
|
+
max_h * 3 * d * t * t +
|
|
426
|
+
lonlat_b.height * t * t * t;
|
|
374
427
|
|
|
375
428
|
var eye_i = ground_i.addA(g_i.scale(height_i));
|
|
376
429
|
var up_i = v_a.smerp(v_b, d);
|
|
@@ -406,7 +459,14 @@ class PlanetCamera extends Camera {
|
|
|
406
459
|
*/
|
|
407
460
|
flyLonLat(lonlat, look, up, ampl, completeCallback, startCallback) {
|
|
408
461
|
var _lonlat = new LonLat(lonlat.lon, lonlat.lat, lonlat.height || this._lonLat.height);
|
|
409
|
-
this.flyCartesian(
|
|
462
|
+
this.flyCartesian(
|
|
463
|
+
this.planet.ellipsoid.lonLatToCartesian(_lonlat),
|
|
464
|
+
look,
|
|
465
|
+
up,
|
|
466
|
+
ampl,
|
|
467
|
+
completeCallback,
|
|
468
|
+
startCallback
|
|
469
|
+
);
|
|
410
470
|
}
|
|
411
471
|
|
|
412
472
|
/**
|
|
@@ -414,7 +474,6 @@ class PlanetCamera extends Camera {
|
|
|
414
474
|
* @public
|
|
415
475
|
*/
|
|
416
476
|
stopFlying() {
|
|
417
|
-
|
|
418
477
|
this.planet.layerLock.free(this._keyLock);
|
|
419
478
|
this.planet.terrainLock.free(this._keyLock);
|
|
420
479
|
this.planet._normalMapCreator.free(this._keyLock);
|
|
@@ -477,7 +536,7 @@ class PlanetCamera extends Camera {
|
|
|
477
536
|
this.update();
|
|
478
537
|
}
|
|
479
538
|
|
|
480
|
-
rotateVertical(angle, center,
|
|
539
|
+
rotateVertical(angle, center, minSlope = 0) {
|
|
481
540
|
var rot = new Mat4().setRotation(this._u, angle);
|
|
482
541
|
var tr = new Mat4().setIdentity().translate(center);
|
|
483
542
|
var ntr = new Mat4().setIdentity().translate(center.negateTo());
|
|
@@ -491,9 +550,16 @@ class PlanetCamera extends Camera {
|
|
|
491
550
|
let eyeNorm = eye.normal();
|
|
492
551
|
let slope = n.dot(eyeNorm);
|
|
493
552
|
|
|
494
|
-
if (
|
|
495
|
-
|
|
496
|
-
|
|
553
|
+
if (minSlope) {
|
|
554
|
+
let dSlope = slope - this.slope;
|
|
555
|
+
|
|
556
|
+
if (slope < minSlope && dSlope < 0) return;
|
|
557
|
+
|
|
558
|
+
if (
|
|
559
|
+
(slope > 0.1 && v.dot(eyeNorm) > 0) ||
|
|
560
|
+
this.slope <= 0.1 ||
|
|
561
|
+
this._v.dot(this.eye.normal()) <= 0.0
|
|
562
|
+
) {
|
|
497
563
|
this.eye = eye;
|
|
498
564
|
this._v = v;
|
|
499
565
|
this._u = u;
|
|
@@ -544,8 +610,12 @@ class PlanetCamera extends Camera {
|
|
|
544
610
|
|
|
545
611
|
checkTerrainCollision() {
|
|
546
612
|
this._terrainAltitude = this._lonLat.height;
|
|
547
|
-
if (this.
|
|
548
|
-
this._terrainAltitude = this._insideSegment.getTerrainPoint(
|
|
613
|
+
if (this._insideSegment && this._insideSegment.planet) {
|
|
614
|
+
this._terrainAltitude = this._insideSegment.getTerrainPoint(
|
|
615
|
+
this.eye,
|
|
616
|
+
this._insideSegmentPosition,
|
|
617
|
+
this._terrainPoint
|
|
618
|
+
);
|
|
549
619
|
if (this._terrainAltitude < this.minAltitude) {
|
|
550
620
|
this.setAltitude(this.minAltitude);
|
|
551
621
|
}
|
|
@@ -559,7 +629,10 @@ class PlanetCamera extends Camera {
|
|
|
559
629
|
|
|
560
630
|
getHeading() {
|
|
561
631
|
let u = this.eye.normal();
|
|
562
|
-
let f = Vec3.proj_b_to_plane(
|
|
632
|
+
let f = Vec3.proj_b_to_plane(
|
|
633
|
+
this.slope >= 0.97 ? this.getUp() : this.getForward(),
|
|
634
|
+
u
|
|
635
|
+
).normalize(),
|
|
563
636
|
n = Vec3.proj_b_to_plane(Vec3.UP, u).normalize();
|
|
564
637
|
let res = Math.sign(u.dot(f.cross(n))) * Math.acos(f.dot(n)) * math.DEGREES;
|
|
565
638
|
if (res < 0.0) {
|
|
@@ -567,7 +640,6 @@ class PlanetCamera extends Camera {
|
|
|
567
640
|
}
|
|
568
641
|
return res;
|
|
569
642
|
}
|
|
643
|
+
}
|
|
570
644
|
|
|
571
|
-
};
|
|
572
|
-
|
|
573
|
-
export { PlanetCamera };
|
|
645
|
+
export { PlanetCamera };
|