Алексей
Алексей

Reputation: 57

The problem with the projection of the vector

I use release 116. First I change the camera position, and then I try to get the projection of the vector (something like this: vector. project(camera)), then I call the scene render and get an incorrect projection value. If I call the scene render again and recalculate the projection value, I get the correct value. I also get the correct value if I call render after changing the camera position. I don't understand why I need to render to get the correct projection of the vector. If there is another way? Thank you for any advice.

Upvotes: 1

Views: 119

Answers (1)

Mugen87
Mugen87

Reputation: 31036

It seems the camera's internal matrices are not up-to-date when you are using Vector3.project(). Try to use the following approach to fix the issue:

camera.updateMatrixWorld();
vector.project(camera);

Upvotes: 0

Related Questions