Skip to content

Commit

Permalink
Remove unnecessary instantiations
Browse files Browse the repository at this point in the history
  • Loading branch information
WestLangley committed Jun 30, 2018
1 parent 52b0b7f commit 1d19232
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions examples/js/controls/EditorControls.js
Expand Up @@ -21,6 +21,8 @@ THREE.EditorControls = function ( object, domElement ) {

var scope = this;
var vector = new THREE.Vector3();
var delta = new THREE.Vector3();
var box = new THREE.Box3();

var STATE = { NONE: - 1, ROTATE: 0, ZOOM: 1, PAN: 2 };
var state = STATE.NONE;
Expand All @@ -37,10 +39,10 @@ THREE.EditorControls = function ( object, domElement ) {

this.focus = function ( target ) {

var box = new THREE.Box3().setFromObject( target );

var distance;

box.setFromObject( target );

if ( box.isEmpty() === false ) {

center.copy( box.getCenter() );
Expand All @@ -55,7 +57,7 @@ THREE.EditorControls = function ( object, domElement ) {

}

var delta = new THREE.Vector3( 0, 0, 1 );
delta.set( 0, 0, 1 );
delta.applyQuaternion( object.quaternion );
delta.multiplyScalar( distance * 4 );

Expand Down Expand Up @@ -156,15 +158,15 @@ THREE.EditorControls = function ( object, domElement ) {

if ( state === STATE.ROTATE ) {

scope.rotate( new THREE.Vector3( - movementX * scope.rotationSpeed, - movementY * scope.rotationSpeed, 0 ) );
scope.rotate( delta.set( - movementX * scope.rotationSpeed, - movementY * scope.rotationSpeed, 0 ) );

} else if ( state === STATE.ZOOM ) {

scope.zoom( new THREE.Vector3( 0, 0, movementY ) );
scope.zoom( delta.set( 0, 0, movementY ) );

} else if ( state === STATE.PAN ) {

scope.pan( new THREE.Vector3( - movementX, movementY, 0 ) );
scope.pan( delta.set( - movementX, movementY, 0 ) );

}

Expand All @@ -188,7 +190,7 @@ THREE.EditorControls = function ( object, domElement ) {
event.preventDefault();

// Normalize deltaY due to https://bugzilla.mozilla.org/show_bug.cgi?id=1392460
scope.zoom( new THREE.Vector3( 0, 0, event.deltaY > 0 ? 1 : - 1 ) );
scope.zoom( delta.set( 0, 0, event.deltaY > 0 ? 1 : - 1 ) );

}

Expand Down Expand Up @@ -283,7 +285,7 @@ THREE.EditorControls = function ( object, domElement ) {
touches[ 0 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 );
touches[ 1 ].set( event.touches[ 1 ].pageX, event.touches[ 1 ].pageY, 0 );
var distance = touches[ 0 ].distanceTo( touches[ 1 ] );
scope.zoom( new THREE.Vector3( 0, 0, prevDistance - distance ) );
scope.zoom( delta.set( 0, 0, prevDistance - distance ) );
prevDistance = distance;


Expand Down

0 comments on commit 1d19232

Please sign in to comment.