|
@@ -362,7 +362,16 @@
|
|
var radiusv3 = position.subtract(this._getTargetPosition());
|
|
var radiusv3 = position.subtract(this._getTargetPosition());
|
|
this.radius = radiusv3.length();
|
|
this.radius = radiusv3.length();
|
|
|
|
|
|
- this.alpha = Math.atan(radiusv3.z / radiusv3.x);
|
|
|
|
|
|
+ // Alpha
|
|
|
|
+ this.alpha = Math.acos(radiusv3.x / Math.sqrt(
|
|
|
|
+ Math.pow(radiusv3.x, 2) +
|
|
|
|
+ Math.pow(radiusv3.z, 2)
|
|
|
|
+ ));
|
|
|
|
+ if (radiusv3.z < 0) {
|
|
|
|
+ this.alpha = 2 * Math.PI - this.alpha;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Beta
|
|
this.beta = Math.acos(radiusv3.y / this.radius);
|
|
this.beta = Math.acos(radiusv3.y / this.radius);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -411,4 +420,4 @@
|
|
this.maxZ = distance * 2;
|
|
this.maxZ = distance * 2;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|