-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjsvaluenoise.min.js
1 lines (1 loc) · 1.24 KB
/
jsvaluenoise.min.js
1
var vnoise=function(){var c=Math.pow,d=Math.floor;function a(a){return a-d(a)}function b(c,a,b){return(1-b)*c+b*a}return{seed:100*Math.random(),hash2d:function(b,c){return b=50*a(.3183099*b+.71),c=50*a(.3183099*c+.113),-1+2*a(1.375986*this.seed+b*c*(b+c))},hash3d:function(b,c,d){return b=50*a(.3183099*b+.71),c=50*a(.3183099*c+.113),d=50*a(.3183099*d+.33),-1+2*a(1.375986*this.seed+b*c*d*(b+c+d))},noise2d:function(c,e){let f=d(c),g=d(e),h=a(c),i=a(e),j=h*h*(3-2*h);return b(b(this.hash2d(f,g),this.hash2d(f+1,g),j),b(this.hash2d(f,g+1),this.hash2d(f+1,g+1),j),i*i*(3-2*i))},noise3d:function(c,e,f){let g=d(c),h=d(e),i=d(f),j=a(c),k=a(e),l=a(f),m=j*j*(3-2*j),n=k*k*(3-2*k);return b(b(b(this.hash3d(g+0,h+0,i+0),this.hash3d(g+1,h+0,i+0),m),b(this.hash3d(g+0,h+1,i+0),this.hash3d(g+1,h+1,i+0),m),n),b(b(this.hash3d(g+0,h+0,i+1),this.hash3d(g+1,h+0,i+1),m),b(this.hash3d(g+0,h+1,i+1),this.hash3d(g+1,h+1,i+1),m),n),l*l*(3-2*l))},fractal2d:function(a,b,d){var e=0;for(let f=0;f<d;f++)e+=this.noise2d(a,b)/c(2,.5+f-.5*f),a-=19*f,b+=7*f,a*=1.57,b*=1.57;return e},fractal3d:function(a,b,d,e){var f=0;for(let g=0;g<e;g++)f+=this.noise3d(a,b,d)/c(2,.5+g-.5*g),a-=7*g,b+=13*g,d-=23*g,a*=1.57,b*=1.57,d*=1.57;return f}}}();"undefined"!=typeof module&&(module.exports=vnoise);