Camera position

Hello,
How can I get the camera position and direction

You can do this for x,y and z , alpha beta:

console.log(Tools.ToDegrees(camera.alpha));  //or beta
console.log(camera.position.y);

or this:

scene.onBeforeRenderObservable.add(() => {
    console.log(Tools.ToDegrees(camera.alpha).toFixed());
});

hope that helps

1 Like

@AbdulrehmanSuliman please provide a playground of what you tried and such so that we can help accordingly also you can usually have a look in our api doc for those: Camera | Babylon.js Documentation

2 Likes

For all cameras, you can generally get the position by using camera.position and using camera.getDirection(vector) for direction. The vector argument in that function is the local axis to use as your frame of reference. For example:

// Get the forward direction
const direction = camera.getDirection(BABYLON.Vector3.Forward())
1 Like