@openglobus/og 0.13.5 → 0.13.8

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 (78) 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/Object3d.js +384 -0
  12. package/src/og/arial.js +1705 -1703
  13. package/src/og/camera/Camera.js +640 -640
  14. package/src/og/control/DebugInfo.js +15 -4
  15. package/src/og/control/EarthCoordinates.js +151 -160
  16. package/src/og/control/KeyboardNavigation.js +48 -2
  17. package/src/og/control/LayerAnimation.js +115 -0
  18. package/src/og/control/MouseNavigation.js +460 -460
  19. package/src/og/control/Sun.js +170 -170
  20. package/src/og/control/TouchNavigation.js +13 -13
  21. package/src/og/control/ZoomControl.js +1 -3
  22. package/src/og/control/index.js +3 -1
  23. package/src/og/control/ruler/Ruler.js +43 -0
  24. package/src/og/control/ruler/RulerScene.js +370 -0
  25. package/src/og/control/visibleExtent/Segment.js +1 -4
  26. package/src/og/ellipsoid/Ellipsoid.js +20 -1
  27. package/src/og/entity/Entity.js +1 -1
  28. package/src/og/entity/GeoObject.js +1 -1
  29. package/src/og/entity/LabelHandler.js +3 -2
  30. package/src/og/input/input.js +7 -1
  31. package/src/og/layer/CanvasTiles.js +8 -8
  32. package/src/og/layer/KML.js +181 -12
  33. package/src/og/layer/Layer.js +27 -42
  34. package/src/og/layer/Vector.js +80 -14
  35. package/src/og/layer/XYZ.js +8 -2
  36. package/src/og/math/Vec3.js +1 -1
  37. package/src/og/math.js +4 -4
  38. package/src/og/quadTree/Node.js +2 -1
  39. package/src/og/renderer/Renderer.js +1 -2
  40. package/src/og/renderer/RendererEvents.js +17 -3
  41. package/src/og/res/images.js +0 -2
  42. package/src/og/scene/Planet.js +92 -32
  43. package/src/og/segment/Segment.js +1 -8
  44. package/src/og/shaders/label.js +30 -42
  45. package/src/og/terrain/EmptyTerrain.js +164 -146
  46. package/src/og/terrain/Geoid.js +246 -241
  47. package/src/og/terrain/GlobusTerrain.js +23 -24
  48. package/src/og/terrain/MapboxTerrain.js +292 -294
  49. package/src/og/utils/FontAtlas.js +1 -2
  50. package/src/og/utils/Loader.js +160 -112
  51. package/src/og/utils/PlainSegmentWorker.js +38 -26
  52. package/src/og/utils/VectorTileCreator.js +1 -1
  53. package/src/og/utils/units.js +78 -0
  54. package/src/og/webgl/ProgramController.js +143 -143
  55. package/types/Object3d.d.ts +21 -0
  56. package/types/arial.d.ts +1 -0
  57. package/types/control/EarthCoordinates.d.ts +27 -30
  58. package/types/control/KeyboardNavigation.d.ts +3 -0
  59. package/types/control/Sun.d.ts +1 -1
  60. package/types/control/index.d.ts +2 -1
  61. package/types/control/ruler/Ruler.d.ts +13 -0
  62. package/types/control/ruler/RulerScene.d.ts +48 -0
  63. package/types/ellipsoid/Ellipsoid.d.ts +8 -0
  64. package/types/input/input.d.ts +6 -0
  65. package/types/layer/KML.d.ts +26 -1
  66. package/types/layer/Layer.d.ts +23 -31
  67. package/types/layer/Vector.d.ts +2 -0
  68. package/types/layer/XYZ.d.ts +1 -0
  69. package/types/math.d.ts +1 -1
  70. package/types/renderer/RendererEvents.d.ts +2 -0
  71. package/types/res/images.d.ts +0 -1
  72. package/types/scene/Planet.d.ts +12 -3
  73. package/types/terrain/EmptyTerrain.d.ts +4 -1
  74. package/types/terrain/Geoid.d.ts +1 -10
  75. package/types/terrain/GlobusTerrain.d.ts +0 -2
  76. package/types/terrain/MapboxTerrain.d.ts +1 -1
  77. package/types/utils/Loader.d.ts +4 -0
  78. package/types/utils/units.d.ts +20 -0
@@ -79,13 +79,16 @@ class DebugInfo extends Control {
79
79
  label: "maxZoom/minZoom",
80
80
  frame: () => p.maxCurrZoom + " / " + p.minCurrZoom
81
81
  },
