@openglobus/og 0.13.4 → 0.13.7

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 (55) hide show
  1. package/css/og.css +66 -25
  2. package/dist/@openglobus/og.css +1 -1
  3. package/dist/@openglobus/og.esm.js +2 -2
  4. package/dist/@openglobus/og.esm.js.map +1 -1
  5. package/dist/@openglobus/og.umd.js +2 -2
  6. package/dist/@openglobus/og.umd.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/og/Events.js +188 -188
  9. package/src/og/Extent.js +1 -9
  10. package/src/og/Globe.js +1 -0
  11. package/src/og/control/DebugInfo.js +15 -4
  12. package/src/og/control/EarthCoordinates.js +151 -160
  13. package/src/og/control/KeyboardNavigation.js +48 -2
  14. package/src/og/control/TouchNavigation.js +13 -13
  15. package/src/og/control/ZoomControl.js +1 -1
  16. package/src/og/ellipsoid/Ellipsoid.js +1 -1
  17. package/src/og/entity/Billboard.js +165 -165
  18. package/src/og/entity/BillboardHandler.js +1 -1
  19. package/src/og/entity/Geometry.js +319 -319
  20. package/src/og/entity/Label.js +348 -346
  21. package/src/og/entity/LabelHandler.js +44 -37
  22. package/src/og/input/input.js +7 -1
  23. package/src/og/layer/CanvasTiles.js +8 -8
  24. package/src/og/layer/KML.js +181 -12
  25. package/src/og/layer/Layer.js +4 -2
  26. package/src/og/layer/XYZ.js +4 -2
  27. package/src/og/quadTree/Node.js +1 -0
  28. package/src/og/renderer/RendererEvents.js +17 -3
  29. package/src/og/scene/Planet.js +89 -30
  30. package/src/og/segment/Segment.js +1 -0
  31. package/src/og/shaders/label.js +56 -13
  32. package/src/og/terrain/EmptyTerrain.js +164 -146
  33. package/src/og/terrain/Geoid.js +246 -241
  34. package/src/og/terrain/GlobusTerrain.js +23 -24
  35. package/src/og/terrain/MapboxTerrain.js +292 -294
  36. package/src/og/utils/FontAtlas.js +25 -15
  37. package/src/og/utils/Loader.js +53 -12
  38. package/src/og/utils/PlainSegmentWorker.js +38 -26
  39. package/src/og/utils/TextureAtlas.js +291 -280
  40. package/src/og/utils/units.js +78 -0
  41. package/types/control/EarthCoordinates.d.ts +27 -30
  42. package/types/control/KeyboardNavigation.d.ts +3 -0
  43. package/types/entity/Label.d.ts +1 -0
  44. package/types/entity/LabelHandler.d.ts +1 -1
  45. package/types/input/input.d.ts +6 -0
  46. package/types/layer/KML.d.ts +26 -1
  47. package/types/renderer/RendererEvents.d.ts +2 -0
  48. package/types/scene/Planet.d.ts +10 -1
  49. package/types/terrain/EmptyTerrain.d.ts +4 -1
  50. package/types/terrain/Geoid.d.ts +1 -10
  51. package/types/terrain/GlobusTerrain.d.ts +0 -2
  52. package/types/terrain/MapboxTerrain.d.ts +1 -1
  53. package/types/utils/Loader.d.ts +3 -0
  54. package/types/utils/TextureAtlas.d.ts +2 -0
  55. package/types/utils/units.d.ts +20 -0
@@ -1,64 +1,36 @@
1
- /**
2
- * @module og/control/EarthCoordinates
3
- */
1
+ 'use strict';
4
2
 
