@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
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { Control } from "./Control";
|
|
2
|
+
import { Quat } from "../math/Quat";
|
|
3
|
+
import { Vec3 } from "../math/Vec3";
|
|
4
|
+
import { createEvents } from "../Events";
|
|
5
|
+
import { input } from "../input/input";
|
|
6
|
+
import { RADIANS } from "../math";
|
|
7
|
+
const MIN_LOCK_DISTANCE = 0.001;
|
|
8
|
+
const MIN_VIEW_DISTANCE = 120.0;
|
|
9
|
+
let qOrientationRot = new Quat();
|
|
10
|
+
const t = 0.08;
|
|
11
|
+
const CameraLockEvents = ["lockview", "unlockview"];
|
|
12
|
+
export class CameraLock extends Control {
|
|
13
|
+
constructor(options = {}) {
|
|
14
|
+
super(options);
|
|
15
|
+
this._onLockViewDraw = () => {
|
|
16
|
+
if (this.renderer && this._lockEntity) {
|
|
17
|
+
if (this._isFromTheBack) {
|
|
18
|
+
// let cam = this.planet.camera;
|
|
19
|
+
// let vehPos = this._lockEntity.getCartesian(),
|
|
20
|
+
// vehDir = this._lockEntity.direction;
|
|
21
|
+
// let currPos = vehPos.sub(this._viewDir.scaleTo(this._lockDistance));
|
|
22
|
+
// let dh = new Vec3();
|
|
23
|
+
// let currPosProj = new Plane(vehPos, vehPos.normal()).getProjectionPoint(currPos, dh);
|
|
24
|
+
// let projViewDir = vehPos.sub(currPosProj);
|
|
25
|
+
// Quat.getRotationBetweenVectorsRes(projViewDir.normal(), vehDir, qOrientationRot);
|
|
26
|
+
// let rot = qOrientationRot.slerp(Quat.IDENTITY, 1.0 - t).normalize();
|
|
27
|
+
// let projViewDir_t = rot.mulVec3(projViewDir.normal());
|
|
28
|
+
// projViewDir = projViewDir_t.scale(projViewDir.length());
|
|
29
|
+
// let newPos = vehPos.add(dh).sub(projViewDir);
|
|
30
|
+
// this._viewDir = vehPos.sub(newPos).normalize();
|
|
31
|
+
// cam.set(newPos, vehPos, vehPos.normal());
|
|
32
|
+
// cam.update();
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
this.renderer.activeCamera.viewDistance(this._lockEntity.getAbsoluteCartesian(), this._lockDistance);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
this._onMouseWheel = (e) => {
|
|
40
|
+
if (this.renderer && this._lockEntity) {
|
|
41
|
+
if (this._isFromTheBack) {
|
|
42
|
+
//...
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
let d = this.renderer.activeCamera.eye.distance(this._lockEntity.getAbsoluteCartesian());
|
|
46
|
+
this._lockDistance -= 0.33 * d * Math.sign(e.wheelDelta);
|
|
47
|
+
if (this._lockDistance < MIN_LOCK_DISTANCE) {
|
|
48
|
+
this._lockDistance = MIN_LOCK_DISTANCE;
|
|
49
|
+
}
|
|
50
|
+
this.renderer.activeCamera.viewDistance(this._lockEntity.getAbsoluteCartesian(), this._lockDistance);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
this._onMouseMove = (ms) => {
|
|
55
|
+
if (this._lockEntity && this.renderer) {
|
|
56
|
+
if (ms.rightButtonDown || this.renderer.events.isKeyPressed(input.KEY_ALT)) {
|
|
57
|
+
let p = this._lockEntity.getAbsoluteCartesian(), cam = this.renderer.activeCamera, l = 0.5 / RADIANS;
|
|
58
|
+
if (l > 0.007)
|
|
59
|
+
l = 0.007;
|
|
60
|
+
if (this.planet) {
|
|
61
|
+
cam.rotateHorizontal(l * (ms.x - ms.prev_x), false, p, p.isZero() ? Vec3.UP : p.normal());
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
cam.rotateHorizontal(l * (ms.x - ms.prev_x), false, p, Vec3.UP);
|
|
65
|
+
}
|
|
66
|
+
cam.rotateVertical(l * (ms.y - ms.prev_y), p);
|
|
67
|
+
this._viewDir = p.sub(cam.eye).normalize();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
this.events = createEvents(CameraLockEvents);
|
|
72
|
+
this._name = "CameraLock";
|
|
73
|
+
this.planet = options.planet || null;
|
|
74
|
+
this._lockDistance = 0;
|
|
75
|
+
this._isFromTheBack = false;
|
|
76
|
+
this._lockEntity = null;
|
|
77
|
+
this._viewDir = new Vec3(0, 0, 0);
|
|
78
|
+
}
|
|
79
|
+
onactivate() {
|
|
80
|
+
if (this.renderer) {
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
ondeactivate() {
|
|
84
|
+
if (this.renderer) {
|
|
85
|
+
this.unlockView();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
oninit() {
|
|
89
|
+
this.activate();
|
|
90
|
+
if (this.renderer) {
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
flyCartesian(cartesian, dist = MIN_VIEW_DISTANCE) {
|
|
94
|
+
if (cartesian.isZero() || !this.renderer) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
this.unlockView();
|
|
98
|
+
if (this.planet) {
|
|
99
|
+
let cam = this.planet.camera;
|
|
100
|
+
if (this.isVisibleDistance(cartesian)) {
|
|
101
|
+
cam.flyDistance(cartesian, dist);
|
|
102
|
+
}
|
|
103
|
+
if (cam.eye.distance(cartesian) < 1000000.0) {
|
|
104
|
+
cam.flyDistance(cartesian, dist);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
cam.viewDistance(cartesian, dist);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
this.renderer.activeCamera.viewDistance(cartesian, dist);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
lockView(entity, fromTheBack = false) {
|
|
115
|
+
if (!this.renderer)
|
|
116
|
+
return;
|
|
117
|
+
this._lockDistance = this._getDistance(entity, this._lockEntity);
|
|
118
|
+
this._isFromTheBack = fromTheBack;
|
|
119
|
+
this._deactivateLockViewEvents();
|
|
120
|
+
this._lockEntity = entity;
|
|
121
|
+
let cam = this.renderer.activeCamera;
|
|
122
|
+
if (this.planet) {
|
|
123
|
+
this.planet.camera.stopFlying();
|
|
124
|
+
}
|
|
125
|
+
cam.viewDistance(entity.getAbsoluteCartesian(), this._lockDistance);
|
|
126
|
+
this._deactivateNav();
|
|
127
|
+
this._activateLockViewEvents();
|
|
128
|
+
this._viewDir = entity.getAbsoluteCartesian().sub(cam.eye).normalize();
|
|
129
|
+
this.events.dispatch(this.events.lockview, this._lockEntity, fromTheBack);
|
|
130
|
+
}
|
|
131
|
+
_activateNav() {
|
|
132
|
+
if (this.renderer && this.renderer.controls.mouseNavigation) {
|
|
133
|
+
this.renderer.controls.mouseNavigation.activate();
|
|
134
|
+
}
|
|
135
|
+
if (this.renderer && this.renderer.controls.simpleNavigation) {
|
|
136
|
+
this.renderer.controls.simpleNavigation.activate();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
_deactivateNav() {
|
|
140
|
+
if (this.renderer && this.renderer.controls.mouseNavigation) {
|
|
141
|
+
this.renderer.controls.mouseNavigation.deactivate();
|
|
142
|
+
this.renderer.controls.mouseNavigation.stop();
|
|
143
|
+
}
|
|
144
|
+
if (this.renderer && this.renderer.controls.simpleNavigation) {
|
|
145
|
+
this.renderer.controls.simpleNavigation.deactivate();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
unlockView() {
|
|
149
|
+
if (this._lockEntity) {
|
|
150
|
+
this._deactivateLockViewEvents();
|
|
151
|
+
this._activateNav();
|
|
152
|
+
this.events.dispatch(this.events.unlockview, this._lockEntity);
|
|
153
|
+
this._lockEntity = null;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
_getCenterDist() {
|
|
157
|
+
if (this.renderer) {
|
|
158
|
+
return this.renderer.getDistanceFromPixel(this.renderer.handler.getCenter()) || 0;
|
|
159
|
+
}
|
|
160
|
+
return 0;
|
|
161
|
+
}
|
|
162
|
+
_getDistance(entity, prevEntity) {
|
|
163
|
+
if (this.renderer) {
|
|
164
|
+
let cartesian = entity.getAbsoluteCartesian();
|
|
165
|
+
let cam = this.renderer.activeCamera;
|
|
166
|
+
let dist = cam.eye.distance(cartesian);
|
|
167
|
+
if (prevEntity) {
|
|
168
|
+
dist = cam.eye.distance(prevEntity.getAbsoluteCartesian());
|
|
169
|
+
}
|
|
170
|
+
if (this.isVisibleDistance(cartesian)) {
|
|
171
|
+
return dist;
|
|
172
|
+
}
|
|
173
|
+
if (cam.eye.distance(cartesian) < 1000000.0) {
|
|
174
|
+
return this._getCenterDist();
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
return MIN_VIEW_DISTANCE;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return 0;
|
|
181
|
+
}
|
|
182
|
+
isVisibleDistance(cart, C = 0.0) {
|
|
183
|
+
if (this.planet) {
|
|
184
|
+
let R = this.planet.ellipsoid.equatorialSize;
|
|
185
|
+
let eye = this.planet.camera.eye;
|
|
186
|
+
let camDist = eye.distance(cart);
|
|
187
|
+
return camDist < Math.sqrt(eye.length2() - R * R) + C;
|
|
188
|
+
}
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
get lockEntity() {
|
|
192
|
+
return this._lockEntity;
|
|
193
|
+
}
|
|
194
|
+
flyLonLat(lonLat, dist = MIN_VIEW_DISTANCE) {
|
|
195
|
+
if (this.planet) {
|
|
196
|
+
let cartesian = this.planet.ellipsoid.lonLatToCartesian(lonLat);
|
|
197
|
+
this.flyCartesian(cartesian, dist);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
_activateLockViewEvents() {
|
|
201
|
+
if (this.renderer) {
|
|
202
|
+
this.renderer.events.on("mousewheel", this._onMouseWheel);
|
|
203
|
+
this.renderer.events.on("mousemove", this._onMouseMove);
|
|
204
|
+
this.renderer.events.on("draw", this._onLockViewDraw);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
_deactivateLockViewEvents() {
|
|
208
|
+
if (this.renderer) {
|
|
209
|
+
this.renderer.events.off("mousewheel", this._onMouseWheel);
|
|
210
|
+
this.renderer.events.off("mousemove", this._onMouseMove);
|
|
211
|
+
if (this._lockEntity) {
|
|
212
|
+
this.renderer.events.off("draw", this._onLockViewDraw);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
@@ -62,7 +62,7 @@ export class Control {
|
|
|
62
62
|
this.renderer = renderer;
|
|
63
63
|
renderer.controls[this.name] = this;
|
|
64
64
|
this.onadd && this.onadd();
|
|
65
|
-
if (renderer.isInitialized()) {
|
|
65
|
+
if (renderer.isInitialized() && !this._initialized) {
|
|
66
66
|
this._initialized = true;
|
|
67
67
|
this.oninit && this.oninit();
|
|
68
68
|
if (this.autoActivate) {
|
|
@@ -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">
|
|
@@ -186,14 +187,14 @@ export class DebugInfo extends Control {
|
|
|
186
187
|
frame: () => p.getViewExtent().toString()
|
|
187
188
|
},
|
|
188
189
|
{
|
|
189
|
-
label: "
|
|
190
|
-
frame: () =>
|
|
191
|
-
|
|
192
|
-
(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
190
|
+
label: "Mouse distance, m",
|
|
191
|
+
frame: () => {
|
|
192
|
+
let cart = p.getCartesianFromMouseTerrain();
|
|
193
|
+
if (cart) {
|
|
194
|
+
return p.camera.eye.distance(cart).toFixed(3);
|
|
195
|
+
}
|
|
196
|
+
return "";
|
|
197
|
+
}
|
|
197
198
|
},
|
|
198
199
|
{
|
|
199
200
|
label: "lodSize",
|
|
@@ -210,6 +211,35 @@ export class DebugInfo extends Control {
|
|
|
210
211
|
{
|
|
211
212
|
label: "-------------------------"
|
|
212
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
|
+
},
|
|
213
243
|
{
|
|
214
244
|
label: "_renderCompleted / renderCompletedActivated",
|
|
215
245
|
frame: () => `${p._renderCompleted} / ${p._renderCompletedActivated}`
|
|
@@ -9,7 +9,7 @@ export class KeyboardNavigation extends Control {
|
|
|
9
9
|
constructor(options = {}) {
|
|
10
10
|
options = options || {};
|
|
11
11
|
super({ name: "KeyboardNavigation", ...options });
|
|
12
|
-
this.step = options.step ||
|
|
12
|
+
this.step = options.step || 25000;
|
|
13
13
|
}
|
|
14
14
|
onactivate() {
|
|
15
15
|
let r = this.renderer;
|
|
@@ -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
|
}
|
|
@@ -1,64 +1,75 @@
|
|
|
1
1
|
import { Control, IControlParams } from "./Control";
|
|
2
|
-
import {
|
|
2
|
+
import { IMouseState } from "../renderer/RendererEvents";
|
|
3
3
|
import { Quat } from "../math/Quat";
|
|
4
4
|
import { Sphere } from "../bv/Sphere";
|
|
5
|
-
import { Vec3 } from "../math/Vec3";
|
|
6
5
|
import { Vec2 } from "../math/Vec2";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
eye: Vec3;
|
|
12
|
-
v: Vec3;
|
|
13
|
-
u: Vec3;
|
|
14
|
-
n: Vec3;
|
|
15
|
-
}
|
|
16
|
-
interface IMouseNavigationParams extends IControlParams {
|
|
17
|
-
minSlope?: number;
|
|
6
|
+
import { Vec3 } from "../math/Vec3";
|
|
7
|
+
interface IEarthNavigationParams extends IControlParams {
|
|
8
|
+
speed?: number;
|
|
9
|
+
fixedUp?: boolean;
|
|
18
10
|
}
|
|
19
|
-
/**
|
|
20
|
-
* Mouse planet camera dragging control.
|
|
21
|
-
*/
|
|
22
11
|
export declare class MouseNavigation extends Control {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
protected
|
|
34
|
-
protected
|
|
35
|
-
protected
|
|
36
|
-
|
|
12
|
+
speed: number;
|
|
13
|
+
force: Vec3;
|
|
14
|
+
force_h: number;
|
|
15
|
+
force_v: number;
|
|
16
|
+
vel: Vec3;
|
|
17
|
+
vel_h: number;
|
|
18
|
+
vel_v: number;
|
|
19
|
+
mass: number;
|
|
20
|
+
vel_roll: number;
|
|
21
|
+
force_roll: number;
|
|
22
|
+
protected _lookPos: Vec3 | undefined;
|
|
23
|
+
protected _grabbedPoint: Vec3 | null;
|
|
24
|
+
protected _targetZoomPoint: Vec3 | null;
|
|
25
|
+
protected _targetDragPoint: Vec3 | null;
|
|
26
|
+
protected _targetRotationPoint: Vec3 | null;
|
|
27
|
+
protected _grabbedSphere: Sphere;
|
|
37
28
|
protected _wheelDirection: number;
|
|
38
|
-
protected
|
|
39
|
-
protected
|
|
29
|
+
protected _currScreenPos: Vec2;
|
|
30
|
+
protected _tUp: Vec3;
|
|
31
|
+
protected _tRad: number;
|
|
40
32
|
protected _shiftBusy: boolean;
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
protected fixedUp: boolean;
|
|
34
|
+
protected _curPitch: number;
|
|
35
|
+
protected _curYaw: number;
|
|
36
|
+
protected _curRoll: number;
|
|
37
|
+
protected _rot: Quat;
|
|
38
|
+
protected _eye0: Vec3;
|
|
39
|
+
protected _grabbedCameraHeight: number;
|
|
40
|
+
protected _newEye: Vec3;
|
|
41
|
+
protected _isTouchPad: boolean;
|
|
42
|
+
protected _velInertia: number;
|
|
43
|
+
protected _hold: boolean;
|
|
44
|
+
protected _prevVel: Vec3;
|
|
45
|
+
protected _screenPosIsChanged: boolean;
|
|
46
|
+
protected _rotHDir: number;
|
|
47
|
+
protected _rotVDir: number;
|
|
48
|
+
constructor(options?: IEarthNavigationParams);
|
|
49
|
+
oninit(): void;
|
|
43
50
|
onactivate(): void;
|
|
44
51
|
ondeactivate(): void;
|
|
45
|
-
activateDoubleClickZoom(): void;
|
|
46
|
-
deactivateDoubleClickZoom(): void;
|
|
47
|
-
protected onMouseEnter(e: IMouseState): void;
|
|
48
|
-
protected onMouseLeave(): void;
|
|
49
|
-
protected onMouseWheel(e: IMouseState): void;
|
|
50
|
-
oninit(): void;
|
|
51
|
-
protected onMouseLeftButtonDoubleClick(e: IMouseState): void;
|
|
52
|
-
protected onMouseLeftButtonClick(): void;
|
|
53
|
-
stopRotation(): void;
|
|
54
|
-
protected onMouseLeftButtonUp(e: IMouseState): void;
|
|
55
|
-
protected onMouseLeftButtonDown(e: IMouseState): void;
|
|
56
|
-
protected onMouseRightButtonClick(e: IMouseState): void;
|
|
57
|
-
protected onMouseRightButtonDown(e: IMouseState): void;
|
|
58
|
-
onShiftFree(): void;
|
|
59
|
-
protected onMouseMove(e: IMouseState): void;
|
|
60
52
|
protected onDraw(): void;
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
_onShiftFree: () => void;
|
|
54
|
+
protected _onMouseMove: (e: IMouseState) => void;
|
|
55
|
+
protected _onMouseEnter: (e: IMouseState) => void;
|
|
56
|
+
protected _onMouseLeave: () => void;
|
|
57
|
+
protected _onRHold: (e: IMouseState) => void;
|
|
58
|
+
protected _handleRotation(): void;
|
|
59
|
+
protected _onRDown: (e: IMouseState) => void;
|
|
60
|
+
protected _getTargetPoint(p: Vec2): Vec3 | null;
|
|
61
|
+
protected _onMouseWheel: (e: IMouseState) => void;
|
|
62
|
+
protected _onLDown: (e: IMouseState) => void;
|
|
63
|
+
protected _onLHold: (e: IMouseState) => void;
|
|
64
|
+
protected _onLUp: (e: IMouseState) => void;
|
|
65
|
+
protected _handleDrag(): void;
|
|
66
|
+
protected _corrRoll(): void;
|
|
67
|
+
protected _handleZoom(): void;
|
|
68
|
+
protected _updateVel(): void;
|
|
69
|
+
protected _updateVel_h(): void;
|
|
70
|
+
protected _updateVel_v(): void;
|
|
71
|
+
protected _updateVel_roll(): void;
|
|
72
|
+
protected get dt(): number;
|
|
73
|
+
stop(): void;
|
|
63
74
|
}
|
|
64
75
|
export {};
|