فهرست منبع

Add attributes to EditorControls (#9819)

* Add attributes to EditorControls

Add attributes to EditorControls to be able to change speed of controls

* Changed attribute name factor to speed
martinRenou 8 سال پیش
والد
کامیت
ba347be773
1فایلهای تغییر یافته به همراه7 افزوده شده و 4 حذف شده
  1. 7 4
      examples/js/controls/EditorControls.js

+ 7 - 4
examples/js/controls/EditorControls.js

@@ -13,6 +13,9 @@ THREE.EditorControls = function ( object, domElement ) {
 
 	this.enabled = true;
 	this.center = new THREE.Vector3();
+	this.panSpeed = 0.001
+	this.zoomSpeed = 0.001
+	this.rotationSpeed = 0.005
 
 	// internals
 
@@ -57,7 +60,7 @@ THREE.EditorControls = function ( object, domElement ) {
 
 		var distance = object.position.distanceTo( center );
 
-		delta.multiplyScalar( distance * 0.001 );
+		delta.multiplyScalar( distance * this.panSpeed );
 		delta.applyMatrix3( normalMatrix.getNormalMatrix( object.matrix ) );
 
 		object.position.add( delta );
@@ -71,7 +74,7 @@ THREE.EditorControls = function ( object, domElement ) {
 
 		var distance = object.position.distanceTo( center );
 
-		delta.multiplyScalar( distance * 0.001 );
+		delta.multiplyScalar( distance * this.zoomSpeed );
 
 		if ( delta.length() > distance ) return;
 
@@ -144,7 +147,7 @@ THREE.EditorControls = function ( object, domElement ) {
 
 		if ( state === STATE.ROTATE ) {
 
-			scope.rotate( new THREE.Vector3( - movementX * 0.005, - movementY * 0.005, 0 ) );
+			scope.rotate( new THREE.Vector3( - movementX * this.rotationSpeed, - movementY * this.rotationSpeed, 0 ) );
 
 		} else if ( state === STATE.ZOOM ) {
 
@@ -267,7 +270,7 @@ THREE.EditorControls = function ( object, domElement ) {
 			case 1:
 				touches[ 0 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 );
 				touches[ 1 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 );
-				scope.rotate( touches[ 0 ].sub( getClosest( touches[ 0 ], prevTouches ) ).multiplyScalar( - 0.005 ) );
+				scope.rotate( touches[ 0 ].sub( getClosest( touches[ 0 ], prevTouches ) ).multiplyScalar( - this.rotationSpeed ) );
 				break;
 
 			case 2: