@openglobus/og 0.16.0 → 0.16.2
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/dist/@openglobus/og.esm.js +2 -2
- package/dist/@openglobus/og.esm.js.map +1 -1
- package/dist/@openglobus/og.umd.js +2 -2
- package/dist/@openglobus/og.umd.js.map +1 -1
- package/package.json +1 -2
- package/src/og/Events.js +2 -1
- package/src/og/control/LayerSwitcher.js +4 -3
- package/src/og/control/TouchNavigation.js +350 -341
- package/src/og/layer/KML.js +1 -3
- package/src/og/scene/Planet.js +1 -1
- package/src/og/shaders/drawnode.js +138 -89
- package/src/og/shaders/geoObject.js +57 -46
- package/src/og/shaders/ray.js +15 -21
- package/src/og/utils/shared.js +1 -1
- package/types/Events.d.ts +3 -2
- package/types/control/TouchNavigation.d.ts +7 -2
- package/types/scene/Planet.d.ts +2 -2
- package/types/utils/shared.d.ts +2 -2
|
@@ -1,341 +1,350 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
this.
|
|
53
|
-
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
56
|
-
this.
|
|
57
|
-
|
|
58
|
-
this.
|
|
59
|
-
this.
|
|
60
|
-
|
|
61
|
-
this.
|
|
62
|
-
|
|
63
|
-
this.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
this.
|
|
68
|
-
this.
|
|
69
|
-
|
|
70
|
-
this.
|
|
71
|
-
|
|
72
|
-
this.
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
this.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
this.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
this.planet.
|
|
134
|
-
this.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
this.
|
|
144
|
-
this.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
) {
|
|
168
|
-
this.
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
t0
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
cam.
|
|
230
|
-
cam.
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
if (
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
var
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Sphere } from "../bv/Sphere.js";
|
|
4
|
+
import { Key } from "../Lock.js";
|
|
5
|
+
import { LonLat } from "../LonLat.js";
|
|
6
|
+
import { Quat } from "../math/Quat.js";
|
|
7
|
+
import { Ray } from "../math/Ray.js";
|
|
8
|
+
import { Vec3 } from "../math/Vec3.js";
|
|
9
|
+
import { Control } from "./Control.js";
|
|
10
|
+
import { Vec2 } from "../math/index.js";
|
|
11
|
+
import { math } from "../index.js";
|
|
12
|
+
|
|
13
|
+
class Touch {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.x = 0;
|
|
16
|
+
this.y = 0;
|
|
17
|
+
this.prev_x = 0;
|
|
18
|
+
this.prev_y = 0;
|
|
19
|
+
this.grabbedPoint = new Vec3();
|
|
20
|
+
this.grabbedSpheroid = new Sphere();
|
|
21
|
+
this._vec = new Vec2();
|
|
22
|
+
this._vecPrev = new Vec2();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get dY() {
|
|
26
|
+
return this.y - this.prev_y;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
get dX() {
|
|
30
|
+
return this.x - this.prev_x;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
get vec() {
|
|
34
|
+
return this._vec.set(this.x, this.y);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get vecPrev() {
|
|
38
|
+
return this._vecPrev.set(this.prev_x, this.prev_y);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Touch pad planet camera dragging control.
|
|
44
|
+
* @class
|
|
45
|
+
* @extends {Control}
|
|
46
|
+
* @param {Object} [options] - Control options.
|
|
47
|
+
*/
|
|
48
|
+
class TouchNavigation extends Control {
|
|
49
|
+
constructor(options) {
|
|
50
|
+
super(options);
|
|
51
|
+
|
|
52
|
+
this._name = "touchNavigation";
|
|
53
|
+
|
|
54
|
+
this.grabbedPoint = new Vec3();
|
|
55
|
+
this.inertia = 0.007;
|
|
56
|
+
this.grabbedSpheroid = new Sphere();
|
|
57
|
+
this.planet = null;
|
|
58
|
+
this.qRot = new Quat();
|
|
59
|
+
this.scaleRot = 0;
|
|
60
|
+
this.rot = 1;
|
|
61
|
+
this._eye0 = new Vec3();
|
|
62
|
+
|
|
63
|
+
this.stepsCount = 5;
|
|
64
|
+
this.stepsForward = null;
|
|
65
|
+
this.stepIndex = 0;
|
|
66
|
+
|
|
67
|
+
this.pointOnEarth = null;
|
|
68
|
+
this.earthUp = null;
|
|
69
|
+
|
|
70
|
+
this.touches = [new Touch(), new Touch()];
|
|
71
|
+
|
|
72
|
+
this._keyLock = new Key();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
oninit() {
|
|
76
|
+
this.renderer.events.on("touchstart", this.onTouchStart, this);
|
|
77
|
+
this.renderer.events.on("touchend", this.onTouchEnd, this);
|
|
78
|
+
this.renderer.events.on("doubletouch", this.onDoubleTouch, this);
|
|
79
|
+
this.renderer.events.on("touchcancel", this.onTouchCancel, this);
|
|
80
|
+
this.renderer.events.on("touchmove", this.onTouchMove, this);
|
|
81
|
+
this.renderer.events.on("draw", this.onDraw, this);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
onTouchStart(e) {
|
|
85
|
+
const handler = this.renderer.handler;
|
|
86
|
+
this._touching = true;
|
|
87
|
+
|
|
88
|
+
if (e.sys.touches.length === 2) {
|
|
89
|
+
const t0 = this.touches[0],
|
|
90
|
+
t1 = this.touches[1];
|
|
91
|
+
|
|
92
|
+
t0.e = e
|
|
93
|
+
t0.x = (e.sys.touches.item(0).clientX - e.sys.offsetLeft) * handler.pixelRatio;
|
|
94
|
+
t0.y = (e.sys.touches.item(0).clientY - e.sys.offsetTop) * handler.pixelRatio;
|
|
95
|
+
t0.prev_x = t0.x;
|
|
96
|
+
t0.prev_y = t0.y;
|
|
97
|
+
t0.grabbedPoint = this.planet.getCartesianFromPixelTerrain(t0, true);
|
|
98
|
+
|
|
99
|
+
t1.x = (e.sys.touches.item(1).clientX - e.sys.offsetLeft) * handler.pixelRatio;
|
|
100
|
+
t1.y = (e.sys.touches.item(1).clientY - e.sys.offsetTop) * handler.pixelRatio;
|
|
101
|
+
t1.prev_x = t1.x;
|
|
102
|
+
t1.prev_y = t1.y;
|
|
103
|
+
t1.grabbedPoint = this.planet.getCartesianFromPixelTerrain(t1, true);
|
|
104
|
+
|
|
105
|
+
this.pointOnEarth = this.planet.getCartesianFromPixelTerrain(
|
|
106
|
+
this.renderer.handler.getCenter(),
|
|
107
|
+
true
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
if (this.pointOnEarth) {
|
|
111
|
+
this.earthUp = this.pointOnEarth.normal();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (t0.grabbedPoint && t1.grabbedPoint) {
|
|
115
|
+
t0.grabbedSpheroid.radius = t0.grabbedPoint.length();
|
|
116
|
+
t1.grabbedSpheroid.radius = t1.grabbedPoint.length();
|
|
117
|
+
this.stopRotation();
|
|
118
|
+
}
|
|
119
|
+
} else if (e.sys.touches.length === 1) {
|
|
120
|
+
this._startTouchOne(e);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
_startTouchOne(e) {
|
|
125
|
+
const t = this.touches[0];
|
|
126
|
+
const handler = this.renderer.handler;
|
|
127
|
+
|
|
128
|
+
t.x = (e.sys.touches.item(0).clientX - e.sys.offsetLeft) * handler.pixelRatio;
|
|
129
|
+
t.y = (e.sys.touches.item(0).clientY - e.sys.offsetTop) * handler.pixelRatio;
|
|
130
|
+
t.prev_x = t.x;
|
|
131
|
+
t.prev_y = t.y;
|
|
132
|
+
|
|
133
|
+
t.grabbedPoint = this.planet.getCartesianFromPixelTerrain(e, true);
|
|
134
|
+
this._eye0.copy(this.renderer.activeCamera.eye);
|
|
135
|
+
|
|
136
|
+
if (t.grabbedPoint) {
|
|
137
|
+
t.grabbedSpheroid.radius = t.grabbedPoint.length();
|
|
138
|
+
this.stopRotation();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
stopRotation() {
|
|
143
|
+
this.qRot.clear();
|
|
144
|
+
this.planet.layerLock.free(this._keyLock);
|
|
145
|
+
this.planet.terrainLock.free(this._keyLock);
|
|
146
|
+
this.planet._normalMapCreator.free(this._keyLock);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
onDoubleTouch(e) {
|
|
150
|
+
if (this.stepIndex) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
this.planet.stopFlying();
|
|
155
|
+
this.stopRotation();
|
|
156
|
+
|
|
157
|
+
var p = this.planet.getCartesianFromPixelTerrain(e);
|
|
158
|
+
if (p) {
|
|
159
|
+
var g = this.planet.ellipsoid.cartesianToLonLat(p);
|
|
160
|
+
this.planet.flyLonLat(
|
|
161
|
+
new LonLat(g.lon, g.lat, this.renderer.activeCamera.eye.distance(p) * 0.57)
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
onTouchEnd(e) {
|
|
167
|
+
if (e.sys.touches.length === 0) {
|
|
168
|
+
this._touching = false;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (e.sys.touches.length === 1) {
|
|
172
|
+
this._startTouchOne(e);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (
|
|
176
|
+
Math.abs(this.touches[0].x - this.touches[0].prev_x) < 3 &&
|
|
177
|
+
Math.abs(this.touches[0].y - this.touches[0].prev_y) < 3
|
|
178
|
+
) {
|
|
179
|
+
this.scaleRot = 0;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
onTouchCancel(e) {
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
onTouchMove(e) {
|
|
187
|
+
var cam = this.renderer.activeCamera;
|
|
188
|
+
const handler = this.renderer.handler;
|
|
189
|
+
if (e.sys.touches.length === 2) {
|
|
190
|
+
this.renderer.controlsBag.scaleRot = 1;
|
|
191
|
+
|
|
192
|
+
var t0 = this.touches[0],
|
|
193
|
+
t1 = this.touches[1];
|
|
194
|
+
|
|
195
|
+
if (!t0.grabbedPoint || !t1.grabbedPoint) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
this.planet.stopFlying();
|
|
200
|
+
|
|
201
|
+
t0.prev_x = t0.x;
|
|
202
|
+
t0.prev_y = t0.y;
|
|
203
|
+
t0.x = (e.sys.touches.item(0).clientX - e.sys.offsetLeft) * handler.pixelRatio;
|
|
204
|
+
t0.y = (e.sys.touches.item(0).clientY - e.sys.offsetTop) * handler.pixelRatio;
|
|
205
|
+
|
|
206
|
+
t1.prev_x = t1.x;
|
|
207
|
+
t1.prev_y = t1.y;
|
|
208
|
+
t1.x = (e.sys.touches.item(1).clientX - e.sys.offsetLeft) * handler.pixelRatio;
|
|
209
|
+
t1.y = (e.sys.touches.item(1).clientY - e.sys.offsetTop) * handler.pixelRatio;
|
|
210
|
+
|
|
211
|
+
const middle = t0.vec.add(t1.vec).scale(0.5);
|
|
212
|
+
const earthMiddlePoint = this.planet.getCartesianFromPixelTerrain(
|
|
213
|
+
middle
|
|
214
|
+
);
|
|
215
|
+
if (earthMiddlePoint) {
|
|
216
|
+
this.pointOnEarth = earthMiddlePoint
|
|
217
|
+
|
|
218
|
+
const prevAngle = Math.atan2(t0.prev_y - t1.prev_y, t0.prev_x - t1.prev_x)
|
|
219
|
+
const curAngle = Math.atan2(t0.y - t1.y, t0.x - t1.x)
|
|
220
|
+
|
|
221
|
+
const deltaAngle = curAngle - prevAngle;
|
|
222
|
+
const distanceToPointOnEarth = cam.eye.distance(this.pointOnEarth);
|
|
223
|
+
|
|
224
|
+
const zoomCur = t0.vec.sub(t1.vec);
|
|
225
|
+
const zoomPrev = t0.vecPrev.sub(t1.vecPrev);
|
|
226
|
+
const scale = zoomCur.length() / zoomPrev.length();
|
|
227
|
+
|
|
228
|
+
let d = distanceToPointOnEarth * -(1 - scale);
|
|
229
|
+
cam.eye.addA(cam.getForward().scale(d));
|
|
230
|
+
cam.rotateAround(-deltaAngle, false, this.pointOnEarth, this.earthUp);
|
|
231
|
+
|
|
232
|
+
const panCur = t0.vec.add(t1.vec).scale(0.5);
|
|
233
|
+
const panPrev = t0.vecPrev.add(t1.vecPrev).scale(0.5);
|
|
234
|
+
const panOffset = panCur.sub(panPrev).scale(-1);
|
|
235
|
+
var l = 0.5 / distanceToPointOnEarth * cam._lonLat.height * math.RADIANS;
|
|
236
|
+
if (l > 0.003) l = 0.003;
|
|
237
|
+
cam.rotateHorizontal(l * -panOffset.x, false, this.pointOnEarth, this.earthUp);
|
|
238
|
+
cam.rotateVertical(l * -panOffset.y, this.pointOnEarth);
|
|
239
|
+
|
|
240
|
+
cam.checkTerrainCollision();
|
|
241
|
+
cam.update();
|
|
242
|
+
}
|
|
243
|
+
this.scaleRot = 0;
|
|
244
|
+
} else if (e.sys.touches.length === 1) {
|
|
245
|
+
var t = this.touches[0];
|
|
246
|
+
|
|
247
|
+
t.prev_x = t.x;
|
|
248
|
+
t.prev_y = t.y;
|
|
249
|
+
t.x = (e.sys.touches.item(0).clientX - e.sys.offsetLeft) * handler.pixelRatio;
|
|
250
|
+
t.y = (e.sys.touches.item(0).clientY - e.sys.offsetTop) * handler.pixelRatio;
|
|
251
|
+
|
|
252
|
+
if (!t.grabbedPoint) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
this.planet.stopFlying();
|
|
257
|
+
|
|
258
|
+
var direction = e.direction
|
|
259
|
+
var targetPoint = new Ray(cam.eye, direction).hitSphere(t.grabbedSpheroid);
|
|
260
|
+
|
|
261
|
+
if (targetPoint) {
|
|
262
|
+
if (cam.slope > 0.2) {
|
|
263
|
+
this.qRot = Quat.getRotationBetweenVectors(
|
|
264
|
+
targetPoint.normal(),
|
|
265
|
+
t.grabbedPoint.normal()
|
|
266
|
+
);
|
|
267
|
+
var rot = this.qRot;
|
|
268
|
+
cam.eye = rot.mulVec3(cam.eye);
|
|
269
|
+
cam._r = rot.mulVec3(cam._r);
|
|
270
|
+
cam._u = rot.mulVec3(cam._u);
|
|
271
|
+
cam._b = rot.mulVec3(cam._b);
|
|
272
|
+
cam.checkTerrainCollision();
|
|
273
|
+
cam.update();
|
|
274
|
+
this.scaleRot = 1;
|
|
275
|
+
} else {
|
|
276
|
+
var p0 = t.grabbedPoint,
|
|
277
|
+
p1 = Vec3.add(p0, cam._u),
|
|
278
|
+
p2 = Vec3.add(p0, p0.normal());
|
|
279
|
+
var dir = cam.unproject(t.x, t.y);
|
|
280
|
+
var px = new Vec3();
|
|
281
|
+
if (new Ray(cam.eye, dir).hitPlane(p0, p1, p2, px) === Ray.INSIDE) {
|
|
282
|
+
cam.eye = this._eye0.addA(px.subA(p0).negate());
|
|
283
|
+
cam.checkTerrainCollision();
|
|
284
|
+
cam.update();
|
|
285
|
+
this.scaleRot = 0;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
onDraw(e) {
|
|
293
|
+
this.renderer.controlsBag.scaleRot = this.scaleRot;
|
|
294
|
+
|
|
295
|
+
if (this._touching) {
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
var r = this.renderer;
|
|
300
|
+
var cam = r.activeCamera;
|
|
301
|
+
var prevEye = cam.eye.clone();
|
|
302
|
+
|
|
303
|
+
if (this.stepIndex) {
|
|
304
|
+
r.controlsBag.scaleRot = 1;
|
|
305
|
+
var sf = this.stepsForward[this.stepsCount - this.stepIndex--];
|
|
306
|
+
cam.eye = sf.eye;
|
|
307
|
+
cam._r = sf.v;
|
|
308
|
+
cam._u = sf.u;
|
|
309
|
+
cam._b = sf.n;
|
|
310
|
+
cam.checkTerrainCollision();
|
|
311
|
+
cam.update();
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (r.events.mouseState.leftButtonDown || !this.scaleRot) {
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
this.scaleRot -= this.inertia;
|
|
319
|
+
if (this.scaleRot <= 0) {
|
|
320
|
+
this.scaleRot = 0;
|
|
321
|
+
} else {
|
|
322
|
+
r.controlsBag.scaleRot = this.scaleRot;
|
|
323
|
+
var rot = this.qRot
|
|
324
|
+
.slerp(Quat.IDENTITY, 1 - this.scaleRot * this.scaleRot * this.scaleRot)
|
|
325
|
+
.normalize();
|
|
326
|
+
if (!(rot.x || rot.y || rot.z)) {
|
|
327
|
+
this.scaleRot = 0;
|
|
328
|
+
}
|
|
329
|
+
cam.eye = rot.mulVec3(cam.eye);
|
|
330
|
+
cam._r = rot.mulVec3(cam._r);
|
|
331
|
+
cam._u = rot.mulVec3(cam._u);
|
|
332
|
+
cam._b = rot.mulVec3(cam._b);
|
|
333
|
+
cam.checkTerrainCollision();
|
|
334
|
+
cam.update();
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (cam.eye.distance(prevEye) / cam._terrainAltitude > 0.01) {
|
|
338
|
+
this.planet.layerLock.lock(this._keyLock);
|
|
339
|
+
this.planet.terrainLock.lock(this._keyLock);
|
|
340
|
+
this.planet._normalMapCreator.lock(this._keyLock);
|
|
341
|
+
} else {
|
|
342
|
+
this.planet.layerLock.free(this._keyLock);
|
|
343
|
+
this.planet.terrainLock.free(this._keyLock);
|
|
344
|
+
this.planet._normalMapCreator.free(this._keyLock);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export { TouchNavigation };
|
|
350
|
+
|