فهرست منبع

Brief:Adding the option of disabling the "roll" outside of the trackball
Summary:

Kevin Schmidt 12 سال پیش
والد
کامیت
245bd69734
1فایلهای تغییر یافته به همراه8 افزوده شده و 1 حذف شده
  1. 8 1
      examples/js/controls/TrackballControls.js

+ 8 - 1
examples/js/controls/TrackballControls.js

@@ -24,6 +24,7 @@ THREE.TrackballControls = function ( object, domElement ) {
 	this.noRotate = false;
 	this.noZoom = false;
 	this.noPan = false;
+	this.noRoll = false;
 
 	this.staticMoving = false;
 	this.dynamicDampingFactor = 0.2;
@@ -110,7 +111,13 @@ THREE.TrackballControls = function ( object, domElement ) {
 
 		var length = mouseOnBall.length();
 
-		if ( length > 1.0 ) {
+		if ( _this.noRoll ) {
+			if (length < Math.SQRT1_2 ) {
+				mouseOnBall.z = Math.sqrt( 1.0 - length*length );
+			} else {
+				mouseOnBall.z = .5 / length;
+			}
+		} else if ( length > 1.0 ) {
 
 			mouseOnBall.normalize();