@openglobus/og 0.11.8 → 0.12.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.
package/css/og.css CHANGED
@@ -261,6 +261,8 @@
261
261
  text-shadow: 0px 0px 3px #616161;
262
262
  padding: 10px;
263
263
  pointer-events: none;
264
+ transform: scale(1.0);
265
+ transform-origin: top left;
264
266
  }
265
267
 
266
268
  .og-debug-info .og-watch-line {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openglobus/og",
3
- "version": "0.11.8",
3
+ "version": "0.12.0",
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"
package/src/og/Globe.js CHANGED
@@ -66,6 +66,7 @@ const PLANET_NAME_PREFIX = "globus_planet_";
66
66
  * @param {Number} [options.maxEqualZoomAltitude=15000000.0] - Maximal altitude since segments on the screen bacame the same zoom level
67
67
  * @param {Number} [options.minEqualZoomAltitude=10000.0] - Minimal altitude since segments on the screen bacame the same zoom level
68
68
  * @param {Number} [options.minEqualZoomCameraSlope=0.8] - Minimal camera slope above te globe where segments on the screen bacame the same zoom level
69
+ * @param {Number} [options.loadingBatchSize=12] -
69
70
  */
70
71
 
71
72
  class Globe {
@@ -97,7 +98,16 @@ class Globe {
97
98
  }
98
99
 
99
100
  this.div.appendChild(this._canvas);
100
- this.div.classList.add("ogViewport");
101
+ this.div.classList.add("ogViewport");
102
+
103
+ document.addEventListener("visibilitychange", () => {
104
+ if (document.visibilityState === 'visible') {
105
+ this.renderer.handler.start();
106
+ this.renderer && this.renderer.resize();
107
+ } else {
108
+ this.renderer.handler.stop();
109
+ }
110
+ });
101
111
 
102
112
  function _disableWheel(e) {
103
113
  e.preventDefault();
@@ -120,7 +130,7 @@ class Globe {
120
130
  */
121
131
  this.renderer = new Renderer(
122
132
  new Handler(_canvasId, {
123
- pixelRatio: window.devicePixelRatio,
133
+ pixelRatio: window.devicePixelRatio + 0.15,
124
134
  context: {
125
135
  alpha: false,
126
136
  antialias: false,
@@ -162,7 +172,8 @@ class Globe {
162
172
  // TODO:
163
173
  } else {
164
174
  this.planet = new Planet({
165
- name: this._planetName,
175
+ name: this._planetName,
176
+ frustums: options.frustums,
166
177
  ellipsoid: options.ellipsoid,
167
178
  maxGridSize: options.maxGridSize,
168
179
  useNightTexture: options.useNightTexture,
@@ -171,7 +182,8 @@ class Globe {
171
182
  maxAltitude: options.maxAltitude || 15000000,
172
183
  maxEqualZoomAltitude: options.maxEqualZoomAltitude,
173
184
  minEqualZoomAltitude: options.minEqualZoomAltitude,
174
- minEqualZoomCameraSlope: options.minEqualZoomCameraSlope
185
+ minEqualZoomCameraSlope: options.minEqualZoomCameraSlope,
186
+ loadingBatchSize: options.loadingBatchSize
175
187
  });
176
188
  }
177
189
 
@@ -193,8 +205,8 @@ class Globe {
193
205
  options.useEarthNavigation
194
206
  ? new EarthNavigation()
195
207
  : new MouseNavigation({
196
- minSlope: options.minSlope
197
- }),
208
+ minSlope: options.minSlope
209
+ }),
198
210
  new TouchNavigation(),
199
211
  new EarthCoordinates(),
200
212
  new ScaleControl(),
@@ -98,26 +98,26 @@ class Camera {
98
98
  * @protected
99
99
  * @type {Vec3}
100
100
  */
101
- this._u = new Vec3(0.0, 1.0, 0.0); // up x n
101
+ this._r = new Vec3(1.0, 0.0, 0.0); // up x n
102
102
 
103
103
  /**
104
104
  * Camera up vector.
105
105
  * @protected
106
106
  * @type {Vec3}
107
107
  */
108
- this._v = new Vec3(1.0, 0.0, 0.0); // n x u - UP
108
+ this._u = new Vec3(0.0, 1.0, 0.0); // n x u - UP
109
109
 
110
110
  /**
111
111
  * Camera forward vector.
112
112
  * @protected
113
113
  * @type {Vec3}
114
114
  */
115
- this._n = new Vec3(0.0, 0.0, 1.0); // eye - look - FORWARD
115
+ this._b = new Vec3(0.0, 0.0, 1.0); // eye - look - FORWARD
116
116
 
117
117
  // Previous frame values
118
- this._pu = this._u.clone();
119
- this._pv = this._v.clone();
120
- this._pn = this._n.clone();
118
+ this._pu = this._r.clone();
119
+ this._pv = this._u.clone();
120
+ this._pn = this._b.clone();
121
121
  this._peye = this.eye.clone();
122
122
  this.isMoved = false;
123
123
 
@@ -173,9 +173,9 @@ class Camera {
173
173
  }
174
174
 
175
175
  checkMoveEnd() {
176
- var u = this._u,
177
- v = this._v,
178
- n = this._n,
176
+ var u = this._r,
177
+ v = this._u,
178
+ n = this._b,
179
179
  eye = this.eye;
180
180
 
181
181
  if (this._peye.equal(eye) && this._pu.equal(u) && this._pv.equal(v) && this._pn.equal(n)) {
@@ -216,27 +216,27 @@ class Camera {
216
216
  }
217
217
 
218
218
  getUp() {
219
- return this._v.clone();
219
+ return this._u.clone();
220
220
  }
221
221
 
222
222
  getDown() {
223
- return this._v.negateTo();
223
+ return this._u.negateTo();
224
224
  }
225
225
 
226
226
  getRight() {
227
- return this._u.clone();
227
+ return this._r.clone();
228
228
  }
229
229
 
230
230
  getLeft() {
231
- return this._u.negateTo();
231
+ return this._r.negateTo();
232
232
  }
233
233
 
234
234
  getForward() {
235
- return this._n.negateTo();
235
+ return this._b.negateTo();
236
236
  }
237
237
 
238
238
  getBackward() {
239
- return this._n.clone();
239
+ return this._b.clone();
240
240
  }
241
241
 
242
242
  /**
@@ -245,9 +245,9 @@ class Camera {
245
245
  * @virtual
246
246
  */
247
247
  update() {
248
- var u = this._u,
249
- v = this._v,
250
- n = this._n,
248
+ var u = this._r,
249
+ v = this._u,
250
+ n = this._b,
251
251
  eye = this.eye;
252
252
 
253
253
  Vec3.doubleToTwoFloat32Array(eye, this.eyeHigh, this.eyeLow);
@@ -321,12 +321,7 @@ class Camera {
321
321
  this._tanViewAngle_hradOneByHeight =
322
322
  this._tanViewAngle_hrad * this.renderer.handler._oneByHeight;
323
323
  var c = this.renderer.handler.canvas;
324
- this._projSizeConst =
325
- Math.min(
326
- c.clientWidth < 256 ? 256 : c.clientWidth,
327
- c.clientHeight < 256 ? 256 : c.clientHeight
328
- ) /
329
- (angle * math.RADIANS);
324
+ this._projSizeConst = Math.min(c.clientWidth < 256 ? 256 : c.clientWidth, c.clientHeight < 256 ? 256 : c.clientHeight) / (angle * math.RADIANS);
330
325
  for (let i = 0, len = this.frustums.length; i < len; i++) {
331
326
  this.frustums[i].setProjectionMatrix(
332
327
  angle,
@@ -368,15 +363,15 @@ class Camera {
368
363
  this.eye.x = eye.x;
369
364
  this.eye.y = eye.y;
370
365
  this.eye.z = eye.z;
371
- look = look || this._n;
372
- up = up || this._v;
373
- this._n.x = eye.x - look.x;
374
- this._n.y = eye.y - look.y;
375
- this._n.z = eye.z - look.z;
376
- this._u.copy(up.cross(this._n));
377
- this._n.normalize();
378
- this._u.normalize();
379
- this._v.copy(this._n.cross(this._u));
366
+ look = look || this._b;
367
+ up = up || this._u;
368
+ this._b.x = eye.x - look.x;
369
+ this._b.y = eye.y - look.y;
370
+ this._b.z = eye.z - look.z;
371
+ this._r.copy(up.cross(this._b));
372
+ this._b.normalize();
373
+ this._r.normalize();
374
+ this._u.copy(this._b.cross(this._r));
380
375
  return this;
381
376
  }
382
377
 
@@ -384,14 +379,14 @@ class Camera {
384
379
  * Sets camera look point
385
380
  * @public
386
381
  * @param {Vec3} look - Look point
387
- * @param {Vec3} [up] - Camera up vector otherwise camera current up vector(this._v)
382
+ * @param {Vec3} [up] - Camera up vector otherwise camera current up vector(this._u)
388
383
  */
389
384
  look(look, up) {
390
- this._n.set(this.eye.x - look.x, this.eye.y - look.y, this.eye.z - look.z);
391
- this._u.copy((up || this._v).cross(this._n));
392
- this._n.normalize();
393
- this._u.normalize();
394
- this._v.copy(this._n.cross(this._u));
385
+ this._b.set(this.eye.x - look.x, this.eye.y - look.y, this.eye.z - look.z);
386
+ this._r.copy((up || this._u).cross(this._b));
387
+ this._b.normalize();
388
+ this._r.normalize();
389
+ this._u.copy(this._b.cross(this._r));
395
390
  }
396
391
 
397
392
  /**
@@ -402,9 +397,9 @@ class Camera {
402
397
  * @param {number} dn - delta Z
403
398
  */
404
399
  slide(du, dv, dn) {
405
- this.eye.x += du * this._u.x + dv * this._v.x + dn * this._n.x;
406
- this.eye.y += du * this._u.y + dv * this._v.y + dn * this._n.y;
407
- this.eye.z += du * this._u.z + dv * this._v.z + dn * this._n.z;
400
+ this.eye.x += du * this._r.x + dv * this._u.x + dn * this._b.x;
401
+ this.eye.y += du * this._r.y + dv * this._u.y + dn * this._b.y;
402
+ this.eye.z += du * this._r.z + dv * this._u.z + dn * this._b.z;
408
403
  }
409
404
 
410
405
  /**
@@ -415,16 +410,16 @@ class Camera {
415
410
  roll(angle) {
416
411
  var cs = Math.cos(math.RADIANS * angle);
417
412
  var sn = Math.sin(math.RADIANS * angle);
418
- var t = this._u.clone();
419
- this._u.set(
420
- cs * t.x - sn * this._v.x,
421
- cs * t.y - sn * this._v.y,
422
- cs * t.z - sn * this._v.z
413
+ var t = this._r.clone();
414
+ this._r.set(
415
+ cs * t.x - sn * this._u.x,
416
+ cs * t.y - sn * this._u.y,
417
+ cs * t.z - sn * this._u.z
423
418
  );
424
- this._v.set(
425
- sn * t.x + cs * this._v.x,
426
- sn * t.y + cs * this._v.y,
427
- sn * t.z + cs * this._v.z
419
+ this._u.set(
420
+ sn * t.x + cs * this._u.x,
421
+ sn * t.y + cs * this._u.y,
422
+ sn * t.z + cs * this._u.z
428
423
  );
429
424
  }
430
425
 
@@ -436,16 +431,16 @@ class Camera {
436
431
  pitch(angle) {
437
432
  var cs = Math.cos(math.RADIANS * angle);
438
433
  var sn = Math.sin(math.RADIANS * angle);
439
- var t = this._n.clone();
440
- this._n.set(
441
- cs * t.x - sn * this._v.x,
442
- cs * t.y - sn * this._v.y,
443
- cs * t.z - sn * this._v.z
434
+ var t = this._b.clone();
435
+ this._b.set(
436
+ cs * t.x - sn * this._u.x,
437
+ cs * t.y - sn * this._u.y,
438
+ cs * t.z - sn * this._u.z
444
439
  );
445
- this._v.set(
446
- sn * t.x + cs * this._v.x,
447
- sn * t.y + cs * this._v.y,
448
- sn * t.z + cs * this._v.z
440
+ this._u.set(
441
+ sn * t.x + cs * this._u.x,
442
+ sn * t.y + cs * this._u.y,
443
+ sn * t.z + cs * this._u.z
449
444
  );
450
445
  }
451
446
 
@@ -457,16 +452,16 @@ class Camera {
457
452
  yaw(angle) {
458
453
  var cs = Math.cos(math.RADIANS * angle);
459
454
  var sn = Math.sin(math.RADIANS * angle);
460
- var t = this._u.clone();
461
- this._u.set(
462
- cs * t.x - sn * this._n.x,
463
- cs * t.y - sn * this._n.y,
464
- cs * t.z - sn * this._n.z
455
+ var t = this._r.clone();
456
+ this._r.set(
457
+ cs * t.x - sn * this._b.x,
458
+ cs * t.y - sn * this._b.y,
459
+ cs * t.z - sn * this._b.z
465
460
  );
466
- this._n.set(
467
- sn * t.x + cs * this._n.x,
468
- sn * t.y + cs * this._n.y,
469
- sn * t.z + cs * this._n.z
461
+ this._b.set(
462
+ sn * t.x + cs * this._b.x,
463
+ sn * t.y + cs * this._b.y,
464
+ sn * t.z + cs * this._b.z
470
465
  );
471
466
  }
472
467
 
@@ -485,12 +480,8 @@ class Camera {
485
480
  var px = (x - w) / w,
486
481
  py = -(y - h) / h;
487
482
 
488
- var world1 = this.frustums[0]._inverseProjectionViewMatrix
489
- .mulVec4(new Vec4(px, py, -1.0, 1.0))
490
- .affinity(),
491
- world2 = this.frustums[0]._inverseProjectionViewMatrix
492
- .mulVec4(new Vec4(px, py, 0.0, 1.0))
493
- .affinity();
483
+ var world1 = this.frustums[0]._inverseProjectionViewMatrix.mulVec4(new Vec4(px, py, -1.0, 1.0)).affinity(),
484
+ world2 = this.frustums[0]._inverseProjectionViewMatrix.mulVec4(new Vec4(px, py, 0.0, 1.0)).affinity();
494
485
 
495
486
  return world2.subA(world1).toVec3().normalize();
496
487
  }
@@ -520,16 +511,16 @@ class Camera {
520
511
  center = center || Vec3.ZERO;
521
512
  up = up || Vec3.UP;
522
513
 
523
- var rot = new Mat4().setRotation(isArc ? this._v : up, angle);
514
+ var rot = new Mat4().setRotation(isArc ? this._u : up, angle);
524
515
  var tr = new Mat4().setIdentity().translate(center);
525
516
  var ntr = new Mat4().setIdentity().translate(center.negateTo());
526
517
 
527
518
  var trm = tr.mul(rot).mul(ntr);
528
519
 
529
520
  this.eye = trm.mulVec3(this.eye);
530
- this._v = rot.mulVec3(this._v).normalize();
531
521
  this._u = rot.mulVec3(this._u).normalize();
532
- this._n = rot.mulVec3(this._n).normalize();
522
+ this._r = rot.mulVec3(this._r).normalize();
523
+ this._b = rot.mulVec3(this._b).normalize();
533
524
  }
534
525
 
535
526
  /**
@@ -551,7 +542,7 @@ class Camera {
551
542
  * @param {Vec3} center - Point that the camera rotates around.
552
543
  */
553
544
  rotateVertical(angle, center) {
554
- this.rotateAround(angle, false, center, this._u);
545
+ this.rotateAround(angle, false, center, this._r);
555
546
  }
556
547
 
557
548
  /**
@@ -36,20 +36,15 @@ class PlanetCamera extends Camera {
36
36
  * @param {Object} [options] - Planet camera options:
37
37
  */
38
38
  constructor(planet, options) {
39
- super(
40
- planet.renderer,
41
- Object.assign(
42
- {},
43
- {
44
- frustums: /*[[100, 10000000]]*/[
45
- [1, 100 + 0.075],
46
- [100, 1000 + 0.075],
47
- [1000, 1e6 + 10000],
48
- [1e6, 1e9]
49
- ] //[[1, 1e3 + 100], [1e3, 1e6 + 10000], [1e6, 1e9]]*/
50
- },
51
- options
52
- )
39
+ super(planet.renderer, {
40
+ frustums: [
41
+ [1, 100 + 0.075],
42
+ [100, 1000 + 0.075],
43
+ [1000, 1e6 + 10000],
44
+ [1e6, 1e9]
45
+ ], //[[1, 1e3 + 100], [1e3, 1e6 + 10000], [1e6, 1e9]]*/
46
+ ...options
47
+ }
53
48
  );
54
49
  /**
55
50
  * Assigned camera's planet.
@@ -144,7 +139,7 @@ class PlanetCamera extends Camera {
144
139
  super.update();
145
140
  this.updateGeodeticPosition();
146
141
  this.eyeNorm = this.eye.normal();
147
- this.slope = this._n.dot(this.eyeNorm);
142
+ this.slope = this._b.dot(this.eyeNorm);
148
143
  this.events.dispatch(this.events.viewchange, this);
149
144
  }
150
145
 
@@ -387,8 +382,8 @@ class PlanetCamera extends Camera {
387
382
  var ground_a = this.planet.ellipsoid.lonLatToCartesian(
388
383
  new LonLat(this._lonLat.lon, this._lonLat.lat)
389
384
  );
390
- var v_a = this._v,
391
- n_a = this._n;
385
+ var v_a = this._u,
386
+ n_a = this._b;
392
387
 
393
388
  var lonlat_b = this.planet.ellipsoid.cartesianToLonLat(cartesian);
394
389
  var up_b = up || Vec3.UP;
@@ -543,18 +538,18 @@ class PlanetCamera extends Camera {
543
538
  }
544
539
 
545
540
  rotateVertical(angle, center, minSlope = 0) {
546
- var rot = new Mat4().setRotation(this._u, angle);
541
+ var rot = new Mat4().setRotation(this._r, angle);
547
542
  var tr = new Mat4().setIdentity().translate(center);
548
543
  var ntr = new Mat4().setIdentity().translate(center.negateTo());
549
544
  var trm = tr.mul(rot).mul(ntr);
550
545
 
551
546
  let eye = trm.mulVec3(this.eye);
552
- let v = rot.mulVec3(this._v).normalize();
553
547
  let u = rot.mulVec3(this._u).normalize();
554
- let n = rot.mulVec3(this._n).normalize();
548
+ let r = rot.mulVec3(this._r).normalize();
549
+ let b = rot.mulVec3(this._b).normalize();
555
550
 
556
551
  let eyeNorm = eye.normal();
557
- let slope = n.dot(eyeNorm);
552
+ let slope = b.dot(eyeNorm);
558
553
 
559
554
  if (minSlope) {
560
555
  let dSlope = slope - this.slope;
@@ -562,20 +557,20 @@ class PlanetCamera extends Camera {
562
557
  if (slope < minSlope && dSlope < 0) return;
563
558
 
564
559
  if (
565
- (slope > 0.1 && v.dot(eyeNorm) > 0) ||
560
+ (slope > 0.1 && u.dot(eyeNorm) > 0) ||
566
561
  this.slope <= 0.1 ||
567
- this._v.dot(this.eye.normal()) <= 0.0
562
+ this._u.dot(this.eye.normal()) <= 0.0
568
563
  ) {
569
564
  this.eye = eye;
570
- this._v = v;
571
565
  this._u = u;
572
- this._n = n;
566
+ this._r = r;
567
+ this._b = b;
573
568
  }
574
569
  } else {
575
570
  this.eye = eye;
576
- this._v = v;
577
571
  this._u = u;
578
- this._n = n;
572
+ this._r = r;
573
+ this._b = b;
579
574
  }
580
575
  }
581
576
 
@@ -592,9 +587,9 @@ class PlanetCamera extends Camera {
592
587
  this.planet._normalMapCreator.lock(this._keyLock);
593
588
 
594
589
  this.eye = this._framesArr[c].eye;
595
- this._u = this._framesArr[c].u;
596
- this._v = this._framesArr[c].v;
597
- this._n = this._framesArr[c].n;
590
+ this._r = this._framesArr[c].u;
591
+ this._u = this._framesArr[c].v;
592
+ this._b = this._framesArr[c].n;
598
593
 
599
594
  if (this._frameCallback) {
600
595
  this._frameCallback();
@@ -93,8 +93,8 @@ class DebugInfo extends Control {
93
93
  frame: () => p.camera.slope.toFixed(3)
94
94
  },
95
95
  {
96
- label: "lodRatio",
97
- frame: () => p._lodRatio.toFixed(3)
96
+ label: "lodSize",
97
+ frame: () => Math.round(p.lodSize)
98
98
  },
99
99
  {
100
100
  label: "deltaTime/FPS",
@@ -6,6 +6,7 @@ import { Quat } from "../math/Quat.js";
6
6
  import { Ray } from "../math/Ray.js";
7
7
  import { Vec3 } from "../math/Vec3.js";
8
8
  import { Control } from "./Control.js";
9
+ import { Mat4 } from "../math/Mat4.js";
9
10
 
10
11
  class Touch {
11
12
  constructor() {
@@ -29,6 +30,7 @@ class EarthNavigation extends Control {
29
30
  super(options);
30
31
 
31
32
  this.grabbedPoint = new Vec3();
33
+ this.grabbedDir = new Vec3();
32
34
  this.inertia = 0.007;
33
35
  this.grabbedSpheroid = new Sphere();
34
36
  this.planet = null;
@@ -39,11 +41,11 @@ class EarthNavigation extends Control {
39
41
  this.currState = 0;
40
42
 
41
43
  this.positionState = [
42
- { h: 17119745.303455353, max: 0.99, min: -0.99 },
43
- { h: 6866011, max: 0.99, min: -0.99 },
44
- { h: 3000000, max: 0.99, min: -0.99 },
45
- { h: 1000000, max: 0.99, min: -0.99 },
46
- { h: 500000, max: 0.99, min: -0.99 }
44
+ { h: 17119745.303455353, max: 0.98, min: -0.98 },
45
+ { h: 6866011, max: 0.98, min: -0.98 },
46
+ { h: 3000000, max: 0.98, min: -0.98 },
47
+ { h: 1000000, max: 0.98, min: -0.98 },
48
+ { h: 500000, max: 0.98, min: -0.98 }
47
49
  ];
48
50
 
49
51
  this.touches = [new Touch(), new Touch()];
@@ -163,9 +165,10 @@ class EarthNavigation extends Control {
163
165
  }
164
166
  }
165
167
 
166
- onMouseLeftButtonClick() {
168
+ onMouseLeftButtonClick(e) {
167
169
  this.renderer.handler.gl.canvas.classList.add("ogGrabbingPoiner");
168
170
  this.grabbedPoint = this.planet.getCartesianFromMouseTerrain(true);
171
+ this.grabbedDir.copy(e.direction);
169
172
  if (this.grabbedPoint) {
170
173
  this.grabbedSpheroid.radius = this.grabbedPoint.length();
171
174
  this.stopRotation();
@@ -195,24 +198,30 @@ class EarthNavigation extends Control {
195
198
  var targetPoint = new Ray(cam.eye, e.direction).hitSphere(this.grabbedSpheroid);
196
199
 
197
200
  if (targetPoint) {
198
- this._a =
199
- Math.acos(this.grabbedPoint.y / this.grabbedSpheroid.radius) -
201
+
202
+ this._a = Math.acos(this.grabbedPoint.y / this.grabbedSpheroid.radius) -
200
203
  Math.acos(targetPoint.y / this.grabbedSpheroid.radius);
201
204
 
202
- this._vRot = Quat.axisAngleToQuat(cam._u, this._a);
205
+ let rot = this._vRot = Quat.axisAngleToQuat(cam._u, this._a);
206
+
207
+ cam.set(rot.mulVec3(cam.eye), Vec3.ZERO, rot.mulVec3(cam.getUp()));
208
+ //cam.update();
209
+
203
210
  this._hRot = Quat.getRotationBetweenVectors(
204
211
  new Vec3(targetPoint.x, 0.0, targetPoint.z).normal(),
205
212
  new Vec3(this.grabbedPoint.x, 0.0, this.grabbedPoint.z).normal()
206
213
  );
207
- var rot = this._hRot.mul(this._vRot);
208
214
 
209
- var state = this.positionState[this.currState];
210
- var lim = rot.mulVec3(cam.eye).normal().dot(Vec3.UP);
211
- if (lim > state.max || lim < state.min) {
212
- rot = Quat.yRotation(rot.getYaw());
213
- }
214
- cam.set(rot.mulVec3(cam.eye), Vec3.ZERO, Vec3.UP);
215
- cam.update();
215
+ rot = this._hRot;
216
+
217
+ //var state = this.positionState[this.currState];
218
+ //var lim = cam.eye.normal().dot(Vec3.UP);
219
+
220
+ //if (lim > state.max || lim < state.min) {
221
+ // rot = Quat.yRotation(rot.getYaw());
222
+ cam.set(rot.mulVec3(cam.eye), Vec3.ZERO, rot.mulVec3(cam.getUp()));
223
+ cam.update();
224
+ //}
216
225
  }
217
226
  } else {
218
227
  this.scaleRot = 0;
@@ -57,9 +57,9 @@ class MouseNavigation extends Control {
57
57
  var steps = [];
58
58
 
59
59
  var eye = cam.eye.clone(),
60
- n = cam._n.clone(),
61
- u = cam._u.clone(),
62
- v = cam._v.clone();
60
+ n = cam._b.clone(),
61
+ u = cam._r.clone(),
62
+ v = cam._u.clone();
63
63
 
64
64
  var a = planet.getCartesianFromPixelTerrain(point, true);
65
65
 
@@ -265,7 +265,6 @@ class MouseNavigation extends Control {
265
265
  this.renderer.handler.canvas.classList.add("ogGrabbingPoiner");
266
266
  this.grabbedPoint = this.planet.getCartesianFromMouseTerrain();
267
267
  if (this.grabbedPoint) {
268
- this.renderer.isActiveBackBuffers = false;
269
268
  this._eye0.copy(this.renderer.activeCamera.eye);
270
269
  this.grabbedSpheroid.radius = this.grabbedPoint.length();
271
270
  this.stopRotation();
@@ -281,7 +280,6 @@ class MouseNavigation extends Control {
281
280
  }
282
281
 
283
282
  onMouseLeftButtonUp(e) {
284
- this.renderer.isActiveBackBuffers = true;
285
283
  this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner");
286
284
  if (e.x === e.prev_x && e.y === e.prev_y) {
287
285
  this.scaleRot = 0.0;
@@ -309,9 +307,9 @@ class MouseNavigation extends Control {
309
307
  );
310
308
  var rot = this.qRot;
311
309
  cam.eye = rot.mulVec3(cam.eye);
312
- cam._v = rot.mulVec3(cam._v);
313
310
  cam._u = rot.mulVec3(cam._u);
314
- cam._n = rot.mulVec3(cam._n);
311
+ cam._r = rot.mulVec3(cam._r);
312
+ cam._b = rot.mulVec3(cam._b);
315
313
 
316
314
  cam.checkTerrainCollision();
317
315
 
@@ -319,7 +317,7 @@ class MouseNavigation extends Control {
319
317
  }
320
318
  } else {
321
319
  var p0 = this.grabbedPoint,
322
- p1 = Vec3.add(p0, cam._u),
320
+ p1 = Vec3.add(p0, cam._r),
323
321
  p2 = Vec3.add(p0, p0.normal());
324
322
 
325
323
  var px = new Vec3();
@@ -395,9 +393,9 @@ class MouseNavigation extends Control {
395
393
  }
396
394
 
397
395
  cam.eye = sf.eye;
398
- cam._v = sf.v;
399
- cam._u = sf.u;
400
- cam._n = sf.n;
396
+ cam._u = sf.v;
397
+ cam._r = sf.u;
398
+ cam._b = sf.n;
401
399
 
402
400
  cam.checkTerrainCollision();
403
401
 
@@ -428,9 +426,9 @@ class MouseNavigation extends Control {
428
426
  this.scaleRot = 0.0;
429
427
  }
430
428
  cam.eye = rot.mulVec3(cam.eye);
431
- cam._v = rot.mulVec3(cam._v);
432
429
  cam._u = rot.mulVec3(cam._u);
433
- cam._n = rot.mulVec3(cam._n);
430
+ cam._r = rot.mulVec3(cam._r);
431
+ cam._b = rot.mulVec3(cam._b);
434
432
 
435
433
  cam.checkTerrainCollision();
436
434
 
@@ -195,9 +195,9 @@ class MouseWheelZoomControl extends Control {
195
195
  }
196
196
 
197
197
  cam.eye = sf.eye;
198
- cam._v = sf.v;
199
- cam._u = sf.u;
200
- cam._n = sf.n;
198
+ cam._u = sf.v;
199
+ cam._r = sf.u;
200
+ cam._b = sf.n;
201
201
 
202
202
  cam.checkTerrainCollision();
203
203
 
@@ -228,9 +228,9 @@ class MouseWheelZoomControl extends Control {
228
228
  this.scaleRot = 0.0;
229
229
  }
230
230
  cam.eye = rot.mulVec3(cam.eye);
231
- cam._v = rot.mulVec3(cam._v);
232
231
  cam._u = rot.mulVec3(cam._u);
233
- cam._n = rot.mulVec3(cam._n);
232
+ cam._r = rot.mulVec3(cam._r);
233
+ cam._b = rot.mulVec3(cam._b);
234
234
 
235
235
  cam.checkTerrainCollision();
236
236