-
Notifications
You must be signed in to change notification settings - Fork 20
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
fix: Camera rotation target from new camera position #3409
fix: Camera rotation target from new camera position #3409
Conversation
Hi!, thanks for the contribution! I have some trouble reproducing the problem you are stating. I'm testing now by calling
, which prints out
The rotation seems to be as expected. Am I misunderstanding the problem? Do you have another specific input that produces the wrong result? |
Hello :) I've just reproduced it on the master branch, using the example viewer provided in the repo. Here's the code I used: Viewer.tsx
When first pressing G, the quaternion and camera quaternion values do not match, however if you press it a second time you should see the values match (due to the camera not moving). Interestingly I do get a matching quaternion value if I use the same value as you tried, however I'm not sure why! |
@hugolafis I see - I've tried again with your value and can reproduce the error now 👍 I'm approving the PR! I see there are some CI steps failing. The first one can be fixed by running |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Updated API documentaiton
a530058
to
68ce414
Compare
Codecov Report
@@ Coverage Diff @@
## master #3409 +/- ##
==========================================
- Coverage 71.53% 71.53% -0.01%
==========================================
Files 344 344
Lines 33232 33235 +3
Branches 2582 2582
==========================================
Hits 23773 23773
- Misses 9355 9358 +3
Partials 104 104
|
Type of change
Description 📝
This PR fixes a bug when both camera position and rotation are set simultaneously. Currently, when the new target is calculated from the provided quaternion, the offset it uses to position itself in world space references the old camera position, instead of the new vector that the camera position will be set to, and results in an incorrect target position.
This fix addresses that by passing the new vector through into the utility function
CameraManagerHelper.calculateNewTargetFromRotation
and utilises that for the target offset.How has this been tested? 🔍
I have manually tested this by utilising a locally build copy of Reveal as a dependency in another application where I first noticed the issue, and the fix appears to have solved the issue.
Test instructions ℹ️
If you call
setCameraState
with a provided vector and quaternion, both these values should now match the resultingcamera.quaternion
andcamera.position
. Previously, if the provided vector was different to the current position of the camera, the resulting camera quaternion would not match the input value.Checklist ☑️