@openglobus/og 0.11.7 → 0.11.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.
- package/css/og.css +3 -2
- package/package.json +1 -1
- package/src/og/control/Lighting.js +52 -73
- package/src/og/control/MouseNavigation.js +21 -18
- package/src/og/control/MouseWheelZoomControl.js +257 -0
- package/src/og/control/index.js +2 -0
- package/src/og/control/visibleExtent/Segment.js +1862 -0
- package/src/og/control/visibleExtent/VisibleExtent.js +80 -0
- package/src/og/control/visibleExtent/drawnode.js +751 -0
- package/src/og/entity/BaseBillboard.js +9 -9
- package/src/og/entity/Label.js +7 -7
- package/src/og/layer/CanvasTiles.js +0 -1
- package/src/og/layer/GeoImage.js +2 -10
- package/src/og/layer/GeoTexture2d.js +2 -10
- package/src/og/layer/GeoVideo.js +2 -10
- package/src/og/layer/Layer.js +0 -22
- package/src/og/layer/WMS.js +0 -2
- package/src/og/layer/XYZ.js +4 -5
- package/src/og/renderer/Renderer.js +69 -94
- package/src/og/renderer/RendererEvents.js +3 -1
- package/src/og/scene/Planet.js +39 -61
- package/src/og/segment/Segment.js +60 -156
- package/src/og/segment/Slice.js +45 -0
- package/src/og/shaders/drawnode.js +197 -287
- package/src/og/utils/GeoImageCreator.js +5 -1
- package/src/og/webgl/Handler.js +1 -1
package/css/og.css
CHANGED
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
height: 19px;
|
|
51
51
|
position: absolute;
|
|
52
52
|
background-color: rgba(22, 76, 155, 1) !important;
|
|
53
|
-
z-index:
|
|
53
|
+
z-index: 35000;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
.ogAttribution {
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
right: 0px;
|
|
154
154
|
width: 17em;
|
|
155
155
|
background-color: rgba(22, 76, 155, 0.4);
|
|
156
|
-
z-index:
|
|
156
|
+
z-index: 25000;
|
|
157
157
|
padding: 0 0 0 10px;
|
|
158
158
|
font-family: "Segoe UI", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif;
|
|
159
159
|
border-radius: 2px;
|
|
@@ -448,6 +448,7 @@
|
|
|
448
448
|
|
|
449
449
|
.og-lighing .og-value {
|
|
450
450
|
float: left;
|
|
451
|
+
width: 50px;
|
|
451
452
|
}
|
|
452
453
|
|
|
453
454
|
.og-lighing #layers {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openglobus/og",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.8",
|
|
4
4
|
"description": "[OpenGlobus](http://www.openglobus.org/) is a javascript library designed to display interactive 3d maps and planets with map tiles, imagery and vector data, markers and 3d objects. It uses the WebGL technology, open source and completely free.",
|
|
5
5
|
"directories": {
|
|
6
6
|
"example": "./sandbox"
|
|
@@ -29,22 +29,9 @@ const TEMPLATE = `<div class="og-lighing">
|
|
|
29
29
|
</div>
|
|
30
30
|
<div class="og-value exposure"></div>
|
|
31
31
|
</div>
|
|
32
|
-
</div>
|
|
33
|
-
|
|
34
|
-
<div class="og-layers">
|
|
35
|
-
<div class="og-caption">Select layer:</div>
|
|
36
|
-
<select id="layers"></select>
|
|
37
|
-
</div>
|
|
32
|
+
</div>
|
|
38
33
|
|
|
39
34
|
<div class="og-color-options">
|
|
40
|
-
<div class="og-caption">Opacity</div>
|
|
41
|
-
<div class="og-option">
|
|
42
|
-
<div class="og-label">A</div>
|
|
43
|
-
<div class="og-slider">
|
|
44
|
-
<input type="range" id="opacity" name="opacity" value="0.0" min="0.0" max="2.0" step="0.01" />
|
|
45
|
-
</div>
|
|
46
|
-
<div class="og-value opacity"></div>
|
|
47
|
-
</div>
|
|
48
35
|
<div class="og-caption">Ambient</div>
|
|
49
36
|
<div class="og-option">
|
|
50
37
|
<div class="og-label">R</div>
|
|
@@ -123,6 +110,21 @@ const TEMPLATE = `<div class="og-lighing">
|
|
|
123
110
|
<div class="og-value shininess"></div>
|
|
124
111
|
</div>
|
|
125
112
|
</div>
|
|
113
|
+
|
|
114
|
+
<div class="og-layers">
|
|
115
|
+
<div class="og-caption">Select layer:</div>
|
|
116
|
+
<select id="layers"></select>
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
<div class="og-caption">Opacity</div>
|
|
120
|
+
<div class="og-option">
|
|
121
|
+
<div class="og-label">A</div>
|
|
122
|
+
<div class="og-slider">
|
|
123
|
+
<input type="range" id="opacity" name="opacity" value="0.0" min="0.0" max="2.0" step="0.01" />
|
|
124
|
+
</div>
|
|
125
|
+
<div class="og-value opacity"></div>
|
|
126
|
+
</div>
|
|
127
|
+
|
|
126
128
|
</div>`;
|
|
127
129
|
|
|
128
130
|
/**
|
|
@@ -142,36 +144,7 @@ class Lighting extends Control {
|
|
|
142
144
|
this._selectedLayer = layer;
|
|
143
145
|
|
|
144
146
|
document.getElementById("opacity").value = layer.opacity;
|
|
145
|
-
|
|
146
|
-
document.getElementById("ambient-r").value = layer.ambient.x;
|
|
147
|
-
document.getElementById("ambient-g").value = layer.ambient.y;
|
|
148
|
-
document.getElementById("ambient-b").value = layer.ambient.z;
|
|
149
|
-
|
|
150
|
-
document.getElementById("diffuse-r").value = layer.diffuse.x;
|
|
151
|
-
document.getElementById("diffuse-g").value = layer.diffuse.y;
|
|
152
|
-
document.getElementById("diffuse-b").value = layer.diffuse.z;
|
|
153
|
-
|
|
154
|
-
document.getElementById("specular-r").value = layer.specular.x;
|
|
155
|
-
document.getElementById("specular-g").value = layer.specular.y;
|
|
156
|
-
document.getElementById("specular-b").value = layer.specular.z;
|
|
157
|
-
|
|
158
|
-
document.getElementById("shininess").value = layer.shininess;
|
|
159
|
-
|
|
160
147
|
document.querySelector(".og-value.opacity").innerHTML = layer.opacity.toString();
|
|
161
|
-
|
|
162
|
-
document.querySelector(".og-value.ambient-r").innerHTML = layer.ambient.x.toString();
|
|
163
|
-
document.querySelector(".og-value.ambient-g").innerHTML = layer.ambient.y.toString();
|
|
164
|
-
document.querySelector(".og-value.ambient-b").innerHTML = layer.ambient.z.toString();
|
|
165
|
-
|
|
166
|
-
document.querySelector(".og-value.diffuse-r").innerHTML = layer.diffuse.x.toString();
|
|
167
|
-
document.querySelector(".og-value.diffuse-g").innerHTML = layer.diffuse.y.toString();
|
|
168
|
-
document.querySelector(".og-value.diffuse-b").innerHTML = layer.diffuse.z.toString();
|
|
169
|
-
|
|
170
|
-
document.querySelector(".og-value.specular-r").innerHTML = layer.specular.x.toString();
|
|
171
|
-
document.querySelector(".og-value.specular-g").innerHTML = layer.specular.y.toString();
|
|
172
|
-
document.querySelector(".og-value.specular-b").innerHTML = layer.specular.z.toString();
|
|
173
|
-
|
|
174
|
-
document.querySelector(".og-value.shininess").innerHTML = layer.shininess.toString();
|
|
175
148
|
}
|
|
176
149
|
|
|
177
150
|
oninit() {
|
|
@@ -215,72 +188,78 @@ class Lighting extends Control {
|
|
|
215
188
|
});
|
|
216
189
|
|
|
217
190
|
document.getElementById("ambient-r").addEventListener("input", function (e) {
|
|
218
|
-
|
|
219
|
-
_this._selectedLayer.ambient.x = Number(this.value);
|
|
220
|
-
}
|
|
191
|
+
_this.planet._ambient[0] = Number(this.value);
|
|
221
192
|
document.querySelector(".og-value.ambient-r").innerHTML = this.value;
|
|
222
193
|
});
|
|
223
194
|
document.getElementById("ambient-g").addEventListener("input", function (e) {
|
|
224
|
-
|
|
225
|
-
_this._selectedLayer.ambient.y = Number(this.value);
|
|
226
|
-
}
|
|
195
|
+
_this.planet._ambient[1] = Number(this.value);
|
|
227
196
|
document.querySelector(".og-value.ambient-g").innerHTML = this.value;
|
|
228
197
|
});
|
|
229
198
|
document.getElementById("ambient-b").addEventListener("input", function (e) {
|
|
230
|
-
|
|
231
|
-
_this._selectedLayer.ambient.z = Number(this.value);
|
|
232
|
-
}
|
|
199
|
+
_this.planet._ambient[2] = Number(this.value);
|
|
233
200
|
document.querySelector(".og-value.ambient-b").innerHTML = this.value;
|
|
234
201
|
});
|
|
235
202
|
|
|
236
203
|
document.getElementById("diffuse-r").addEventListener("input", function (e) {
|
|
237
|
-
|
|
238
|
-
_this._selectedLayer.diffuse.x = Number(this.value);
|
|
239
|
-
}
|
|
204
|
+
_this.planet._diffuse[0] = Number(this.value);
|
|
240
205
|
document.querySelector(".og-value.diffuse-r").innerHTML = this.value;
|
|
241
206
|
});
|
|
242
207
|
document.getElementById("diffuse-g").addEventListener("input", function (e) {
|
|
243
|
-
|
|
244
|
-
_this._selectedLayer.diffuse.y = Number(this.value);
|
|
245
|
-
}
|
|
208
|
+
_this.planet._diffuse[1] = Number(this.value);
|
|
246
209
|
document.querySelector(".og-value.diffuse-g").innerHTML = this.value;
|
|
247
210
|
});
|
|
248
211
|
document.getElementById("diffuse-b").addEventListener("input", function (e) {
|
|
249
|
-
|
|
250
|
-
_this._selectedLayer.diffuse.z = Number(this.value);
|
|
251
|
-
}
|
|
212
|
+
_this.planet._diffuse[2] = Number(this.value);
|
|
252
213
|
document.querySelector(".og-value.diffuse-b").innerHTML = this.value;
|
|
253
214
|
});
|
|
254
215
|
|
|
255
216
|
document.getElementById("specular-r").addEventListener("input", function (e) {
|
|
256
|
-
|
|
257
|
-
_this._selectedLayer.specular.x = Number(this.value);
|
|
258
|
-
}
|
|
217
|
+
_this.planet._specular[0] = Number(this.value);
|
|
259
218
|
document.querySelector(".og-value.specular-r").innerHTML = this.value;
|
|
260
219
|
});
|
|
261
220
|
document.getElementById("specular-g").addEventListener("input", function (e) {
|
|
262
|
-
|
|
263
|
-
_this._selectedLayer.specular.y = Number(this.value);
|
|
264
|
-
}
|
|
221
|
+
_this.planet._specular[1] = Number(this.value);
|
|
265
222
|
document.querySelector(".og-value.specular-g").innerHTML = this.value;
|
|
266
223
|
});
|
|
267
224
|
document.getElementById("specular-b").addEventListener("input", function (e) {
|
|
268
|
-
|
|
269
|
-
_this._selectedLayer.specular.z = Number(this.value);
|
|
270
|
-
}
|
|
225
|
+
_this.planet._specular[2] = Number(this.value);
|
|
271
226
|
document.querySelector(".og-value.specular-b").innerHTML = this.value;
|
|
272
227
|
});
|
|
273
228
|
|
|
274
229
|
document.getElementById("shininess").addEventListener("input", function (e) {
|
|
275
|
-
|
|
276
|
-
_this._selectedLayer.shininess = Number(this.value);
|
|
277
|
-
}
|
|
230
|
+
_this.planet._specular[3] = Number(this.value);
|
|
278
231
|
document.querySelector(".og-value.shininess").innerHTML = this.value;
|
|
279
232
|
});
|
|
280
233
|
|
|
281
234
|
if (this.planet) {
|
|
282
235
|
this.planet.events.on("layeradd", this._onLayerAdd, this);
|
|
283
236
|
this.planet.events.on("layerremove", this._onLayerRemove, this);
|
|
237
|
+
|
|
238
|
+
document.getElementById("ambient-r").value = this.planet._ambient[0];
|
|
239
|
+
document.getElementById("ambient-g").value = this.planet._ambient[1];
|
|
240
|
+
document.getElementById("ambient-b").value = this.planet._ambient[2];
|
|
241
|
+
|
|
242
|
+
document.getElementById("diffuse-r").value = this.planet._diffuse[0];
|
|
243
|
+
document.getElementById("diffuse-g").value = this.planet._diffuse[1];
|
|
244
|
+
document.getElementById("diffuse-b").value = this.planet._diffuse[2];
|
|
245
|
+
|
|
246
|
+
document.getElementById("specular-r").value = this.planet._specular[0];
|
|
247
|
+
document.getElementById("specular-g").value = this.planet._specular[1];
|
|
248
|
+
document.getElementById("specular-b").value = this.planet._specular[2];
|
|
249
|
+
document.getElementById("shininess").value = this.planet._specular[3];
|
|
250
|
+
|
|
251
|
+
document.querySelector(".og-value.ambient-r").innerHTML = this.planet._ambient[0].toString();
|
|
252
|
+
document.querySelector(".og-value.ambient-g").innerHTML = this.planet._ambient[1].toString();
|
|
253
|
+
document.querySelector(".og-value.ambient-b").innerHTML = this.planet._ambient[2].toString();
|
|
254
|
+
|
|
255
|
+
document.querySelector(".og-value.diffuse-r").innerHTML = this.planet._diffuse[0].toString();
|
|
256
|
+
document.querySelector(".og-value.diffuse-g").innerHTML = this.planet._diffuse[1].toString();
|
|
257
|
+
document.querySelector(".og-value.diffuse-b").innerHTML = this.planet._diffuse[2].toString();
|
|
258
|
+
|
|
259
|
+
document.querySelector(".og-value.specular-r").innerHTML = this.planet._specular[0].toString();
|
|
260
|
+
document.querySelector(".og-value.specular-g").innerHTML = this.planet._specular[1].toString();
|
|
261
|
+
document.querySelector(".og-value.specular-b").innerHTML = this.planet._specular[2].toString();
|
|
262
|
+
document.querySelector(".og-value.shininess").innerHTML = this.planet._specular[3].toString();
|
|
284
263
|
}
|
|
285
264
|
|
|
286
265
|
this._fetchLayers();
|
|
@@ -46,7 +46,9 @@ class MouseNavigation extends Control {
|
|
|
46
46
|
|
|
47
47
|
this._lmbDoubleClickActive = true;
|
|
48
48
|
|
|
49
|
-
this.minSlope = options.minSlope || 0.1;
|
|
49
|
+
this.minSlope = options.minSlope || 0.1;
|
|
50
|
+
|
|
51
|
+
this._wheelDirection = +1;
|
|
50
52
|
|
|
51
53
|
this._keyLock = new Key();
|
|
52
54
|
}
|
|
@@ -73,7 +75,7 @@ class MouseNavigation extends Control {
|
|
|
73
75
|
var d = a ? (delta * cam.eye.distance(a)) / stepsCount : 1000;
|
|
74
76
|
|
|
75
77
|
if (forward) {
|
|
76
|
-
d = -d;
|
|
78
|
+
d = -1.25*d;
|
|
77
79
|
} else {
|
|
78
80
|
d *= 2;
|
|
79
81
|
}
|
|
@@ -224,7 +226,10 @@ class MouseNavigation extends Control {
|
|
|
224
226
|
ms,
|
|
225
227
|
event.wheelDelta > 0,
|
|
226
228
|
ms.direction
|
|
227
|
-
);
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
this._wheelDirection = event.wheelDelta;
|
|
232
|
+
|
|
228
233
|
if (this.stepsForward) {
|
|
229
234
|
this.stepIndex = this.stepsCount;
|
|
230
235
|
}
|
|
@@ -240,7 +245,7 @@ class MouseNavigation extends Control {
|
|
|
240
245
|
onMouseLeftButtonDoubleClick() {
|
|
241
246
|
this.planet.stopFlying();
|
|
242
247
|
this.stopRotation();
|
|
243
|
-
var p = this.planet.getCartesianFromPixelTerrain(this.renderer.events.mouseState
|
|
248
|
+
var p = this.planet.getCartesianFromPixelTerrain(this.renderer.events.mouseState);
|
|
244
249
|
if (p) {
|
|
245
250
|
var g = this.planet.ellipsoid.cartesianToLonLat(p);
|
|
246
251
|
if (this.renderer.events.isKeyPressed(input.KEY_ALT)) {
|
|
@@ -258,8 +263,9 @@ class MouseNavigation extends Control {
|
|
|
258
263
|
onMouseLeftButtonClick() {
|
|
259
264
|
if (this._active) {
|
|
260
265
|
this.renderer.handler.canvas.classList.add("ogGrabbingPoiner");
|
|
261
|
-
this.grabbedPoint = this.planet.getCartesianFromMouseTerrain(
|
|
262
|
-
if (this.grabbedPoint) {
|
|
266
|
+
this.grabbedPoint = this.planet.getCartesianFromMouseTerrain();
|
|
267
|
+
if (this.grabbedPoint) {
|
|
268
|
+
this.renderer.isActiveBackBuffers = false;
|
|
263
269
|
this._eye0.copy(this.renderer.activeCamera.eye);
|
|
264
270
|
this.grabbedSpheroid.radius = this.grabbedPoint.length();
|
|
265
271
|
this.stopRotation();
|
|
@@ -274,7 +280,8 @@ class MouseNavigation extends Control {
|
|
|
274
280
|
this.planet._normalMapCreator.free(this._keyLock);
|
|
275
281
|
}
|
|
276
282
|
|
|
277
|
-
onMouseLeftButtonUp(e) {
|
|
283
|
+
onMouseLeftButtonUp(e) {
|
|
284
|
+
this.renderer.isActiveBackBuffers = true;
|
|
278
285
|
this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner");
|
|
279
286
|
if (e.x === e.prev_x && e.y === e.prev_y) {
|
|
280
287
|
this.scaleRot = 0.0;
|
|
@@ -331,20 +338,14 @@ class MouseNavigation extends Control {
|
|
|
331
338
|
onMouseRightButtonClick(e) {
|
|
332
339
|
this.stopRotation();
|
|
333
340
|
this.planet.stopFlying();
|
|
334
|
-
this.pointOnEarth = this.planet.getCartesianFromPixelTerrain(
|
|
335
|
-
{
|
|
336
|
-
x: e.x,
|
|
337
|
-
y: e.y
|
|
338
|
-
},
|
|
339
|
-
true
|
|
340
|
-
);
|
|
341
|
+
this.pointOnEarth = this.planet.getCartesianFromPixelTerrain(e);
|
|
341
342
|
if (this.pointOnEarth) {
|
|
342
343
|
this.earthUp = this.pointOnEarth.normal();
|
|
343
344
|
}
|
|
344
345
|
}
|
|
345
346
|
|
|
346
347
|
onMouseRightButtonDown(e) {
|
|
347
|
-
var cam = this.renderer.activeCamera;
|
|
348
|
+
var cam = this.renderer.activeCamera;
|
|
348
349
|
|
|
349
350
|
if (this.pointOnEarth && this.renderer.events.mouseState.moving) {
|
|
350
351
|
this.renderer.controlsBag.scaleRot = 1.0;
|
|
@@ -385,9 +386,11 @@ class MouseNavigation extends Control {
|
|
|
385
386
|
r.controlsBag.scaleRot = 1.0;
|
|
386
387
|
var sf = this.stepsForward[this.stepsCount - this.stepIndex--];
|
|
387
388
|
|
|
388
|
-
let maxAlt = cam.maxAltitude + this.planet.ellipsoid.
|
|
389
|
-
|
|
390
|
-
|
|
389
|
+
let maxAlt = cam.maxAltitude + this.planet.ellipsoid._b;
|
|
390
|
+
let minAlt = cam.minAltitude + this.planet.ellipsoid._b;
|
|
391
|
+
const camAlt = sf.eye.length();
|
|
392
|
+
if (camAlt > maxAlt || camAlt < minAlt && this._wheelDirection > 0) {
|
|
393
|
+
this._wheelDirection = +1;
|
|
391
394
|
return;
|
|
392
395
|
}
|
|
393
396
|
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module og/control/MouseWheelZoomControl
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
import { Control } from "./Control.js";
|
|
8
|
+
import { Key } from "../Lock.js";
|
|
9
|
+
import { Quat } from "../math/Quat.js";
|
|
10
|
+
import { Sphere } from "../bv/Sphere.js";
|
|
11
|
+
import { Vec3 } from "../math/Vec3.js";
|
|
12
|
+
import { MouseNavigation } from "./MouseNavigation.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Planet zoom buttons control.
|
|
16
|
+
* @class
|
|
17
|
+
* @extends {Control}
|
|
18
|
+
* @params {Object} [options] - Control options.
|
|
19
|
+
*/
|
|
20
|
+
class MouseWheelZoomControl extends Control {
|
|
21
|
+
constructor(options) {
|
|
22
|
+
super(options);
|
|
23
|
+
|
|
24
|
+
this._name = "MouseWheelZoomControl";
|
|
25
|
+
|
|
26
|
+
options = options || {};
|
|
27
|
+
|
|
28
|
+
this.grabbedPoint = new Vec3();
|
|
29
|
+
this._eye0 = new Vec3();
|
|
30
|
+
this.pointOnEarth = new Vec3();
|
|
31
|
+
this.earthUp = new Vec3();
|
|
32
|
+
this.inertia = 0.007;
|
|
33
|
+
this.grabbedSpheroid = new Sphere();
|
|
34
|
+
this.planet = null;
|
|
35
|
+
this.qRot = new Quat();
|
|
36
|
+
this.scaleRot = 0.0;
|
|
37
|
+
|
|
38
|
+
this.distDiff = 0.3;
|
|
39
|
+
this.stepsCount = 8;
|
|
40
|
+
this.stepsForward = null;
|
|
41
|
+
this.stepIndex = 0;
|
|
42
|
+
|
|
43
|
+
this._lmbDoubleClickActive = true;
|
|
44
|
+
|
|
45
|
+
this.minSlope = options.minSlope || 0.1;
|
|
46
|
+
|
|
47
|
+
this._keyLock = new Key();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
oninit() {
|
|
51
|
+
var zoomDiv = document.createElement("div"),
|
|
52
|
+
btnZoomIn = document.createElement("button"),
|
|
53
|
+
btnZoomOut = document.createElement("button");
|
|
54
|
+
|
|
55
|
+
zoomDiv.className = "ogZoomControl";
|
|
56
|
+
btnZoomIn.className = "ogZoomButton ogZoomIn";
|
|
57
|
+
btnZoomOut.className = "ogZoomButton ogZoomOut";
|
|
58
|
+
|
|
59
|
+
zoomDiv.appendChild(btnZoomIn);
|
|
60
|
+
zoomDiv.appendChild(btnZoomOut);
|
|
61
|
+
|
|
62
|
+
this.renderer.div.appendChild(zoomDiv);
|
|
63
|
+
|
|
64
|
+
btnZoomIn.addEventListener("mousedown", (e) => this.zoomIn());
|
|
65
|
+
btnZoomIn.addEventListener("mouseup", (e) => this.stopZoom());
|
|
66
|
+
|
|
67
|
+
btnZoomOut.addEventListener("mousedown", (e) => this.zoomOut());
|
|
68
|
+
btnZoomOut.addEventListener("mouseup", (e) => this.stopZoom());
|
|
69
|
+
|
|
70
|
+
btnZoomIn.addEventListener("touchstart", (e) => {
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
this.zoomIn();
|
|
73
|
+
});
|
|
74
|
+
btnZoomIn.addEventListener("touchend", (e) => {
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
this.stopZoom();
|
|
77
|
+
});
|
|
78
|
+
btnZoomIn.addEventListener("touchcancel", (e) => {
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
this.stopZoom();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
btnZoomOut.addEventListener("touchstart", (e) => {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
this.zoomOut();
|
|
86
|
+
});
|
|
87
|
+
btnZoomOut.addEventListener("touchend", (e) => {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
this.stopZoom();
|
|
90
|
+
});
|
|
91
|
+
btnZoomOut.addEventListener("touchcancel", (e) => {
|
|
92
|
+
e.preventDefault();
|
|
93
|
+
this.stopZoom();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
this.renderer.events.on("draw", this._draw, this);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Planet zoom in.
|
|
101
|
+
* @public
|
|
102
|
+
*/
|
|
103
|
+
zoomIn() {
|
|
104
|
+
if (this.stepIndex) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
this.planet.stopFlying();
|
|
109
|
+
|
|
110
|
+
this.stopRotation();
|
|
111
|
+
|
|
112
|
+
this._deactivate = true;
|
|
113
|
+
|
|
114
|
+
this.planet.layerLock.lock(this._keyLock);
|
|
115
|
+
this.planet.terrainLock.lock(this._keyLock);
|
|
116
|
+
this.planet._normalMapCreator.lock(this._keyLock);
|
|
117
|
+
|
|
118
|
+
this.stepsForward = MouseNavigation.getMovePointsFromPixelTerrain(
|
|
119
|
+
this.renderer.activeCamera,
|
|
120
|
+
this.planet,
|
|
121
|
+
this.stepsCount,
|
|
122
|
+
this.distDiff,
|
|
123
|
+
this.renderer.getCenter(),
|
|
124
|
+
true,
|
|
125
|
+
null
|
|
126
|
+
);
|
|
127
|
+
if (this.stepsForward) {
|
|
128
|
+
this.stepIndex = this.stepsCount;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Planet zoom out.
|
|
134
|
+
* @public
|
|
135
|
+
*/
|
|
136
|
+
zoomOut() {
|
|
137
|
+
if (this.stepIndex) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
this.planet.stopFlying();
|
|
142
|
+
|
|
143
|
+
this.stopRotation();
|
|
144
|
+
|
|
145
|
+
this._deactivate = true;
|
|
146
|
+
|
|
147
|
+
this.planet.layerLock.lock(this._keyLock);
|
|
148
|
+
this.planet.terrainLock.lock(this._keyLock);
|
|
149
|
+
this.planet._normalMapCreator.lock(this._keyLock);
|
|
150
|
+
|
|
151
|
+
this.stepsForward = MouseNavigation.getMovePointsFromPixelTerrain(
|
|
152
|
+
this.renderer.activeCamera,
|
|
153
|
+
this.planet,
|
|
154
|
+
this.stepsCount,
|
|
155
|
+
this.distDiff,
|
|
156
|
+
this.renderer.getCenter(),
|
|
157
|
+
false,
|
|
158
|
+
null
|
|
159
|
+
);
|
|
160
|
+
if (this.stepsForward) {
|
|
161
|
+
this.stepIndex = this.stepsCount;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
stopRotation() {
|
|
166
|
+
this.qRot.clear();
|
|
167
|
+
this.planet.layerLock.free(this._keyLock);
|
|
168
|
+
this.planet.terrainLock.free(this._keyLock);
|
|
169
|
+
this.planet._normalMapCreator.free(this._keyLock);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
stopZoom() {
|
|
173
|
+
this._move = 0;
|
|
174
|
+
|
|
175
|
+
this.planet.layerLock.free(this._keyLock);
|
|
176
|
+
this.planet.terrainLock.free(this._keyLock);
|
|
177
|
+
this.planet._normalMapCreator.free(this._keyLock);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
_draw(e) {
|
|
181
|
+
if (this._active) {
|
|
182
|
+
var r = this.renderer;
|
|
183
|
+
var cam = r.activeCamera;
|
|
184
|
+
var prevEye = cam.eye.clone();
|
|
185
|
+
|
|
186
|
+
if (this.stepIndex) {
|
|
187
|
+
r.controlsBag.scaleRot = 1.0;
|
|
188
|
+
var sf = this.stepsForward[this.stepsCount - this.stepIndex--];
|
|
189
|
+
|
|
190
|
+
let maxAlt = cam.maxAltitude + this.planet.ellipsoid._a;
|
|
191
|
+
let minAlt = cam.minAltitude + this.planet.ellipsoid._a;
|
|
192
|
+
const camAlt = sf.eye.length();
|
|
193
|
+
if (camAlt > maxAlt || camAlt < minAlt) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
cam.eye = sf.eye;
|
|
198
|
+
cam._v = sf.v;
|
|
199
|
+
cam._u = sf.u;
|
|
200
|
+
cam._n = sf.n;
|
|
201
|
+
|
|
202
|
+
cam.checkTerrainCollision();
|
|
203
|
+
|
|
204
|
+
cam.update();
|
|
205
|
+
} else {
|
|
206
|
+
if (this._deactivate) {
|
|
207
|
+
this._deactivate = false;
|
|
208
|
+
|
|
209
|
+
this.planet.layerLock.free(this._keyLock);
|
|
210
|
+
this.planet.terrainLock.free(this._keyLock);
|
|
211
|
+
this.planet._normalMapCreator.free(this._keyLock);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (r.events.mouseState.leftButtonDown || !this.scaleRot) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
this.scaleRot -= this.inertia;
|
|
220
|
+
if (this.scaleRot <= 0.0) {
|
|
221
|
+
this.scaleRot = 0.0;
|
|
222
|
+
} else {
|
|
223
|
+
r.controlsBag.scaleRot = this.scaleRot;
|
|
224
|
+
var rot = this.qRot
|
|
225
|
+
.slerp(Quat.IDENTITY, 1.0 - this.scaleRot * this.scaleRot * this.scaleRot)
|
|
226
|
+
.normalize();
|
|
227
|
+
if (!(rot.x || rot.y || rot.z)) {
|
|
228
|
+
this.scaleRot = 0.0;
|
|
229
|
+
}
|
|
230
|
+
cam.eye = rot.mulVec3(cam.eye);
|
|
231
|
+
cam._v = rot.mulVec3(cam._v);
|
|
232
|
+
cam._u = rot.mulVec3(cam._u);
|
|
233
|
+
cam._n = rot.mulVec3(cam._n);
|
|
234
|
+
|
|
235
|
+
cam.checkTerrainCollision();
|
|
236
|
+
|
|
237
|
+
cam.update();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (cam.eye.distance(prevEye) / cam._terrainAltitude > 0.01) {
|
|
241
|
+
this.planet.layerLock.lock(this._keyLock);
|
|
242
|
+
this.planet.terrainLock.lock(this._keyLock);
|
|
243
|
+
this.planet._normalMapCreator.lock(this._keyLock);
|
|
244
|
+
} else {
|
|
245
|
+
this.planet.layerLock.free(this._keyLock);
|
|
246
|
+
this.planet.terrainLock.free(this._keyLock);
|
|
247
|
+
this.planet._normalMapCreator.free(this._keyLock);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export function mouseWheelZoomControl(options) {
|
|
254
|
+
return new MouseWheelZoomControl(options);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export { MouseWheelZoomControl };
|
package/src/og/control/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import { SimpleNavigation } from "./SimpleNavigation.js";
|
|
|
13
13
|
import { ShowFps } from "./ShowFps.js";
|
|
14
14
|
import { Sun } from "./Sun.js";
|
|
15
15
|
import { ZoomControl } from "./ZoomControl.js";
|
|
16
|
+
import { MouseWheelZoomControl } from "./MouseWheelZoomControl.js";
|
|
16
17
|
import { Lighting } from "./Lighting.js";
|
|
17
18
|
|
|
18
19
|
export {
|
|
@@ -31,5 +32,6 @@ export {
|
|
|
31
32
|
ShowFps,
|
|
32
33
|
Sun,
|
|
33
34
|
ZoomControl,
|
|
35
|
+
MouseWheelZoomControl,
|
|
34
36
|
Lighting
|
|
35
37
|
};
|