5
- "use strict";
6
-
7
- import { Control } from "./Control.js";
8
-
9
- function dec2deg(base) {
10
- var t;
11
- var degrees = base < 0 ? Math.ceil(base) : Math.floor(base);
12
- var minutes = Math.floor((t = Math.abs(base - degrees) * 60));
13
- var seconds = Math.floor((t - minutes) * 6000);
14
- seconds = seconds / 100.0;
15
- return (
16
- numToFixedString(degrees, 3) +
17
- "\u00B0" +
18
- numToFixedString(minutes, 2) +
19
- "\u0027" +
20
- numToFixedString(seconds.toFixed(2), 2) +
21
- "\u0022"
22
- );
23
- }
3
+ import * as units from '../utils/units.js';
4
+ import { heightMode } from '../utils/units.js';
5
+ import { Control } from './Control.js';
6
+ import { throttle } from '../utils/shared.js';
7
+ import { LonLat } from '../LonLat.js';
24
8
 
25
- function numToFixedString(num, fixed) {
26
- var dl = num.toString().split(".")[0].length;
27
- var white = "&nbsp;";
28
- for (var i = dl; i < fixed; i++) {
29
- white += "&nbsp;&nbsp;";
30
- }
31
- return white + num.toString();
32
- }
9
+ const DECIMAL_TEMPLATE =
10
+ `<div class="og-lat-side"></div><div class="og-lat-val"></div>
11
+ <div class="og-lon-side"></div><div class="og-lon-val"></div>
12
+ <div class="og-height"></div>
13
+ <div class="og-units-height"></div>`;
33
14
 
34
- function toDecimal(ll) {
35
- return ll.lat.toFixed(5) + ", " + ll.lon.toFixed(5);
36
- }
15
+ const DEGREE_TEMPLATE =
16
+ `<div class="og-lat-side"></div><div class="og-lat-val"></div>
17
+ <div class="og-lon-side"></div><div class="og-lon-val"></div>
18
+ <div class="og-height"></div>
19
+ <div class="og-units-height"></div>`;
37
20
 
38
- function toDegrees(ll) {
39
- return dec2deg(ll.lat) + ", " + dec2deg(ll.lon);
40
- }
21
+ const CENTER_SVG = '<svg width="12" height="12"><g><path stroke-width="1" stroke-opacity="1" d="M6 0L6 12M0 6L12 6" stroke="#337ab7"></path></g></svg>';
41
22
 
42
- function toMercator(ll) {
43
- var m = ll.forwardMercator();
44
- return m.lat.toFixed(5) + ", " + m.lon.toFixed(5);
45
- }
46
-
47
- const DisplayTypesConverters = [toDecimal, toDegrees, toMercator];
23
+ const TYPE_HTML = [DECIMAL_TEMPLATE, DEGREE_TEMPLATE];
48
24
 
49
25
  /**
50
26
  * Control displays mouse or screen center Earth coordinates.
51
27
  * @class
52
- * @extends {Control}
28
+ * @extends {og.control.Control}
53
29
  * @param {Object} [options] - Options:
54
30
  * @param {Boolean} [options.center] - Earth coordiantes by screen center otherwise mouse pointer. False is default.
55
31
  * @param {Boolean} [options.type] - Coordinates shown: 0 - is decimal degrees, 1 - degrees, 2 - mercator geodetic coordinates.
56
32
  */
