Skip to content

Commit

Permalink
Changes the way the yaw limit is checked
Browse files Browse the repository at this point in the history
  • Loading branch information
Nehon committed Aug 22, 2018
1 parent 2d35c84 commit f2e382a
Showing 1 changed file with 43 additions and 5 deletions.
48 changes: 43 additions & 5 deletions sources/osgGA/OrbitManipulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ utils.createPrototypeObject(
this._limitZoomIn = 1e-4;
this._limitZoomOut = Infinity;

this._constrainYaw = false;
this._constrainPitch = false;
this._constrainYaw = false;
this._constrainZoom = false;

// instance of controller
var self = this;

Expand All @@ -109,16 +114,47 @@ utils.createPrototypeObject(
},
setLimitYawLeft: function(left) {
this._limitYawLeft = left;
this._constrainYaw = true;
},
setLimitYawRight: function(right) {
this._limitYawRight = right;
this._constrainYaw = true;
},
setLimitZoomOut: function(zoomOut) {
this._limitZoomOut = zoomOut;
this._constrainZoom = true;
},
setLimitZoomIn: function(zoomIn) {
this._limitZoomIn = zoomIn;
this._constrainZoom = true;
},

setConstrainPitch: function(limit) {
this._constrainPitch = limit;
this._previousPitch = undefined;
},

isConstrainPitch: function() {
return this._constrainPitch;
},

setConstrainYaw: function(constrain) {
this._constrainYaw = constrain;
this._previousYaw = undefined;
},

isConstrainYaw: function() {
return this._constrainYaw;
},

setConstrainZoom: function(limit) {
this._constrainZoom = limit;
},

isConstrainZoom: function() {
return this._constrainZoom;
},

setDelay: function(dt) {
this._rotate.setDelay(dt);
this._pan.setDelay(dt);
Expand Down Expand Up @@ -274,7 +310,7 @@ utils.createPrototypeObject(
var left = this._limitYawLeft;
var right = this._limitYawRight;

if (right !== Math.PI || left !== -Math.PI) {
if (this._constrainYaw) {
if (right < left) {
if (yaw > Math.PI) {
previousYaw -= TWO_PI;
Expand Down Expand Up @@ -324,10 +360,12 @@ utils.createPrototypeObject(
vec3.add(this._target, this._target, dir);
}

this._distance = Math.max(
this._limitZoomIn,
Math.min(this._limitZoomOut, newValue)
);
if (this._constrainZoom) {
this._distance = Math.max(
this._limitZoomIn,
Math.min(this._limitZoomOut, newValue)
);
}
};
})(),

Expand Down

0 comments on commit f2e382a

Please sign in to comment.