Hi there,
I wrote this a few months ago.
It’s based on the 2D noise-function, and uses the logic that if you follow a circle through a “noise field”, you end up at the same value.
You have to call the function and it just returns a number, so you still have to add that number to the current value.
For 2 or 3 dimensional properties (position for example), you have to call it multiple times with different seeds:
// for a 1-dimensional property: (loopTime is in seconds)
value+loopedWiggle (freq=1,amp=50, oct=2, amp_mult= .5, t=time, loopTime=3, seed=200);
function loopedWiggle (freq, amp, oct, amp_mult, t, loopTime, seed) {
seedRandom(seed, timeless = true);
startPos=random([5000,5000]);
radius=(loopTime/Math.PI)*freq;
// if the looptime is long, the radius should increase, otherwise the frequency would drop. 8-P
maxValue=0;
n=0;
multiplier=1;
for (i=1; i<=oct; i++) {
radius=radius*(i-0.5);
x=startPos[0] + Math.cos(degreesToRadians(360*t/loopTime + oct))*radius;
y=startPos[1] + Math.sin(degreesToRadians(360*t/loopTime + oct))*radius;
n += noise([x,y])*multiplier;
maxValue += multiplier;
multiplier *= amp_mult;
}
return n*amp;
}
for position (2d) you would start out with something like this:
wiggledx=loopedWiggle (freq=1,amp=50, oct=2, amp_mult= .5, t=time, loopTime=3, seed=200);
wiggledy=loopedWiggle (freq=1,amp=50, oct=2, amp_mult= .5, t=time, loopTime=3, seed=600);
value+[wiggledx,wiggledy]
function