@openglobus/og 0.22.2 → 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/css/og.css +137 -1
- package/lib/@openglobus/js/Globe.d.ts +0 -1
- package/lib/@openglobus/js/Object3d.d.ts +20 -10
- package/lib/@openglobus/js/camera/Camera.d.ts +57 -15
- package/lib/@openglobus/js/camera/Frustum.d.ts +3 -0
- package/lib/@openglobus/js/camera/PlanetCamera.d.ts +13 -0
- package/lib/@openglobus/js/control/CameraLock.d.ts +38 -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/SimpleNavigation.d.ts +27 -10
- package/lib/@openglobus/js/control/geoObjectEditor/ArrowEntity.d.ts +15 -0
- package/lib/@openglobus/js/control/geoObjectEditor/AxisTrackEntity.d.ts +9 -0
- package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditor.d.ts +13 -0
- package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorDialog.d.ts +69 -0
- package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +78 -9
- package/lib/@openglobus/js/control/geoObjectEditor/MoveAxisEntity.d.ts +17 -0
- package/lib/@openglobus/js/control/geoObjectEditor/MovePlaneEntity.d.ts +7 -0
- package/lib/@openglobus/js/control/geoObjectEditor/RotateEntity.d.ts +9 -0
- package/lib/@openglobus/js/control/geoObjectEditor/colors.d.ts +8 -0
- package/lib/@openglobus/js/control/index.d.ts +3 -2
- package/lib/@openglobus/js/entity/Entity.d.ts +282 -19
- package/lib/@openglobus/js/entity/EntityCollection.d.ts +8 -9
- package/lib/@openglobus/js/entity/GeoObject.d.ts +135 -39
- package/lib/@openglobus/js/entity/GeoObjectHandler.d.ts +39 -63
- package/lib/@openglobus/js/entity/InstanceData.d.ts +76 -0
- package/lib/@openglobus/js/entity/Polyline.d.ts +19 -6
- package/lib/@openglobus/js/entity/PolylineHandler.d.ts +7 -0
- package/lib/@openglobus/js/index.d.ts +2 -1
- package/lib/@openglobus/js/input/MouseHandler.d.ts +1 -0
- package/lib/@openglobus/js/layer/Vector.d.ts +4 -0
- package/lib/@openglobus/js/light/LightSource.d.ts +1 -139
- 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 +47 -33
- package/lib/@openglobus/js/math/Ray.d.ts +10 -14
- package/lib/@openglobus/js/math/Vec2.d.ts +22 -0
- package/lib/@openglobus/js/math/Vec3.d.ts +15 -0
- package/lib/@openglobus/js/math.d.ts +2 -2
- package/lib/@openglobus/js/quadTree/EntityCollectionNode.d.ts +2 -2
- package/lib/@openglobus/js/quadTree/Node.d.ts +1 -1
- package/lib/@openglobus/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +1 -1
- package/lib/@openglobus/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +1 -1
- package/lib/@openglobus/js/renderer/Renderer.d.ts +63 -44
- package/lib/@openglobus/js/renderer/RendererEvents.d.ts +2 -0
- package/lib/@openglobus/js/scene/Planet.d.ts +15 -7
- package/lib/@openglobus/js/scene/RenderNode.d.ts +10 -25
- package/lib/@openglobus/js/shaders/drawnode.d.ts +1 -0
- package/lib/@openglobus/js/shaders/geoObject.d.ts +1 -0
- package/lib/@openglobus/js/shaders/utils.d.ts +1 -1
- package/lib/@openglobus/js/ui/Checkbox.d.ts +31 -0
- package/lib/@openglobus/js/ui/Dialog.d.ts +3 -0
- package/lib/@openglobus/js/ui/Input.d.ts +32 -0
- package/lib/@openglobus/js/ui/View.d.ts +3 -1
- package/lib/@openglobus/js/utils/objParser.d.ts +44 -12
- package/lib/@openglobus/js/utils/shared.d.ts +22 -0
- package/lib/@openglobus/js/webgl/BaseFramebuffer.d.ts +0 -1
- package/lib/@openglobus/js/webgl/Framebuffer.d.ts +35 -8
- package/lib/@openglobus/js/webgl/Handler.d.ts +22 -12
- package/lib/@openglobus/og.css +1 -1
- 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/Object3d.d.ts +20 -10
- package/lib/js/Object3d.js +124 -48
- package/lib/js/Popup.js +1 -1
- package/lib/js/camera/Camera.d.ts +57 -15
- package/lib/js/camera/Camera.js +109 -29
- package/lib/js/camera/Frustum.d.ts +3 -0
- package/lib/js/camera/Frustum.js +7 -0
- package/lib/js/camera/PlanetCamera.d.ts +13 -0
- package/lib/js/camera/PlanetCamera.js +52 -5
- package/lib/js/control/Atmosphere.js +10 -6
- package/lib/js/control/CameraLock.d.ts +38 -0
- package/lib/js/control/CameraLock.js +216 -0
- package/lib/js/control/Control.js +1 -1
- package/lib/js/control/DebugInfo.js +38 -8
- package/lib/js/control/KeyboardNavigation.js +9 -9
- 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 +11 -5
- package/lib/js/control/SimpleNavigation.d.ts +27 -10
- package/lib/js/control/SimpleNavigation.js +149 -49
- package/lib/js/control/Sun.js +6 -6
- package/lib/js/control/TouchNavigation.js +11 -8
- package/lib/js/control/elevationProfile/ElevationProfileScene.js +6 -5
- package/lib/js/control/geoObjectEditor/ArrowEntity.d.ts +15 -0
- package/lib/js/control/geoObjectEditor/ArrowEntity.js +59 -0
- package/lib/js/control/geoObjectEditor/AxisTrackEntity.d.ts +9 -0
- package/lib/js/control/geoObjectEditor/AxisTrackEntity.js +93 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditor.d.ts +13 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditor.js +30 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.d.ts +69 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.js +488 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +78 -9
- package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.js +487 -43
- package/lib/js/control/geoObjectEditor/MoveAxisEntity.d.ts +17 -0
- package/lib/js/control/geoObjectEditor/MoveAxisEntity.js +107 -0
- package/lib/js/control/geoObjectEditor/MovePlaneEntity.d.ts +7 -0
- package/lib/js/control/geoObjectEditor/MovePlaneEntity.js +31 -0
- package/lib/js/control/geoObjectEditor/RotateEntity.d.ts +9 -0
- package/lib/js/control/geoObjectEditor/RotateEntity.js +105 -0
- package/lib/js/control/geoObjectEditor/colors.d.ts +8 -0
- package/lib/js/control/geoObjectEditor/colors.js +8 -0
- package/lib/js/control/index.d.ts +3 -2
- package/lib/js/control/index.js +3 -2
- package/lib/js/control/timeline/TimelineControl.js +2 -0
- package/lib/js/control/visibleExtent/Segment.js +4 -4
- package/lib/js/entity/Entity.d.ts +282 -19
- package/lib/js/entity/Entity.js +497 -62
- package/lib/js/entity/EntityCollection.d.ts +8 -9
- package/lib/js/entity/EntityCollection.js +48 -45
- package/lib/js/entity/GeoObject.d.ts +135 -39
- package/lib/js/entity/GeoObject.js +150 -90
- package/lib/js/entity/GeoObjectHandler.d.ts +39 -63
- package/lib/js/entity/GeoObjectHandler.js +198 -295
- package/lib/js/entity/InstanceData.d.ts +76 -0
- package/lib/js/entity/InstanceData.js +347 -0
- package/lib/js/entity/Polyline.d.ts +19 -6
- package/lib/js/entity/Polyline.js +76 -36
- package/lib/js/entity/PolylineHandler.d.ts +7 -0
- package/lib/js/entity/PolylineHandler.js +26 -1
- package/lib/js/index.d.ts +2 -1
- package/lib/js/index.js +2 -1
- package/lib/js/input/MouseHandler.d.ts +1 -0
- package/lib/js/input/MouseHandler.js +12 -1
- package/lib/js/layer/Bing.js +2 -2
- package/lib/js/layer/Vector.d.ts +4 -0
- package/lib/js/layer/Vector.js +16 -0
- package/lib/js/light/LightSource.d.ts +1 -139
- package/lib/js/light/LightSource.js +21 -227
- 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 +47 -33
- package/lib/js/math/Quat.js +92 -90
- package/lib/js/math/Ray.d.ts +10 -14
- package/lib/js/math/Ray.js +56 -33
- package/lib/js/math/Vec2.d.ts +22 -0
- package/lib/js/math/Vec2.js +32 -0
- package/lib/js/math/Vec3.d.ts +15 -0
- package/lib/js/math/Vec3.js +30 -1
- package/lib/js/math.d.ts +2 -2
- package/lib/js/math.js +3 -3
- package/lib/js/quadTree/EntityCollectionNode.d.ts +2 -2
- package/lib/js/quadTree/EntityCollectionNode.js +8 -8
- package/lib/js/quadTree/Node.d.ts +1 -1
- package/lib/js/quadTree/Node.js +2 -2
- package/lib/js/quadTree/QuadTreeStrategy.js +1 -1
- package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +1 -1
- package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.js +2 -2
- package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +1 -1
- package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.js +2 -2
- package/lib/js/renderer/Renderer.d.ts +63 -44
- package/lib/js/renderer/Renderer.js +267 -266
- package/lib/js/renderer/RendererEvents.d.ts +2 -0
- package/lib/js/renderer/RendererEvents.js +5 -2
- package/lib/js/scene/Planet.d.ts +15 -7
- package/lib/js/scene/Planet.js +133 -90
- package/lib/js/scene/RenderNode.d.ts +10 -25
- package/lib/js/scene/RenderNode.js +70 -58
- package/lib/js/segment/Segment.js +4 -4
- package/lib/js/shaders/depth.js +2 -5
- package/lib/js/shaders/drawnode.d.ts +1 -0
- package/lib/js/shaders/drawnode.js +51 -52
- package/lib/js/shaders/geoObject.d.ts +1 -0
- package/lib/js/shaders/geoObject.js +154 -91
- package/lib/js/shaders/polyline.js +68 -51
- package/lib/js/shaders/utils.d.ts +1 -1
- package/lib/js/shaders/utils.js +11 -0
- package/lib/js/terrain/GlobusTerrain.js +2 -2
- package/lib/js/ui/Checkbox.d.ts +31 -0
- package/lib/js/ui/Checkbox.js +110 -0
- package/lib/js/ui/Color.js +2 -1
- package/lib/js/ui/Dialog.d.ts +3 -0
- package/lib/js/ui/Dialog.js +20 -0
- package/lib/js/ui/Input.d.ts +32 -0
- package/lib/js/ui/Input.js +107 -0
- package/lib/js/ui/View.d.ts +3 -1
- package/lib/js/ui/View.js +6 -0
- package/lib/js/utils/objParser.d.ts +44 -12
- package/lib/js/utils/objParser.js +241 -149
- package/lib/js/utils/shared.d.ts +22 -0
- package/lib/js/utils/shared.js +34 -0
- package/lib/js/webgl/BaseFramebuffer.d.ts +0 -1
- package/lib/js/webgl/Framebuffer.d.ts +35 -8
- package/lib/js/webgl/Framebuffer.js +136 -29
- package/lib/js/webgl/Handler.d.ts +22 -12
- package/lib/js/webgl/Handler.js +53 -34
- package/lib/js/webgl/Program.js +0 -8
- package/package.json +5 -3
- 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
|
@@ -1,358 +1,414 @@
|
|
|
1
|
-
import * as math from "../math";
|
|
2
1
|
import { Control } from "./Control";
|
|
3
|
-
import { input } from "../input/input";
|
|
4
|
-
import { Key } from "../Lock";
|
|
5
|
-
import { LonLat } from "../LonLat";
|
|
6
|
-
import { Mat4 } from "../math/Mat4";
|
|
7
2
|
import { Quat } from "../math/Quat";
|
|
8
3
|
import { Ray } from "../math/Ray";
|
|
9
4
|
import { Sphere } from "../bv/Sphere";
|
|
5
|
+
import { Vec2 } from "../math/Vec2";
|
|
10
6
|
import { Vec3 } from "../math/Vec3";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
import { input } from "../input/input";
|
|
8
|
+
import { Plane } from "../math/Plane";
|
|
9
|
+
const DEFAULT_VELINERTIA = 0.96;
|
|
14
10
|
export class MouseNavigation extends Control {
|
|
15
11
|
constructor(options = {}) {
|
|
16
|
-
super(
|
|
17
|
-
|
|
12
|
+
super({
|
|
13
|
+
name: "mouseNavigation",
|
|
14
|
+
autoActivate: true,
|
|
15
|
+
...options
|
|
16
|
+
});
|
|
18
17
|
this._shiftBusy = false;
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
this.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const steps = [];
|
|
39
|
-
let eye = cam.eye.clone(), n = cam._b.clone(), u = cam._r.clone(), v = cam._u.clone();
|
|
40
|
-
let a = planet.getCartesianFromPixelTerrain(point);
|
|
41
|
-
if (!a) {
|
|
42
|
-
a = planet.getCartesianFromPixelTerrain(planet.renderer.handler.getCenter());
|
|
43
|
-
}
|
|
44
|
-
if (a) {
|
|
45
|
-
if (!dir) {
|
|
46
|
-
dir = Vec3.sub(a, cam.eye).normalize();
|
|
18
|
+
this._hold = false;
|
|
19
|
+
this._prevVel = new Vec3();
|
|
20
|
+
this._screenPosIsChanged = true;
|
|
21
|
+
this._onShiftFree = () => {
|
|
22
|
+
this._shiftBusy = false;
|
|
23
|
+
};
|
|
24
|
+
this._onMouseMove = (e) => {
|
|
25
|
+
if (this._active && this.renderer.events.isKeyPressed(input.KEY_ALT)) {
|
|
26
|
+
if (!this._shiftBusy) {
|
|
27
|
+
this._shiftBusy = true;
|
|
28
|
+
this._onRHold(e);
|
|
29
|
+
}
|
|
30
|
+
this._onRDown(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
this._onMouseEnter = (e) => {
|
|
34
|
+
const renderEvents = this.renderer.events;
|
|
35
|
+
if (renderEvents.isKeyPressed(input.KEY_ALT)) {
|
|
36
|
+
renderEvents.releaseKeys();
|
|
47
37
|
}
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
|
|
38
|
+
renderEvents.updateButtonsStates(e.sys.buttons);
|
|
39
|
+
if (renderEvents.mouseState.leftButtonDown) {
|
|
40
|
+
this.renderer.handler.canvas.classList.add("ogGrabbingPoiner");
|
|
51
41
|
}
|
|
52
42
|
else {
|
|
53
|
-
|
|
43
|
+
this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner");
|
|
54
44
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
45
|
+
};
|
|
46
|
+
this._onMouseLeave = () => {
|
|
47
|
+
if (this.renderer.events.mouseState.leftButtonDown) {
|
|
48
|
+
this.vel.scale(0);
|
|
49
|
+
}
|
|
50
|
+
this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner");
|
|
51
|
+
};
|
|
52
|
+
this._onRHold = (e) => {
|
|
53
|
+
if (this._targetRotationPoint) {
|
|
54
|
+
let _noRotationInertia = false;
|
|
55
|
+
this._velInertia = 0.8;
|
|
56
|
+
this.force_h = 0.2 * (e.x - e.prev_x);
|
|
57
|
+
this.force_v = 0.2 * (e.y - e.prev_y);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
this._onRDown = (e) => {
|
|
61
|
+
if (this.planet) {
|
|
62
|
+
this.planet.stopFlying();
|
|
63
|
+
this._targetRotationPoint = this._getTargetPoint(e.pos);
|
|
64
|
+
if (this._targetRotationPoint) {
|
|
65
|
+
this._targetZoomPoint = null;
|
|
66
|
+
this._targetDragPoint = null;
|
|
67
|
+
this.vel.set(0, 0, 0);
|
|
68
|
+
this._tUp = this._targetRotationPoint.getNormal();
|
|
69
|
+
this._tRad = this.planet.camera.eye.distance(this._targetRotationPoint);
|
|
73
70
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
this._onMouseWheel = (e) => {
|
|
74
|
+
if (this.planet) {
|
|
75
|
+
this._targetRotationPoint = null;
|
|
76
|
+
this._targetDragPoint = null;
|
|
77
|
+
let _targetZoomPoint = this._getTargetPoint(e.pos);
|
|
78
|
+
if (!_targetZoomPoint)
|
|
79
|
+
return;
|
|
80
|
+
this._targetZoomPoint = _targetZoomPoint;
|
|
81
|
+
this._grabbedSphere.radius = this._targetZoomPoint.length();
|
|
82
|
+
this._curPitch = this.planet.camera.getPitch();
|
|
83
|
+
this._curYaw = this.planet.camera.getYaw();
|
|
84
|
+
this._curRoll = this.planet.camera.getRoll();
|
|
85
|
+
if (Math.sign(e.wheelDelta) !== this._wheelDirection) {
|
|
86
|
+
this.vel.scale(0.3);
|
|
87
|
+
this._currScreenPos.set(e.x, e.y);
|
|
88
|
+
this._wheelDirection = Math.sign(e.wheelDelta);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
//let dd = this.targetPoint!.distance(this.planet.camera.eye);
|
|
92
|
+
// let brk = 1;
|
|
93
|
+
// if (this._wheelDirection > 0 && dd < 5000) {
|
|
94
|
+
//this.vel.scale(0.3);
|
|
95
|
+
// brk = dist / 5000;
|
|
96
|
+
// }
|
|
97
|
+
this._currScreenPos.set(e.x, e.y);
|
|
98
|
+
this._wheelDirection = Math.sign(e.wheelDelta);
|
|
99
|
+
let scale = 2;
|
|
100
|
+
this._isTouchPad = e.isTouchPad;
|
|
101
|
+
if (e.isTouchPad) {
|
|
102
|
+
this._velInertia = 0.88;
|
|
103
|
+
scale = 0.5;
|
|
84
104
|
}
|
|
85
105
|
else {
|
|
86
|
-
|
|
87
|
-
for (let i = 0; i < stepsCount; i++) {
|
|
88
|
-
steps[i] = {
|
|
89
|
-
eye: eye.addA(scaled_n).clone(),
|
|
90
|
-
v: v,
|
|
91
|
-
u: u,
|
|
92
|
-
n: n,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
106
|
+
this._velInertia = DEFAULT_VELINERTIA;
|
|
95
107
|
}
|
|
108
|
+
let dist = this.planet.camera.eye.distance(this._targetZoomPoint) * scale;
|
|
109
|
+
this.force = (e.direction.scale(Math.sign(this._wheelDirection))).normalize().scale(dist);
|
|
110
|
+
this.force_roll = this._curRoll;
|
|
96
111
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
112
|
+
};
|
|
113
|
+
this._onLDown = (e) => {
|
|
114
|
+
this.stop();
|
|
115
|
+
this._targetRotationPoint = null;
|
|
116
|
+
this._targetZoomPoint = null;
|
|
117
|
+
if (!this.planet)
|
|
118
|
+
return;
|
|
119
|
+
this.planet.stopFlying();
|
|
120
|
+
this._grabbedPoint = this._getTargetPoint(e.pos);
|
|
121
|
+
if (!this._grabbedPoint)
|
|
122
|
+
return;
|
|
123
|
+
this.renderer.handler.canvas.classList.add("ogGrabbingPoiner");
|
|
124
|
+
this._grabbedSphere.radius = this._grabbedPoint.length();
|
|
125
|
+
this._eye0 = this.planet.camera.eye.clone();
|
|
126
|
+
this._grabbedCameraHeight = this._eye0.length();
|
|
127
|
+
this._curPitch = this.planet.camera.getPitch();
|
|
128
|
+
this._curYaw = this.planet.camera.getYaw();
|
|
129
|
+
this._curRoll = this.planet.camera.getRoll();
|
|
130
|
+
this._currScreenPos.copy(e.pos);
|
|
131
|
+
if (this.planet.camera.getUp().dot(new Vec3(0, 0, 1)) > 0.3) {
|
|
132
|
+
this.fixedUp = true;
|
|
106
133
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
134
|
+
};
|
|
135
|
+
this._onLHold = (e) => {
|
|
136
|
+
if (this._grabbedPoint && this.planet) {
|
|
137
|
+
let cam = this.planet.camera;
|
|
138
|
+
if (cam.slope > 0.2) {
|
|
139
|
+
let _targetDragPoint = new Ray(cam.eye, e.direction).hitSphere(this._grabbedSphere);
|
|
140
|
+
if (!_targetDragPoint) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
this._targetDragPoint = _targetDragPoint;
|
|
144
|
+
let newEye = new Vec3();
|
|
145
|
+
let rot = Quat.getRotationBetweenVectors(this._targetDragPoint.getNormal(), this._grabbedPoint.getNormal());
|
|
146
|
+
newEye.copy(rot.mulVec3(cam.eye));
|
|
147
|
+
this.force = newEye.sub(cam.eye).scale(70);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
let p0 = this._grabbedPoint, p1 = Vec3.add(p0, cam.getRight()), p2 = Vec3.add(p0, p0.getNormal());
|
|
151
|
+
let px = new Vec3();
|
|
152
|
+
new Ray(cam.eye, e.direction).hitPlaneRes(Plane.fromPoints(p0, p1, p2), px);
|
|
153
|
+
let newEye = cam.eye.add(px.subA(p0).negate());
|
|
154
|
+
this.force = newEye.sub(cam.eye).scale(70);
|
|
155
|
+
this._targetDragPoint = px;
|
|
156
|
+
}
|
|
157
|
+
this.vel.set(0.0, 0.0, 0.0);
|
|
158
|
+
if (!this._currScreenPos.equal(e.pos)) {
|
|
159
|
+
this._screenPosIsChanged = true;
|
|
160
|
+
this._currScreenPos.copy(e.pos);
|
|
161
|
+
}
|
|
162
|
+
this._hold = true;
|
|
124
163
|
}
|
|
125
|
-
}
|
|
164
|
+
};
|
|
165
|
+
this._onLUp = (e) => {
|
|
166
|
+
this._hold = false;
|
|
167
|
+
this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner");
|
|
168
|
+
};
|
|
169
|
+
this.speed = options.speed || 1.0; // m/s
|
|
170
|
+
this.force = new Vec3();
|
|
171
|
+
this.force_h = 0;
|
|
172
|
+
this.force_v = 0;
|
|
173
|
+
this.vel = new Vec3();
|
|
174
|
+
this.vel_h = 0;
|
|
175
|
+
this.vel_v = 0;
|
|
176
|
+
this.vel_roll = 0;
|
|
177
|
+
this.force_roll = 0;
|
|
178
|
+
this.mass = 1;
|
|
179
|
+
this._velInertia = DEFAULT_VELINERTIA;
|
|
180
|
+
this._lookPos = undefined;
|
|
181
|
+
this._grabbedPoint = null;
|
|
182
|
+
this._targetZoomPoint = null;
|
|
183
|
+
this._targetDragPoint = null;
|
|
184
|
+
this._targetRotationPoint = null;
|
|
185
|
+
this._tUp = new Vec3();
|
|
186
|
+
this._tRad = 0;
|
|
187
|
+
this._rotHDir = 0;
|
|
188
|
+
this._rotVDir = 0;
|
|
189
|
+
this._wheelDirection = 1;
|
|
190
|
+
this._currScreenPos = new Vec2();
|
|
191
|
+
this._grabbedSphere = new Sphere();
|
|
192
|
+
this.fixedUp = options.fixedUp != undefined ? options.fixedUp : true;
|
|
193
|
+
this._rot = new Quat();
|
|
194
|
+
this._curPitch = 0;
|
|
195
|
+
this._curYaw = 0;
|
|
196
|
+
this._curRoll = 0;
|
|
197
|
+
this._eye0 = new Vec3();
|
|
198
|
+
this._newEye = new Vec3();
|
|
199
|
+
this._grabbedCameraHeight = 0;
|
|
200
|
+
this._isTouchPad = false;
|
|
126
201
|
}
|
|
127
|
-
|
|
202
|
+
oninit() {
|
|
128
203
|
if (this.renderer) {
|
|
129
|
-
this.renderer.events.
|
|
130
|
-
this.renderer.events.
|
|
131
|
-
this.renderer.events.off("rhold", this.onMouseRightButtonDown);
|
|
132
|
-
this.renderer.events.off("ldown", this.onMouseLeftButtonClick);
|
|
133
|
-
this.renderer.events.off("lup", this.onMouseLeftButtonUp);
|
|
134
|
-
this.renderer.events.off("rdown", this.onMouseRightButtonClick);
|
|
135
|
-
this.renderer.events.off("draw", this.onDraw);
|
|
136
|
-
this.renderer.events.off("ldblclick", this.onMouseLeftButtonDoubleClick);
|
|
137
|
-
this.renderer.events.off("mouseleave", this.onMouseLeave);
|
|
138
|
-
this.renderer.events.off("mouseenter", this.onMouseEnter);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
activateDoubleClickZoom() {
|
|
142
|
-
if (!this._lmbDoubleClickActive) {
|
|
143
|
-
this._lmbDoubleClickActive = true;
|
|
144
|
-
this.renderer && this.renderer.events.on("ldblclick", this.onMouseLeftButtonDoubleClick, this);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
deactivateDoubleClickZoom() {
|
|
148
|
-
if (this._lmbDoubleClickActive) {
|
|
149
|
-
this._lmbDoubleClickActive = false;
|
|
150
|
-
this.renderer && this.renderer.events.off("ldblclick", this.onMouseLeftButtonDoubleClick);
|
|
204
|
+
this.renderer.events.on("keyfree", input.KEY_ALT, this._onShiftFree);
|
|
205
|
+
this.renderer.events.on("keyfree", input.KEY_PRINTSCREEN, this._onShiftFree);
|
|
151
206
|
}
|
|
152
207
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
208
|
+
onactivate() {
|
|
209
|
+
super.onactivate();
|
|
210
|
+
let r = this.renderer;
|
|
211
|
+
r.events.on("mousewheel", this._onMouseWheel);
|
|
212
|
+
r.events.on("rhold", this._onRHold);
|
|
213
|
+
r.events.on("rdown", this._onRDown);
|
|
214
|
+
r.events.on("lhold", this._onLHold);
|
|
215
|
+
r.events.on("ldown", this._onLDown);
|
|
216
|
+
r.events.on("lup", this._onLUp);
|
|
217
|
+
r.events.on("draw", this.onDraw, this, -1000);
|
|
218
|
+
r.events.on("mousemove", this._onMouseMove);
|
|
219
|
+
r.events.on("mouseleave", this._onMouseLeave);
|
|
220
|
+
r.events.on("mouseenter", this._onMouseEnter);
|
|
165
221
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
222
|
+
ondeactivate() {
|
|
223
|
+
super.ondeactivate();
|
|
224
|
+
let r = this.renderer;
|
|
225
|
+
r.events.off("mousewheel", this._onMouseWheel);
|
|
226
|
+
r.events.off("rhold", this._onRHold);
|
|
227
|
+
r.events.off("rdown", this._onRDown);
|
|
228
|
+
r.events.off("lhold", this._onLHold);
|
|
229
|
+
r.events.off("ldown", this._onLDown);
|
|
230
|
+
r.events.off("lup", this._onLUp);
|
|
231
|
+
r.events.off("draw", this.onDraw);
|
|
232
|
+
r.events.off("mousemove", this._onMouseMove);
|
|
233
|
+
r.events.off("mouseleave", this._onMouseLeave);
|
|
234
|
+
r.events.off("mouseenter", this._onMouseEnter);
|
|
171
235
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
this.
|
|
177
|
-
this.stopRotation();
|
|
178
|
-
this._deactivate = true;
|
|
179
|
-
this.lockPlanet(true);
|
|
180
|
-
this.stepsForward = MouseNavigation.getMovePointsFromPixelTerrain(this.planet.camera, this.planet, this.stepsCount, this.distDiff, e.pos, e.wheelDelta > 0, e.direction) || null;
|
|
181
|
-
this._wheelDirection = e.wheelDelta;
|
|
182
|
-
if (this.stepsForward) {
|
|
183
|
-
this.stepIndex = this.stepsCount;
|
|
184
|
-
}
|
|
236
|
+
onDraw() {
|
|
237
|
+
this._updateVel();
|
|
238
|
+
this._handleZoom();
|
|
239
|
+
this._handleDrag();
|
|
240
|
+
this._handleRotation();
|
|
185
241
|
}
|
|
186
|
-
|
|
187
|
-
this.
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
242
|
+
_handleRotation() {
|
|
243
|
+
if (this.planet && this._targetRotationPoint) {
|
|
244
|
+
let cam = this.planet.camera;
|
|
245
|
+
// let l = (0.3 / this._tRad) * math.RADIANS;
|
|
246
|
+
// if (l > 0.007) {
|
|
247
|
+
// l = 0.007;
|
|
248
|
+
// } else if (l < 0.003) {
|
|
249
|
+
// l = 0.003;
|
|
250
|
+
// }
|
|
251
|
+
let d_v_h = this.vel_h * this.dt;
|
|
252
|
+
let d_v_v = this.vel_v * this.dt;
|
|
253
|
+
cam.rotateHorizontal(d_v_h, false, this._targetRotationPoint, this._tUp);
|
|
254
|
+
cam.rotateVertical(d_v_v, this._targetRotationPoint, 0.1);
|
|
255
|
+
this._curPitch = cam.getPitch();
|
|
256
|
+
this._curYaw = cam.getYaw();
|
|
257
|
+
this._curRoll = cam.getRoll();
|
|
258
|
+
this._velInertia = DEFAULT_VELINERTIA;
|
|
191
259
|
}
|
|
192
260
|
}
|
|
193
|
-
|
|
194
|
-
this.planet
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
if (p) {
|
|
198
|
-
const cam = this.planet.camera;
|
|
199
|
-
let maxAlt = cam.maxAltitude + this.planet.ellipsoid.polarSize;
|
|
200
|
-
let minAlt = cam.minAltitude + this.planet.ellipsoid.polarSize;
|
|
201
|
-
const camAlt = cam.eye.length();
|
|
202
|
-
const g = this.planet.ellipsoid.cartesianToLonLat(p);
|
|
203
|
-
if (camAlt > maxAlt || camAlt < minAlt) {
|
|
204
|
-
this.planet.flyLonLat(new LonLat(g.lon, g.lat));
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
if (this.renderer.events.isKeyPressed(input.KEY_ALT)) {
|
|
208
|
-
this.planet.flyLonLat(new LonLat(g.lon, g.lat, cam.eye.distance(p) * 2.0));
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
this.planet.flyLonLat(new LonLat(g.lon, g.lat, cam.eye.distance(p) * 0.57));
|
|
261
|
+
_getTargetPoint(p) {
|
|
262
|
+
if (this.planet) {
|
|
263
|
+
if (this.planet.camera.getAltitude() > 10000) {
|
|
264
|
+
return this.planet.getCartesianFromPixelEllipsoid(p) || null;
|
|
212
265
|
}
|
|
266
|
+
return this.planet.getCartesianFromPixelTerrain(p) || null;
|
|
213
267
|
}
|
|
268
|
+
return null;
|
|
214
269
|
}
|
|
215
|
-
|
|
216
|
-
if (this.
|
|
217
|
-
this.
|
|
218
|
-
|
|
219
|
-
if (
|
|
220
|
-
this.
|
|
221
|
-
this.grabbedSpheroid.radius = this.grabbedPoint.length();
|
|
222
|
-
this.stopRotation();
|
|
270
|
+
_handleDrag() {
|
|
271
|
+
if (this.planet && this._targetDragPoint && this._grabbedPoint && this.vel.length() > 0.0) {
|
|
272
|
+
this._velInertia = DEFAULT_VELINERTIA;
|
|
273
|
+
let cam = this.planet.camera;
|
|
274
|
+
if (Math.abs(cam.eyeNorm.dot(Vec3.NORTH)) > 0.9) {
|
|
275
|
+
this.fixedUp = false;
|
|
223
276
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
this.freePlanet();
|
|
229
|
-
}
|
|
230
|
-
onMouseLeftButtonUp(e) {
|
|
231
|
-
this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner");
|
|
232
|
-
if (e.x === e.prev_x && e.y === e.prev_y) {
|
|
233
|
-
this.scaleRot = 0.0;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
onMouseLeftButtonDown(e) {
|
|
237
|
-
if (this._active) {
|
|
238
|
-
if (!this.grabbedPoint) {
|
|
239
|
-
return;
|
|
277
|
+
if (!this._screenPosIsChanged) {
|
|
278
|
+
if (this.vel.length() > this._prevVel.length()) {
|
|
279
|
+
this.fixedUp = false;
|
|
280
|
+
}
|
|
240
281
|
}
|
|
241
|
-
this.
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
cam._b = rot.mulVec3(cam._b);
|
|
254
|
-
}
|
|
282
|
+
this._screenPosIsChanged = false;
|
|
283
|
+
this._prevVel.copy(this.vel);
|
|
284
|
+
if (cam.slope > 0.2) {
|
|
285
|
+
let d_v = this.vel.scaleTo(this.dt);
|
|
286
|
+
// let d_s = d_v;
|
|
287
|
+
// let newEye = cam.eye.add(d_s).normalize().scale(this._grabbedCameraHeight);
|
|
288
|
+
let d_s = Vec3.proj_b_to_plane(d_v, cam.eyeNorm);
|
|
289
|
+
let newEye = cam.eye.add(d_s).normalize().scale(this._grabbedCameraHeight);
|
|
290
|
+
if (this.fixedUp) {
|
|
291
|
+
cam.eye.copy(newEye);
|
|
292
|
+
this._corrRoll();
|
|
293
|
+
cam.setPitchYawRoll(this._curPitch, this._curYaw, this._curRoll);
|
|
255
294
|
}
|
|
256
295
|
else {
|
|
257
|
-
let
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
cam.eye = this._eye0.addA(px.subA(p0).negate());
|
|
261
|
-
}
|
|
296
|
+
let rot = Quat.getRotationBetweenVectors(cam.eye.getNormal(), newEye.getNormal());
|
|
297
|
+
cam.rotate(rot);
|
|
298
|
+
cam.eye.copy(newEye);
|
|
262
299
|
}
|
|
263
300
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
this.pointOnEarth = this.planet.getCartesianFromPixelTerrain(e.pos);
|
|
270
|
-
if (this.pointOnEarth) {
|
|
271
|
-
this.earthUp = this.pointOnEarth.normal();
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
onMouseRightButtonDown(e) {
|
|
275
|
-
const cam = this.planet.camera;
|
|
276
|
-
if (this.pointOnEarth && e.moving) {
|
|
277
|
-
this.renderer.controlsBag.scaleRot = 1.0;
|
|
278
|
-
let l = (0.5 / cam.eye.distance(this.pointOnEarth)) * cam._lonLat.height * math.RADIANS;
|
|
279
|
-
if (l > 0.007) {
|
|
280
|
-
l = 0.007;
|
|
281
|
-
}
|
|
282
|
-
else if (l < 0.003) {
|
|
283
|
-
l = 0.003;
|
|
301
|
+
else {
|
|
302
|
+
let d_v = this.vel.scaleTo(this.dt);
|
|
303
|
+
let newEye = cam.eye.add(d_v);
|
|
304
|
+
cam.eye.copy(newEye);
|
|
305
|
+
cam.checkTerrainCollision();
|
|
284
306
|
}
|
|
285
|
-
cam.rotateHorizontal(l * (e.x - e.prev_x), false, this.pointOnEarth, this.earthUp);
|
|
286
|
-
cam.rotateVertical(l * (e.y - e.prev_y), this.pointOnEarth, this.minSlope);
|
|
287
307
|
}
|
|
288
308
|
}
|
|
289
|
-
|
|
290
|
-
this.
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
if (!this._shiftBusy) {
|
|
295
|
-
this._shiftBusy = true;
|
|
296
|
-
this.onMouseRightButtonClick(e);
|
|
309
|
+
_corrRoll() {
|
|
310
|
+
if (this.planet.camera.slope < 0.5) {
|
|
311
|
+
this._curRoll -= this.vel_roll * this.dt;
|
|
312
|
+
if (this._curRoll < 0.01 * Math.PI / 180) {
|
|
313
|
+
this._curRoll = 0.01 * Math.PI / 180;
|
|
297
314
|
}
|
|
298
|
-
this.onMouseRightButtonDown(e);
|
|
299
315
|
}
|
|
300
316
|
}
|
|
301
|
-
|
|
302
|
-
if (this.
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
let
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
317
|
+
_handleZoom() {
|
|
318
|
+
if (this._targetZoomPoint && this.vel.length() > 0.0) {
|
|
319
|
+
// Common
|
|
320
|
+
let cam = this.planet.camera;
|
|
321
|
+
let a = this._targetZoomPoint;
|
|
322
|
+
let dir = a.sub(cam.eye).normalize();
|
|
323
|
+
let eye = cam.eye.clone();
|
|
324
|
+
let velDir = Math.sign(this.vel.getNormal().dot(cam.getForward()));
|
|
325
|
+
let d_v = this.vel.scaleTo(this.dt);
|
|
326
|
+
let d_s = d_v.projToVec(cam.getForward().scale(velDir));
|
|
327
|
+
//let d_s = cam.getForward().scaleTo(velDir * d_v.length());
|
|
328
|
+
// Braking tweak
|
|
329
|
+
let destDist = cam.eye.distance(a);
|
|
330
|
+
if (d_s.length() * 10 > destDist) {
|
|
331
|
+
let temp = d_s.length();
|
|
332
|
+
d_s.normalize().scale(temp * 0.5);
|
|
333
|
+
this.vel.scale(0.5);
|
|
319
334
|
}
|
|
320
|
-
|
|
335
|
+
eye.addA(d_s);
|
|
336
|
+
// Check max camera distance
|
|
337
|
+
let maxAlt = cam.maxAltitude + this.planet.ellipsoid.getEquatorialSize();
|
|
338
|
+
if (eye.length() > maxAlt) {
|
|
339
|
+
eye.copy(eye.getNormal().scale(maxAlt));
|
|
321
340
|
return;
|
|
322
341
|
}
|
|
323
|
-
|
|
324
|
-
if (
|
|
325
|
-
this.
|
|
326
|
-
|
|
327
|
-
else {
|
|
328
|
-
r.controlsBag.scaleRot = this.scaleRot;
|
|
329
|
-
let rot = this.qRot
|
|
330
|
-
.slerp(Quat.IDENTITY, 1.0 - this.scaleRot * this.scaleRot * this.scaleRot)
|
|
331
|
-
.normalize();
|
|
332
|
-
if (!(rot.x || rot.y || rot.z)) {
|
|
333
|
-
this.scaleRot = 0.0;
|
|
334
|
-
}
|
|
335
|
-
cam.eye = rot.mulVec3(cam.eye);
|
|
336
|
-
cam._u = rot.mulVec3(cam._u);
|
|
337
|
-
cam._r = rot.mulVec3(cam._r);
|
|
338
|
-
cam._b = rot.mulVec3(cam._b);
|
|
339
|
-
}
|
|
340
|
-
if (cam.eye.distance(prevEye) / cam.getAltitude() > 0.01) {
|
|
341
|
-
this.lockPlanet();
|
|
342
|
+
let b = new Ray(eye, dir).hitSphere(this._grabbedSphere);
|
|
343
|
+
if (!b) {
|
|
344
|
+
this.vel.set(0, 0, 0);
|
|
345
|
+
return;
|
|
342
346
|
}
|
|
343
|
-
|
|
344
|
-
|
|
347
|
+
let rot = Quat.getRotationBetweenVectors(b.getNormal(), a.getNormal());
|
|
348
|
+
cam.eye = rot.mulVec3(eye);
|
|
349
|
+
cam.rotate(rot);
|
|
350
|
+
if (this.fixedUp) {
|
|
351
|
+
this._corrRoll();
|
|
352
|
+
// restore camera direction
|
|
353
|
+
cam.setPitchYawRoll(this._curPitch, this._curYaw, this._curRoll);
|
|
354
|
+
cam.update();
|
|
355
|
+
let dirCurr = cam.unproject2v(this._currScreenPos);
|
|
356
|
+
let dirNew = a.sub(cam.eye).normalize();
|
|
357
|
+
let px0 = new Vec3();
|
|
358
|
+
let px1 = new Vec3();
|
|
359
|
+
let pl = Plane.fromPoints(a, a.add(cam.getUp()), a.add(cam.getRight()));
|
|
360
|
+
new Ray(cam.eye, dirCurr).hitPlaneRes(pl, px0);
|
|
361
|
+
new Ray(cam.eye, dirNew).hitPlaneRes(pl, px1);
|
|
362
|
+
let dp = px1.sub(px0);
|
|
363
|
+
cam.eye = cam.eye.add(dp);
|
|
364
|
+
// ver.2
|
|
365
|
+
// let px0 = new Ray(cam.eye, dirCurr).hitSphere(this._grabbedSphere)!;
|
|
366
|
+
// let px1 = new Ray(cam.eye, dirNew).hitSphere(this._grabbedSphere)!;
|
|
345
367
|
}
|
|
368
|
+
cam.checkTerrainCollision();
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
_updateVel() {
|
|
372
|
+
let acc = this.force.scale(1.0 / this.mass);
|
|
373
|
+
this.vel.addA(acc);
|
|
374
|
+
this.vel.scale(this._velInertia);
|
|
375
|
+
if (this.vel.length() < 0.001) {
|
|
376
|
+
this.vel.set(0, 0, 0);
|
|
346
377
|
}
|
|
378
|
+
this.force.set(0, 0, 0);
|
|
379
|
+
this._updateVel_h();
|
|
380
|
+
this._updateVel_v();
|
|
381
|
+
this._updateVel_roll();
|
|
382
|
+
}
|
|
383
|
+
_updateVel_h() {
|
|
384
|
+
let acc = this.force_h / this.mass;
|
|
385
|
+
this.vel_h += acc;
|
|
386
|
+
this.vel_h *= this._velInertia;
|
|
387
|
+
this.force_h = 0;
|
|
388
|
+
}
|
|
389
|
+
_updateVel_v() {
|
|
390
|
+
let acc = this.force_v / this.mass;
|
|
391
|
+
this.vel_v += acc;
|
|
392
|
+
this.vel_v *= this._velInertia;
|
|
393
|
+
this.force_v = 0;
|
|
394
|
+
}
|
|
395
|
+
_updateVel_roll() {
|
|
396
|
+
let acc = this.force_roll / this.mass;
|
|
397
|
+
this.vel_roll += acc;
|
|
398
|
+
this.vel_roll *= this._velInertia;
|
|
399
|
+
this.force_roll = 0;
|
|
347
400
|
}
|
|
348
|
-
|
|
349
|
-
this.
|
|
350
|
-
!skipTerrain && this.planet.terrainLock.lock(this._keyLock);
|
|
351
|
-
this.planet._normalMapCreator.lock(this._keyLock);
|
|
401
|
+
get dt() {
|
|
402
|
+
return 0.001 * this.renderer.handler.deltaTime;
|
|
352
403
|
}
|
|
353
|
-
|
|
354
|
-
this.
|
|
355
|
-
this.
|
|
356
|
-
this.
|
|
404
|
+
stop() {
|
|
405
|
+
this.vel.set(0, 0, 0);
|
|
406
|
+
this.vel_h = 0;
|
|
407
|
+
this.vel_v = 0;
|
|
408
|
+
this._velInertia = DEFAULT_VELINERTIA;
|
|
409
|
+
this._targetZoomPoint = null;
|
|
410
|
+
this._grabbedPoint = null;
|
|
411
|
+
this._targetRotationPoint = null;
|
|
412
|
+
this._targetDragPoint = null;
|
|
357
413
|
}
|
|
358
414
|
}
|