Interactive linear waves in Javascript