SHARE
TWEET

simplex-noise.js

Kicshikxo Aug 19th, 2019 586 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * A fast javascript implementation of simplex noise by Jonas Wagner
  3.  
  4. Based on a speed-improved simplex noise algorithm for 2D, 3D and 4D in Java.
  5. Which is based on example code by Stefan Gustavson (stegu@itn.liu.se).
  6. With Optimisations by Peter Eastman (peastman@drizzle.stanford.edu).
  7. Better rank ordering method by Stefan Gustavson in 2012.
  8.  
  9.  Copyright (c) 2018 Jonas Wagner
  10.  
  11.  Permission is hereby granted, free of charge, to any person obtaining a copy
  12.  of this software and associated documentation files (the "Software"), to deal
  13.  in the Software without restriction, including without limitation the rights
  14.  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  15.  copies of the Software, and to permit persons to whom the Software is
  16.  furnished to do so, subject to the following conditions:
  17.  
  18.  The above copyright notice and this permission notice shall be included in all
  19.  copies or substantial portions of the Software.
  20.  
  21.  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22.  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  23.  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24.  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25.  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26.  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  27.  SOFTWARE.
  28.  */
  29. (function() {
  30.   'use strict';
  31.  
  32.   var F2 = 0.5 * (Math.sqrt(3.0) - 1.0);
  33.   var G2 = (3.0 - Math.sqrt(3.0)) / 6.0;
  34.   var F3 = 1.0 / 3.0;
  35.   var G3 = 1.0 / 6.0;
  36.   var F4 = (Math.sqrt(5.0) - 1.0) / 4.0;
  37.   var G4 = (5.0 - Math.sqrt(5.0)) / 20.0;
  38.  
  39.   function SimplexNoise(randomOrSeed) {
  40.     var random;
  41.     if (typeof randomOrSeed == 'function') {
  42.       random = randomOrSeed;
  43.     }
  44.     else if (randomOrSeed) {
  45.       random = alea(randomOrSeed);
  46.     } else {
  47.       random = Math.random;
  48.     }
  49.     this.p = buildPermutationTable(random);
  50.     this.perm = new Uint8Array(512);
  51.     this.permMod12 = new Uint8Array(512);
  52.     for (var i = 0; i < 512; i++) {
  53.       this.perm[i] = this.p[i & 255];
  54.       this.permMod12[i] = this.perm[i] % 12;
  55.     }
  56.  
  57.   }
  58.   SimplexNoise.prototype = {
  59.     grad3: new Float32Array([1, 1, 0,
  60.       -1, 1, 0,
  61.       1, -1, 0,
  62.  
  63.       -1, -1, 0,
  64.       1, 0, 1,
  65.       -1, 0, 1,
  66.  
  67.       1, 0, -1,
  68.       -1, 0, -1,
  69.       0, 1, 1,
  70.  
  71.       0, -1, 1,
  72.       0, 1, -1,
  73.       0, -1, -1]),
  74.     grad4: new Float32Array([0, 1, 1, 1, 0, 1, 1, -1, 0, 1, -1, 1, 0, 1, -1, -1,
  75.       0, -1, 1, 1, 0, -1, 1, -1, 0, -1, -1, 1, 0, -1, -1, -1,
  76.       1, 0, 1, 1, 1, 0, 1, -1, 1, 0, -1, 1, 1, 0, -1, -1,
  77.       -1, 0, 1, 1, -1, 0, 1, -1, -1, 0, -1, 1, -1, 0, -1, -1,
  78.       1, 1, 0, 1, 1, 1, 0, -1, 1, -1, 0, 1, 1, -1, 0, -1,
  79.       -1, 1, 0, 1, -1, 1, 0, -1, -1, -1, 0, 1, -1, -1, 0, -1,
  80.       1, 1, 1, 0, 1, 1, -1, 0, 1, -1, 1, 0, 1, -1, -1, 0,
  81.       -1, 1, 1, 0, -1, 1, -1, 0, -1, -1, 1, 0, -1, -1, -1, 0]),
  82.     noise2D: function(xin, yin) {
  83.       var permMod12 = this.permMod12;
  84.       var perm = this.perm;
  85.       var grad3 = this.grad3;
  86.       var n0 = 0; // Noise contributions from the three corners
  87.       var n1 = 0;
  88.       var n2 = 0;
  89.       // Skew the input space to determine which simplex cell we're in
  90.       var s = (xin + yin) * F2; // Hairy factor for 2D
  91.       var i = Math.floor(xin + s);
  92.       var j = Math.floor(yin + s);
  93.       var t = (i + j) * G2;
  94.       var X0 = i - t; // Unskew the cell origin back to (x,y) space
  95.       var Y0 = j - t;
  96.       var x0 = xin - X0; // The x,y distances from the cell origin
  97.       var y0 = yin - Y0;
  98.       // For the 2D case, the simplex shape is an equilateral triangle.
  99.       // Determine which simplex we are in.
  100.       var i1, j1; // Offsets for second (middle) corner of simplex in (i,j) coords
  101.       if (x0 > y0) {
  102.         i1 = 1;
  103.         j1 = 0;
  104.       } // lower triangle, XY order: (0,0)->(1,0)->(1,1)
  105.       else {
  106.         i1 = 0;
  107.         j1 = 1;
  108.       } // upper triangle, YX order: (0,0)->(0,1)->(1,1)
  109.       // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and
  110.       // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where
  111.       // c = (3-sqrt(3))/6
  112.       var x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords
  113.       var y1 = y0 - j1 + G2;
  114.       var x2 = x0 - 1.0 + 2.0 * G2; // Offsets for last corner in (x,y) unskewed coords
  115.       var y2 = y0 - 1.0 + 2.0 * G2;
  116.       // Work out the hashed gradient indices of the three simplex corners
  117.       var ii = i & 255;
  118.       var jj = j & 255;
  119.       // Calculate the contribution from the three corners
  120.       var t0 = 0.5 - x0 * x0 - y0 * y0;
  121.       if (t0 >= 0) {
  122.         var gi0 = permMod12[ii + perm[jj]] * 3;
  123.         t0 *= t0;
  124.         n0 = t0 * t0 * (grad3[gi0] * x0 + grad3[gi0 + 1] * y0); // (x,y) of grad3 used for 2D gradient
  125.       }
  126.       var t1 = 0.5 - x1 * x1 - y1 * y1;
  127.       if (t1 >= 0) {
  128.         var gi1 = permMod12[ii + i1 + perm[jj + j1]] * 3;
  129.         t1 *= t1;
  130.         n1 = t1 * t1 * (grad3[gi1] * x1 + grad3[gi1 + 1] * y1);
  131.       }
  132.       var t2 = 0.5 - x2 * x2 - y2 * y2;
  133.       if (t2 >= 0) {
  134.         var gi2 = permMod12[ii + 1 + perm[jj + 1]] * 3;
  135.         t2 *= t2;
  136.         n2 = t2 * t2 * (grad3[gi2] * x2 + grad3[gi2 + 1] * y2);
  137.       }
  138.       // Add contributions from each corner to get the final noise value.
  139.       // The result is scaled to return values in the interval [-1,1].
  140.       return 70.0 * (n0 + n1 + n2);
  141.     },
  142.     // 3D simplex noise
  143.     noise3D: function(xin, yin, zin) {
  144.       var permMod12 = this.permMod12;
  145.       var perm = this.perm;
  146.       var grad3 = this.grad3;
  147.       var n0, n1, n2, n3; // Noise contributions from the four corners
  148.       // Skew the input space to determine which simplex cell we're in
  149.       var s = (xin + yin + zin) * F3; // Very nice and simple skew factor for 3D
  150.       var i = Math.floor(xin + s);
  151.       var j = Math.floor(yin + s);
  152.       var k = Math.floor(zin + s);
  153.       var t = (i + j + k) * G3;
  154.       var X0 = i - t; // Unskew the cell origin back to (x,y,z) space
  155.       var Y0 = j - t;
  156.       var Z0 = k - t;
  157.       var x0 = xin - X0; // The x,y,z distances from the cell origin
  158.       var y0 = yin - Y0;
  159.       var z0 = zin - Z0;
  160.       // For the 3D case, the simplex shape is a slightly irregular tetrahedron.
  161.       // Determine which simplex we are in.
  162.       var i1, j1, k1; // Offsets for second corner of simplex in (i,j,k) coords
  163.       var i2, j2, k2; // Offsets for third corner of simplex in (i,j,k) coords
  164.       if (x0 >= y0) {
  165.         if (y0 >= z0) {
  166.           i1 = 1;
  167.           j1 = 0;
  168.           k1 = 0;
  169.           i2 = 1;
  170.           j2 = 1;
  171.           k2 = 0;
  172.         } // X Y Z order
  173.         else if (x0 >= z0) {
  174.           i1 = 1;
  175.           j1 = 0;
  176.           k1 = 0;
  177.           i2 = 1;
  178.           j2 = 0;
  179.           k2 = 1;
  180.         } // X Z Y order
  181.         else {
  182.           i1 = 0;
  183.           j1 = 0;
  184.           k1 = 1;
  185.           i2 = 1;
  186.           j2 = 0;
  187.           k2 = 1;
  188.         } // Z X Y order
  189.       }
  190.       else { // x0<y0
  191.         if (y0 < z0) {
  192.           i1 = 0;
  193.           j1 = 0;
  194.           k1 = 1;
  195.           i2 = 0;
  196.           j2 = 1;
  197.           k2 = 1;
  198.         } // Z Y X order
  199.         else if (x0 < z0) {
  200.           i1 = 0;
  201.           j1 = 1;
  202.           k1 = 0;
  203.           i2 = 0;
  204.           j2 = 1;
  205.           k2 = 1;
  206.         } // Y Z X order
  207.         else {
  208.           i1 = 0;
  209.           j1 = 1;
  210.           k1 = 0;
  211.           i2 = 1;
  212.           j2 = 1;
  213.           k2 = 0;
  214.         } // Y X Z order
  215.       }
  216.       // A step of (1,0,0) in (i,j,k) means a step of (1-c,-c,-c) in (x,y,z),
  217.       // a step of (0,1,0) in (i,j,k) means a step of (-c,1-c,-c) in (x,y,z), and
  218.       // a step of (0,0,1) in (i,j,k) means a step of (-c,-c,1-c) in (x,y,z), where
  219.       // c = 1/6.
  220.       var x1 = x0 - i1 + G3; // Offsets for second corner in (x,y,z) coords
  221.       var y1 = y0 - j1 + G3;
  222.       var z1 = z0 - k1 + G3;
  223.       var x2 = x0 - i2 + 2.0 * G3; // Offsets for third corner in (x,y,z) coords
  224.       var y2 = y0 - j2 + 2.0 * G3;
  225.       var z2 = z0 - k2 + 2.0 * G3;
  226.       var x3 = x0 - 1.0 + 3.0 * G3; // Offsets for last corner in (x,y,z) coords
  227.       var y3 = y0 - 1.0 + 3.0 * G3;
  228.       var z3 = z0 - 1.0 + 3.0 * G3;
  229.       // Work out the hashed gradient indices of the four simplex corners
  230.       var ii = i & 255;
  231.       var jj = j & 255;
  232.       var kk = k & 255;
  233.       // Calculate the contribution from the four corners
  234.       var t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0;
  235.       if (t0 < 0) n0 = 0.0;
  236.       else {
  237.         var gi0 = permMod12[ii + perm[jj + perm[kk]]] * 3;
  238.         t0 *= t0;
  239.         n0 = t0 * t0 * (grad3[gi0] * x0 + grad3[gi0 + 1] * y0 + grad3[gi0 + 2] * z0);
  240.       }
  241.       var t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1;
  242.       if (t1 < 0) n1 = 0.0;
  243.       else {
  244.         var gi1 = permMod12[ii + i1 + perm[jj + j1 + perm[kk + k1]]] * 3;
  245.         t1 *= t1;
  246.         n1 = t1 * t1 * (grad3[gi1] * x1 + grad3[gi1 + 1] * y1 + grad3[gi1 + 2] * z1);
  247.       }
  248.       var t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2;
  249.       if (t2 < 0) n2 = 0.0;
  250.       else {
  251.         var gi2 = permMod12[ii + i2 + perm[jj + j2 + perm[kk + k2]]] * 3;
  252.         t2 *= t2;
  253.         n2 = t2 * t2 * (grad3[gi2] * x2 + grad3[gi2 + 1] * y2 + grad3[gi2 + 2] * z2);
  254.       }
  255.       var t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3;
  256.       if (t3 < 0) n3 = 0.0;
  257.       else {
  258.         var gi3 = permMod12[ii + 1 + perm[jj + 1 + perm[kk + 1]]] * 3;
  259.         t3 *= t3;
  260.         n3 = t3 * t3 * (grad3[gi3] * x3 + grad3[gi3 + 1] * y3 + grad3[gi3 + 2] * z3);
  261.       }
  262.       // Add contributions from each corner to get the final noise value.
  263.       // The result is scaled to stay just inside [-1,1]
  264.       return 32.0 * (n0 + n1 + n2 + n3);
  265.     },
  266.     // 4D simplex noise, better simplex rank ordering method 2012-03-09
  267.     noise4D: function(x, y, z, w) {
  268.       var perm = this.perm;
  269.       var grad4 = this.grad4;
  270.  
  271.       var n0, n1, n2, n3, n4; // Noise contributions from the five corners
  272.       // Skew the (x,y,z,w) space to determine which cell of 24 simplices we're in
  273.       var s = (x + y + z + w) * F4; // Factor for 4D skewing
  274.       var i = Math.floor(x + s);
  275.       var j = Math.floor(y + s);
  276.       var k = Math.floor(z + s);
  277.       var l = Math.floor(w + s);
  278.       var t = (i + j + k + l) * G4; // Factor for 4D unskewing
  279.       var X0 = i - t; // Unskew the cell origin back to (x,y,z,w) space
  280.       var Y0 = j - t;
  281.       var Z0 = k - t;
  282.       var W0 = l - t;
  283.       var x0 = x - X0; // The x,y,z,w distances from the cell origin
  284.       var y0 = y - Y0;
  285.       var z0 = z - Z0;
  286.       var w0 = w - W0;
  287.       // For the 4D case, the simplex is a 4D shape I won't even try to describe.
  288.       // To find out which of the 24 possible simplices we're in, we need to
  289.       // determine the magnitude ordering of x0, y0, z0 and w0.
  290.       // Six pair-wise comparisons are performed between each possible pair
  291.       // of the four coordinates, and the results are used to rank the numbers.
  292.       var rankx = 0;
  293.       var ranky = 0;
  294.       var rankz = 0;
  295.       var rankw = 0;
  296.       if (x0 > y0) rankx++;
  297.       else ranky++;
  298.       if (x0 > z0) rankx++;
  299.       else rankz++;
  300.       if (x0 > w0) rankx++;
  301.       else rankw++;
  302.       if (y0 > z0) ranky++;
  303.       else rankz++;
  304.       if (y0 > w0) ranky++;
  305.       else rankw++;
  306.       if (z0 > w0) rankz++;
  307.       else rankw++;
  308.       var i1, j1, k1, l1; // The integer offsets for the second simplex corner
  309.       var i2, j2, k2, l2; // The integer offsets for the third simplex corner
  310.       var i3, j3, k3, l3; // The integer offsets for the fourth simplex corner
  311.       // simplex[c] is a 4-vector with the numbers 0, 1, 2 and 3 in some order.
  312.       // Many values of c will never occur, since e.g. x>y>z>w makes x<z, y<w and x<w
  313.       // impossible. Only the 24 indices which have non-zero entries make any sense.
  314.       // We use a thresholding to set the coordinates in turn from the largest magnitude.
  315.       // Rank 3 denotes the largest coordinate.
  316.       i1 = rankx >= 3 ? 1 : 0;
  317.       j1 = ranky >= 3 ? 1 : 0;
  318.       k1 = rankz >= 3 ? 1 : 0;
  319.       l1 = rankw >= 3 ? 1 : 0;
  320.       // Rank 2 denotes the second largest coordinate.
  321.       i2 = rankx >= 2 ? 1 : 0;
  322.       j2 = ranky >= 2 ? 1 : 0;
  323.       k2 = rankz >= 2 ? 1 : 0;
  324.       l2 = rankw >= 2 ? 1 : 0;
  325.       // Rank 1 denotes the second smallest coordinate.
  326.       i3 = rankx >= 1 ? 1 : 0;
  327.       j3 = ranky >= 1 ? 1 : 0;
  328.       k3 = rankz >= 1 ? 1 : 0;
  329.       l3 = rankw >= 1 ? 1 : 0;
  330.       // The fifth corner has all coordinate offsets = 1, so no need to compute that.
  331.       var x1 = x0 - i1 + G4; // Offsets for second corner in (x,y,z,w) coords
  332.       var y1 = y0 - j1 + G4;
  333.       var z1 = z0 - k1 + G4;
  334.       var w1 = w0 - l1 + G4;
  335.       var x2 = x0 - i2 + 2.0 * G4; // Offsets for third corner in (x,y,z,w) coords
  336.       var y2 = y0 - j2 + 2.0 * G4;
  337.       var z2 = z0 - k2 + 2.0 * G4;
  338.       var w2 = w0 - l2 + 2.0 * G4;
  339.       var x3 = x0 - i3 + 3.0 * G4; // Offsets for fourth corner in (x,y,z,w) coords
  340.       var y3 = y0 - j3 + 3.0 * G4;
  341.       var z3 = z0 - k3 + 3.0 * G4;
  342.       var w3 = w0 - l3 + 3.0 * G4;
  343.       var x4 = x0 - 1.0 + 4.0 * G4; // Offsets for last corner in (x,y,z,w) coords
  344.       var y4 = y0 - 1.0 + 4.0 * G4;
  345.       var z4 = z0 - 1.0 + 4.0 * G4;
  346.       var w4 = w0 - 1.0 + 4.0 * G4;
  347.       // Work out the hashed gradient indices of the five simplex corners
  348.       var ii = i & 255;
  349.       var jj = j & 255;
  350.       var kk = k & 255;
  351.       var ll = l & 255;
  352.       // Calculate the contribution from the five corners
  353.       var t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0;
  354.       if (t0 < 0) n0 = 0.0;
  355.       else {
  356.         var gi0 = (perm[ii + perm[jj + perm[kk + perm[ll]]]] % 32) * 4;
  357.         t0 *= t0;
  358.         n0 = t0 * t0 * (grad4[gi0] * x0 + grad4[gi0 + 1] * y0 + grad4[gi0 + 2] * z0 + grad4[gi0 + 3] * w0);
  359.       }
  360.       var t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1;
  361.       if (t1 < 0) n1 = 0.0;
  362.       else {
  363.         var gi1 = (perm[ii + i1 + perm[jj + j1 + perm[kk + k1 + perm[ll + l1]]]] % 32) * 4;
  364.         t1 *= t1;
  365.         n1 = t1 * t1 * (grad4[gi1] * x1 + grad4[gi1 + 1] * y1 + grad4[gi1 + 2] * z1 + grad4[gi1 + 3] * w1);
  366.       }
  367.       var t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2;
  368.       if (t2 < 0) n2 = 0.0;
  369.       else {
  370.         var gi2 = (perm[ii + i2 + perm[jj + j2 + perm[kk + k2 + perm[ll + l2]]]] % 32) * 4;
  371.         t2 *= t2;
  372.         n2 = t2 * t2 * (grad4[gi2] * x2 + grad4[gi2 + 1] * y2 + grad4[gi2 + 2] * z2 + grad4[gi2 + 3] * w2);
  373.       }
  374.       var t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3;
  375.       if (t3 < 0) n3 = 0.0;
  376.       else {
  377.         var gi3 = (perm[ii + i3 + perm[jj + j3 + perm[kk + k3 + perm[ll + l3]]]] % 32) * 4;
  378.         t3 *= t3;
  379.         n3 = t3 * t3 * (grad4[gi3] * x3 + grad4[gi3 + 1] * y3 + grad4[gi3 + 2] * z3 + grad4[gi3 + 3] * w3);
  380.       }
  381.       var t4 = 0.6 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4;
  382.       if (t4 < 0) n4 = 0.0;
  383.       else {
  384.         var gi4 = (perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] % 32) * 4;
  385.         t4 *= t4;
  386.         n4 = t4 * t4 * (grad4[gi4] * x4 + grad4[gi4 + 1] * y4 + grad4[gi4 + 2] * z4 + grad4[gi4 + 3] * w4);
  387.       }
  388.       // Sum up and scale the result to cover the range [-1,1]
  389.       return 27.0 * (n0 + n1 + n2 + n3 + n4);
  390.     }
  391.   };
  392.  
  393.   function buildPermutationTable(random) {
  394.     var i;
  395.     var p = new Uint8Array(256);
  396.     for (i = 0; i < 256; i++) {
  397.       p[i] = i;
  398.     }
  399.     for (i = 0; i < 255; i++) {
  400.       var r = i + ~~(random() * (256 - i));
  401.       var aux = p[i];
  402.       p[i] = p[r];
  403.       p[r] = aux;
  404.     }
  405.     return p;
  406.   }
  407.   SimplexNoise._buildPermutationTable = buildPermutationTable;
  408.  
  409.   /*
  410.   The ALEA PRNG and masher code used by simplex-noise.js
  411.   is based on code by Johannes Baag√łe, modified by Jonas Wagner.
  412.   See alea.md for the full license.
  413.   */
  414.   function alea() {
  415.     var s0 = 0;
  416.     var s1 = 0;
  417.     var s2 = 0;
  418.     var c = 1;
  419.  
  420.     var mash = masher();
  421.     s0 = mash(' ');
  422.     s1 = mash(' ');
  423.     s2 = mash(' ');
  424.  
  425.     for (var i = 0; i < arguments.length; i++) {
  426.       s0 -= mash(arguments[i]);
  427.       if (s0 < 0) {
  428.         s0 += 1;
  429.       }
  430.       s1 -= mash(arguments[i]);
  431.       if (s1 < 0) {
  432.         s1 += 1;
  433.       }
  434.       s2 -= mash(arguments[i]);
  435.       if (s2 < 0) {
  436.         s2 += 1;
  437.       }
  438.     }
  439.     mash = null;
  440.     return function() {
  441.       var t = 2091639 * s0 + c * 2.3283064365386963e-10; // 2^-32
  442.       s0 = s1;
  443.       s1 = s2;
  444.       return s2 = t - (c = t | 0);
  445.     };
  446.   }
  447.   function masher() {
  448.     var n = 0xefc8249d;
  449.     return function(data) {
  450.       data = data.toString();
  451.       for (var i = 0; i < data.length; i++) {
  452.         n += data.charCodeAt(i);
  453.         var h = 0.02519603282416938 * n;
  454.         n = h >>> 0;
  455.         h -= n;
  456.         h *= n;
  457.         n = h >>> 0;
  458.         h -= n;
  459.         n += h * 0x100000000; // 2^32
  460.       }
  461.       return (n >>> 0) * 2.3283064365386963e-10; // 2^-32
  462.     };
  463.   }
  464.  
  465.   // amd
  466.   if (typeof define !== 'undefined' && define.amd) define(function() {return SimplexNoise;});
  467.   // common js
  468.   if (typeof exports !== 'undefined') exports.SimplexNoise = SimplexNoise;
  469.   // browser
  470.   else if (typeof window !== 'undefined') window.SimplexNoise = SimplexNoise;
  471.   // nodejs
  472.   if (typeof module !== 'undefined') {
  473.     module.exports = SimplexNoise;
  474.   }
  475.  
  476. })();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top