|
@@ -86,21 +86,16 @@ THREE.EditorControls = function ( object, domElement ) {
|
|
|
|
|
|
vector.copy( object.position ).sub( center );
|
|
|
|
|
|
- var theta = Math.atan2( vector.x, vector.z );
|
|
|
- var phi = Math.atan2( Math.sqrt( vector.x * vector.x + vector.z * vector.z ), vector.y );
|
|
|
+ var spherical = new THREE.Spherical().fromDirection( vector );
|
|
|
|
|
|
- theta += delta.x;
|
|
|
- phi += delta.y;
|
|
|
+ spherical.theta += delta.x;
|
|
|
+ spherical.phi += delta.y;
|
|
|
|
|
|
- var EPS = 0.000001;
|
|
|
-
|
|
|
- phi = Math.max( EPS, Math.min( Math.PI - EPS, phi ) );
|
|
|
+ spherical.makeSafe();
|
|
|
|
|
|
var radius = vector.length();
|
|
|
|
|
|
- vector.x = radius * Math.sin( phi ) * Math.sin( theta );
|
|
|
- vector.y = radius * Math.cos( phi );
|
|
|
- vector.z = radius * Math.sin( phi ) * Math.cos( theta );
|
|
|
+ vector = spherical.direction().multiplyScalar( radius );
|
|
|
|
|
|
object.position.copy( center ).add( vector );
|
|
|
|