@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
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { Control } from "./Control";
|
|
2
|
-
import { LonLat } from "../LonLat";
|
|
3
|
-
import { Quat } from "../math/Quat";
|
|
4
|
-
import { Ray } from "../math/Ray";
|
|
5
|
-
import { Sphere } from "../bv/Sphere";
|
|
6
|
-
import { Vec2 } from "../math/Vec2";
|
|
7
|
-
import { Vec3 } from "../math/Vec3";
|
|
8
|
-
class TouchExt {
|
|
9
|
-
constructor() {
|
|
10
|
-
this.x = 0;
|
|
11
|
-
this.y = 0;
|
|
12
|
-
this.prev_x = 0;
|
|
13
|
-
this.prev_y = 0;
|
|
14
|
-
this.grabbedPoint = new Vec3();
|
|
15
|
-
this.grabbedSpheroid = new Sphere();
|
|
16
|
-
}
|
|
17
|
-
dX() {
|
|
18
|
-
return this.x - this.prev_x;
|
|
19
|
-
}
|
|
20
|
-
dY() {
|
|
21
|
-
return this.y - this.prev_y;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
export class EarthNavigation extends Control {
|
|
25
|
-
constructor(options = {}) {
|
|
26
|
-
super(options);
|
|
27
|
-
this.grabbedPoint = new Vec3();
|
|
28
|
-
this.grabbedDir = new Vec3();
|
|
29
|
-
this.inertia = 0.007;
|
|
30
|
-
this.grabbedSpheroid = new Sphere();
|
|
31
|
-
this.planet = null;
|
|
32
|
-
this._vRot = new Quat();
|
|
33
|
-
this._hRot = new Quat();
|
|
34
|
-
this._a = 0.0;
|
|
35
|
-
this.scaleRot = 0;
|
|
36
|
-
this.currState = 0;
|
|
37
|
-
this.positionState = [
|
|
38
|
-
{ h: 17119745.303455353, max: 0.98, min: -0.98 },
|
|
39
|
-
{ h: 6866011, max: 0.98, min: -0.98 },
|
|
40
|
-
{ h: 3000000, max: 0.98, min: -0.98 },
|
|
41
|
-
{ h: 1000000, max: 0.98, min: -0.98 },
|
|
42
|
-
{ h: 500000, max: 0.98, min: -0.98 }
|
|
43
|
-
];
|
|
44
|
-
this.touches = [new TouchExt(), new TouchExt()];
|
|
45
|
-
}
|
|
46
|
-
switchZoomState(wheelDelta) {
|
|
47
|
-
this.stopRotation();
|
|
48
|
-
if (wheelDelta > 0) {
|
|
49
|
-
this.currState++;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
this.currState--;
|
|
53
|
-
}
|
|
54
|
-
if (this.currState <= 0)
|
|
55
|
-
this.currState = 0;
|
|
56
|
-
if (this.currState >= this.positionState.length) {
|
|
57
|
-
this.currState = this.positionState.length - 1;
|
|
58
|
-
}
|
|
59
|
-
this.planet.stopFlying();
|
|
60
|
-
const ll = this.planet.camera._lonLat;
|
|
61
|
-
this.planet.flyLonLat(new LonLat(ll.lon, ll.lat, this.positionState[this.currState].h));
|
|
62
|
-
}
|
|
63
|
-
onMouseWheel(event) {
|
|
64
|
-
this.switchZoomState(event.wheelDelta);
|
|
65
|
-
}
|
|
66
|
-
oninit() {
|
|
67
|
-
this.activate();
|
|
68
|
-
}
|
|
69
|
-
onactivate() {
|
|
70
|
-
let r = this.renderer;
|
|
71
|
-
r.events.on("mousewheel", this.onMouseWheel, this);
|
|
72
|
-
r.events.on("lhold", this.onMouseLeftButtonDown, this);
|
|
73
|
-
r.events.on("ldown", this.onMouseLeftButtonClick, this);
|
|
74
|
-
r.events.on("lup", this.onMouseLeftButtonUp, this);
|
|
75
|
-
r.events.on("touchstart", this.onTouchStart, this);
|
|
76
|
-
r.events.on("touchend", this.onTouchEnd, this);
|
|
77
|
-
r.events.on("touchmove", this.onTouchMove, this);
|
|
78
|
-
r.events.on("draw", this.onDraw, this);
|
|
79
|
-
}
|
|
80
|
-
onTouchStart(e) {
|
|
81
|
-
if (e.sys.touches.length == 1) {
|
|
82
|
-
const t = this.touches[0];
|
|
83
|
-
t.x = e.sys.touches.item(0).pageX - e.sys.offsetLeft;
|
|
84
|
-
t.y = e.sys.touches.item(0).pageY - e.sys.offsetTop;
|
|
85
|
-
t.prev_x = e.sys.touches.item(0).pageX - e.sys.offsetLeft;
|
|
86
|
-
t.prev_y = e.sys.touches.item(0).pageY - e.sys.offsetTop;
|
|
87
|
-
// t.grabbedPoint = this.planet!.getCartesianFromPixelTerrain(t, true);
|
|
88
|
-
t.grabbedPoint = this.planet.getCartesianFromPixelTerrain(new Vec2(t.x, t.y)) || null;
|
|
89
|
-
if (t.grabbedPoint) {
|
|
90
|
-
t.grabbedSpheroid.radius = t.grabbedPoint.length();
|
|
91
|
-
this.stopRotation();
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
onTouchEnd(e) {
|
|
96
|
-
if (e.sys.touches.length == 0) {
|
|
97
|
-
this.scaleRot = 1;
|
|
98
|
-
if (Math.abs(this.touches[0].x - this.touches[0].prev_x) < 3 &&
|
|
99
|
-
Math.abs(this.touches[0].y - this.touches[0].prev_y) < 3)
|
|
100
|
-
this.stopRotation();
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
onTouchMove(e) {
|
|
104
|
-
if (e.sys.touches.length == 1) {
|
|
105
|
-
let cam = this.planet.camera;
|
|
106
|
-
let t = this.touches[0];
|
|
107
|
-
t.prev_x = t.x;
|
|
108
|
-
t.prev_y = t.y;
|
|
109
|
-
t.x = e.sys.touches.item(0).pageX - e.sys.offsetLeft;
|
|
110
|
-
t.y = e.sys.touches.item(0).pageY - e.sys.offsetTop;
|
|
111
|
-
if (!t.grabbedPoint)
|
|
112
|
-
return;
|
|
113
|
-
let direction = cam.unproject(t.x, t.y);
|
|
114
|
-
let targetPoint = new Ray(cam.eye, direction).hitSphere(t.grabbedSpheroid);
|
|
115
|
-
if (targetPoint) {
|
|
116
|
-
this._a =
|
|
117
|
-
Math.acos(t.grabbedPoint.y / t.grabbedSpheroid.radius) -
|
|
118
|
-
Math.acos(targetPoint.y / t.grabbedSpheroid.radius);
|
|
119
|
-
this._vRot = Quat.axisAngleToQuat(cam._u, this._a);
|
|
120
|
-
this._hRot = Quat.getRotationBetweenVectors(new Vec3(targetPoint.x, 0.0, targetPoint.z).normal(), new Vec3(t.grabbedPoint.x, 0.0, t.grabbedPoint.z).normal());
|
|
121
|
-
let rot = this._hRot.mul(this._vRot);
|
|
122
|
-
let state = this.positionState[this.currState];
|
|
123
|
-
let lim = rot.mulVec3(cam.eye).normal().dot(Vec3.NORTH);
|
|
124
|
-
if (lim > state.max || lim < state.min) {
|
|
125
|
-
rot = Quat.yRotation(rot.getYaw());
|
|
126
|
-
}
|
|
127
|
-
cam.set(rot.mulVec3(cam.eye), Vec3.ZERO, Vec3.NORTH);
|
|
128
|
-
cam.update();
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
onMouseLeftButtonClick(e) {
|
|
133
|
-
this.renderer.handler.canvas.classList.add("ogGrabbingPoiner");
|
|
134
|
-
this.grabbedPoint = this.planet.getCartesianFromMouseTerrain() || null;
|
|
135
|
-
this.grabbedDir.copy(e.direction);
|
|
136
|
-
if (this.grabbedPoint) {
|
|
137
|
-
this.grabbedSpheroid.radius = this.grabbedPoint.length();
|
|
138
|
-
this.stopRotation();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
stopRotation() {
|
|
142
|
-
this.scaleRot = 0.0;
|
|
143
|
-
this._a = 0.0;
|
|
144
|
-
this._vRot.clear();
|
|
145
|
-
this._hRot.clear();
|
|
146
|
-
}
|
|
147
|
-
onMouseLeftButtonUp(e) {
|
|
148
|
-
this.scaleRot = 1;
|
|
149
|
-
this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner");
|
|
150
|
-
if (Math.abs(e.x - e.prev_x) < 3 && Math.abs(e.y - e.prev_y) < 3)
|
|
151
|
-
this.stopRotation();
|
|
152
|
-
}
|
|
153
|
-
onMouseLeftButtonDown(e) {
|
|
154
|
-
let cam = this.planet.camera;
|
|
155
|
-
if (!this.grabbedPoint || cam.isFlying())
|
|
156
|
-
return;
|
|
157
|
-
if (this.renderer.events.mouseState.moving) {
|
|
158
|
-
let targetPoint = new Ray(cam.eye, e.direction).hitSphere(this.grabbedSpheroid);
|
|
159
|
-
if (targetPoint) {
|
|
160
|
-
this._a = Math.acos(this.grabbedPoint.y / this.grabbedSpheroid.radius) -
|
|
161
|
-
Math.acos(targetPoint.y / this.grabbedSpheroid.radius);
|
|
162
|
-
let rot = this._vRot = Quat.axisAngleToQuat(cam._u, this._a);
|
|
163
|
-
cam.set(rot.mulVec3(cam.eye), Vec3.ZERO, rot.mulVec3(cam.getUp()));
|
|
164
|
-
this._hRot = Quat.getRotationBetweenVectors(new Vec3(targetPoint.x, 0.0, targetPoint.z).normal(), new Vec3(this.grabbedPoint.x, 0.0, this.grabbedPoint.z).normal());
|
|
165
|
-
rot = this._hRot;
|
|
166
|
-
cam.set(rot.mulVec3(cam.eye), Vec3.ZERO, rot.mulVec3(cam.getUp()));
|
|
167
|
-
cam.update();
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
this.scaleRot = 0;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
onDraw() {
|
|
175
|
-
let r = this.renderer;
|
|
176
|
-
let cam = this.planet.camera;
|
|
177
|
-
if (r.events.mouseState.leftButtonDown || !this.scaleRot || cam.isFlying())
|
|
178
|
-
return;
|
|
179
|
-
this.scaleRot -= this.inertia;
|
|
180
|
-
if (this.scaleRot <= 0) {
|
|
181
|
-
this.scaleRot = 0;
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
this._vRot = Quat.axisAngleToQuat(cam._u, this._a);
|
|
185
|
-
let rot = this._vRot.mul(this._hRot);
|
|
186
|
-
let lim = rot.mulVec3(cam.eye).normal().dot(Vec3.NORTH);
|
|
187
|
-
let state = this.positionState[this.currState];
|
|
188
|
-
if (lim > state.max || lim < state.min) {
|
|
189
|
-
rot = Quat.yRotation(rot.getYaw());
|
|
190
|
-
}
|
|
191
|
-
r.controlsBag.scaleRot = this.scaleRot;
|
|
192
|
-
rot = rot
|
|
193
|
-
.slerp(Quat.IDENTITY, 1 - this.scaleRot * this.scaleRot * this.scaleRot)
|
|
194
|
-
.normalize();
|
|
195
|
-
if (!(rot.x || rot.y || rot.z)) {
|
|
196
|
-
this.scaleRot = 0;
|
|
197
|
-
}
|
|
198
|
-
cam.set(rot.mulVec3(cam.eye), Vec3.ZERO, Vec3.NORTH);
|
|
199
|
-
cam.update();
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|