uil 1.0.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +57 -0
  2. package/build/uil.js +7040 -4199
  3. package/build/uil.min.js +6 -4
  4. package/build/uil.module.js +7200 -2761
  5. package/examples/js/BufferGeometryUtils.js +921 -0
  6. package/examples/js/SimplexNoise.js +324 -0
  7. package/examples/js/controls/OrbitControls.js +1215 -0
  8. package/examples/js/controls/OrbitControls_.js +1042 -0
  9. package/examples/js/libs/sea3d.min.js +373 -0
  10. package/examples/js/libs/three.min.js +6 -0
  11. package/examples/js/math.js +447 -0
  12. package/examples/js/objects/Landscape.js +778 -0
  13. package/examples/js/objects/Lensflare.js +372 -0
  14. package/examples/js/objects/SuperSky.js +297 -0
  15. package/examples/js/objects/Water.js +329 -0
  16. package/package.json +56 -54
  17. package/src/Uil.js +2 -17
  18. package/src/Uil_dev.js +15 -0
  19. package/src/core/Gui.js +601 -299
  20. package/src/core/Proto.js +490 -220
  21. package/src/core/Roots.js +864 -0
  22. package/src/core/Tools.js +591 -140
  23. package/src/core/V2.js +131 -0
  24. package/src/core/add.js +52 -57
  25. package/src/proto/Bool.js +117 -52
  26. package/src/proto/Button.js +286 -146
  27. package/src/proto/Circular.js +162 -130
  28. package/src/proto/Color.js +331 -289
  29. package/src/proto/Empty.js +15 -0
  30. package/src/proto/Fps.js +232 -159
  31. package/src/proto/Graph.js +310 -0
  32. package/src/proto/Grid.js +297 -0
  33. package/src/proto/Group.js +334 -160
  34. package/src/proto/Item.js +120 -0
  35. package/src/proto/Joystick.js +159 -185
  36. package/src/proto/Knob.js +210 -91
  37. package/src/proto/List.js +661 -249
  38. package/src/proto/Numeric.js +329 -162
  39. package/src/proto/Pad2D.js +268 -0
  40. package/src/proto/Rubric.js +0 -0
  41. package/src/proto/Select.js +178 -0
  42. package/src/proto/Selector.js +13 -0
  43. package/src/proto/Slide.js +191 -185
  44. package/src/proto/TextInput.js +149 -59
  45. package/src/proto/Title.js +40 -31
