@openglobus/og 0.23.0 → 0.24.0
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/lib/@openglobus/js/Globe.d.ts +0 -1
- package/lib/@openglobus/js/camera/Camera.d.ts +48 -15
- package/lib/@openglobus/js/camera/PlanetCamera.d.ts +13 -0
- package/lib/@openglobus/js/control/MouseNavigation.d.ts +62 -51
- package/lib/@openglobus/js/control/OldMouseNavigation.d.ts +64 -0
- package/lib/@openglobus/js/control/index.d.ts +1 -2
- package/lib/@openglobus/js/entity/Entity.d.ts +24 -20
- package/lib/@openglobus/js/entity/GeoObject.d.ts +0 -9
- package/lib/@openglobus/js/input/MouseHandler.d.ts +1 -0
- package/lib/@openglobus/js/math/Mat3.d.ts +1 -1
- package/lib/@openglobus/js/math/Mat4.d.ts +10 -1
- package/lib/@openglobus/js/math/Plane.d.ts +3 -1
- package/lib/@openglobus/js/math/Quat.d.ts +1 -0
- package/lib/@openglobus/js/math/Ray.d.ts +6 -16
- package/lib/@openglobus/js/math/Vec2.d.ts +22 -0
- package/lib/@openglobus/js/renderer/RendererEvents.d.ts +1 -0
- package/lib/@openglobus/js/scene/Planet.d.ts +4 -0
- package/lib/@openglobus/js/webgl/Handler.d.ts +21 -12
- package/lib/@openglobus/og.esm.js +1 -1
- package/lib/@openglobus/og.esm.js.map +1 -1
- package/lib/@openglobus/og.umd.js +1 -1
- package/lib/@openglobus/og.umd.js.map +1 -1
- package/lib/js/Globe.d.ts +0 -1
- package/lib/js/Globe.js +4 -2
- package/lib/js/Popup.js +1 -1
- package/lib/js/camera/Camera.d.ts +48 -15
- package/lib/js/camera/Camera.js +82 -28
- package/lib/js/camera/PlanetCamera.d.ts +13 -0
- package/lib/js/camera/PlanetCamera.js +52 -5
- package/lib/js/control/CameraLock.js +1 -1
- package/lib/js/control/DebugInfo.js +30 -10
- package/lib/js/control/KeyboardNavigation.js +8 -8
- package/lib/js/control/MouseNavigation.d.ts +62 -51
- package/lib/js/control/MouseNavigation.js +361 -305
- package/lib/js/control/MouseWheelZoomControl.d.ts +0 -44
- package/lib/js/control/MouseWheelZoomControl.js +270 -181
- package/lib/js/control/OldMouseNavigation.d.ts +64 -0
- package/lib/js/control/OldMouseNavigation.js +368 -0
- package/lib/js/control/ScaleControl.js +2 -2
- package/lib/js/control/SimpleNavigation.js +8 -7
- package/lib/js/control/Sun.js +5 -5
- package/lib/js/control/TouchNavigation.js +11 -8
- package/lib/js/control/elevationProfile/ElevationProfileScene.js +2 -1
- package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.js +19 -33
- package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.js +18 -18
- package/lib/js/control/geoObjectEditor/MoveAxisEntity.js +3 -2
- package/lib/js/control/geoObjectEditor/MovePlaneEntity.js +1 -4
- package/lib/js/control/geoObjectEditor/RotateEntity.js +1 -1
- package/lib/js/control/index.d.ts +1 -2
- package/lib/js/control/index.js +1 -2
- package/lib/js/control/visibleExtent/Segment.js +4 -4
- package/lib/js/entity/Entity.d.ts +24 -20
- package/lib/js/entity/Entity.js +62 -47
- package/lib/js/entity/GeoObject.d.ts +0 -9
- package/lib/js/entity/GeoObject.js +0 -3
- package/lib/js/entity/InstanceData.js +6 -3
- package/lib/js/input/MouseHandler.d.ts +1 -0
- package/lib/js/input/MouseHandler.js +12 -1
- package/lib/js/math/Mat3.d.ts +1 -1
- package/lib/js/math/Mat3.js +1 -1
- package/lib/js/math/Mat4.d.ts +10 -1
- package/lib/js/math/Mat4.js +17 -1
- package/lib/js/math/Plane.d.ts +3 -1
- package/lib/js/math/Plane.js +11 -1
- package/lib/js/math/Quat.d.ts +1 -0
- package/lib/js/math/Quat.js +1 -0
- package/lib/js/math/Ray.d.ts +6 -16
- package/lib/js/math/Ray.js +53 -46
- package/lib/js/math/Vec2.d.ts +22 -0
- package/lib/js/math/Vec2.js +32 -0
- package/lib/js/renderer/Renderer.js +10 -6
- package/lib/js/renderer/RendererEvents.d.ts +1 -0
- package/lib/js/renderer/RendererEvents.js +3 -1
- package/lib/js/scene/Planet.d.ts +4 -0
- package/lib/js/scene/Planet.js +24 -3
- package/lib/js/segment/Segment.js +4 -4
- package/lib/js/terrain/GlobusTerrain.js +2 -2
- package/lib/js/webgl/Handler.d.ts +21 -12
- package/lib/js/webgl/Handler.js +42 -33
- package/package.json +2 -2
- package/lib/@openglobus/js/control/EarthNavigation.d.ts +0 -50
- package/lib/@openglobus/js/control/MouseWheelZoomControl.d.ts +0 -44
- package/lib/js/control/EarthNavigation.d.ts +0 -50
- package/lib/js/control/EarthNavigation.js +0 -202
package/lib/js/Globe.d.ts
CHANGED
package/lib/js/Globe.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// #StandWithUkraine
|
|
2
2
|
import { CompassButton } from "./control/CompassButton";
|
|
3
3
|
import { EarthCoordinates } from "./control/EarthCoordinates";
|
|
4
|
-
import { EarthNavigation } from "./control/EarthNavigation";
|
|
5
4
|
import { EmptyTerrain } from "./terrain/EmptyTerrain";
|
|
6
5
|
import { Handler } from "./webgl/Handler";
|
|
7
6
|
import { isEmpty } from "./utils/shared";
|
|
@@ -178,7 +177,7 @@ class Globe {
|
|
|
178
177
|
else {
|
|
179
178
|
this.planet.addControls([
|
|
180
179
|
new ZoomControl(),
|
|
181
|
-
|
|
180
|
+
new MouseNavigation(),
|
|
182
181
|
new TouchNavigation(),
|
|
183
182
|
new EarthCoordinates(),
|
|
184
183
|
new ScaleControl(),
|
|
@@ -262,6 +261,9 @@ class Globe {
|
|
|
262
261
|
t.appendChild(this.$inner);
|
|
263
262
|
}
|
|
264
263
|
}
|
|
264
|
+
else {
|
|
265
|
+
console.warn(`Target container not found. Provided target: ${target}`);
|
|
266
|
+
}
|
|
265
267
|
}
|
|
266
268
|
detach() {
|
|
267
269
|
if (this.$target) {
|
package/lib/js/Popup.js
CHANGED
|
@@ -117,7 +117,7 @@ class Popup extends View {
|
|
|
117
117
|
let look = cart.sub(cam.eye), v = Math.sqrt((f + g) * (f + g) - f * f);
|
|
118
118
|
if (v > look.length() && cam.getForward().dot(look.normalize()) > 0.0) {
|
|
119
119
|
this.el.style.display = "block";
|
|
120
|
-
this.setScreen(cam.
|
|
120
|
+
this.setScreen(cam.project3v(cart));
|
|
121
121
|
}
|
|
122
122
|
else {
|
|
123
123
|
this.el.style.display = "none";
|
|
@@ -6,6 +6,7 @@ import { Renderer } from "../renderer/Renderer";
|
|
|
6
6
|
import { Vec2, NumberArray2 } from "../math/Vec2";
|
|
7
7
|
import { Vec3 } from "../math/Vec3";
|
|
8
8
|
import { Sphere } from "../bv/Sphere";
|
|
9
|
+
import { Quat } from "../math/Quat";
|
|
9
10
|
type CameraEvents = ["viewchange", "moveend"];
|
|
10
11
|
export interface ICameraParams {
|
|
11
12
|
eye?: Vec3;
|
|
@@ -89,22 +90,28 @@ declare class Camera {
|
|
|
89
90
|
protected _normalMatrix: Mat3;
|
|
90
91
|
/**
|
|
91
92
|
* Camera right vector.
|
|
92
|
-
* @
|
|
93
|
+
* @protected
|
|
93
94
|
* @type {Vec3}
|
|
94
95
|
*/
|
|
95
96
|
_r: Vec3;
|
|
96
97
|
/**
|
|
97
98
|
* Camera up vector.
|
|
98
|
-
* @
|
|
99
|
+
* @protected
|
|
99
100
|
* @type {Vec3}
|
|
100
101
|
*/
|
|
101
102
|
_u: Vec3;
|
|
102
103
|
/**
|
|
103
104
|
* Camera backward vector.
|
|
104
|
-
* @
|
|
105
|
+
* @protected
|
|
105
106
|
* @type {Vec3}
|
|
106
107
|
*/
|
|
107
108
|
_b: Vec3;
|
|
109
|
+
/**
|
|
110
|
+
* Camera forward vector.
|
|
111
|
+
* @protected
|
|
112
|
+
* @type {Vec3}
|
|
113
|
+
*/
|
|
114
|
+
_f: Vec3;
|
|
108
115
|
protected _pr: Vec3;
|
|
109
116
|
protected _pu: Vec3;
|
|
110
117
|
protected _pb: Vec3;
|
|
@@ -208,23 +215,40 @@ declare class Camera {
|
|
|
208
215
|
*/
|
|
209
216
|
slide(du: number, dv: number, dn: number): void;
|
|
210
217
|
/**
|
|
211
|
-
* Roll the camera to the angle in
|
|
218
|
+
* Roll the camera to the angle in radians
|
|
219
|
+
* @public
|
|
220
|
+
* @param {number} angle - Delta roll angle in radians
|
|
221
|
+
*/
|
|
222
|
+
setRoll(angle: number): void;
|
|
223
|
+
/**
|
|
224
|
+
* Pitch the camera to the angle in radians
|
|
212
225
|
* @public
|
|
213
|
-
* @param {number} angle - Delta
|
|
226
|
+
* @param {number} angle - Delta pitch angle in radians
|
|
214
227
|
*/
|
|
215
|
-
|
|
228
|
+
setPitch(angle: number): void;
|
|
216
229
|
/**
|
|
217
|
-
*
|
|
230
|
+
* Yaw the camera to the angle in radians
|
|
218
231
|
* @public
|
|
219
|
-
* @param {number} angle - Delta
|
|
232
|
+
* @param {number} angle - Delta yaw angle in radians
|
|
233
|
+
*/
|
|
234
|
+
setYaw(angle: number): void;
|
|
235
|
+
setPitchYawRoll(pitch: number, yaw: number, roll: number): void;
|
|
236
|
+
getPitch(): number;
|
|
237
|
+
getYaw(): number;
|
|
238
|
+
getRoll(): number;
|
|
239
|
+
/**
|
|
240
|
+
* Returns camera quaternion
|
|
220
241
|
*/
|
|
221
|
-
|
|
242
|
+
getRotation(): Quat;
|
|
243
|
+
setRotation(rot: Quat, up?: Vec3, right?: Vec3, back?: Vec3): void;
|
|
244
|
+
rotate(rot: Quat): void;
|
|
222
245
|
/**
|
|
223
|
-
*
|
|
246
|
+
* Returns normal vector direction to the unprojected screen point from camera eye
|
|
224
247
|
* @public
|
|
225
|
-
* @param {
|
|
248
|
+
* @param {Vec2} pos - Screen X coordinate
|
|
249
|
+
* @returns {Vec3} - Direction vector
|
|
226
250
|
*/
|
|
227
|
-
|
|
251
|
+
unproject2v(pos: Vec2): Vec3;
|
|
228
252
|
/**
|
|
229
253
|
* Returns normal vector direction to the unprojected screen point from camera eye
|
|
230
254
|
* @public
|
|
@@ -239,7 +263,16 @@ declare class Camera {
|
|
|
239
263
|
* @param {Vec3} v - Cartesian 3d coordinates
|
|
240
264
|
* @returns {Vec2} - Screen point coordinates
|
|
241
265
|
*/
|
|
242
|
-
|
|
266
|
+
project3v(v: Vec3): Vec2;
|
|
267
|
+
/**
|
|
268
|
+
* Gets projected 3d point to the 2d screen coordinates
|
|
269
|
+
* @public
|
|
270
|
+
* @param {number} x - X coordinate
|
|
271
|
+
* @param {number} y - Y coordinate
|
|
272
|
+
* @param {number} z - Z coordinate
|
|
273
|
+
* @returns {Vec2} - Screen point coordinates
|
|
274
|
+
*/
|
|
275
|
+
project(x: number, y: number, z: number): Vec2;
|
|
243
276
|
/**
|
|
244
277
|
* Rotates camera around center point
|
|
245
278
|
* @public
|
|
@@ -249,7 +282,7 @@ declare class Camera {
|
|
|
249
282
|
* @param {Vec3} [center] - Point that the camera rotates around
|
|
250
283
|
* @param {Vec3} [up] - Camera up vector
|
|
251
284
|
*/
|
|
252
|
-
rotateAround(angle: number, isArc?: boolean, center?: Vec3
|
|
285
|
+
rotateAround(angle: number, isArc?: boolean, center?: Vec3, up?: Vec3): void;
|
|
253
286
|
/**
|
|
254
287
|
* Rotates camera around center point by horizontal.
|
|
255
288
|
* @public
|
|
@@ -259,7 +292,7 @@ declare class Camera {
|
|
|
259
292
|
* @param {Vec3} [center] - Point that the camera rotates around.
|
|
260
293
|
* @param {Vec3} [up] - Camera up vector.
|
|
261
294
|
*/
|
|
262
|
-
rotateHorizontal(angle: number, isArc?: boolean, center?: Vec3
|
|
295
|
+
rotateHorizontal(angle: number, isArc?: boolean, center?: Vec3, up?: Vec3): void;
|
|
263
296
|
/**
|
|
264
297
|
* Rotates camera around center point by vertical.
|
|
265
298
|
* @param {number} angle - Rotation angle in radians.
|
package/lib/js/camera/Camera.js
CHANGED
|
@@ -7,6 +7,7 @@ import { Vec2 } from "../math/Vec2";
|
|
|
7
7
|
import { Vec3 } from "../math/Vec3";
|
|
8
8
|
import { Vec4 } from "../math/Vec4";
|
|
9
9
|
import { Quat } from "../math/Quat";
|
|
10
|
+
import { RADIANS } from "../math";
|
|
10
11
|
const EVENT_NAMES = [
|
|
11
12
|
/**
|
|
12
13
|
* When camera has been updated.
|
|
@@ -50,6 +51,7 @@ class Camera {
|
|
|
50
51
|
this._r = new Vec3(1.0, 0.0, 0.0);
|
|
51
52
|
this._u = new Vec3(0.0, 1.0, 0.0);
|
|
52
53
|
this._b = new Vec3(0.0, 0.0, 1.0);
|
|
54
|
+
this._f = this._b.negateTo();
|
|
53
55
|
// Previous frame values
|
|
54
56
|
this._pr = this._r.clone();
|
|
55
57
|
this._pu = this._u.clone();
|
|
@@ -147,7 +149,7 @@ class Camera {
|
|
|
147
149
|
return this._r.negateTo();
|
|
148
150
|
}
|
|
149
151
|
getForward() {
|
|
150
|
-
return this.
|
|
152
|
+
return this._f.clone();
|
|
151
153
|
}
|
|
152
154
|
getBackward() {
|
|
153
155
|
return this._b.clone();
|
|
@@ -218,7 +220,7 @@ class Camera {
|
|
|
218
220
|
this._tanViewAngle_hradOneByHeight =
|
|
219
221
|
this._tanViewAngle_hrad * this.renderer.handler._oneByHeight;
|
|
220
222
|
let c = this.renderer.handler.canvas;
|
|
221
|
-
this._projSizeConst = Math.min(c.clientWidth < 512 ? 512 : c.clientWidth, c.clientHeight < 512 ? 512 : c.clientHeight) / (angle *
|
|
223
|
+
this._projSizeConst = Math.min(c.clientWidth < 512 ? 512 : c.clientWidth, c.clientHeight < 512 ? 512 : c.clientHeight) / (angle * RADIANS);
|
|
222
224
|
for (let i = 0, len = this.frustums.length; i < len; i++) {
|
|
223
225
|
this.frustums[i].setProjectionMatrix(angle, aspect, this.frustums[i].near, this.frustums[i].far);
|
|
224
226
|
}
|
|
@@ -264,6 +266,7 @@ class Camera {
|
|
|
264
266
|
this._b.normalize();
|
|
265
267
|
this._r.normalize();
|
|
266
268
|
this._u.copy(this._b.cross(this._r));
|
|
269
|
+
this._f.set(-this._b.x, -this._b.y, -this._b.z);
|
|
267
270
|
return this;
|
|
268
271
|
}
|
|
269
272
|
/**
|
|
@@ -276,6 +279,7 @@ class Camera {
|
|
|
276
279
|
this._b.set(this.eye.x - look.x, this.eye.y - look.y, this.eye.z - look.z);
|
|
277
280
|
this._r.copy((up || this._u).cross(this._b));
|
|
278
281
|
this._b.normalize();
|
|
282
|
+
this._f.set(-this._b.x, -this._b.y, -this._b.z);
|
|
279
283
|
this._r.normalize();
|
|
280
284
|
this._u.copy(this._b.cross(this._r));
|
|
281
285
|
}
|
|
@@ -292,41 +296,82 @@ class Camera {
|
|
|
292
296
|
this.eye.z += du * this._r.z + dv * this._u.z + dn * this._b.z;
|
|
293
297
|
}
|
|
294
298
|
/**
|
|
295
|
-
* Roll the camera to the angle in
|
|
299
|
+
* Roll the camera to the angle in radians
|
|
296
300
|
* @public
|
|
297
|
-
* @param {number} angle - Delta roll angle in
|
|
301
|
+
* @param {number} angle - Delta roll angle in radians
|
|
298
302
|
*/
|
|
299
|
-
|
|
300
|
-
let cs = Math.cos(
|
|
301
|
-
let sn = Math.sin(
|
|
303
|
+
setRoll(angle) {
|
|
304
|
+
let cs = Math.cos(angle);
|
|
305
|
+
let sn = Math.sin(angle);
|
|
302
306
|
let t = this._r.clone();
|
|
303
307
|
this._r.set(cs * t.x - sn * this._u.x, cs * t.y - sn * this._u.y, cs * t.z - sn * this._u.z);
|
|
304
308
|
this._u.set(sn * t.x + cs * this._u.x, sn * t.y + cs * this._u.y, sn * t.z + cs * this._u.z);
|
|
305
309
|
}
|
|
306
310
|
/**
|
|
307
|
-
* Pitch the camera to the angle in
|
|
311
|
+
* Pitch the camera to the angle in radians
|
|
308
312
|
* @public
|
|
309
|
-
* @param {number} angle - Delta pitch angle in
|
|
313
|
+
* @param {number} angle - Delta pitch angle in radians
|
|
310
314
|
*/
|
|
311
|
-
|
|
312
|
-
let cs = Math.cos(
|
|
313
|
-
let sn = Math.sin(
|
|
314
|
-
let t = this._b
|
|
315
|
+
setPitch(angle) {
|
|
316
|
+
let cs = Math.cos(angle);
|
|
317
|
+
let sn = Math.sin(angle);
|
|
318
|
+
let t = this._b;
|
|
315
319
|
this._b.set(cs * t.x - sn * this._u.x, cs * t.y - sn * this._u.y, cs * t.z - sn * this._u.z);
|
|
316
320
|
this._u.set(sn * t.x + cs * this._u.x, sn * t.y + cs * this._u.y, sn * t.z + cs * this._u.z);
|
|
317
321
|
}
|
|
318
322
|
/**
|
|
319
|
-
* Yaw the camera to the angle in
|
|
323
|
+
* Yaw the camera to the angle in radians
|
|
320
324
|
* @public
|
|
321
|
-
* @param {number} angle - Delta yaw angle in
|
|
325
|
+
* @param {number} angle - Delta yaw angle in radians
|
|
322
326
|
*/
|
|
323
|
-
|
|
324
|
-
let cs = Math.cos(
|
|
325
|
-
let sn = Math.sin(
|
|
326
|
-
let t = this._r
|
|
327
|
+
setYaw(angle) {
|
|
328
|
+
let cs = Math.cos(angle);
|
|
329
|
+
let sn = Math.sin(angle);
|
|
330
|
+
let t = this._r;
|
|
327
331
|
this._r.set(cs * t.x - sn * this._b.x, cs * t.y - sn * this._b.y, cs * t.z - sn * this._b.z);
|
|
328
332
|
this._b.set(sn * t.x + cs * this._b.x, sn * t.y + cs * this._b.y, sn * t.z + cs * this._b.z);
|
|
329
333
|
}
|
|
334
|
+
setPitchYawRoll(pitch, yaw, roll) {
|
|
335
|
+
let qRot = new Quat();
|
|
336
|
+
qRot.setPitchYawRoll(pitch, yaw, roll);
|
|
337
|
+
this.setRotation(qRot);
|
|
338
|
+
}
|
|
339
|
+
getPitch() {
|
|
340
|
+
return this.getRotation().getPitch();
|
|
341
|
+
}
|
|
342
|
+
getYaw() {
|
|
343
|
+
return this.getRotation().getYaw();
|
|
344
|
+
}
|
|
345
|
+
getRoll() {
|
|
346
|
+
return this.getRotation().getRoll();
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Returns camera quaternion
|
|
350
|
+
*/
|
|
351
|
+
getRotation() {
|
|
352
|
+
return Quat.getLookRotation(this._f, this._u).conjugate();
|
|
353
|
+
}
|
|
354
|
+
setRotation(rot, up, right, back) {
|
|
355
|
+
rot.mulVec3Res(up || new Vec3(0, 1, 0), this._u);
|
|
356
|
+
rot.mulVec3Res(right || new Vec3(1, 0, 0), this._r);
|
|
357
|
+
rot.mulVec3Res(back || new Vec3(0, 0, 1), this._b);
|
|
358
|
+
this._f.set(-this._b.x, -this._b.y, -this._b.z);
|
|
359
|
+
}
|
|
360
|
+
rotate(rot) {
|
|
361
|
+
rot.mulVec3Res(this._u, this._u);
|
|
362
|
+
rot.mulVec3Res(this._r, this._r);
|
|
363
|
+
rot.mulVec3Res(this._b, this._b);
|
|
364
|
+
this._f.set(-this._b.x, -this._b.y, -this._b.z);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Returns normal vector direction to the unprojected screen point from camera eye
|
|
368
|
+
* @public
|
|
369
|
+
* @param {Vec2} pos - Screen X coordinate
|
|
370
|
+
* @returns {Vec3} - Direction vector
|
|
371
|
+
*/
|
|
372
|
+
unproject2v(pos) {
|
|
373
|
+
return this.unproject(pos.x, pos.y);
|
|
374
|
+
}
|
|
330
375
|
/**
|
|
331
376
|
* Returns normal vector direction to the unprojected screen point from camera eye
|
|
332
377
|
* @public
|
|
@@ -346,8 +391,19 @@ class Camera {
|
|
|
346
391
|
* @param {Vec3} v - Cartesian 3d coordinates
|
|
347
392
|
* @returns {Vec2} - Screen point coordinates
|
|
348
393
|
*/
|
|
349
|
-
|
|
350
|
-
|
|
394
|
+
project3v(v) {
|
|
395
|
+
return this.project(v.x, v.y, v.z);
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Gets projected 3d point to the 2d screen coordinates
|
|
399
|
+
* @public
|
|
400
|
+
* @param {number} x - X coordinate
|
|
401
|
+
* @param {number} y - Y coordinate
|
|
402
|
+
* @param {number} z - Z coordinate
|
|
403
|
+
* @returns {Vec2} - Screen point coordinates
|
|
404
|
+
*/
|
|
405
|
+
project(x, y, z) {
|
|
406
|
+
let r = this.frustums[0].projectionViewMatrix.mulVec4(new Vec4(x, y, z, 1.0)), c = this.renderer.handler.canvas;
|
|
351
407
|
return new Vec2((1 + r.x / r.w) * c.width * 0.5, (1 - r.y / r.w) * c.height * 0.5);
|
|
352
408
|
}
|
|
353
409
|
/**
|
|
@@ -359,17 +415,15 @@ class Camera {
|
|
|
359
415
|
* @param {Vec3} [center] - Point that the camera rotates around
|
|
360
416
|
* @param {Vec3} [up] - Camera up vector
|
|
361
417
|
*/
|
|
362
|
-
rotateAround(angle, isArc, center, up) {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
let
|
|
366
|
-
let tr = new Mat4().setIdentity().translate(center);
|
|
367
|
-
let ntr = new Mat4().setIdentity().translate(center.negateTo());
|
|
368
|
-
let trm = tr.mul(rot).mul(ntr);
|
|
418
|
+
rotateAround(angle, isArc = false, center = Vec3.ZERO, up = Vec3.UP) {
|
|
419
|
+
up = isArc ? this._u : up;
|
|
420
|
+
let rot = Mat4.getRotation(angle, up);
|
|
421
|
+
let trm = Mat4.getRotationAroundPoint(angle, center, up);
|
|
369
422
|
this.eye = trm.mulVec3(this.eye);
|
|
370
423
|
this._u = rot.mulVec3(this._u).normalize();
|
|
371
424
|
this._r = rot.mulVec3(this._r).normalize();
|
|
372
425
|
this._b = rot.mulVec3(this._b).normalize();
|
|
426
|
+
this._f.set(-this._b.x, -this._b.y, -this._b.z);
|
|
373
427
|
}
|
|
374
428
|
/**
|
|
375
429
|
* Rotates camera around center point by horizontal.
|
|
@@ -228,7 +228,20 @@ declare class PlanetCamera extends Camera {
|
|
|
228
228
|
checkFly(): void;
|
|
229
229
|
checkTerrainCollision(): Vec3 | undefined;
|
|
230
230
|
getSurfaceVisibleDistance(d: number): number;
|
|
231
|
+
/**
|
|
232
|
+
* should be yje same as getYaw
|
|
233
|
+
*/
|
|
231
234
|
getHeading(): number;
|
|
232
235
|
isVisible(poi: Vec3): boolean;
|
|
236
|
+
getPitch(): number;
|
|
237
|
+
/**
|
|
238
|
+
* should be the same as getHeading
|
|
239
|
+
*/
|
|
240
|
+
getYaw(): number;
|
|
241
|
+
getRoll(): number;
|
|
242
|
+
setPitch(a: number): void;
|
|
243
|
+
setYaw(a: number): void;
|
|
244
|
+
setRoll(a: number): void;
|
|
245
|
+
setPitchYawRoll(pitch: number, yaw: number, roll: number): void;
|
|
233
246
|
}
|
|
234
247
|
export { PlanetCamera };
|
|
@@ -7,6 +7,7 @@ import { Mat4 } from "../math/Mat4";
|
|
|
7
7
|
import { Quat } from "../math/Quat";
|
|
8
8
|
import { Ray } from "../math/Ray";
|
|
9
9
|
import { Vec3 } from "../math/Vec3";
|
|
10
|
+
import { RADIANS } from "../math";
|
|
10
11
|
/**
|
|
11
12
|
* Planet camera.
|
|
12
13
|
* @class
|
|
@@ -167,7 +168,7 @@ class PlanetCamera extends Camera {
|
|
|
167
168
|
let up = right.cross(direction).normalize();
|
|
168
169
|
let _h = Math.max(Math.abs(up.dot(northWest)), Math.abs(up.dot(southEast)), Math.abs(up.dot(northEast)), Math.abs(up.dot(southWest)));
|
|
169
170
|
let _w = Math.max(Math.abs(right.dot(northWest)), Math.abs(right.dot(southEast)), Math.abs(right.dot(northEast)), Math.abs(right.dot(southWest)));
|
|
170
|
-
let tanPhi = Math.tan(this._viewAngle *
|
|
171
|
+
let tanPhi = Math.tan(this._viewAngle * RADIANS * 0.5);
|
|
171
172
|
let tanTheta = this._aspect * tanPhi;
|
|
172
173
|
let d = Math.max(_w / tanTheta, _h / tanPhi);
|
|
173
174
|
center.normalize();
|
|
@@ -329,6 +330,7 @@ class PlanetCamera extends Camera {
|
|
|
329
330
|
this._framesArr = [];
|
|
330
331
|
this._framesCounter = -1;
|
|
331
332
|
this._frameCallback = null;
|
|
333
|
+
this.planet.stopDragging();
|
|
332
334
|
}
|
|
333
335
|
/**
|
|
334
336
|
* Returns camera is flying.
|
|
@@ -345,7 +347,7 @@ class PlanetCamera extends Camera {
|
|
|
345
347
|
* @param {boolean} [spin] - If its true rotates around globe spin.
|
|
346
348
|
*/
|
|
347
349
|
rotateLeft(angle, spin) {
|
|
348
|
-
this.rotateHorizontal(angle
|
|
350
|
+
this.rotateHorizontal(angle, spin !== true, Vec3.ZERO);
|
|
349
351
|
this.update();
|
|
350
352
|
}
|
|
351
353
|
/**
|
|
@@ -355,7 +357,7 @@ class PlanetCamera extends Camera {
|
|
|
355
357
|
* @param {boolean} [spin] - If its true rotates around globe spin.
|
|
356
358
|
*/
|
|
357
359
|
rotateRight(angle, spin) {
|
|
358
|
-
this.rotateHorizontal(-angle
|
|
360
|
+
this.rotateHorizontal(-angle, spin !== true, Vec3.ZERO);
|
|
359
361
|
this.update();
|
|
360
362
|
}
|
|
361
363
|
/**
|
|
@@ -364,7 +366,7 @@ class PlanetCamera extends Camera {
|
|
|
364
366
|
* @param {number} angle - Rotation angle.
|
|
365
367
|
*/
|
|
366
368
|
rotateUp(angle) {
|
|
367
|
-
this.rotateVertical(angle
|
|
369
|
+
this.rotateVertical(angle, Vec3.ZERO);
|
|
368
370
|
this.update();
|
|
369
371
|
}
|
|
370
372
|
/**
|
|
@@ -373,7 +375,7 @@ class PlanetCamera extends Camera {
|
|
|
373
375
|
* @param {number} angle - Rotation angle.
|
|
374
376
|
*/
|
|
375
377
|
rotateDown(angle) {
|
|
376
|
-
this.rotateVertical(-angle
|
|
378
|
+
this.rotateVertical(-angle, Vec3.ZERO);
|
|
377
379
|
this.update();
|
|
378
380
|
}
|
|
379
381
|
rotateVertical(angle, center, minSlope = 0) {
|
|
@@ -398,6 +400,7 @@ class PlanetCamera extends Camera {
|
|
|
398
400
|
this._u = u;
|
|
399
401
|
this._r = r;
|
|
400
402
|
this._b = b;
|
|
403
|
+
this._f.set(-b.x, -b.y, -b.z);
|
|
401
404
|
}
|
|
402
405
|
}
|
|
403
406
|
else {
|
|
@@ -405,6 +408,7 @@ class PlanetCamera extends Camera {
|
|
|
405
408
|
this._u = u;
|
|
406
409
|
this._r = r;
|
|
407
410
|
this._b = b;
|
|
411
|
+
this._f.set(-b.x, -b.y, -b.z);
|
|
408
412
|
}
|
|
409
413
|
}
|
|
410
414
|
/**
|
|
@@ -421,6 +425,7 @@ class PlanetCamera extends Camera {
|
|
|
421
425
|
this._r = this._framesArr[c].u;
|
|
422
426
|
this._u = this._framesArr[c].v;
|
|
423
427
|
this._b = this._framesArr[c].n;
|
|
428
|
+
this._f.set(-this._b.x, -this._b.y, -this._b.z);
|
|
424
429
|
if (this._frameCallback) {
|
|
425
430
|
this._frameCallback();
|
|
426
431
|
}
|
|
@@ -449,6 +454,9 @@ class PlanetCamera extends Camera {
|
|
|
449
454
|
let R = this.planet.ellipsoid.equatorialSize;
|
|
450
455
|
return R * Math.acos(R / (R + this._lonLat.height + d));
|
|
451
456
|
}
|
|
457
|
+
/**
|
|
458
|
+
* should be yje same as getYaw
|
|
459
|
+
*/
|
|
452
460
|
getHeading() {
|
|
453
461
|
let u = this.eye.getNormal();
|
|
454
462
|
let f = Vec3.proj_b_to_plane(this.slope >= 0.97 ? this.getUp() : this.getForward(), u).normalize(), n = Vec3.proj_b_to_plane(Vec3.NORTH, u).normalize();
|
|
@@ -462,5 +470,44 @@ class PlanetCamera extends Camera {
|
|
|
462
470
|
let e = this.eye.length();
|
|
463
471
|
return this.eye.distance(poi) < Math.sqrt(e * e - this.planet.ellipsoid.equatorialSizeSqr);
|
|
464
472
|
}
|
|
473
|
+
getPitch() {
|
|
474
|
+
let qFrame = this.planet.getFrameRotation(this.eye);
|
|
475
|
+
return qFrame.conjugate().inverse().mul(this.getRotation()).getPitch();
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* should be the same as getHeading
|
|
479
|
+
*/
|
|
480
|
+
getYaw() {
|
|
481
|
+
let qFrame = this.planet.getFrameRotation(this.eye);
|
|
482
|
+
return qFrame.conjugate().inverse().mul(this.getRotation()).getYaw();
|
|
483
|
+
}
|
|
484
|
+
getRoll() {
|
|
485
|
+
let qFrame = this.planet.getFrameRotation(this.eye);
|
|
486
|
+
return qFrame.conjugate().inverse().mul(this.getRotation()).getRoll();
|
|
487
|
+
}
|
|
488
|
+
setPitch(a) {
|
|
489
|
+
let qFrame = this.planet.getFrameRotation(this.eye);
|
|
490
|
+
let qRot = new Quat();
|
|
491
|
+
qRot.setPitchYawRoll(a, this.getYaw(), this.getRoll(), qFrame);
|
|
492
|
+
this.setRotation(qRot);
|
|
493
|
+
}
|
|
494
|
+
setYaw(a) {
|
|
495
|
+
let qFrame = this.planet.getFrameRotation(this.eye);
|
|
496
|
+
let qRot = new Quat();
|
|
497
|
+
qRot.setPitchYawRoll(this.getYaw(), a, this.getRoll(), qFrame);
|
|
498
|
+
this.setRotation(qRot);
|
|
499
|
+
}
|
|
500
|
+
setRoll(a) {
|
|
501
|
+
let qFrame = this.planet.getFrameRotation(this.eye);
|
|
502
|
+
let qRot = new Quat();
|
|
503
|
+
qRot.setPitchYawRoll(this.getPitch(), this.getYaw(), a, qFrame);
|
|
504
|
+
this.setRotation(qRot);
|
|
505
|
+
}
|
|
506
|
+
setPitchYawRoll(pitch, yaw, roll) {
|
|
507
|
+
let qFrame = this.planet.getFrameRotation(this.eye);
|
|
508
|
+
let qRot = new Quat();
|
|
509
|
+
qRot.setPitchYawRoll(pitch, yaw, roll, qFrame).conjugate();
|
|
510
|
+
this.setRotation(qRot);
|
|
511
|
+
}
|
|
465
512
|
}
|
|
466
513
|
export { PlanetCamera };
|
|
@@ -139,7 +139,7 @@ export class CameraLock extends Control {
|
|
|
139
139
|
_deactivateNav() {
|
|
140
140
|
if (this.renderer && this.renderer.controls.mouseNavigation) {
|
|
141
141
|
this.renderer.controls.mouseNavigation.deactivate();
|
|
142
|
-
this.renderer.controls.mouseNavigation.
|
|
142
|
+
this.renderer.controls.mouseNavigation.stop();
|
|
143
143
|
}
|
|
144
144
|
if (this.renderer && this.renderer.controls.simpleNavigation) {
|
|
145
145
|
this.renderer.controls.simpleNavigation.deactivate();
|
|
@@ -2,6 +2,7 @@ import { Control } from "./Control";
|
|
|
2
2
|
import { Dialog } from "../ui/Dialog";
|
|
3
3
|
import { ToggleButton } from "../ui/ToggleButton";
|
|
4
4
|
import { CanvasTiles } from "../layer/CanvasTiles";
|
|
5
|
+
import { DEGREES } from "../math";
|
|
5
6
|
const ICON_LOCK_BUTTON_SVG = `<?xml version="1.0" encoding="utf-8"?>
|
|
6
7
|
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
|
7
8
|
<svg fill="#000000" width="800px" height="800px" viewBox="-7.5 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
|
@@ -195,16 +196,6 @@ export class DebugInfo extends Control {
|
|
|
195
196
|
return "";
|
|
196
197
|
}
|
|
197
198
|
},
|
|
198
|
-
{
|
|
199
|
-
label: "height/alt, m",
|
|
200
|
-
frame: () => `<div style="width:190px">${(p.camera._lonLat.height).toFixed(2) +
|
|
201
|
-
" / " +
|
|
202
|
-
(p.camera.getAltitude()).toFixed(2)}</div>`
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
label: "cam.slope",
|
|
206
|
-
frame: () => p.camera.slope.toFixed(3)
|
|
207
|
-
},
|
|
208
199
|
{
|
|
209
200
|
label: "lodSize",
|
|
210
201
|
frame: () => Math.round(p.lodSize)
|
|
@@ -220,6 +211,35 @@ export class DebugInfo extends Control {
|
|
|
220
211
|
{
|
|
221
212
|
label: "-------------------------"
|
|
222
213
|
},
|
|
214
|
+
{
|
|
215
|
+
label: "Pitch, deg",
|
|
216
|
+
frame: () => (p.camera.getPitch() * DEGREES).toFixed(2)
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
label: "Yaw, deg",
|
|
220
|
+
frame: () => (p.camera.getYaw() * DEGREES).toFixed(2)
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
label: "Roll, deg",
|
|
224
|
+
frame: () => (p.camera.getRoll() * DEGREES).toFixed(2)
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
label: "Lon, Lat",
|
|
228
|
+
frame: () => `<div style="width:190px">${(p.camera._lonLat.lon).toFixed(7)}, ${(p.camera._lonLat.lon).toFixed(7)}</div>`
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
label: "height/alt, m",
|
|
232
|
+
frame: () => `<div style="width:190px">${(p.camera._lonLat.height).toFixed(2) +
|
|
233
|
+
" / " +
|
|
234
|
+
(p.camera.getAltitude()).toFixed(2)}</div>`
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
label: "cam.slope",
|
|
238
|
+
frame: () => p.camera.slope.toFixed(3)
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
label: "-------------------------"
|
|
242
|
+
},
|
|
223
243
|
{
|
|
224
244
|
label: "_renderCompleted / renderCompletedActivated",
|
|
225
245
|
frame: () => `${p._renderCompleted} / ${p._renderCompletedActivated}`
|
|
@@ -71,7 +71,7 @@ export class KeyboardNavigation extends Control {
|
|
|
71
71
|
onCameraLookUp() {
|
|
72
72
|
let cam = this.planet.camera;
|
|
73
73
|
if (this.renderer.events.isKeyPressed(input.KEY_SHIFT)) {
|
|
74
|
-
cam.
|
|
74
|
+
cam.setPitch(15 / this.renderer.handler.deltaTime);
|
|
75
75
|
}
|
|
76
76
|
else {
|
|
77
77
|
cam.rotateVertical((cam.getAltitude() / 3000000) * math.RADIANS, Vec3.ZERO);
|
|
@@ -80,7 +80,7 @@ export class KeyboardNavigation extends Control {
|
|
|
80
80
|
onCameraLookDown() {
|
|
81
81
|
let cam = this.planet.camera;
|
|
82
82
|
if (this.renderer.events.isKeyPressed(input.KEY_SHIFT)) {
|
|
83
|
-
cam.
|
|
83
|
+
cam.setPitch(-15 / this.renderer.handler.deltaTime);
|
|
84
84
|
}
|
|
85
85
|
else {
|
|
86
86
|
cam.rotateVertical((-cam.getAltitude() / 3000000) * math.RADIANS, Vec3.ZERO);
|
|
@@ -89,7 +89,7 @@ export class KeyboardNavigation extends Control {
|
|
|
89
89
|
onCameraLookLeft() {
|
|
90
90
|
let cam = this.planet.camera;
|
|
91
91
|
if (this.renderer.events.isKeyPressed(input.KEY_SHIFT)) {
|
|
92
|
-
cam.
|
|
92
|
+
cam.setRoll(15 / this.renderer.handler.deltaTime);
|
|
93
93
|
}
|
|
94
94
|
else {
|
|
95
95
|
cam.rotateHorizontal((cam.getAltitude() / 3000000) * math.RADIANS);
|
|
@@ -98,7 +98,7 @@ export class KeyboardNavigation extends Control {
|
|
|
98
98
|
onCameraLookRight() {
|
|
99
99
|
let cam = this.planet.camera;
|
|
100
100
|
if (this.renderer.events.isKeyPressed(input.KEY_SHIFT)) {
|
|
101
|
-
cam.
|
|
101
|
+
cam.setRoll(-15 / this.renderer.handler.deltaTime);
|
|
102
102
|
}
|
|
103
103
|
else {
|
|
104
104
|
cam.rotateHorizontal((-cam.getAltitude() / 3000000) * math.RADIANS);
|
|
@@ -107,7 +107,7 @@ export class KeyboardNavigation extends Control {
|
|
|
107
107
|
onCameraTurnLeft() {
|
|
108
108
|
let cam = this.planet.camera;
|
|
109
109
|
if (this.renderer.events.isKeyPressed(input.KEY_SHIFT)) {
|
|
110
|
-
cam.
|
|
110
|
+
cam.setYaw(15 / this.renderer.handler.deltaTime);
|
|
111
111
|
}
|
|
112
112
|
else {
|
|
113
113
|
cam.rotateHorizontal((cam.getAltitude() / 3000000) * math.RADIANS);
|
|
@@ -116,7 +116,7 @@ export class KeyboardNavigation extends Control {
|
|
|
116
116
|
onCameraTurnRight() {
|
|
117
117
|
let cam = this.planet.camera;
|
|
118
118
|
if (this.renderer.events.isKeyPressed(input.KEY_SHIFT)) {
|
|
119
|
-
cam.
|
|
119
|
+
cam.setYaw(-15 / this.renderer.handler.deltaTime);
|
|
120
120
|
}
|
|
121
121
|
else {
|
|
122
122
|
cam.rotateHorizontal((-cam.getAltitude() / 3000000) * math.RADIANS, false, Vec3.ZERO);
|
|
@@ -135,9 +135,9 @@ export class KeyboardNavigation extends Control {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
onCameraRollLeft() {
|
|
138
|
-
this.planet.camera.
|
|
138
|
+
this.planet.camera.setRoll(-15 / this.renderer.handler.deltaTime);
|
|
139
139
|
}
|
|
140
140
|
onCameraRollRight() {
|
|
141
|
-
this.planet.camera.
|
|
141
|
+
this.planet.camera.setRoll(15 / this.renderer.handler.deltaTime);
|
|
142
142
|
}
|
|
143
143
|
}
|