-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
OrbitControls: Support frame rate independent autoRotate
.
#26472
OrbitControls: Support frame rate independent autoRotate
.
#26472
Conversation
See my first commit on the branch to see some of my logic expressed in some comments, I'm pretty sure the math is equivalent. |
Some unexpected failures here, is this typical? |
You can do this in your app. See #24956 (comment). To maintain the current default rotation rate, you would do this:
|
I think it would be good to make it FPS independent by default for all users of the class :) |
Another discussion about this topic: https://discourse.threejs.org/t/speed-of-orbitcontrols-autorotate-not-related-to-fps/43910 Maybe we can to try to find solution within |
|
||
return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed; | ||
|
||
return (2 * Math.PI / 60 * scope.autoRotateSpeed) * _clock.getDelta(); |
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.
The problem with using THREE.Clock
is that when users switch to another tab and then come back to the application after a while, you end up with a huge time delta value that leads to a visible jump. Compare the PRs version with prod to see this effect:
https://raw.githack.com/Issung/three.js/%2326471-orbitcontrols-framerate-independent/examples/webgl2_volume_instancing.html
https://threejs.org/examples/webgl2_volume_instancing
This issue can only be solved with another time class implementation like #17912.
The controls now also produce large time delta values when users enable - disable - enable auto rotation.
This PR changes the behavior of A behavior change is not a problem in principle but a) we have to know them and b) inform the user via the migration guide if we decide to make this change. |
Ah valid points, thanks for the githack link I didn't know that was a thing, that will be helpful fo testing. Ideally I hope to make this change in such a way that it can produce the same behaviour in legitimate situations so that we don't need a migration guide at all, just a fix patch note. I think it may be possible to solve the issue with the Clock class but might need some additional fiddling to take into account the special cases you mentioned (tab going to sleep, user disabling/enabling autorotate). I'll investigate some solutions soon. |
… tab is hidden for a long time with autoRotate enabled
Tried another impl to fix those issues but it's still not super consistent, I would like to use that Timer class but it's been in PR for a while, any idea when it will get merged? |
I think we should finally merge #17912 since I've seen apps adopting the exact same class or use something similar with a slightly different interface. It does not make sense to leak the implementation of the @Issung |
I agree totally. I just wanted to see how "ugly" my change would be in OrbitControls and the answer is too ugly for my liking, I would like to use the Timer class. |
@yomotsu I've checked I wonder if we overlook a potential issue with using an alternative |
Thanks for your interest.
These depend on user requirements, and ended up I thought auto-rotate is not simple and should be handled in user-land. |
By the way, can we just add a delta time argument to |
That is a good point! @Issung Would you be okay with that solution? |
Passing the delta time to the update method is a nice non-breaking change that could be made, but it still has the issue of when the tab is put in the background for a few seconds, when coming back to the tab it will have a large visible jump because of the large delta time. |
It might be a good interim solution while we wait for the Timer class PR to be merged, I could make another PR for that if you like? |
Yes, it would be good to update the PR. If the time delta value is eventually computed with |
I was thinking of making a new seperate PR with @yomotsu 's idea, and keeping this one around for when the Timer class is reaches |
THB, I don't think we have to integrate timer if the |
Aright sounds good to me, I'll re-shape the PR when I get a moment 👍 |
…d into the OrbitControls update function
I've simplified the PR with @yomotsu 's idea. I included the change as a demo in webgl2_volume_instancing.html, should I include it there and in other demos or just leave it out? Also is the documentation stored in the repo as well to update with the new information? |
It seems my update to webgl2_volume_instancing is what is making the tests fail, I'll await your reply on my above question to see what action we should take |
Clean up.
Clean up.
Try to regenerate the E2E screenshot via:
Updating one example is sufficient for now. However, updating the docs would be great! |
More clean up.
autoRotate
frame rate independent.
autoRotate
frame rate independent.autoRotate
.
I'll merge and clean up. |
Fixed #26471.
Updates the OrbitControls
getAutoRotationAngle()
function to take into account clock delta so thatautoRotate
can become framerate independent.