-
-
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
Timer: Added FixedTimer #27423
Timer: Added FixedTimer #27423
Conversation
Very nice for physics or delta-based simulation, also see https://gafferongames.com/post/fix_your_timestep. |
Hmm... In the context of physics in the browser, isn't this better? const fps = 60;
setInterval( step, 1000 / fps );
function step() {
world.stepSimulation( 1000 / fps, 10 );
...
} https://github.com/mrdoob/three.js/blob/dev/examples/jsm/physics/AmmoPhysics.js#L265 Otherwise, |
The idea of fixed time deltas comes from Unity: https://docs.unity3d.com/ScriptReference/Time.html. They describe their property as follows:
I have found it useful by myself if I can configure a fixed time delta for testing purposes. |
Does the |
Using Then we compute the deltas ourselves: I can imagine |
I had misunderstood how this class worked. Physics wants to subdivide the real delta time as per the reference I linked, which is not what this class does. |
# Conflicts: # examples/jsm/misc/Timer.js
@mrdoob Indeed, we can't use it for physics but The refactoring itself definitely makes sense and the PR in its current state looks good to me (just need to clean up the docs). |
I think we can keep I'll remove the references to |
* Timer: Added FixedTimer. * Updated docs. * Updated docs.
Related issue: #17912
Description
Moved the
_fixedDelta
and_useFixedDelta
functionality into its ownFixedTimer
class and removed theenableFixedDelta()
anddisableFixedDelta()
methods.I think this approach is cleaner... but I'm not sure how
FixedTimer
is supposed to be used.@Mugen87 I guess it's supposed to be used for debugging? #17912 (comment)