Fix Hyperspeed partial options override and improve performance#882
Merged
DavidHDev merged 7 commits intoDavidHDev:mainfrom Feb 14, 2026
Merged
Conversation
I did't figure out how to measure, but remove console.log are a performance boost with no side effect
Owner
|
Awesome thanks! |
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
completely discard all other defaults. Defaults are now extracted to a module-level DEFAULT_EFFECT_OPTIONS constant and
merged at runtime, so users can override individual options without losing the rest.
roadColor: 0xff0000 } } only overrides roadColor while preserving all other color defaults.
render, causing the effect to re-run constantly. Now depends on the stable effectOptions prop reference.
Performance note
Extracting defaults to a module-level constant (DEFAULT_EFFECT_OPTIONS) avoids recreating the object on every render and
provides a stable reference for useEffect dependencies — but only when no custom prop is passed. When the consumer
passes an inline effectOptions object, it will still be a new reference on every parent re-render, causing the WebGL
scene to be destroyed and recreated. A usage tip was added to the docs reminding consumers to memoize their
effectOptions (via useMemo or a constant) to prevent this.
Bug fixes
Bug: Partial options ignored defaults
Before: <Hyperspeed effectOptions={{ fov: 120 }} /> lost all other defaults
After: All defaults preserved, only fov overridden
────────────────────────────────────────
Bug: Partial colors replaced entire object
Before: { colors: { roadColor: 0xff0000 } } wiped other colors
After: Only roadColor overridden, rest kept
────────────────────────────────────────
Bug: useEffect re-ran every render (TS)
Before: Dependency on mergedOptions (new object each render)
After: Dependency on effectOptions (stable ref)
────────────────────────────────────────
Bug: console.log in render loop
Before: Logged isHyper on every frame
After: Removed
Changed files
Note: A little related to issue #875 (comment), but does't adress this specific issue (it is an overall performance, but not a cleanup of WebGL contexts
Note 2: If you want, I can record a video running Profiler to see the performance boost