Allows tilt and wobble control, solving issue #244#250
Open
QGRRK wants to merge 1 commit intocatdad:masterfrom
Open
Allows tilt and wobble control, solving issue #244#250QGRRK wants to merge 1 commit intocatdad:masterfrom
QGRRK wants to merge 1 commit intocatdad:masterfrom
Conversation
puffcocos
reviewed
Dec 10, 2025
puffcocos
left a comment
There was a problem hiding this comment.
I needed this feature as well! Glad to see this PR.
| //wobbleSpeed: Math.min(0.11, Math.random() * 0.1 + 0.05), | ||
| velocity: (opts.startVelocity * 0.5) + (Math.random() * opts.startVelocity), | ||
| angle2D: -radAngle + ((0.5 * radSpread) - (Math.random() * radSpread)), | ||
| tiltAngle: (Math.random() * (0.75 - 0.25) + 0.25) * Math.PI, |
There was a problem hiding this comment.
It seems like this line might override the new tiltAngle.
| scalar: 1 | ||
| scalar: 1, | ||
| /* New feature 3-D wobble/tilt control */ | ||
| tiltRange: [-Math.PI * 0.5, Math.PI * 0.5], // [min,max] radians |
There was a problem hiding this comment.
The original canvas-confetti tiltAngle calculation logic:
tiltAngle: (Math.random() * (0.75 - 0.25) + 0.25) * Math.PI
// Result: 0.25π ~ 0.75π (45° ~ 135°)The current PR's default value is -90° ~ 90°, but to maintain the original behavior, I think it should be 45° ~ 135°.
Suggestion:
tiltRange: [Math.PI * 0.25, Math.PI * 0.75]
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.
Expose tilt & wobble parameters for finer animation control, solving issue #244
This PR adds four new options that let callers tune particle orientation and path wobble:
tiltRange[min,max]radians[-Math.PI/2, Math.PI/2]tiltSpeed[min,max]rad ∙ tick⁻¹[0.05, 0.4]wobbleRange[min,max]px[5, 10]wobbleSpeed[min,max]rad ∙ tick⁻¹[0.1, 0.2]No code changes are required for existing users; omitted fields keep current behaviour, and
flat: truestill disables all 3‑D motion.Quick example
Implementation highlights
defaults extended with the four ranges.
randomPhysics() now pulls values from those ranges (or defaults) and stores wobble, wobbleSpeed, tiltAngle, tiltIncrement on each particle.
updateFetti() uses those fields instead of hard‑coded constants.
Tests
Back‑compat visual suite – all legacy tests still green.
Motion test – freezes velocity & gravity, fires one particle, captures two frames 100 ms apart, asserts centroid moved ≥ 8 px while palette stayed the same.
Parameter presence test – with front end testing, confirms particles receive the exact wobble/tilt values passed in.