Prechádzať zdrojové kódy

*Controls: Renamed freeze to enabled.

Mr.doob 10 rokov pred
rodič
commit
8e2d3a8cbc

+ 5 - 7
examples/js/controls/DeviceOrientationControls.js

@@ -10,13 +10,11 @@ THREE.DeviceOrientationControls = function ( object ) {
 	var scope = this;
 
 	this.object = object;
-
 	this.object.rotation.reorder( "YXZ" );
 
-	this.freeze = true;
+	this.enabled = true;
 
 	this.deviceOrientation = {};
-
 	this.screenOrientation = 0;
 
 	var onDeviceOrientationChangeEvent = function ( event ) {
@@ -64,22 +62,22 @@ THREE.DeviceOrientationControls = function ( object ) {
 		window.addEventListener( 'orientationchange', onScreenOrientationChangeEvent, false );
 		window.addEventListener( 'deviceorientation', onDeviceOrientationChangeEvent, false );
 
-		scope.freeze = false;
+		scope.enabled = true;
 
 	};
 
 	this.disconnect = function() {
 
-		scope.freeze = true;
-
 		window.removeEventListener( 'orientationchange', onScreenOrientationChangeEvent, false );
 		window.removeEventListener( 'deviceorientation', onDeviceOrientationChangeEvent, false );
 
+		scope.enabled = false;
+
 	};
 
 	this.update = function () {
 
-		if ( scope.freeze ) return;
+		if ( scope.enabled === false ) return;
 
 		var alpha  = scope.deviceOrientation.alpha ? THREE.Math.degToRad( scope.deviceOrientation.alpha ) : 0; // Z
 		var beta   = scope.deviceOrientation.beta  ? THREE.Math.degToRad( scope.deviceOrientation.beta  ) : 0; // X'

+ 4 - 10
examples/js/controls/FirstPersonControls.js

@@ -11,12 +11,13 @@ THREE.FirstPersonControls = function ( object, domElement ) {
 
 	this.domElement = ( domElement !== undefined ) ? domElement : document;
 
+	this.enabled = true;
+
 	this.movementSpeed = 1.0;
 	this.lookSpeed = 0.005;
 
 	this.lookVertical = true;
 	this.autoForward = false;
-	// this.invertVertical = false;
 
 	this.activeLook = true;
 
@@ -43,7 +44,6 @@ THREE.FirstPersonControls = function ( object, domElement ) {
 	this.moveBackward = false;
 	this.moveLeft = false;
 	this.moveRight = false;
-	this.freeze = false;
 
 	this.mouseDragOn = false;
 
@@ -157,8 +157,6 @@ THREE.FirstPersonControls = function ( object, domElement ) {
 			case 82: /*R*/ this.moveUp = true; break;
 			case 70: /*F*/ this.moveDown = true; break;
 
-			case 81: /*Q*/ this.freeze = !this.freeze; break;
-
 		}
 
 	};
@@ -188,11 +186,7 @@ THREE.FirstPersonControls = function ( object, domElement ) {
 
 	this.update = function( delta ) {
 
-		if ( this.freeze ) {
-
-			return;
-
-		}
+		if ( this.enabled === false ) return;
 
 		if ( this.heightSpeed ) {
 
@@ -265,7 +259,7 @@ THREE.FirstPersonControls = function ( object, domElement ) {
 	this.domElement.addEventListener( 'mousemove', bind( this, this.onMouseMove ), false );
 	this.domElement.addEventListener( 'mousedown', bind( this, this.onMouseDown ), false );
 	this.domElement.addEventListener( 'mouseup', bind( this, this.onMouseUp ), false );
-	
+
 	window.addEventListener( 'keydown', bind( this, this.onKeyDown ), false );
 	window.addEventListener( 'keyup', bind( this, this.onKeyUp ), false );
 

+ 2 - 5
examples/js/controls/OculusControls.js

@@ -11,8 +11,8 @@ THREE.OculusControls = function ( object ) {
 	this.object = object;
 	this.target = new THREE.Vector3( 0, 0, 0 );
 
+	this.enabled = true;
 	this.headquat = new THREE.Quaternion();
-	this.freeze = false;
 
 	this.loadAjaxJSON = function ( url, callback ) {
 		var xhr = new XMLHttpRequest();
@@ -45,10 +45,7 @@ THREE.OculusControls = function ( object ) {
 	}
 
 	this.update = function( delta ) {
-		if ( this.freeze ) {
-			return;
-		}
-
+		if ( this.enabled === false ) return;
 		this.object.quaternion.multiply(this.headquat);
 	};