refactor: use THREE.Timer instead of deprecated THREE.Clock#396
Open
onderilkesever wants to merge 1 commit into
Open
refactor: use THREE.Timer instead of deprecated THREE.Clock#396onderilkesever wants to merge 1 commit into
onderilkesever wants to merge 1 commit into
Conversation
THREE.Clock was deprecated in three.js r183 in favor of THREE.Timer. SparkRenderer only ever reads elapsed time once per frame (deltaTime is derived independently), so the swap is a straightforward call to timer.update() followed by timer.getElapsed(). The cloneClock helper is removed in favor of sharing the passed-in THREE.Timer instance directly, since Timer exposes no public fields to clone. Rebuilt dist/, which also cleans up stale Old*/oldWorker build output left over from a previous commit that removed those source files without regenerating dist. Note: this renames the public SparkRendererOptions.clock option to `timer`, which is a breaking change for callers that pass a custom clock.
14ef8ce to
a6b5dd3
Compare
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.
Summary
THREE.Clockwas deprecated in three.js r183 in favor ofTHREE.Timer. Consuming apps on three r183+ see a console deprecation warning the moment aSparkRenderer/OldSparkRendereris constructed, since the constructor unconditionally doesnew THREE.Clock().Both renderers only ever read elapsed time once per frame (
clock.getElapsedTime()), anddeltaTimeis derived independently (time - previousTime), not from the clock. So the swap toTimeris a small, local change: calltimer.update()once per frame, then readtimer.getElapsed().cloneClock(inutils.ts) is removed. It doesn't have aTimer-compatible equivalent sinceTimerexposes no public fields to copy — sharing the passed-inTimerinstance directly is the more idiomatic way to sync time across systems anyway.SparkRendererand the legacyOldSparkRenderer(still exported fromindex.ts) for consistency.dist/and updated theclockrow indocs/docs/spark-renderer.md.Breaking change — flagging for discussion
This renames the public option
SparkRendererOptions.clock?: THREE.Clock(andOldSparkRendererOptions.clock) totimer?: THREE.Timer. Any caller passing a customclockwill need to switch totimer. Happy to add a deprecatedclockalias for back-compat if preferred — wanted to surface the tradeoff rather than assume.Test plan
npm run lint/npm test(via pre-commit hooks) passnpm run build(dev + production) succeeds; verified noTHREE.Clockreferences remain indist/