57
33
  class EarthCoordinates extends Control {
58
- /**
59
- *
60
- * @param {Object} [options] - Options:
61
- */
62
34
  constructor(options) {
63
35
  super(options);
64
36
 
@@ -69,154 +41,173 @@ class EarthCoordinates extends Control {
69
41
  * @private
70
42
  * @type {Boolean}
71
43
  */
72
- this._displayType = options.type || 0;
44
+ this._type = options.type || 0;
73
45
 
74
- /**
75
- * Current coordinates type converter.
76
- * @private
77
- * @function
78
- */
79
- this._converter = DisplayTypesConverters[0];
46
+ this._TYPE_FUNC = [this._SHOW_DECIMAL, this._SHOW_DEGREE];
80
47
 
81
- /**
82
- * Display dom element.
83
- * @private
84
- * @type {Object}
85
- */
86
- this._display = null;
48
+ this._showFn = null;
87
49
 
88
50
  /**
89
- * Screen center or mouse pointer coordinates show flag.
90
- * @private
91
- * @type {Boolean}
51
+ * Current position.
52
+ * @public
53
+ * @type {og.Vec3}
92
54
  */
55
+ this._lonLat = new LonLat();
93
56
 
94
- var pad = false;
95
- if (
96
- /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
97
- navigator.userAgent
98
- )
99
- ) {
100
- pad = true;
101
- }
57
+ this._latSideEl = null;
58
+ this._lonSideEl = null;
59
+ this._latValEl = null;
60
+ this._lonValEl = null;
61
+ this._heightEl = null;
102
62
 
103
- this._center = options.center || pad;
63
+ this._altUnitVal = options.altitudeUnit || "m";
64
+ this._heightModeVal = options.heightMode || "ell";
104
65
 
105
- this._centerDiv = null;
66
+ this._altUnit = units[this._altUnitVal];
67
+ this._heightMode = heightMode[this._heightModeVal];
106
68
 
107
- /**
108
- * Current position.
109
- * @public
110
- * @type {Vec3}
111
- */
112
- this.position = null;
69
+ this._centerMode = options.centerMode || false;
113
70
  }
114
71
 
115
- oninit() {
116
- this._display = document.createElement("div");
117
- this._display.className = "ogEarthCoordinatesControl";
118
- var that = this;
72
+ _SHOW_DECIMAL(ll) {
73
+ if (ll) {
74
+ let lat = ll.lat,
75
+ lon = ll.lon;
119
76
 
120
- function _refresh(el) {
121
- if (that._displayType >= DisplayTypesConverters.length) {
122
- that._displayType = 0;
77
+ if (lat >= 0) {
78
+ this._latSideEl.innerHTML = 'N';
79
+ } else {
80
+ this._latSideEl.innerHTML = 'S';
123
81
  }
124
82
 
125
- if (that._displayType == 0) {
126
- el.style.width = "275px";
127
- } else if (that._displayType == 1) {
128
- el.style.width = "355px";
129
- } else if (that._displayType == 2) {
130
- el.style.width = "350px";
83
+ if (lon >= 0) {
84
+ this._lonSideEl.innerHTML = 'E';
85
+ } else {
86
+ this._lonSideEl.innerHTML = 'W';
131
87
  }
132
- that._converter = DisplayTypesConverters[that._displayType];
133
- that._showPosition();
88
+
89
+ this._latValEl.innerHTML = Math.abs(lat).toFixed(5) + '°';
90
+ this._lonValEl.innerHTML = Math.abs(lon).toFixed(5) + '°';
134
91
  }
92
+ }
135
93
 
136
- this._display.onclick = function (e) {
137
- that._displayType += 1;
138
- _refresh(this);
139
- };
94
+ _SHOW_DEGREE(ll) {
95
+ if (ll) {
96
+ let lat = ll.lat,
97
+ lon = ll.lon;
140
98
 
141
- this.renderer.div.appendChild(this._display);
99
+ if (lat >= 0) {
100
+ this._latSideEl.innerHTML = 'N';
101
+ } else {
102
+ this._latSideEl.innerHTML = 'S';
103
+ }
104
+
105
+ if (lon >= 0) {
106
+ this._lonSideEl.innerHTML = 'E';
107
+ } else {
108
+ this._lonSideEl.innerHTML = 'W';
109
+ }
142
110
 
143
- _refresh(this._display);
111
+ let t = 0;
144
112
 
145
- this._centerDiv = document.createElement("div");
146
- this._centerDiv.className = "ogCenterIcon";
147
- this._centerDiv.innerHTML =
148
- '<svg width="12" height="12"><g><path stroke-width="1" stroke-opacity="1" d="M6 0L6 12M0 6L12 6" stroke="#009DFF"></path></g></svg>';
149
- this.renderer.div.appendChild(this._centerDiv);
113
+ let deg = lat < 0 ? Math.ceil(lat) : Math.floor(lat);
114
+ let min = Math.floor(t = Math.abs((lat - deg)) * 60);
115
+ let sec = Math.floor((t - min) * 6000) / 100.0;
116
+ this._latValEl.innerHTML = Math.abs(deg) + '°' + min + "'" + sec.toFixed(0) + '"';
150
117
 
151
- if (this._center) {
152
- this.renderer.activeCamera.events.on("moveend", this._grabCoordinates, this);
153
- this._centerDiv.style.display = "block";
154
- } else {
155
- this.renderer.events.on("mousemove", this._onMouseMove, this);
156
- this._centerDiv.style.display = "none";
118
+ deg = lon < 0 ? Math.ceil(lon) : Math.floor(lon);
119
+ min = Math.floor(t = Math.abs((lon - deg)) * 60);
120
+ sec = Math.floor((t - min) * 6000) / 100.0;
121
+ this._lonValEl.innerHTML = Math.abs(deg) + '°' + min + "'" + sec.toFixed(0) + '"';
157
122
  }
158
123
  }
159
124
 
160
- /**
161
- * Sets coordinates capturing type.
162
- * @public
163
- * @param {Boolean} center - True - capture screen center, false - mouse pointer.
164
- */
165
- setCenter(center) {
166
- if (center != this._center) {
167
- this._center = center;
168
- if (center) {
169
- this.renderer.events.off("mousemove", this._onMouseMove);
170
- this.renderer.activeCamera.events.on("moveend", this._grabCoordinates, this);
171
- this._centerDiv.style.display = "block";
172
- } else {
173
- this.renderer.events.off("draw", this._draw);
174
- this.renderer.events.on("mousemove", this._onMouseMove, this);
175
- this._centerDiv.style.display = "none";
176
- }
125
+ _createCenterEl() {
126
+ let el = document.createElement('div');
127
+ el.className = 'og-center-icon';
128
+ el.innerHTML = CENTER_SVG;
129
+ return el;
130
+ }
131
+
132
+ _updateUnits() {
133
+ this._heightMode = heightMode[this._heightModeVal];
134
+ this._altUnit = units[this._altUnitVal];
135
+ this._el.querySelector(".og-units-height").innerHTML = units.toString(this._altUnit);
136
+ this._showHeight();
137
+ }
138
+
139
+ _refreshCoordinates() {
140
+
141
+ if (this._type >= this._TYPE_FUNC.length) {
142
+ this._type = 0;
177
143
  }
144
+
145
+ this._el.innerHTML = TYPE_HTML[this._type];
146
+
147
+ this._latSideEl = this._el.querySelector(".og-lat-side");
148
+ this._lonSideEl = this._el.querySelector(".og-lon-side");
149
+ this._latValEl = this._el.querySelector(".og-lat-val");
150
+ this._lonValEl = this._el.querySelector(".og-lon-val");
151
+ this._heightEl = this._el.querySelector(".og-height");
152
+
153
+ this._showFn = this._TYPE_FUNC[this._type];
154
+ this._showFn(this._lonLat);
178
155
  }
179
156
 
180
- _showPosition() {
181
- if (this.position) {
182
- this.position.height =
183
- this.position.height > 10000 || this.position.height < -10000
184
- ? 0
185
- : this.position.height;
186
- this._display.innerHTML =
187
- "Lat/Lon: " +
188
- this._converter(this.position) +
189
- " h(m): " +
190
- (this.position.height > 0
191
- ? "~" + (Math.round(this.position.height) / 1000).toFixed(3) * 1000
192
- : "-");
157
+ oninit() {
158
+ this._el = document.createElement('div');
159
+ this._el.classList.add("og-coordinates");
160
+
161
+ this.renderer.div.appendChild(this._el);
162
+
163
+ this._el.addEventListener("click", () => {
164
+ this._type++;
165
+ this._refreshCoordinates();
166
+ this._updateUnits();
167
+ this._showHeight();
168
+ });
169
+
170
+ if (this._centerMode) {
171
+ this.renderer.div.appendChild(this._createCenterEl());
172
+ this.renderer.activeCamera.events.on("moveend", this._grabCoordinates, this);
173
+ this.renderer.activeCamera.events.on("moveend", throttle((e) => this._showHeight(), 400, true), this);
193
174
  } else {
194
- this._display.innerHTML = "Lat/Lon: " + "_____________________";
175
+ this.renderer.events.on("mousemove", this._grabCoordinates, this);
176
+ this.renderer.events.on("mousestop", throttle((e) => this._showHeight(), 400, true), this);
195
177
  }
196
- }
197
178
 
198
- _grabCoordinates() {
199
- var r = this.renderer;
200
- this.position = this.planet.getLonLatFromPixelTerrain(r.handler.getCenter());
201
- this._showPosition();
179
+ this._refreshCoordinates();
180
+
181
+ this._updateUnits();
202
182
  }
203
183
 
204
- _onMouseMove() {
205
- var r = this.renderer;
206
- var ms = r.events.mouseState;
207
- if (
208
- !(ms.leftButtonDown || ms.rightButtonDown) &&
209
- r.controlsBag.scaleRot <= 0 &&
210
- !r.activeCamera._flying
211
- ) {
212
- this.position = this.planet.getLonLatFromPixelTerrain(ms, true);
213
- this._showPosition();
184
+ _grabCoordinates(px) {
185
+ let scrPx;
186
+ if (this._centerMode) {
187
+ scrPx = r.handler.getCenter();
188
+ } else {
189
+ scrPx = px;
214
190
  }
191
+ let r = this.renderer;
192
+ this._lonLat = this.planet.getLonLatFromPixelTerrain(scrPx);
193
+ this._showFn(this._lonLat);
215
194
  }
216
- }
217
195
 
218
- export function earthCoordinates(options) {
219
- return new EarthCoordinates(options);
196
+ async _showHeight() {
197
+ if (this._lonLat) {
198
+ let alt = 0;
199
+ this._heightEl.style.opacity = 0.7;
200
+ if (this._heightMode === heightMode.ell) {
201
+ alt = await this.planet.getHeightAboveELL(this._lonLat);
202
+ alt = units.convertExt(true, units.m, this._altUnit, alt);
203
+ } else if (this._heightMode === heightMode.msl) {
204
+ alt = await this.planet.getHeightDefault(this._lonLat);
205
+ alt = units.convertExt(true, units.m, this._altUnit, alt);
206
+ }
207
+ this._heightEl.style.opacity = 1.0;
208
+ this._heightEl.innerHTML = alt.toString();
209
+ }
210
+ }
220
211
  }
221
212
 
222
213
  export { EarthCoordinates };
@@ -24,16 +24,22 @@ class KeyboardNavigation extends Control {
24
24
  }
25
25
 
26
26
  oninit() {
27
+ this.renderer.events.on("keypress", input.KEY_PGUP, this.onCameraMoveForward, this);
28
+ this.renderer.events.on("keypress", input.KEY_PGDN, this.onCameraMoveBackward, this);
29
+ this.renderer.events.on("keypress", input.KEY_PLUS, this.onCameraMoveForward, this);
30
+ this.renderer.events.on("keypress", input.KEY_EQUALS, this.onCameraMoveForward, this);
31
+ this.renderer.events.on("keypress", input.KEY_MINUS, this.onCameraMoveBackward, this);
27
32
  this.renderer.events.on("keypress", input.KEY_W, this.onCameraMoveForward, this);
28
33
  this.renderer.events.on("keypress", input.KEY_S, this.onCameraMoveBackward, this);
29
34
  this.renderer.events.on("keypress", input.KEY_A, this.onCameraStrifeLeft, this);
30
35
  this.renderer.events.on("keypress", input.KEY_D, this.onCameraStrifeRight, this);
31
36
  this.renderer.events.on("keypress", input.KEY_UP, this.onCameraLookUp, this);
32
37
  this.renderer.events.on("keypress", input.KEY_DOWN, this.onCameraLookDown, this);
33
- this.renderer.events.on("keypress", input.KEY_LEFT, this.onCameraTurnLeft, this);
34
- this.renderer.events.on("keypress", input.KEY_RIGHT, this.onCameraTurnRight, this);
38
+ this.renderer.events.on("keypress", input.KEY_LEFT, this.onCameraLookLeft, this);
39
+ this.renderer.events.on("keypress", input.KEY_RIGHT, this.onCameraLookRight, this);
35
40
  this.renderer.events.on("keypress", input.KEY_Q, this.onCameraRollLeft, this);
36
41
  this.renderer.events.on("keypress", input.KEY_E, this.onCameraRollRight, this);
42
+ this.renderer.events.on("keypress", input.KEY_N, this.onCameraRollNorth, this);
37
43
  }
38
44
 
39
45
  onCameraMoveForward(event) {
@@ -84,6 +90,26 @@ class KeyboardNavigation extends Control {
84
90
  cam.update();
85
91
  }
86
92
 
93
+ onCameraLookLeft(event) {
94
+ var cam = this.renderer.activeCamera;
95
+ if (this.renderer.events.isKeyPressed(input.KEY_SHIFT)) {
96
+ cam.roll(15 / this.renderer.handler.deltaTime);
97
+ } else {
98
+ cam.rotateHorizontal((cam._lonLat.height / 3000000) * math.RADIANS, Vec3.ZERO);
99
+ }
100
+ cam.update();
101
+ }
102
+
103
+ onCameraLookRight(event) {
104
+ var cam = this.renderer.activeCamera;
105
+ if (this.renderer.events.isKeyPressed(input.KEY_SHIFT)) {
106
+ cam.roll(-15 / this.renderer.handler.deltaTime);
107
+ } else {
108
+ cam.rotateHorizontal((-cam._lonLat.height / 3000000) * math.RADIANS, Vec3.ZERO);
109
+ }
110
+ cam.update();
111
+ }
112
+
87
113
  onCameraTurnLeft(event) {
88
114
  var cam = this.renderer.activeCamera;
89
115
  if (this.renderer.events.isKeyPressed(input.KEY_SHIFT)) {
@@ -104,6 +130,26 @@ class KeyboardNavigation extends Control {
104
130
  cam.update();
105
131
  }
106
132
 
133
+ // from CompassButton._onClick()
134
+ onCameraRollNorth(event) {
135
+ let c = this.planet.getCartesianFromPixelTerrain(this.renderer.handler.getCenter());
136
+ if (c) {
137
+ this.planet.flyCartesian(
138
+ c.normal().scaleTo(c.length() + c.distance(this.planet.camera.eye)),
139
+ null,
140
+ null,
141
+ 0,
142
+ null,
143
+ null,
144
+ () => {
145
+ this.planet.camera.look(c);
146
+ }
147
+ );
148
+ } else {
149
+ this.planet.flyCartesian(this.planet.camera.eye);
150
+ }
151
+ }
152
+
107
153
  onCameraRollLeft(event) {
108
154
  this.renderer.activeCamera.roll(-15 / this.renderer.handler.deltaTime);
109
155
  this.renderer.activeCamera.update();
@@ -83,13 +83,13 @@ class TouchNavigation extends Control {
83
83
  t0.y = e.sys.touches.item(0).clientY - e.sys.offsetTop;
84
84
  t0.prev_x = e.sys.touches.item(0).clientX - e.sys.offsetLeft;
85
85
  t0.prev_y = e.sys.touches.item(0).clientY - e.sys.offsetTop;
86
- t0.grabbedPoint = this.planet.getCartesianFromPixelTerrain(t0, true);
86
+ t0.grabbedPoint = this.planet.getCartesianFromPixelTerrain(e, true);
87
87
 
88
88
  t1.x = e.sys.touches.item(1).clientX - e.sys.offsetLeft;
89
89
  t1.y = e.sys.touches.item(1).clientY - e.sys.offsetTop;
90
90
  t1.prev_x = e.sys.touches.item(1).clientX - e.sys.offsetLeft;
91
91
  t1.prev_y = e.sys.touches.item(1).clientY - e.sys.offsetTop;
92
- t1.grabbedPoint = this.planet.getCartesianFromPixelTerrain(t1, true);
92
+ t1.grabbedPoint = this.planet.getCartesianFromPixelTerrain(e, true);
93
93
 
94
94
  // this.planet._viewChanged = true;
95
95
  this.pointOnEarth = this.planet.getCartesianFromPixelTerrain(
@@ -119,7 +119,7 @@ class TouchNavigation extends Control {
119
119
  t.prev_x = e.sys.touches.item(0).clientX - e.sys.offsetLeft;
120
120
  t.prev_y = e.sys.touches.item(0).clientY - e.sys.offsetTop;
121
121
 
122
- t.grabbedPoint = this.planet.getCartesianFromPixelTerrain(t, true);
122
+ t.grabbedPoint = this.planet.getCartesianFromPixelTerrain(e, true);
123
123
  this._eye0.copy(this.renderer.activeCamera.eye);
124
124
 
125
125
  if (t.grabbedPoint) {
@@ -142,7 +142,8 @@ class TouchNavigation extends Control {
142
142
 
143
143
  this.planet.stopFlying();
144
144
  this.stopRotation();
145
- var p = this.planet.getCartesianFromPixelTerrain(this.touches[0], true);
145
+
146
+ var p = this.planet.getCartesianFromPixelTerrain(e);
146
147
  if (p) {
147
148
  var g = this.planet.ellipsoid.cartesianToLonLat(p);
148
149
  this.planet.flyLonLat(
@@ -199,11 +200,6 @@ class TouchNavigation extends Control {
199
200
  // distance < 0 --> zoomIn; distance > 0 --> zoomOut
200
201
  var t0t1Distance = Math.abs(t0.prev_x - t1.prev_x) + Math.abs(t0.prev_y - t1.prev_y) - (Math.abs(t0.x - t1.x) + Math.abs(t0.y - t1.y))
201
202
  var _move = 0
202
- var _targetPoint = this.renderer.getCenter()
203
- var d =
204
- cam.eye.distance(
205
- this.planet.getCartesianFromPixelTerrain(_targetPoint, true)
206
- ) * 0.075;
207
203
  if (t0t1Distance < 0) {
208
204
  _move = 1
209
205
  }
@@ -211,9 +207,13 @@ class TouchNavigation extends Control {
211
207
  _move = -1
212
208
  }
213
209
  if (_move !== 0) {
214
- cam.eye.addA(cam.getForward().scale(_move * d));
215
- cam.checkTerrainCollision();
216
- cam.update();
210
+ let pos = this.planet.getCartesianFromPixelTerrain(e);
211
+ if (pos) {
212
+ let d = cam.eye.distance(pos) * 0.075;
213
+ cam.eye.addA(cam.getForward().scale(_move * d));
214
+ cam.checkTerrainCollision();
215
+ cam.update();
216
+ }
217
217
  }
218
218
 
219
219
  if (
@@ -246,7 +246,7 @@ class TouchNavigation extends Control {
246
246
 
247
247
  this.planet.stopFlying();
248
248
 
249
- var direction = cam.unproject(t.x, t.y);
249
+ var direction = e.direction
250
250
  var targetPoint = new Ray(cam.eye, direction).hitSphere(t.grabbedSpheroid);
251
251
 
252
252
  if (targetPoint) {
@@ -114,7 +114,7 @@ class ZoomControl extends Control {
114
114
  var cam = this.renderer.activeCamera;
115
115
 
116
116
  if (this._move !== 0) {
117
- let pos = this.planet.getCartesianFromPixelTerrain(this._targetPoint);
117
+ let pos = this.planet.getCartesianFromPixelTerrain(e);
118
118
  if (pos) {
119
119
  let d = cam.eye.distance(pos) * 0.035;
120
120
  cam.eye.addA(cam.getForward().scale(this._move * d));
@@ -536,7 +536,7 @@ class Ellipsoid {
536
536
 
537
537
  let eps = Math.abs(qw2 - product);
538
538
 
539
- if (eps > math.EPSILON10 && qw2 < product) {
539
+ if (eps > math.EPSILON15 && qw2 < product) {
540
540
  // Imaginary roots (0 intersections).
541
541
  return null;
542
542
  } else if (qw2 > product) {