-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Vector3.unproject(): Avoid computing inverse #15996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I think it's okay to do this change since we also assume in |
318be01 to
8bad3a4
Compare
|
@Mugen87 Search for |
|
I see what you mean. In the examples, the copy happens in It seems three.js/src/helpers/CameraHelper.js Line 164 in f74563d
|
|
@Mugen87 I think we need this subtle change in the comment and code: // we need just camera projection matrix inverse
// world matrix must be identity
camera.projectionMatrixInverse.copy( this.camera.projectionMatrixInverse ); |
|
Thanks! |
|
I've isolated this PR as the one that breaks raycasting in my app. I am using const matrixToCopy = this.isUsingOrthographicCamera ?
this._orthographicCamera.projectionMatrix :
this._perspectiveCamera.projectionMatrix;
this._hybridCamera.projectionMatrix.copy(matrixToCopy);And the full file is here: https://gist.github.com/bleighb/83ff6814a7c8968425d48db0f580f442 |
|
Pinging @Mugen87 @WestLangley Any help would be greatly appreciated 😊 |
|
@bleighb This is not a help site. Please use the three.js forum instead. |
|
Sorry about that. I'm not asking for handouts, it's just I took a good amount of time to isolate the exact commit that broke my app and I figured other people might be affected by this bug. Since you made the change, I thought the answer might either indicate that either there was a mistake on your part or I'm doing something terribly wrong 😄 |
|
I just fixed it by copying over the You mentioned before:
I believe this is what happened to me. The matrices came out of sync and it yielded weird side effects. I'm not asking for help anymore - I'm just trying to see if this is an issue or could be improved. |
|
Good. You were able to solve the bug in your app yourself. I think the library is fine as is. |
|
Thanks @bleighb for highlighting this, helped me with my own debugging! For any 8th Wall users who have ended up here due to issues since |
As suggested in #14685 (comment).
...plus it removes another annoying cyclic reference in the build. :-)
In some examples,
Vector3.unproject()is recomputing the matrix inverse every frame.I think we are safe making this change now, but we need to be careful when using
projectionMatrix.copy().@Mugen87 What do you think?