|
@@ -344,7 +344,16 @@ var BABYLON;
|
|
|
var radiusv3 = position.subtract(this._getTargetPosition());
|
|
|
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);
|
|
|
};
|
|
|
|