82
+ {
83
+ label: "viewExtent",
84
+ frame: () => p.getViewExtent().toString()
85
+ },
82
86
  {
83
87
  label: "height/alt (km)",
84
88
  frame: () =>
85
- `<div style="width:190px">${
86
- (p.camera._lonLat.height / 1000.0).toFixed(2) +
87
- " / " +
88
- (p.camera.getAltitude() / 1000.0).toFixed(2)
89
+ `<div style="width:190px">${(p.camera._lonLat.height / 1000.0).toFixed(2) +
90
+ " / " +
91
+ (p.camera.getAltitude() / 1000.0).toFixed(2)
89
92
  }</div>`
90
93
  },
91
94
  {
@@ -108,6 +111,14 @@ class DebugInfo extends Control {
108
111
  {
109
112
  label: "-------------------------"
110
113
  },
114
+ {
115
+ label: "_renderCompleted / renderCompletedActivated",
116
+ frame: () => `${p._renderCompleted} / ${p._renderCompletedActivated}`
117
+ },
118
+ {
119
+ label: "_terrainCompleted / terrainCompletedActivated",
120
+ frame: () => `${p._terrainCompleted} / ${p._terrainCompletedActivated}`
121
+ },
111
122
  {
112
123
  label: "PlainWorker",
113
124
  frame: () => p._plainSegmentWorker._pendingQueue.length
@@ -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
+ let r = this.renderer;
187
+ if (this._centerMode) {
188
+ scrPx = r.handler.getCenter();
189
+ } else {
190
+ scrPx = px;
214
191
  }
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();
@@ -0,0 +1,115 @@
1
+ /**
2
+ * @module og/control/LayerAnimation
3
+ */
4
+
5
+ "use strict";
6
+
7
+ import { Control } from "./Control.js";
8
+ import { Events } from '../Events.js';
9
+
10
+ /**
11
+ *
12
+ * @class
13
+ * @extends {Control}
14
+ * @param {Object} [options] - Control options.
15
+ */
16
+ class LayerAnimation extends Control {
17
+ constructor(options = {}) {
18
+ super(options);
19
+
20
+ this.events = new Events(["change"])
21
+
22
+ this._name = `layerAnimation ${this._id}`;
23
+
24
+ this._layersArr = options.layers || [];
25
+ this._layersIndexesArr = this._layersArr.map((l) => l._id);
26
+
27
+ this._currentIndex = -1;
28
+ }
29
+
30
+ oninit() {
31
+ super.oninit();
32
+
33
+ for (let i = 0; i < this._layersArr.length; i++) {
34
+ let li = this._layersArr[i];
35
+ li.setVisibility(false);
36
+ li.opacity = 0.0;
37
+ this.planet.addLayer(li);
38
+ }
39
+
40
+
41
+ this._onLayerLoadend_ = this._onLayerLoadend.bind(this);
42
+ this.planet._tileLoader.events.on("layerloadend", this._onLayerLoadend_, this);
43
+
44
+ this.setCurrentIndex(0);
45
+ }
46
+
47
+ onactivate() {
48
+ super.onactivate();
49
+ //...
50
+ }
51
+
52
+ ondeactivate() {
53
+ super.ondeactivate();
54
+
55
+ for (let i = 0; i < this._layersArr.length; i++) {
56
+ this._layersArr[i].setVisibility(false);
57
+ this._layersArr[i].opacity = 1.0;
58
+ }
59
+
60
+ this.planet._tileLoader.events.off("layerloadend", this._onLayerLoadend_);
61
+ this._onLayerLoadend_ = null;
62
+ }
63
+
64
+ _onLayerLoadend(layer) {
65
+ let currLayer = this._layersArr[this._currentIndex];
66
+ if (currLayer.isEqual(layer)) {
67
+ console.log("current layer is visible now");
68
+ currLayer.opacity = 1.0;
69
+ let prevLayer = this._layersArr[this._prevIndex];
70
+ if (prevLayer) {
71
+ prevLayer.setVisibility(false);
72
+ prevLayer.opacity = 0.0;
73
+ }
74
+ }
75
+ }
76
+
77
+ setLayers(layers) {
78
+
79
+ }
80
+
81
+ appendLayer(layer) {
82
+
83
+ }
84
+
85
+ setCurrentIndex(index) {
86
+ if (index != this._currentIndex && index >= 0 && index < this._layersArr.length) {
87
+ this._prevIndex = this._currentIndex;
88
+ this._currentIndex = index;
89
+
90
+ let prevLayer = this._layersArr[this._prevIndex],
91
+ currLayer = this._layersArr[index];
92
+
93
+ if (currLayer) {
94
+ currLayer.opacity = 0.0;
95
+ currLayer.setVisibility(true);
96
+ requestAnimationFrame(() => {
97
+ if (currLayer.isIdle) {
98
+ currLayer.opacity = 1.0;
99
+ if (prevLayer) {
100
+ prevLayer.setVisibility(false);
101
+ prevLayer.opacity = 0.0;
102
+ }
103
+ }
104
+ });
105
+ }
106
+ this.events.dispatch(this.events.change, this._currentIndex, this._prevIndex);
107
+ }
108
+ }
109
+ }
110
+
111
+ export function layerAnimation(options) {
112
+ return LayerAnimation(options);
113
+ }
114
+
115
+ export { LayerAnimation };