mirror of
https://github.com/MapMakersAndProgrammers/Alternativa3D.git
synced 2025-10-27 18:39:07 -07:00
added Camera setPosition and lookAt methods
This commit is contained in:
@@ -406,6 +406,29 @@ public class Camera3D extends Object3D {
|
||||
occluders.length = 0;
|
||||
context3D = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup Camera3D position using x, y, z coordinates
|
||||
*/
|
||||
|
||||
public function setPosition(x:Number, y:Number, z:Number):void{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Camera3D lookAt method
|
||||
*/
|
||||
public function lookAt(x:Number, y:Number, z:Number):void{
|
||||
var deltaX:Number = x - this.x;
|
||||
var deltaY:Number = y - this.y;
|
||||
var deltaZ:Number = z - this.z;
|
||||
var rotX = Math.atan2(deltaZ, Math.sqrt(deltaX * deltaX + deltaY * deltaY));
|
||||
rotationX = rotX - 0.5 * Math.PI;
|
||||
rotationY = 0;
|
||||
rotationZ = - Math.atan2(deltaX,deltaY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
Reference in New Issue
Block a user