Expression Library

Falling Leaves

Author: Dan Ebberts

In a 3D environment, allows a solid, shape, or other layer to fall in a side to side drifting manner, like a falling leaf. 

Top

Code Sample

Hover over the code and click the copy button.

				
					//Position:

yVelocity = 200; //pixels per second
oscFreq = 1.5; //oscillations per second
oscDepth = 35; //oscillation depth (pixels)
drift = 25; // drift (wind?) (pixels per second: - = left, + = right)

value + [oscDepth*Math.sin(oscFreq*Math.PI*2*time) + drift *time,
yVelocity*time,0]


//Z rotation:

seedRandom(index,true);
random(360);

//Y rotation:

oscFreq = 1.5;
maxTilt = 15; //degrees

maxTilt*Math.cos(oscFreq*Math.PI*2*time)