Browse Source

avoid new's in editor controls with Spherical.

Ben Houston 9 years ago
parent
commit
9d42f10fc7
1 changed files with 4 additions and 3 deletions
  1. 4 3
      examples/js/controls/EditorControls.js

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

@@ -26,6 +26,7 @@ THREE.EditorControls = function ( object, domElement ) {
 	var normalMatrix = new THREE.Matrix3();
 	var pointer = new THREE.Vector2();
 	var pointerOld = new THREE.Vector2();
+	var spherical = new THREE.Spherical();
 
 	// events
 
@@ -86,15 +87,15 @@ THREE.EditorControls = function ( object, domElement ) {
 
 		vector.copy( object.position ).sub( center );
 
-		var spherical = new THREE.Spherical().fromVector3( vector );
+		spherical.fromVector3( vector );
 
 		spherical.theta += delta.x;
 		spherical.phi += delta.y;
 
 		spherical.makeSafe();
 
-		vector = spherical.toVector3();
-		
+		vector = spherical.toVector3( vector );
+
 		object.position.copy( center ).add( vector );
 
 		object.lookAt( center );