Perlin noise implementation in JavaScript (UnityScript)