getMatrixFromCamera is deprecated, then what do we use instead?

const cameraDirection = viewer.view.getCamera().getMatrixFromCamera().transform(new Communicator.Point3(0, 0, 1));

getMatrixFromCamera appears to be deprecated. What do we use instead? I just want to know in which direction the camera is pointing.

Thanks!

Hello @mark.aronin,

If you just want to know the direction vector of the current camera, you can subtract the camera position from the camera target, for example:

var cam = hwv.view.getCamera();
var vec = new Communicator.Point3(cam.getTarget().x - cam.getPosition().x, cam.getTarget().y - cam.getPosition().y, cam.getTarget().z - cam.getPosition().z).normalize();

Thanks,
Tino

Yes!! Thank you Tino :heart:

1 Like