Open
Conversation
Not sure I got everyone perfect but, the effects assumes 60fps. At least in Chrome on M1 Macs they run at 120fps so all the effects run too fast (unless that was the intent) One thing I didn't fix, at 120fps, effects that spawn particles spawn twice as many particles. Note: normally I'd compute deltaTime in seconds as in ``` const deltaTime = (time - lastTime) / 1000 ``` But, all the calculations in the code assumed 60 fps so it seemed easier to pass in a 60fps clock, meaning, if the frame rate is 60fps then deltaTime will equal 1.0 and all the calculations will be the same. If fthe frame rate is 120fps then deltaTime will equal 0.5. If the frame rate is 30fps then deltaTime will equal 2.0. As for the limit, if the user changes tabs then requestAnimationFrame stop firing. When you get back deltaTime might be giant which could break calculations so the code limits the framerate to 10fps. Below that things will always run at 10fps. This is also useful for debugging because otherwise, stepping through the code, deltaTime would be giant.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Not sure I got everyone perfect but, the effects
assumes 60fps. At least in Chrome on M1 Macs they run
at 120fps so all the effects run too fast (unless that was the intent)
One thing I didn't fix, at 120fps, effects that spawn particles
spawn twice as many particles.
Note: normally I'd compute deltaTime in seconds as in
But, all the calculations in the code assumed 60 fps so it seemed easier
to pass in a 60fps clock, meaning, if the frame rate is 60fps then
deltaTime will equal 1.0 and all the calculations will be the same.
If fthe frame rate is 120fps then deltaTime will equal 0.5. If the frame
rate is 30fps then deltaTime will equal 2.0.
As for the limit, if the user changes tabs then requestAnimationFrame
stop firing. When you get back deltaTime might be giant which could
break calculations so the code limits the framerate to 10fps. Below that
things will always run at 10fps. This is also useful for debugging
because otherwise, stepping through the code, deltaTime would be giant.