Hi all,
I’m new to Away3D and trying to create a free cam (‘fly around’ through the scene). The basic movement is quite simple; updating pitch and yaw based on mouse position and forward movement based on if spacebar is pressed or not.
The difficulty I’m experiencing is in the forward movement: calculating the new values for the camera’s x, y and z properties, based on current rotation of the camera.
In my latest attempt I’m using the camera’s eulers to calculate direction. This works fine till I start circling around through the scene, resulting in movement in the wrong direction.
Here’s a bit of the code:
var eulers:Vector3D = view.camera.eulers;
var dx:Number = Math.sin(eulers.x * Math.PI/180) * Math.cos(eulers.y * Math.PI/180);
var dy:Number = Math.sin(eulers.x * Math.PI/180);
var dz:Number = Math.cos(eulers.x * Math.PI/180) * Math.cos(eulers.y * Math.PI/180);
view.camera.x += _speed * dx;
view.camera.y += _speed * dy;
view.camera.z += _speed * dz;
Anyone who can point me in the right direction? Or perhaps with a working example?
Thanks!