@@ -0,0 +1,324 @@
1
+ // Ported from Stefan Gustavson's java implementation
2
+ // http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
3
+ // Read Stefan's excellent paper for details on how this code works.
4
+ //
5
+ // Sean McCullough banksean@gmail.com
6
+ //
7
+ // Added 4D noise
8
+ // Joshua Koo zz85nus@gmail.com
9
+
10
+ /**
11
+ * You can pass in a random number generator object if you like.
12
+ * It is assumed to have a random() method.
13
+ */
14
+ var SimplexNoise = function(r) {
15
+ if (r == undefined) r = Math;
16
+ this.grad3 = [[ 1,1,0 ],[ -1,1,0 ],[ 1,-1,0 ],[ -1,-1,0 ],
17
+ [ 1,0,1 ],[ -1,0,1 ],[ 1,0,-1 ],[ -1,0,-1 ],
18
+ [ 0,1,1 ],[ 0,-1,1 ],[ 0,1,-1 ],[ 0,-1,-1 ]];
19
+
20
+ this.grad4 = [[ 0,1,1,1 ], [ 0,1,1,-1 ], [ 0,1,-1,1 ], [ 0,1,-1,-1 ],
21
+ [ 0,-1,1,1 ], [ 0,-1,1,-1 ], [ 0,-1,-1,1 ], [ 0,-1,-1,-1 ],
22
+ [ 1,0,1,1 ], [ 1,0,1,-1 ], [ 1,0,-1,1 ], [ 1,0,-1,-1 ],
23
+ [ -1,0,1,1 ], [ -1,0,1,-1 ], [ -1,0,-1,1 ], [ -1,0,-1,-1 ],
24
+ [ 1,1,0,1 ], [ 1,1,0,-1 ], [ 1,-1,0,1 ], [ 1,-1,0,-1 ],
25
+ [ -1,1,0,1 ], [ -1,1,0,-1 ], [ -1,-1,0,1 ], [ -1,-1,0,-1 ],
26
+ [ 1,1,1,0 ], [ 1,1,-1,0 ], [ 1,-1,1,0 ], [ 1,-1,-1,0 ],
27
+ [ -1,1,1,0 ], [ -1,1,-1,0 ], [ -1,-1,1,0 ], [ -1,-1,-1,0 ]];
28
+
29
+ this.p = [];
30
+ for (var i = 0; i < 256; i ++) {
31
+ this.p[i] = Math.floor(r.random() * 256);
32
+ }
33
+ // To remove the need for index wrapping, double the permutation table length
34
+ this.perm = [];
35
+ for (var i = 0; i < 512; i ++) {
36
+ this.perm[i] = this.p[i & 255];
37
+ }
38
+
39
+ // A lookup table to traverse the simplex around a given point in 4D.
40
+ // Details can be found where this table is used, in the 4D noise method.
41
+ this.simplex = [
42
+ [ 0,1,2,3 ],[ 0,1,3,2 ],[ 0,0,0,0 ],[ 0,2,3,1 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 1,2,3,0 ],
43
+ [ 0,2,1,3 ],[ 0,0,0,0 ],[ 0,3,1,2 ],[ 0,3,2,1 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 1,3,2,0 ],
44
+ [ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],
45
+ [ 1,2,0,3 ],[ 0,0,0,0 ],[ 1,3,0,2 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 2,3,0,1 ],[ 2,3,1,0 ],
46
+ [ 1,0,2,3 ],[ 1,0,3,2 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 2,0,3,1 ],[ 0,0,0,0 ],[ 2,1,3,0 ],
47
+ [ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],
48
+ [ 2,0,1,3 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 3,0,1,2 ],[ 3,0,2,1 ],[ 0,0,0,0 ],[ 3,1,2,0 ],
49
+ [ 2,1,0,3 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 3,1,0,2 ],[ 0,0,0,0 ],[ 3,2,0,1 ],[ 3,2,1,0 ]];
50
+ };
51
+
52
+ SimplexNoise.prototype.dot = function(g, x, y) {
53
+ return g[0] * x + g[1] * y;
54
+ };
55
+
56
+ SimplexNoise.prototype.dot3 = function(g, x, y, z) {
57
+ return g[0] * x + g[1] * y + g[2] * z;
58
+ };
59
+
60
+ SimplexNoise.prototype.dot4 = function(g, x, y, z, w) {
61
+ return g[0] * x + g[1] * y + g[2] * z + g[3] * w;
62
+ };
63
+
64
+ SimplexNoise.prototype.noise = function(xin, yin) {
65
+ var n0, n1, n2; // Noise contributions from the three corners
66
+ // Skew the input space to determine which simplex cell we're in
67
+ var F2 = 0.5 * (Math.sqrt(3.0) - 1.0);
68
+ var s = (xin + yin) * F2; // Hairy factor for 2D
69
+ var i = Math.floor(xin + s);
70
+ var j = Math.floor(yin + s);
71
+ var G2 = (3.0 - Math.sqrt(3.0)) / 6.0;
72
+ var t = (i + j) * G2;
73
+ var X0 = i - t; // Unskew the cell origin back to (x,y) space
74
+ var Y0 = j - t;
75
+ var x0 = xin - X0; // The x,y distances from the cell origin
76
+ var y0 = yin - Y0;
77
+ // For the 2D case, the simplex shape is an equilateral triangle.
78
+ // Determine which simplex we are in.
79
+ var i1, j1; // Offsets for second (middle) corner of simplex in (i,j) coords
80
+ if (x0 > y0) {i1 = 1; j1 = 0;} // lower triangle, XY order: (0,0)->(1,0)->(1,1)
81
+ else {i1 = 0; j1 = 1;} // upper triangle, YX order: (0,0)->(0,1)->(1,1)
82
+ // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and
83
+ // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where
84
+ // c = (3-sqrt(3))/6
85
+ var x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords
86
+ var y1 = y0 - j1 + G2;
87
+ var x2 = x0 - 1.0 + 2.0 * G2; // Offsets for last corner in (x,y) unskewed coords
88
+ var y2 = y0 - 1.0 + 2.0 * G2;
89
+ // Work out the hashed gradient indices of the three simplex corners
90
+ var ii = i & 255;
91
+ var jj = j & 255;
92
+ var gi0 = this.perm[ii + this.perm[jj]] % 12;
93
+ var gi1 = this.perm[ii + i1 + this.perm[jj + j1]] % 12;
94
+ var gi2 = this.perm[ii + 1 + this.perm[jj + 1]] % 12;
95
+ // Calculate the contribution from the three corners
96
+ var t0 = 0.5 - x0 * x0 - y0 * y0;
97
+ if (t0 < 0) n0 = 0.0;
98
+ else {
99
+ t0 *= t0;
100
+ n0 = t0 * t0 * this.dot(this.grad3[gi0], x0, y0); // (x,y) of grad3 used for 2D gradient
101
+ }
102
+ var t1 = 0.5 - x1 * x1 - y1 * y1;
103
+ if (t1 < 0) n1 = 0.0;
104
+ else {
105
+ t1 *= t1;
106
+ n1 = t1 * t1 * this.dot(this.grad3[gi1], x1, y1);
107
+ }
108
+ var t2 = 0.5 - x2 * x2 - y2 * y2;
109
+ if (t2 < 0) n2 = 0.0;
110
+ else {
111
+ t2 *= t2;
112
+ n2 = t2 * t2 * this.dot(this.grad3[gi2], x2, y2);
113
+ }
114
+ // Add contributions from each corner to get the final noise value.
115
+ // The result is scaled to return values in the interval [-1,1].
116
+ return 70.0 * (n0 + n1 + n2);
117
+ };
118
+
119
+ // 3D simplex noise
120
+ SimplexNoise.prototype.noise3d = function(xin, yin, zin) {
121
+ var n0, n1, n2, n3; // Noise contributions from the four corners
122
+ // Skew the input space to determine which simplex cell we're in
123
+ var F3 = 1.0 / 3.0;
124
+ var s = (xin + yin + zin) * F3; // Very nice and simple skew factor for 3D
125
+ var i = Math.floor(xin + s);
126
+ var j = Math.floor(yin + s);
127
+ var k = Math.floor(zin + s);
128
+ var G3 = 1.0 / 6.0; // Very nice and simple unskew factor, too
129
+ var t = (i + j + k) * G3;
130
+ var X0 = i - t; // Unskew the cell origin back to (x,y,z) space
131
+ var Y0 = j - t;
132
+ var Z0 = k - t;
133
+ var x0 = xin - X0; // The x,y,z distances from the cell origin
134
+ var y0 = yin - Y0;
135
+ var z0 = zin - Z0;
136
+ // For the 3D case, the simplex shape is a slightly irregular tetrahedron.
137
+ // Determine which simplex we are in.
138
+ var i1, j1, k1; // Offsets for second corner of simplex in (i,j,k) coords
139
+ var i2, j2, k2; // Offsets for third corner of simplex in (i,j,k) coords
140
+ if (x0 >= y0) {
141
+ if (y0 >= z0)
142
+ { i1 = 1; j1 = 0; k1 = 0; i2 = 1; j2 = 1; k2 = 0; } // X Y Z order
143
+ else if (x0 >= z0) { i1 = 1; j1 = 0; k1 = 0; i2 = 1; j2 = 0; k2 = 1; } // X Z Y order
144
+ else { i1 = 0; j1 = 0; k1 = 1; i2 = 1; j2 = 0; k2 = 1; } // Z X Y order
145
+ }
146
+ else { // x0<y0
147
+ if (y0 < z0) { i1 = 0; j1 = 0; k1 = 1; i2 = 0; j2 = 1; k2 = 1; } // Z Y X order
148
+ else if (x0 < z0) { i1 = 0; j1 = 1; k1 = 0; i2 = 0; j2 = 1; k2 = 1; } // Y Z X order
149
+ else { i1 = 0; j1 = 1; k1 = 0; i2 = 1; j2 = 1; k2 = 0; } // Y X Z order
150
+ }
151
+ // A step of (1,0,0) in (i,j,k) means a step of (1-c,-c,-c) in (x,y,z),
152
+ // a step of (0,1,0) in (i,j,k) means a step of (-c,1-c,-c) in (x,y,z), and
153
+ // a step of (0,0,1) in (i,j,k) means a step of (-c,-c,1-c) in (x,y,z), where
154
+ // c = 1/6.
155
+ var x1 = x0 - i1 + G3; // Offsets for second corner in (x,y,z) coords
156
+ var y1 = y0 - j1 + G3;
157
+ var z1 = z0 - k1 + G3;
158
+ var x2 = x0 - i2 + 2.0 * G3; // Offsets for third corner in (x,y,z) coords
159
+ var y2 = y0 - j2 + 2.0 * G3;
160
+ var z2 = z0 - k2 + 2.0 * G3;
161
+ var x3 = x0 - 1.0 + 3.0 * G3; // Offsets for last corner in (x,y,z) coords
162
+ var y3 = y0 - 1.0 + 3.0 * G3;
163
+ var z3 = z0 - 1.0 + 3.0 * G3;
164
+ // Work out the hashed gradient indices of the four simplex corners
165
+ var ii = i & 255;
166
+ var jj = j & 255;
167
+ var kk = k & 255;
168
+ var gi0 = this.perm[ii + this.perm[jj + this.perm[kk]]] % 12;
169
+ var gi1 = this.perm[ii + i1 + this.perm[jj + j1 + this.perm[kk + k1]]] % 12;
170
+ var gi2 = this.perm[ii + i2 + this.perm[jj + j2 + this.perm[kk + k2]]] % 12;
171
+ var gi3 = this.perm[ii + 1 + this.perm[jj + 1 + this.perm[kk + 1]]] % 12;
172
+ // Calculate the contribution from the four corners
173
+ var t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0;
174
+ if (t0 < 0) n0 = 0.0;
175
+ else {
176
+ t0 *= t0;
177
+ n0 = t0 * t0 * this.dot3(this.grad3[gi0], x0, y0, z0);
178
+ }
179
+ var t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1;
180
+ if (t1 < 0) n1 = 0.0;
181
+ else {
182
+ t1 *= t1;
183
+ n1 = t1 * t1 * this.dot3(this.grad3[gi1], x1, y1, z1);
184
+ }
185
+ var t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2;
186
+ if (t2 < 0) n2 = 0.0;
187
+ else {
188
+ t2 *= t2;
189
+ n2 = t2 * t2 * this.dot3(this.grad3[gi2], x2, y2, z2);
190
+ }
191
+ var t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3;
192
+ if (t3 < 0) n3 = 0.0;
193
+ else {
194
+ t3 *= t3;
195
+ n3 = t3 * t3 * this.dot3(this.grad3[gi3], x3, y3, z3);
196
+ }
197
+ // Add contributions from each corner to get the final noise value.
198
+ // The result is scaled to stay just inside [-1,1]
199
+ return 32.0 * (n0 + n1 + n2 + n3);
200
+ };
201
+
202
+ // 4D simplex noise
203
+ SimplexNoise.prototype.noise4d = function( x, y, z, w ) {
204
+ // For faster and easier lookups
205
+ var grad4 = this.grad4;
206
+ var simplex = this.simplex;
207
+ var perm = this.perm;
208
+
209
+ // The skewing and unskewing factors are hairy again for the 4D case
210
+ var F4 = (Math.sqrt(5.0) - 1.0) / 4.0;
211
+ var G4 = (5.0 - Math.sqrt(5.0)) / 20.0;
212
+ var n0, n1, n2, n3, n4; // Noise contributions from the five corners
213
+ // Skew the (x,y,z,w) space to determine which cell of 24 simplices we're in
214
+ var s = (x + y + z + w) * F4; // Factor for 4D skewing
215
+ var i = Math.floor(x + s);
216
+ var j = Math.floor(y + s);
217
+ var k = Math.floor(z + s);
218
+ var l = Math.floor(w + s);
219
+ var t = (i + j + k + l) * G4; // Factor for 4D unskewing
220
+ var X0 = i - t; // Unskew the cell origin back to (x,y,z,w) space
221
+ var Y0 = j - t;
222
+ var Z0 = k - t;
223
+ var W0 = l - t;
224
+ var x0 = x - X0; // The x,y,z,w distances from the cell origin
225
+ var y0 = y - Y0;
226
+ var z0 = z - Z0;
227
+ var w0 = w - W0;
228
+
229
+ // For the 4D case, the simplex is a 4D shape I won't even try to describe.
230
+ // To find out which of the 24 possible simplices we're in, we need to
231
+ // determine the magnitude ordering of x0, y0, z0 and w0.
232
+ // The method below is a good way of finding the ordering of x,y,z,w and
233
+ // then find the correct traversal order for the simplex we’re in.
234
+ // First, six pair-wise comparisons are performed between each possible pair
235
+ // of the four coordinates, and the results are used to add up binary bits
236
+ // for an integer index.
237
+ var c1 = (x0 > y0) ? 32 : 0;
238
+ var c2 = (x0 > z0) ? 16 : 0;
239
+ var c3 = (y0 > z0) ? 8 : 0;
240
+ var c4 = (x0 > w0) ? 4 : 0;
241
+ var c5 = (y0 > w0) ? 2 : 0;
242
+ var c6 = (z0 > w0) ? 1 : 0;
243
+ var c = c1 + c2 + c3 + c4 + c5 + c6;
244
+ var i1, j1, k1, l1; // The integer offsets for the second simplex corner
245
+ var i2, j2, k2, l2; // The integer offsets for the third simplex corner
246
+ var i3, j3, k3, l3; // The integer offsets for the fourth simplex corner
247
+ // simplex[c] is a 4-vector with the numbers 0, 1, 2 and 3 in some order.
248
+ // Many values of c will never occur, since e.g. x>y>z>w makes x<z, y<w and x<w
249
+ // impossible. Only the 24 indices which have non-zero entries make any sense.
250
+ // We use a thresholding to set the coordinates in turn from the largest magnitude.
251
+ // The number 3 in the "simplex" array is at the position of the largest coordinate.
252
+ i1 = simplex[c][0] >= 3 ? 1 : 0;
253
+ j1 = simplex[c][1] >= 3 ? 1 : 0;
254
+ k1 = simplex[c][2] >= 3 ? 1 : 0;
255
+ l1 = simplex[c][3] >= 3 ? 1 : 0;
256
+ // The number 2 in the "simplex" array is at the second largest coordinate.
257
+ i2 = simplex[c][0] >= 2 ? 1 : 0;
258
+ j2 = simplex[c][1] >= 2 ? 1 : 0; k2 = simplex[c][2] >= 2 ? 1 : 0;
259
+ l2 = simplex[c][3] >= 2 ? 1 : 0;
260
+ // The number 1 in the "simplex" array is at the second smallest coordinate.
261
+ i3 = simplex[c][0] >= 1 ? 1 : 0;
262
+ j3 = simplex[c][1] >= 1 ? 1 : 0;
263
+ k3 = simplex[c][2] >= 1 ? 1 : 0;
264
+ l3 = simplex[c][3] >= 1 ? 1 : 0;
265
+ // The fifth corner has all coordinate offsets = 1, so no need to look that up.
266
+ var x1 = x0 - i1 + G4; // Offsets for second corner in (x,y,z,w) coords
267
+ var y1 = y0 - j1 + G4;
268
+ var z1 = z0 - k1 + G4;
269
+ var w1 = w0 - l1 + G4;
270
+ var x2 = x0 - i2 + 2.0 * G4; // Offsets for third corner in (x,y,z,w) coords
271
+ var y2 = y0 - j2 + 2.0 * G4;
272
+ var z2 = z0 - k2 + 2.0 * G4;
273
+ var w2 = w0 - l2 + 2.0 * G4;
274
+ var x3 = x0 - i3 + 3.0 * G4; // Offsets for fourth corner in (x,y,z,w) coords
275
+ var y3 = y0 - j3 + 3.0 * G4;
276
+ var z3 = z0 - k3 + 3.0 * G4;
277
+ var w3 = w0 - l3 + 3.0 * G4;
278
+ var x4 = x0 - 1.0 + 4.0 * G4; // Offsets for last corner in (x,y,z,w) coords
279
+ var y4 = y0 - 1.0 + 4.0 * G4;
280
+ var z4 = z0 - 1.0 + 4.0 * G4;
281
+ var w4 = w0 - 1.0 + 4.0 * G4;
282
+ // Work out the hashed gradient indices of the five simplex corners
283
+ var ii = i & 255;
284
+ var jj = j & 255;
285
+ var kk = k & 255;
286
+ var ll = l & 255;
287
+ var gi0 = perm[ii + perm[jj + perm[kk + perm[ll]]]] % 32;
288
+ var gi1 = perm[ii + i1 + perm[jj + j1 + perm[kk + k1 + perm[ll + l1]]]] % 32;
289
+ var gi2 = perm[ii + i2 + perm[jj + j2 + perm[kk + k2 + perm[ll + l2]]]] % 32;
290
+ var gi3 = perm[ii + i3 + perm[jj + j3 + perm[kk + k3 + perm[ll + l3]]]] % 32;
291
+ var gi4 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] % 32;
292
+ // Calculate the contribution from the five corners
293
+ var t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0;
294
+ if (t0 < 0) n0 = 0.0;
295
+ else {
296
+ t0 *= t0;
297
+ n0 = t0 * t0 * this.dot4(grad4[gi0], x0, y0, z0, w0);
298
+ }
299
+ var t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1;
300
+ if (t1 < 0) n1 = 0.0;
301
+ else {
302
+ t1 *= t1;
303
+ n1 = t1 * t1 * this.dot4(grad4[gi1], x1, y1, z1, w1);
304
+ }
305
+ var t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2;
306
+ if (t2 < 0) n2 = 0.0;
307
+ else {
308
+ t2 *= t2;
309
+ n2 = t2 * t2 * this.dot4(grad4[gi2], x2, y2, z2, w2);
310
+ } var t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3;
311
+ if (t3 < 0) n3 = 0.0;
312
+ else {
313
+ t3 *= t3;
314
+ n3 = t3 * t3 * this.dot4(grad4[gi3], x3, y3, z3, w3);
315
+ }
316
+ var t4 = 0.6 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4;
317
+ if (t4 < 0) n4 = 0.0;
318
+ else {
319
+ t4 *= t4;
320
+ n4 = t4 * t4 * this.dot4(grad4[gi4], x4, y4, z4, w4);
321
+ }
322
+ // Sum up and scale the result to cover the range [-1,1]
323
+ return 27.0 * (n0 + n1 + n2 + n3 + n4);
324
+ };