Skip to content

Conversation

@QGRRK
Copy link

@QGRRK QGRRK commented May 3, 2025

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:

Option Unit / type What it does Default (keeps 1.x look)
tiltRange [min,max] radians Initial tilt angle [-Math.PI/2, Math.PI/2]
tiltSpeed [min,max] rad ∙ tick⁻¹ Tilt speed over time [0.05, 0.4]
wobbleRange [min,max] px Wobble radius [5, 10]
wobbleSpeed [min,max] rad ∙ tick⁻¹ Wobble angular velocity [0.1, 0.2]

No code changes are required for existing users; omitted fields keep current behaviour, and flat: true still disables all 3‑D motion.


Quick example

confetti({
  particleCount : 40,
  tiltRange     : [-Math.PI/4, Math.PI/4],
  tiltSpeed     : [0.05, 0.1],
  wobbleRange   : [3, 8],
  wobbleSpeed   : [0.05, 0.15]
});

Implementation highlights

  1. defaults extended with the four ranges.

  2. randomPhysics() now pulls values from those ranges (or defaults) and stores wobble, wobbleSpeed, tiltAngle, tiltIncrement on each particle.

  3. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant