three.js - Eliminating off-of-ball roll in Trackball controls (with code/fix) -


is intent of trackballcontrol have "border" outside trackball induces roll? dislike it. bit discontinuous, , does't have lot of purpose (imho).

if not, function getmouseprojectiononball can changed similar following. 2 things (not "correctly"):

  1. normalize radius fill both axis
  2. map z values outside of ball (ie z 0)

i find lot more natural, personally.

thoughts?

 this.getmouseprojectiononball = function(clientx, clienty)  {     var xnormalized = (clientx - _this.screen.width * 0.5 - _this.screen.offsetleft) / (_this.screen.width / 2.0);     var ynormalized = (_this.screen.height * 0.5 + _this.screen.offsettop - clienty) / (_this.screen.height / 2.0);     var mouseonball = new three.vector3(         xnormalized,         ynormalized,         0.0     );      var length = mouseonball.length();      var ballradius = 1.0;  // fraction of screen      if (length > ballradius * 0.70710678118654752440) {         var temp = ballradius / 1.41421356237309504880;         mouseonball.z = temp * temp / length;          // remove old method.         // left z = 0, meant rotation axis         // becomes z, roll         //mouseonball.normalize();      } else {         mouseonball.z = math.sqrt(1.0 - length * length);     }      _eye.copy(_this.object.position).sub(_this.target);      var projection = _this.object.up.clone().setlength(mouseonball.y);     projection.add(_this.object.up.clone().cross(_eye).setlength(mouseonball.x));     projection.add(_eye.setlength(mouseonball.z));      return projection;  }; 


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -