freq = 1.5;
amp = 15;
decay = 0; // Set to 0.1 if you want it to stop eventually
// Offset phase by index so ornaments sway differently
offset = index * 10;
Math.sin((time + offset) * freq) * amp;
Generates a smooth, physics-based sine wave rotation that mimics an object dangling in a breeze. It automatically offsets the timing based on the layer index, ensuring a row of objects swings naturally rather than in robotic unison.
Contributed by:
Essential for animating hanging decorations, lanterns, signs suspended by chains, or any object that needs to react to simulated wind.