Explorar el Código

Removed redundant code from FPS controls.

The functionality removed is repeated directly after this code block.
The entire process is actually being done twice, which is undoubtedly incorrect or otherwise very unclear.

Given that it is simply doing 3 actions:

a) Adjusting the pitch/yaw based on the mouse position deltas, then multiplying that by the lookSpeed.
b) Clamping, transforming the pitch space (to the X,Z coordinate frame) and then converting the pitch/yaw (lat/lon) to radians.
c) Calculating the target position 100 units in the direction specified by the pitch/yaw.

This process has no reason to be repeated.
Daniel Cousens hace 13 años
padre
commit
97ced7ec86
Se han modificado 1 ficheros con 0 adiciones y 14 borrados
  1. 0 14
      examples/js/controls/FirstPersonControls.js

+ 0 - 14
examples/js/controls/FirstPersonControls.js

@@ -227,20 +227,6 @@ THREE.FirstPersonControls = function ( object, domElement ) {
 
 			}
 
-			this.lon += this.mouseX * actualLookSpeed;
-			if( this.lookVertical ) this.lat -= this.mouseY * actualLookSpeed; // * this.invertVertical?-1:1;
-
-			this.lat = Math.max( - 85, Math.min( 85, this.lat ) );
-			this.phi = THREE.Math.degToRad( 90 - this.lat );
-			this.theta = THREE.Math.degToRad( this.lon );
-
-			var targetPosition = this.target,
-				position = this.object.position;
-
-			targetPosition.x = position.x + 100 * Math.sin( this.phi ) * Math.cos( this.theta );
-			targetPosition.y = position.y + 100 * Math.cos( this.phi );
-			targetPosition.z = position.z + 100 * Math.sin( this.phi ) * Math.sin( this.theta );
-
 		}
 
 		var verticalLookRatio = 1;

粤ICP备19079148号