Browse Source

OrbitControls: added reset()

WestLangley 11 years ago
parent
commit
d946b8e0ce
1 changed files with 16 additions and 0 deletions
  1. 16 0
      examples/js/controls/OrbitControls.js

+ 16 - 0
examples/js/controls/OrbitControls.js

@@ -103,6 +103,11 @@ THREE.OrbitControls = function ( object, domElement ) {
 
 	var state = STATE.NONE;
 
+	// for reset
+
+	this.target0 = this.target.clone();
+	this.position0 = this.object.position.clone();
+
 	// events
 
 	var changeEvent = { type: 'change' };
@@ -279,6 +284,17 @@ THREE.OrbitControls = function ( object, domElement ) {
 	};
 
 
+	this.reset = function () {
+
+		state = STATE.NONE;
+
+		this.target.copy( this.target0 );
+		this.object.position.copy( this.position0 );
+
+		this.update();
+
+	};
+
 	function getAutoRotationAngle() {
 
 		return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;