Skip to content

Commit ba347be

Browse files
martinRenoumrdoob
authored andcommitted
Add attributes to EditorControls (mrdoob#9819)
* Add attributes to EditorControls Add attributes to EditorControls to be able to change speed of controls * Changed attribute name factor to speed
1 parent 843e733 commit ba347be

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

examples/js/controls/EditorControls.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ THREE.EditorControls = function ( object, domElement ) {
1313

1414
this.enabled = true;
1515
this.center = new THREE.Vector3();
16+
this.panSpeed = 0.001
17+
this.zoomSpeed = 0.001
18+
this.rotationSpeed = 0.005
1619

1720
// internals
1821

@@ -57,7 +60,7 @@ THREE.EditorControls = function ( object, domElement ) {
5760

5861
var distance = object.position.distanceTo( center );
5962

60-
delta.multiplyScalar( distance * 0.001 );
63+
delta.multiplyScalar( distance * this.panSpeed );
6164
delta.applyMatrix3( normalMatrix.getNormalMatrix( object.matrix ) );
6265

6366
object.position.add( delta );
@@ -71,7 +74,7 @@ THREE.EditorControls = function ( object, domElement ) {
7174

7275
var distance = object.position.distanceTo( center );
7376

74-
delta.multiplyScalar( distance * 0.001 );
77+
delta.multiplyScalar( distance * this.zoomSpeed );
7578

7679
if ( delta.length() > distance ) return;
7780

@@ -144,7 +147,7 @@ THREE.EditorControls = function ( object, domElement ) {
144147

145148
if ( state === STATE.ROTATE ) {
146149

147-
scope.rotate( new THREE.Vector3( - movementX * 0.005, - movementY * 0.005, 0 ) );
150+
scope.rotate( new THREE.Vector3( - movementX * this.rotationSpeed, - movementY * this.rotationSpeed, 0 ) );
148151

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

@@ -267,7 +270,7 @@ THREE.EditorControls = function ( object, domElement ) {
267270
case 1:
268271
touches[ 0 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 );
269272
touches[ 1 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 );
270-
scope.rotate( touches[ 0 ].sub( getClosest( touches[ 0 ], prevTouches ) ).multiplyScalar( - 0.005 ) );
273+
scope.rotate( touches[ 0 ].sub( getClosest( touches[ 0 ], prevTouches ) ).multiplyScalar( - this.rotationSpeed ) );
271274
break;
272275

273276
case 2:

0 commit comments

Comments
 (0)