Răsfoiți Sursa

OrbitControls: Add `keyRotateSpeed`. (#29988)

* feat: Add keyRotateSpeed to OrbitControls

This allows for setting a different speed of rotation when using the
keyboard vs when using a mouse. Similar in approach to the existing
keyPanSpeed.

* fix: reduce keyRotateSpeed down to 1
Simon Gaeremynck 1 an în urmă
părinte
comite
d9c9920c28

+ 5 - 0
docs/examples/en/controls/OrbitControls.html

@@ -141,6 +141,11 @@
 			How fast to pan the camera when the keyboard is used. Default is 7.0 pixels per keypress.
 			How fast to pan the camera when the keyboard is used. Default is 7.0 pixels per keypress.
 		</p>
 		</p>
 
 
+		<h3>[property:Float keyRotateSpeed]</h3>
+		<p>
+			How fast to rotate the camera when the keyboard is used. Default is 1.
+		</p>
+
 		<h3>[property:Object keys]</h3>
 		<h3>[property:Object keys]</h3>
 		<p>
 		<p>
 			This object contains references to the keycodes for controlling camera panning. Default is the 4 arrow keys.
 			This object contains references to the keycodes for controlling camera panning. Default is the 4 arrow keys.

+ 5 - 4
examples/jsm/controls/OrbitControls.js

@@ -92,6 +92,7 @@ class OrbitControls extends Controls {
 		// Set to false to disable rotating
 		// Set to false to disable rotating
 		this.enableRotate = true;
 		this.enableRotate = true;
 		this.rotateSpeed = 1.0;
 		this.rotateSpeed = 1.0;
+		this.keyRotateSpeed = 1.0;
 
 
 		// Set to false to disable panning
 		// Set to false to disable panning
 		this.enablePan = true;
 		this.enablePan = true;
@@ -786,7 +787,7 @@ class OrbitControls extends Controls {
 
 
 					if ( this.enableRotate ) {
 					if ( this.enableRotate ) {
 
 
-						this._rotateUp( _twoPI * this.rotateSpeed / this.domElement.clientHeight );
+						this._rotateUp( _twoPI * this.keyRotateSpeed / this.domElement.clientHeight );
 
 
 					}
 					}
 
 
@@ -809,7 +810,7 @@ class OrbitControls extends Controls {
 
 
 					if ( this.enableRotate ) {
 					if ( this.enableRotate ) {
 
 
-						this._rotateUp( - _twoPI * this.rotateSpeed / this.domElement.clientHeight );
+						this._rotateUp( - _twoPI * this.keyRotateSpeed / this.domElement.clientHeight );
 
 
 					}
 					}
 
 
@@ -832,7 +833,7 @@ class OrbitControls extends Controls {
 
 
 					if ( this.enableRotate ) {
 					if ( this.enableRotate ) {
 
 
-						this._rotateLeft( _twoPI * this.rotateSpeed / this.domElement.clientHeight );
+						this._rotateLeft( _twoPI * this.keyRotateSpeed / this.domElement.clientHeight );
 
 
 					}
 					}
 
 
@@ -855,7 +856,7 @@ class OrbitControls extends Controls {
 
 
 					if ( this.enableRotate ) {
 					if ( this.enableRotate ) {
 
 
-						this._rotateLeft( - _twoPI * this.rotateSpeed / this.domElement.clientHeight );
+						this._rotateLeft( - _twoPI * this.keyRotateSpeed / this.domElement.clientHeight );
 
 
 					}
 					}
 
 

粤ICP备19079148号