@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.
Files changed (84) hide show
  1. package/lib/@openglobus/js/Globe.d.ts +0 -1
  2. package/lib/@openglobus/js/camera/Camera.d.ts +48 -15
  3. package/lib/@openglobus/js/camera/PlanetCamera.d.ts +13 -0
  4. package/lib/@openglobus/js/control/MouseNavigation.d.ts +62 -51
  5. package/lib/@openglobus/js/control/OldMouseNavigation.d.ts +64 -0
  6. package/lib/@openglobus/js/control/index.d.ts +1 -2
  7. package/lib/@openglobus/js/entity/Entity.d.ts +24 -20
  8. package/lib/@openglobus/js/entity/GeoObject.d.ts +0 -9
  9. package/lib/@openglobus/js/input/MouseHandler.d.ts +1 -0
  10. package/lib/@openglobus/js/math/Mat3.d.ts +1 -1
  11. package/lib/@openglobus/js/math/Mat4.d.ts +10 -1
  12. package/lib/@openglobus/js/math/Plane.d.ts +3 -1
  13. package/lib/@openglobus/js/math/Quat.d.ts +1 -0
  14. package/lib/@openglobus/js/math/Ray.d.ts +6 -16
  15. package/lib/@openglobus/js/math/Vec2.d.ts +22 -0
  16. package/lib/@openglobus/js/renderer/RendererEvents.d.ts +1 -0
  17. package/lib/@openglobus/js/scene/Planet.d.ts +4 -0
  18. package/lib/@openglobus/js/webgl/Handler.d.ts +21 -12
  19. package/lib/@openglobus/og.esm.js +1 -1
  20. package/lib/@openglobus/og.esm.js.map +1 -1
  21. package/lib/@openglobus/og.umd.js +1 -1
  22. package/lib/@openglobus/og.umd.js.map +1 -1
  23. package/lib/js/Globe.d.ts +0 -1
  24. package/lib/js/Globe.js +4 -2
  25. package/lib/js/Popup.js +1 -1
  26. package/lib/js/camera/Camera.d.ts +48 -15
  27. package/lib/js/camera/Camera.js +82 -28
  28. package/lib/js/camera/PlanetCamera.d.ts +13 -0
  29. package/lib/js/camera/PlanetCamera.js +52 -5
  30. package/lib/js/control/CameraLock.js +1 -1
  31. package/lib/js/control/DebugInfo.js +30 -10
  32. package/lib/js/control/KeyboardNavigation.js +8 -8
  33. package/lib/js/control/MouseNavigation.d.ts +62 -51
  34. package/lib/js/control/MouseNavigation.js +361 -305
  35. package/lib/js/control/MouseWheelZoomControl.d.ts +0 -44
  36. package/lib/js/control/MouseWheelZoomControl.js +270 -181
  37. package/lib/js/control/OldMouseNavigation.d.ts +64 -0
  38. package/lib/js/control/OldMouseNavigation.js +368 -0
  39. package/lib/js/control/ScaleControl.js +2 -2
  40. package/lib/js/control/SimpleNavigation.js +8 -7
  41. package/lib/js/control/Sun.js +5 -5
  42. package/lib/js/control/TouchNavigation.js +11 -8
  43. package/lib/js/control/elevationProfile/ElevationProfileScene.js +2 -1
  44. package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.js +19 -33
  45. package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.js +18 -18
  46. package/lib/js/control/geoObjectEditor/MoveAxisEntity.js +3 -2
  47. package/lib/js/control/geoObjectEditor/MovePlaneEntity.js +1 -4
  48. package/lib/js/control/geoObjectEditor/RotateEntity.js +1 -1
  49. package/lib/js/control/index.d.ts +1 -2
  50. package/lib/js/control/index.js +1 -2
  51. package/lib/js/control/visibleExtent/Segment.js +4 -4
  52. package/lib/js/entity/Entity.d.ts +24 -20
  53. package/lib/js/entity/Entity.js +62 -47
  54. package/lib/js/entity/GeoObject.d.ts +0 -9
  55. package/lib/js/entity/GeoObject.js +0 -3
  56. package/lib/js/entity/InstanceData.js +6 -3
  57. package/lib/js/input/MouseHandler.d.ts +1 -0
  58. package/lib/js/input/MouseHandler.js +12 -1
  59. package/lib/js/math/Mat3.d.ts +1 -1
  60. package/lib/js/math/Mat3.js +1 -1
  61. package/lib/js/math/Mat4.d.ts +10 -1
  62. package/lib/js/math/Mat4.js +17 -1
  63. package/lib/js/math/Plane.d.ts +3 -1
  64. package/lib/js/math/Plane.js +11 -1
  65. package/lib/js/math/Quat.d.ts +1 -0
  66. package/lib/js/math/Quat.js +1 -0
  67. package/lib/js/math/Ray.d.ts +6 -16
  68. package/lib/js/math/Ray.js +53 -46
  69. package/lib/js/math/Vec2.d.ts +22 -0
  70. package/lib/js/math/Vec2.js +32 -0
  71. package/lib/js/renderer/Renderer.js +10 -6
  72. package/lib/js/renderer/RendererEvents.d.ts +1 -0
  73. package/lib/js/renderer/RendererEvents.js +3 -1
  74. package/lib/js/scene/Planet.d.ts +4 -0
  75. package/lib/js/scene/Planet.js +24 -3
  76. package/lib/js/segment/Segment.js +4 -4
  77. package/lib/js/terrain/GlobusTerrain.js +2 -2
  78. package/lib/js/webgl/Handler.d.ts +21 -12
  79. package/lib/js/webgl/Handler.js +42 -33
  80. package/package.json +2 -2
  81. package/lib/@openglobus/js/control/EarthNavigation.d.ts +0 -50
  82. package/lib/@openglobus/js/control/MouseWheelZoomControl.d.ts +0 -44
  83. package/lib/js/control/EarthNavigation.d.ts +0 -50
  84. package/lib/js/control/EarthNavigation.js +0 -202
@@ -0,0 +1,368 @@
1
+ import * as math from "../math";
2
+ 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
+ import { Quat } from "../math/Quat";
8
+ import { Ray } from "../math/Ray";
9
+ import { Sphere } from "../bv/Sphere";
10
+ import { Vec3 } from "../math/Vec3";
11
+ import { Plane } from "../math/Plane";
12
+ /**
13
+ * Mouse planet camera dragging control.
14
+ */
15
+ export class OldMouseNavigation extends Control {
16
+ constructor(options = {}) {
17
+ super(options);
18
+ this._deactivate = false;
19
+ this._shiftBusy = false;
20
+ this._name = "mouseNavigation";
21
+ this.grabbedPoint = new Vec3();
22
+ this._eye0 = new Vec3();
23
+ this.pointOnEarth = new Vec3();
24
+ this.earthUp = new Vec3();
25
+ this.inertia = 0.007;
26
+ this.grabbedSpheroid = new Sphere();
27
+ this.qRot = new Quat();
28
+ this.scaleRot = 0.0;
29
+ this.distDiff = 0.3;
30
+ this.stepsCount = 8;
31
+ this.stepsForward = null;
32
+ this.stepIndex = 0;
33
+ this._lmbDoubleClickActive = true;
34
+ this.minSlope = options.minSlope || 0.1;
35
+ this._wheelDirection = +1;
36
+ this._keyLock = new Key();
37
+ }
38
+ static getMovePointsFromPixelTerrain(cam, planet, stepsCount, delta, point, forward, dir) {
39
+ const steps = [];
40
+ let eye = cam.eye.clone(), n = cam.getBackward(), u = cam.getRight(), v = cam.getUp();
41
+ let a = planet.getCartesianFromPixelTerrain(point);
42
+ if (!a) {
43
+ a = planet.getCartesianFromPixelTerrain(planet.renderer.handler.getCenter());
44
+ }
45
+ if (a) {
46
+ if (!dir) {
47
+ dir = Vec3.sub(a, cam.eye).normalize();
48
+ }
49
+ let d = (delta * cam.eye.distance(a)) / stepsCount;
50
+ if (forward) {
51
+ d = -1.25 * d;
52
+ }
53
+ else {
54
+ d *= 2;
55
+ }
56
+ const scaled_n = n.scaleTo(d);
57
+ const slope = dir.dot(cam.eye.normal().negate());
58
+ if (slope >= 0.1) {
59
+ const grabbedSpheroid = new Sphere();
60
+ grabbedSpheroid.radius = a.length();
61
+ let rotArr = [], eyeArr = [];
62
+ let breaked = false;
63
+ for (let i = 0; i < stepsCount; i++) {
64
+ eye.addA(scaled_n);
65
+ const b = new Ray(eye, dir).hitSphere(grabbedSpheroid);
66
+ eyeArr[i] = eye.clone();
67
+ if (b) {
68
+ rotArr[i] = new Mat4().rotateBetweenVectors(a.normal(), b.normal());
69
+ }
70
+ else {
71
+ breaked = true;
72
+ break;
73
+ }
74
+ }
75
+ if (!breaked) {
76
+ for (let i = 0; i < stepsCount; i++) {
77
+ let rot = rotArr[i];
78
+ steps[i] = {
79
+ eye: rot.mulVec3(eyeArr[i]),
80
+ v: rot.mulVec3(v),
81
+ u: rot.mulVec3(u),
82
+ n: rot.mulVec3(n)
83
+ };
84
+ }
85
+ }
86
+ else {
87
+ eye = cam.eye.clone();
88
+ for (let i = 0; i < stepsCount; i++) {
89
+ steps[i] = {
90
+ eye: eye.addA(scaled_n).clone(),
91
+ v: v,
92
+ u: u,
93
+ n: n,
94
+ };
95
+ }
96
+ }
97
+ }
98
+ else {
99
+ for (let i = 0; i < stepsCount; i++) {
100
+ steps[i] = {
101
+ eye: eye.addA(dir.scaleTo(-d)).clone(),
102
+ v: v,
103
+ u: u,
104
+ n: n,
105
+ };
106
+ }
107
+ }
108
+ return steps;
109
+ }
110
+ }
111
+ onactivate() {
112
+ if (this.renderer) {
113
+ this.renderer.events.on("mousewheel", this.onMouseWheel, this);
114
+ this.renderer.events.on("lhold", this.onMouseLeftButtonDown, this);
115
+ this.renderer.events.on("rhold", this.onMouseRightButtonDown, this);
116
+ this.renderer.events.on("ldown", this.onMouseLeftButtonClick, this);
117
+ this.renderer.events.on("lup", this.onMouseLeftButtonUp, this);
118
+ this.renderer.events.on("rdown", this.onMouseRightButtonClick, this);
119
+ this.renderer.events.on("draw", this.onDraw, this, -1000);
120
+ this.renderer.events.on("mousemove", this.onMouseMove, this);
121
+ this.renderer.events.on("mouseleave", this.onMouseLeave, this);
122
+ this.renderer.events.on("mouseenter", this.onMouseEnter, this);
123
+ if (this._lmbDoubleClickActive) {
124
+ this.renderer.events.on("ldblclick", this.onMouseLeftButtonDoubleClick, this);
125
+ }
126
+ }
127
+ }
128
+ ondeactivate() {
129
+ if (this.renderer) {
130
+ this.renderer.events.off("mousewheel", this.onMouseWheel);
131
+ this.renderer.events.off("lhold", this.onMouseLeftButtonDown);
132
+ this.renderer.events.off("rhold", this.onMouseRightButtonDown);
133
+ this.renderer.events.off("ldown", this.onMouseLeftButtonClick);
134
+ this.renderer.events.off("lup", this.onMouseLeftButtonUp);
135
+ this.renderer.events.off("rdown", this.onMouseRightButtonClick);
136
+ this.renderer.events.off("draw", this.onDraw);
137
+ this.renderer.events.off("ldblclick", this.onMouseLeftButtonDoubleClick);
138
+ this.renderer.events.off("mouseleave", this.onMouseLeave);
139
+ this.renderer.events.off("mouseenter", this.onMouseEnter);
140
+ }
141
+ }
142
+ activateDoubleClickZoom() {
143
+ if (!this._lmbDoubleClickActive) {
144
+ this._lmbDoubleClickActive = true;
145
+ this.renderer && this.renderer.events.on("ldblclick", this.onMouseLeftButtonDoubleClick, this);
146
+ }
147
+ }
148
+ deactivateDoubleClickZoom() {
149
+ if (this._lmbDoubleClickActive) {
150
+ this._lmbDoubleClickActive = false;
151
+ this.renderer && this.renderer.events.off("ldblclick", this.onMouseLeftButtonDoubleClick);
152
+ }
153
+ }
154
+ onMouseEnter(e) {
155
+ const renderEvents = this.renderer.events;
156
+ if (renderEvents.isKeyPressed(input.KEY_ALT)) {
157
+ renderEvents.releaseKeys();
158
+ }
159
+ renderEvents.updateButtonsStates(e.sys.buttons);
160
+ if (renderEvents.mouseState.leftButtonDown) {
161
+ this.renderer.handler.canvas.classList.add("ogGrabbingPoiner");
162
+ }
163
+ else {
164
+ this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner");
165
+ }
166
+ }
167
+ onMouseLeave() {
168
+ if (this.renderer.events.mouseState.leftButtonDown) {
169
+ this.scaleRot = 0;
170
+ }
171
+ this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner");
172
+ }
173
+ onMouseWheel(e) {
174
+ if (this.stepIndex) {
175
+ return;
176
+ }
177
+ this.planet.stopFlying();
178
+ this.stopRotation();
179
+ this._deactivate = true;
180
+ this.lockPlanet(true);
181
+ this.stepsForward = OldMouseNavigation.getMovePointsFromPixelTerrain(this.planet.camera, this.planet, this.stepsCount, this.distDiff, e.pos, e.wheelDelta > 0, e.direction) || null;
182
+ this._wheelDirection = e.wheelDelta;
183
+ if (this.stepsForward) {
184
+ this.stepIndex = this.stepsCount;
185
+ }
186
+ }
187
+ oninit() {
188
+ this.activate();
189
+ if (this.renderer) {
190
+ this.renderer.events.on("keyfree", input.KEY_ALT, this.onShiftFree, this);
191
+ this.renderer.events.on("keyfree", input.KEY_PRINTSCREEN, this.onShiftFree, this);
192
+ }
193
+ }
194
+ onMouseLeftButtonDoubleClick(e) {
195
+ this.planet.stopFlying();
196
+ this.stopRotation();
197
+ const p = this.planet.getCartesianFromPixelTerrain(e.pos);
198
+ if (p) {
199
+ const cam = this.planet.camera;
200
+ let maxAlt = cam.maxAltitude + this.planet.ellipsoid.polarSize;
201
+ let minAlt = cam.minAltitude + this.planet.ellipsoid.polarSize;
202
+ const camAlt = cam.eye.length();
203
+ const g = this.planet.ellipsoid.cartesianToLonLat(p);
204
+ if (camAlt > maxAlt || camAlt < minAlt) {
205
+ this.planet.flyLonLat(new LonLat(g.lon, g.lat));
206
+ return;
207
+ }
208
+ if (this.renderer.events.isKeyPressed(input.KEY_ALT)) {
209
+ this.planet.flyLonLat(new LonLat(g.lon, g.lat, cam.eye.distance(p) * 2.0));
210
+ }
211
+ else {
212
+ this.planet.flyLonLat(new LonLat(g.lon, g.lat, cam.eye.distance(p) * 0.57));
213
+ }
214
+ }
215
+ }
216
+ onMouseLeftButtonClick() {
217
+ if (this._active) {
218
+ this.renderer.handler.canvas.classList.add("ogGrabbingPoiner");
219
+ this.grabbedPoint = this.planet.getCartesianFromMouseTerrain();
220
+ if (this.grabbedPoint) {
221
+ this._eye0.copy(this.planet.camera.eye);
222
+ this.grabbedSpheroid.radius = this.grabbedPoint.length();
223
+ this.stopRotation();
224
+ }
225
+ }
226
+ }
227
+ stopRotation() {
228
+ this.qRot.clear();
229
+ this.freePlanet();
230
+ }
231
+ onMouseLeftButtonUp(e) {
232
+ this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner");
233
+ if (e.x === e.prev_x && e.y === e.prev_y) {
234
+ this.scaleRot = 0.0;
235
+ }
236
+ }
237
+ onMouseLeftButtonDown(e) {
238
+ if (this._active) {
239
+ if (!this.grabbedPoint) {
240
+ return;
241
+ }
242
+ this.planet.stopFlying();
243
+ if (e.moving) {
244
+ let cam = this.planet.camera;
245
+ if (cam.slope > 0.2) {
246
+ const targetPoint = new Ray(cam.eye, e.direction).hitSphere(this.grabbedSpheroid);
247
+ if (targetPoint) {
248
+ this.scaleRot = 1.0;
249
+ this.qRot = Quat.getRotationBetweenVectors(targetPoint.normal(), this.grabbedPoint.normal());
250
+ let rot = this.qRot;
251
+ cam.eye = rot.mulVec3(cam.eye);
252
+ cam.rotate(rot);
253
+ // cam._u = rot.mulVec3(cam._u);
254
+ // cam._r = rot.mulVec3(cam._r);
255
+ // cam._b = rot.mulVec3(cam._b);
256
+ // cam._f.set(-cam._b.x, -cam._b.y, -cam._b.z);
257
+ }
258
+ }
259
+ else {
260
+ let p0 = this.grabbedPoint, p1 = Vec3.add(p0, cam.getRight()), p2 = Vec3.add(p0, p0.normal());
261
+ let px = new Vec3();
262
+ if (new Ray(cam.eye, e.direction).hitPlaneRes(Plane.fromPoints(p0, p1, p2), px) === Ray.INSIDE) {
263
+ cam.eye = this._eye0.addA(px.subA(p0).negate());
264
+ }
265
+ }
266
+ }
267
+ }
268
+ }
269
+ onMouseRightButtonClick(e) {
270
+ this.stopRotation();
271
+ this.planet.stopFlying();
272
+ this.pointOnEarth = this.planet.getCartesianFromPixelTerrain(e.pos);
273
+ if (this.pointOnEarth) {
274
+ this.earthUp = this.pointOnEarth.normal();
275
+ }
276
+ }
277
+ onMouseRightButtonDown(e) {
278
+ const cam = this.planet.camera;
279
+ if (this.pointOnEarth && e.moving) {
280
+ this.renderer.controlsBag.scaleRot = 1.0;
281
+ let l = (0.5 / cam.eye.distance(this.pointOnEarth)) * cam._lonLat.height * math.RADIANS;
282
+ if (l > 0.007) {
283
+ l = 0.007;
284
+ }
285
+ else if (l < 0.003) {
286
+ l = 0.003;
287
+ }
288
+ cam.rotateHorizontal(l * (e.x - e.prev_x), false, this.pointOnEarth, this.earthUp);
289
+ cam.rotateVertical(l * (e.y - e.prev_y), this.pointOnEarth, this.minSlope);
290
+ }
291
+ }
292
+ onShiftFree() {
293
+ this._shiftBusy = false;
294
+ }
295
+ onMouseMove(e) {
296
+ if (this._active && this.renderer.events.isKeyPressed(input.KEY_ALT)) {
297
+ if (!this._shiftBusy) {
298
+ this._shiftBusy = true;
299
+ this.onMouseRightButtonClick(e);
300
+ }
301
+ this.onMouseRightButtonDown(e);
302
+ }
303
+ }
304
+ onDraw() {
305
+ if (this._active) {
306
+ const r = this.renderer;
307
+ const cam = this.planet.camera;
308
+ let prevEye = cam.eye.clone();
309
+ if (this.stepIndex) {
310
+ r.controlsBag.scaleRot = 1.0;
311
+ const sf = this.stepsForward[this.stepsCount - this.stepIndex--];
312
+ cam.eye = sf.eye;
313
+ //@ts-ignore
314
+ cam._u = sf.v;
315
+ //@ts-ignore
316
+ cam._r = sf.u;
317
+ //@ts-ignore
318
+ cam._b = sf.n;
319
+ //@ts-ignore
320
+ cam._f.set(-cam._b.x, -cam._b.y, -cam._b.z);
321
+ }
322
+ else {
323
+ if (this._deactivate) {
324
+ this._deactivate = false;
325
+ this.freePlanet();
326
+ }
327
+ }
328
+ if (r.events.mouseState.leftButtonDown || !this.scaleRot) {
329
+ return;
330
+ }
331
+ this.scaleRot -= this.inertia;
332
+ if (this.scaleRot <= 0.0) {
333
+ this.scaleRot = 0.0;
334
+ }
335
+ else {
336
+ r.controlsBag.scaleRot = this.scaleRot;
337
+ let rot = this.qRot
338
+ .slerp(Quat.IDENTITY, 1.0 - this.scaleRot * this.scaleRot * this.scaleRot)
339
+ .normalize();
340
+ if (!(rot.x || rot.y || rot.z)) {
341
+ this.scaleRot = 0.0;
342
+ }
343
+ cam.eye = rot.mulVec3(cam.eye);
344
+ cam.rotate(rot);
345
+ // cam._u = rot.mulVec3(cam._u);
346
+ // cam._r = rot.mulVec3(cam._r);
347
+ // cam._b = rot.mulVec3(cam._b);
348
+ // cam._f.set(-cam._b.x, -cam._b.y, -cam._b.z);
349
+ }
350
+ if (cam.eye.distance(prevEye) / cam.getAltitude() > 0.01) {
351
+ this.lockPlanet();
352
+ }
353
+ else {
354
+ this.freePlanet();
355
+ }
356
+ }
357
+ }
358
+ lockPlanet(skipTerrain) {
359
+ this.planet.layerLock.lock(this._keyLock);
360
+ !skipTerrain && this.planet.terrainLock.lock(this._keyLock);
361
+ this.planet._normalMapCreator.lock(this._keyLock);
362
+ }
363
+ freePlanet() {
364
+ this.planet.layerLock.free(this._keyLock);
365
+ this.planet.terrainLock.free(this._keyLock);
366
+ this.planet._normalMapCreator.free(this._keyLock);
367
+ }
368
+ }
@@ -63,13 +63,13 @@ export class ScaleControl extends Control {
63
63
  let s0 = px;
64
64
  let dist = this.planet.getDistanceFromPixel(s0) || 0;
65
65
  if (dist === 0) {
66
- s0 = cam.project(Vec3.ZERO);
66
+ s0 = cam.project3v(Vec3.ZERO);
67
67
  dist = this.planet.getDistanceFromPixel(s0) || 0;
68
68
  }
69
69
  let p0 = cam.getForward().scaleTo(dist).addA(cam.eye);
70
70
  let tempSize = dist * Math.tan(cam.viewAngle * RADIANS);
71
71
  let p1 = p0.add(cam.getRight().scaleTo(tempSize));
72
- let s1 = cam.project(p1);
72
+ let s1 = cam.project3v(p1);
73
73
  this._mPx = tempSize / s1.distance(s0);
74
74
  let metersInMinSize = this._mPx * this._minWidth;
75
75
  let index = binarySearch(scale, metersInMinSize, (a, b) => a - b);
@@ -3,6 +3,7 @@ import { input } from "../input/input";
3
3
  import { Vec3 } from "../math/Vec3";
4
4
  import * as math from "../math";
5
5
  import { Ray } from "../math/Ray";
6
+ import { Plane } from "../math/Plane";
6
7
  /**
7
8
  * Simple keyboard camera navigation with W,S,A,D and shift keys to fly around the scene.
8
9
  */
@@ -45,7 +46,7 @@ export class SimpleNavigation extends Control {
45
46
  p2 = Vec3.add(p0, Vec3.UP);
46
47
  }
47
48
  let px = new Vec3();
48
- if (new Ray(cam.eye, e.direction).hitPlane(p0, p1, p2, px) === Ray.INSIDE) {
49
+ if (new Ray(cam.eye, e.direction).hitPlaneRes(Plane.fromPoints(p0, p1, p2), px) === Ray.INSIDE) {
49
50
  cam.eye = this._eye0.addA(px.subA(p0).negate());
50
51
  }
51
52
  }
@@ -97,32 +98,32 @@ export class SimpleNavigation extends Control {
97
98
  };
98
99
  this.onCameraLookUp = () => {
99
100
  let cam = this.renderer.activeCamera;
100
- cam.pitch(0.5);
101
+ cam.setPitch(0.5);
101
102
  cam.update();
102
103
  };
103
104
  this.onCameraLookDown = () => {
104
105
  let cam = this.renderer.activeCamera;
105
- cam.pitch(-0.5);
106
+ cam.setPitch(-0.5);
106
107
  cam.update();
107
108
  };
108
109
  this.onCameraTurnLeft = () => {
109
110
  let cam = this.renderer.activeCamera;
110
- cam.yaw(0.5);
111
+ cam.setYaw(0.5);
111
112
  cam.update();
112
113
  };
113
114
  this.onCameraTurnRight = () => {
114
115
  let cam = this.renderer.activeCamera;
115
- cam.yaw(-0.5);
116
+ cam.setYaw(-0.5);
116
117
  cam.update();
117
118
  };
118
119
  this.onCameraRollLeft = () => {
119
120
  let cam = this.renderer.activeCamera;
120
- cam.roll(-0.5);
121
+ cam.setRoll(-0.5);
121
122
  cam.update();
122
123
  };
123
124
  this.onCameraRollRight = () => {
124
125
  let cam = this.renderer.activeCamera;
125
- cam.roll(0.5);
126
+ cam.setRoll(0.5);
126
127
  cam.update();
127
128
  };
128
129
  this.speed = options.speed || 1.0; // m/s
@@ -71,18 +71,18 @@ export class Sun extends Control {
71
71
  this._lightOn = true;
72
72
  this._f = 1;
73
73
  let n = cam.eye.normal(), u = cam.getForward();
74
- u.scale(Math.sign(cam._u.dot(n))); // up
74
+ u.scale(Math.sign(cam.getUp().dot(n))); // up
75
75
  if (cam.slope > 0.99) {
76
- u = cam._u;
76
+ u = cam.getUp();
77
77
  }
78
78
  let tu = Vec3.proj_b_to_plane(u, n, u).normalize().scale(this.offsetVertical);
79
- let tr = Vec3.proj_b_to_plane(cam._r, n, cam._r)
79
+ let tr = Vec3.proj_b_to_plane(cam.getRight(), n, cam.getRight())
80
80
  .normalize()
81
81
  .scale(this.offsetHorizontal); // right
82
82
  let d = tu.add(tr);
83
83
  let pos = cam.eye.add(d);
84
84
  if (this._k > 0) {
85
- this._k -= 0.01;
85
+ this._k -= 0.001;
86
86
  let rot = Quat.getRotationBetweenVectors(this.sunlight._position.normal(), pos.normal());
87
87
  let r = rot.slerp(Quat.IDENTITY, this._k).normalize();
88
88
  this.sunlight.setPosition3v(r.mulVec3(this.sunlight._position));
@@ -94,7 +94,7 @@ export class Sun extends Control {
94
94
  else {
95
95
  this._k = 1;
96
96
  if (this._f > 0) {
97
- this._f -= 0.01;
97
+ this._f -= 0.001;
98
98
  let rot = Quat.getRotationBetweenVectors(this.sunlight._position.normal(), getSunPosition(this._currDate).normal());
99
99
  let r = rot.slerp(Quat.IDENTITY, this._f).normalize();
100
100
  this.sunlight.setPosition3v(r.mulVec3(this.sunlight._position));
@@ -7,6 +7,7 @@ import { Ray } from "../math/Ray";
7
7
  import { Sphere } from "../bv/Sphere";
8
8
  import { Vec2 } from "../math/Vec2";
9
9
  import { Vec3 } from "../math/Vec3";
10
+ import { Plane } from "../math/Plane";
10
11
  class TouchExt {
11
12
  constructor() {
12
13
  this.x = 0;
@@ -198,18 +199,19 @@ export class TouchNavigation extends Control {
198
199
  this.qRot = Quat.getRotationBetweenVectors(targetPoint.normal(), t.grabbedPoint.normal());
199
200
  let rot = this.qRot;
200
201
  cam.eye = rot.mulVec3(cam.eye);
201
- cam._r = rot.mulVec3(cam._r);
202
- cam._u = rot.mulVec3(cam._u);
203
- cam._b = rot.mulVec3(cam._b);
202
+ cam.rotate(rot);
203
+ // cam._r = rot.mulVec3(cam._r);
204
+ // cam._u = rot.mulVec3(cam._u);
205
+ // cam._b = rot.mulVec3(cam._b);
204
206
  cam.checkTerrainCollision();
205
207
  cam.update();
206
208
  this.scaleRot = 1;
207
209
  }
208
210
  else {
209
- let p0 = t.grabbedPoint, p1 = Vec3.add(p0, cam._u), p2 = Vec3.add(p0, p0.normal());
211
+ let p0 = t.grabbedPoint, p1 = Vec3.add(p0, cam.getUp()), p2 = Vec3.add(p0, p0.getNormal());
210
212
  let dir = cam.unproject(t.x, t.y);
211
213
  let px = new Vec3();
212
- if (new Ray(cam.eye, dir).hitPlane(p0, p1, p2, px) === Ray.INSIDE) {
214
+ if (new Ray(cam.eye, dir).hitPlaneRes(Plane.fromPoints(p0, p1, p2), px) === Ray.INSIDE) {
213
215
  cam.eye = this._eye0.addA(px.subA(p0).negate());
214
216
  cam.checkTerrainCollision();
215
217
  cam.update();
@@ -243,9 +245,10 @@ export class TouchNavigation extends Control {
243
245
  this.scaleRot = 0;
244
246
  }
245
247
  cam.eye = rot.mulVec3(cam.eye);
246
- cam._r = rot.mulVec3(cam._r);
247
- cam._u = rot.mulVec3(cam._u);
248
- cam._b = rot.mulVec3(cam._b);
248
+ cam.rotate(rot);
249
+ // cam._r = rot.mulVec3(cam._r);
250
+ // cam._u = rot.mulVec3(cam._u);
251
+ // cam._b = rot.mulVec3(cam._b);
249
252
  cam.checkTerrainCollision();
250
253
  cam.update();
251
254
  }
@@ -8,6 +8,7 @@ import { Vector } from '../../layer/Vector';
8
8
  import { Vec2 } from '../../math/Vec2';
9
9
  import { Vec3 } from '../../math/Vec3';
10
10
  import { Ray } from "../../math/Ray";
11
+ import { Plane } from "../../math/Plane";
11
12
  let groundObj3d = Object3d.createCylinder(0.33, 0, 1.0, 20, 1, true, false, 0, 0, 0);
12
13
  let headObj3d = Object3d.createCylinder(0.33, 0.33, 1.1, 20, 1, true, true, 0, -0.55, 0);
13
14
  const POINTER_RAY_OPTIONS = {
@@ -79,7 +80,7 @@ class ElevationProfileScene extends RenderNode {
79
80
  let p1 = p0.add(groundNormal);
80
81
  let p2 = p0.add(cam.getRight());
81
82
  let px = new Vec3();
82
- if (new Ray(cam.eye, e.direction).hitPlane(p0, p1, p2, px) === Ray.INSIDE) {
83
+ if (new Ray(cam.eye, e.direction).hitPlaneRes(Plane.fromPoints(p0, p1, p2), px) === Ray.INSIDE) {
83
84
  let h = Vec3.proj_b_to_a(px, p0);
84
85
  let s = h.sub(p0).dot(p0);
85
86
  let headPos = p0.add(groundNormal.scale(Math.sign(s) * h.distance(p0)));
@@ -4,6 +4,7 @@ import { Checkbox } from "../../ui/Checkbox";
4
4
  import { Button } from "../../ui/Button";
5
5
  import { Vec3 } from "../../math/Vec3";
6
6
  import { ToggleButton } from "../../ui/ToggleButton";
7
+ import { DEGREES, RADIANS } from "../../math";
7
8
  const ICON_LOCK_BUTTON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" id="filter-center-focus">
8
9
  <path d="M5 15H3v4c0 1.1.9 2 2 2h4v-2H5v-4zM5 5h4V3H5c-1.1 0-2 .9-2 2v4h2V5zm14-2h-4v2h4v4h2V5c0-1.1-.9-2-2-2zm0 16h-4v2h4c1.1 0 2-.9 2-2v-4h-2v4zM12 9c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"/>
9
10
  </svg>`;
@@ -41,39 +42,24 @@ export class GeoObjectPropertiesDialog extends Dialog {
41
42
  };
42
43
  this._onPosition = (pos, entity) => {
43
44
  this._refresh(entity);
44
- // let ll = entity.getLonLat();
45
- // this._lonView.stopPropagation();
46
- // this._latView.stopPropagation();
47
- // this._heightView.stopPropagation();
48
- // this._lonView.value = ll.lon;
49
- // this._latView.value = ll.lat;
50
- // this._heightView.value = ll.height;
51
- //
52
- // let cart = entity.getCartesian();
53
- // this._xView.stopPropagation();
54
- // this._yView.stopPropagation();
55
- // this._zView.stopPropagation();
56
- // this._xView.value = cart.x;
57
- // this._yView.value = cart.y;
58
- // this._zView.value = cart.z;
59
45
  };
60
46
  this._onPitch = (a, entity) => {
61
47
  this._pitchView.stopPropagation();
62
- this._pitchView.value = entity.getPitch();
48
+ this._pitchView.value = entity.getPitch() * DEGREES;
63
49
  this._absolutePitchView.stopPropagation();
64
- this._absolutePitchView.value = entity.getAbsolutePitch();
50
+ this._absolutePitchView.value = entity.getAbsolutePitch() * DEGREES;
65
51
  };
66
52
  this._onYaw = (a, entity) => {
67
53
  this._yawView.stopPropagation();
68
- this._yawView.value = entity.getYaw();
54
+ this._yawView.value = entity.getYaw() * DEGREES;
69
55
  this._absoluteYawView.stopPropagation();
70
- this._absoluteYawView.value = entity.getAbsoluteYaw();
56
+ this._absoluteYawView.value = entity.getAbsoluteYaw() * DEGREES;
71
57
  };
72
58
  this._onRoll = (a, entity) => {
73
59
  this._rollView.stopPropagation();
74
- this._rollView.value = entity.getRoll();
60
+ this._rollView.value = entity.getRoll() * DEGREES;
75
61
  this._absoluteRollView.stopPropagation();
76
- this._absoluteRollView.value = entity.getAbsoluteRoll();
62
+ this._absoluteRollView.value = entity.getAbsoluteRoll() * DEGREES;
77
63
  };
78
64
  this._onChangeLon = (val) => {
79
65
  let entity = this.model.getSelectedEntity();
@@ -150,42 +136,42 @@ export class GeoObjectPropertiesDialog extends Dialog {
150
136
  this._onChangePitch = (val) => {
151
137
  let entity = this.model.getSelectedEntity();
152
138
  if (entity) {
153
- entity.setPitch(parseFloat(val));
139
+ entity.setPitch(parseFloat(val) * RADIANS);
154
140
  this._refresh(entity);
155
141
  }
156
142
  };
157
143
  this._onChangeYaw = (val) => {
158
144
  let entity = this.model.getSelectedEntity();
159
145
  if (entity) {
160
- entity.setYaw(parseFloat(val));
146
+ entity.setYaw(parseFloat(val) * RADIANS);
161
147
  this._refresh(entity);
162
148
  }
163
149
  };
164
150
  this._onChangeRoll = (val) => {
165
151
  let entity = this.model.getSelectedEntity();
166
152
  if (entity) {
167
- entity.setRoll(parseFloat(val));
153
+ entity.setRoll(parseFloat(val) * RADIANS);
168
154
  this._refresh(entity);
169
155
  }
170
156
  };
171
157
  this._onChangeAbsolutePitch = (val) => {
172
158
  let entity = this.model.getSelectedEntity();
173
159
  if (entity) {
174
- entity.setAbsolutePitch(parseFloat(val));
160
+ entity.setAbsolutePitch(parseFloat(val) * RADIANS);
175
161
  this._refresh(entity);
176
162
  }
177
163
  };
178
164
  this._onChangeAbsoluteYaw = (val) => {
179
165
  let entity = this.model.getSelectedEntity();
180
166
  if (entity) {
181
- entity.setAbsoluteYaw(parseFloat(val));
167
+ entity.setAbsoluteYaw(parseFloat(val) * RADIANS);
182
168
  this._refresh(entity);
183
169
  }
184
170
  };
185
171
  this._onChangeAbsoluteRoll = (val) => {
186
172
  let entity = this.model.getSelectedEntity();
187
173
  if (entity) {
188
- entity.setAbsoluteRoll(parseFloat(val));
174
+ entity.setAbsoluteRoll(parseFloat(val) * RADIANS);
189
175
  this._refresh(entity);
190
176
  }
191
177
  };
@@ -470,15 +456,15 @@ export class GeoObjectPropertiesDialog extends Dialog {
470
456
  this._pitchView.stopPropagation();
471
457
  this._yawView.stopPropagation();
472
458
  this._rollView.stopPropagation();
473
- this._pitchView.value = entity.getPitch();
474
- this._yawView.value = entity.getYaw();
475
- this._rollView.value = entity.getRoll();
459
+ this._pitchView.value = entity.getPitch() * DEGREES;
460
+ this._yawView.value = entity.getYaw() * DEGREES;
461
+ this._rollView.value = entity.getRoll() * DEGREES;
476
462
  this._absolutePitchView.stopPropagation();
477
463
  this._absoluteYawView.stopPropagation();
478
464
  this._absoluteRollView.stopPropagation();
479
- this._absolutePitchView.value = entity.getAbsolutePitch();
480
- this._absoluteYawView.value = entity.getAbsoluteYaw();
481
- this._absoluteRollView.value = entity.getAbsoluteRoll();
465
+ this._absolutePitchView.value = entity.getAbsolutePitch() * DEGREES;
466
+ this._absoluteYawView.value = entity.getAbsoluteYaw() * DEGREES;
467
+ this._absoluteRollView.value = entity.getAbsoluteRoll() * DEGREES;
482
468
  this._scaleView.stopPropagation();
483
469
  let scl = entity.getScale();
484
470
  if ((scl.x === scl.y) && (scl.y === scl.z)) {