uil 4.0.0 → 4.0.4

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 (46) hide show
  1. package/README.md +5 -1
  2. package/build/uil.js +33 -45
  3. package/build/uil.min.js +1 -1
  4. package/build/uil.module.js +45 -58
  5. package/package.json +6 -10
  6. package/examples/js/BufferGeometryUtils.js +0 -921
  7. package/examples/js/SimplexNoise.js +0 -324
  8. package/examples/js/controls/OrbitControls.js +0 -1215
  9. package/examples/js/controls/OrbitControls_.js +0 -1042
  10. package/examples/js/libs/sea3d.min.js +0 -373
  11. package/examples/js/libs/three.min.js +0 -6
  12. package/examples/js/math.js +0 -447
  13. package/examples/js/objects/Landscape.js +0 -778
  14. package/examples/js/objects/Lensflare.js +0 -372
  15. package/examples/js/objects/SuperSky.js +0 -297
  16. package/examples/js/objects/Water.js +0 -329
  17. package/src/Uil.js +0 -6
  18. package/src/Uil_dev.js +0 -15
  19. package/src/core/Gui.js +0 -807
  20. package/src/core/Proto.js +0 -679
  21. package/src/core/Roots.js +0 -864
  22. package/src/core/Tools.js +0 -830
  23. package/src/core/V2.js +0 -131
  24. package/src/core/add.js +0 -85
  25. package/src/polyfills.js +0 -85
  26. package/src/proto/Bool.js +0 -147
  27. package/src/proto/Button.js +0 -357
  28. package/src/proto/Circular.js +0 -230
  29. package/src/proto/Color.js +0 -411
  30. package/src/proto/Empty.js +0 -15
  31. package/src/proto/Fps.js +0 -327
  32. package/src/proto/Graph.js +0 -310
  33. package/src/proto/Grid.js +0 -297
  34. package/src/proto/Group.js +0 -430
  35. package/src/proto/Item.js +0 -120
  36. package/src/proto/Joystick.js +0 -241
  37. package/src/proto/Knob.js +0 -262
  38. package/src/proto/List.js +0 -789
  39. package/src/proto/Numeric.js +0 -417
  40. package/src/proto/Pad2D.js +0 -268
  41. package/src/proto/Rubric.js +0 -0
  42. package/src/proto/Select.js +0 -178
  43. package/src/proto/Selector.js +0 -13
  44. package/src/proto/Slide.js +0 -267
  45. package/src/proto/TextInput.js +0 -181
  46. package/src/proto/Title.js +0 -61
@@ -1,447 +0,0 @@
1
- 'use strict';
2
-
3
- // performance.now
4
-
5
- var now;
6
-
7
- (function(w){
8
- var perfNow;
9
- var perfNowNames = ['now', 'webkitNow', 'msNow', 'mozNow'];
10
- if(!!w['performance']) for(var i = 0; i < perfNowNames.length; ++i){
11
- var n = perfNowNames[i];
12
- if(!!w['performance'][n]){
13
- perfNow = function(){return w['performance'][n]()};
14
- break;
15
- }
16
- }
17
- if(!perfNow) perfNow = Date.now;
18
- now = perfNow;
19
- })(window);
20
-
21
- /*
22
- var PI = Math.PI;
23
-
24
- //Faster replacement for Math object methods.
25
- Math.round(PI) === PI + (PI < 0 ? -0.5 : +0.5) >> 0;
26
- Math.ceil(PI) === PI + (PI < 0 ? -1 : 0) >> 0;
27
- Math.floor(PI) === PI + (PI < 0 ? -1 : 0) >> 0;
28
-
29
- //Conditional operator is faster than Math object methods.
30
- Math.max(a, b) === (a > b) ? a : b;
31
- Math.min(a, b) === (a < b) ? a : b;
32
-
33
- Math.abs(n) === n = n > 0 ? -n : n;
34
-
35
- var array = [1, 5, 3, 2, 4];
36
- //Sort Array in ascending order
37
- array.sort(function (a, b) { return a - b});
38
- //Sort Aarray in descending order
39
- array.sort(function (a, b) { return b - a});
40
- */
41
- Math.torad = 0.0174532925199432957;
42
- Math.todeg = 57.295779513082320876;
43
- Math.Pi = 3.141592653589793;
44
- Math.TwoPI = 6.283185307179586;
45
- Math.PI90 = 1.570796326794896;
46
- Math.PI45 = 0.7853981633973;
47
- Math.PI270 = 4.712388980384689;
48
- Math.inv255 = 0.003921569;
49
- Math.golden = 10.166407384630519;
50
-
51
- Math.int = function(x) { return Math.floor(x); };
52
-
53
- //Math.golden = Math.TwoPI * (Math.sqrt(5) + 1) * 0.5; // golden ratio
54
-
55
- // RANDOM FUNCTION
56
-
57
- Math.lerp = function ( x, y, t ) { return ( 1 - t ) * x + t * y; };
58
- Math.rand = function ( low, high ) { return low + Math.random() * ( high - low ); };
59
- Math.randInt = function ( low, high ) { return low + Math.floor( Math.random() * ( high - low + 1 ) ); };
60
-
61
- Math.seed = function( s ) { return function() { s = Math.sin(s) * 10000; return s - Math.floor(s); }; };
62
- Math.seed1 = Math.seed(32);
63
- Math.seed2 = Math.seed(Math.seed1());
64
- Math.ranSeed = Math.seed(Math.seed2());
65
-
66
- //Math.ranSeed = Math.seed( Math.seed( Math.seed( 42 ) ) );
67
- Math.randFix = function ( low, high ) { return low + Math.ranSeed() * ( high - low ); };
68
- Math.randIntFix = function ( low, high ) { return low + Math.floor( Math.ranSeed() * ( high - low + 1 ) ); };
69
-
70
- Math.distanceVector = function ( a, b ) {
71
-
72
- var x = b.x-a.x;
73
- var y = b.y-a.y;
74
- var z = b.z-a.z;
75
- var d = Math.sqrt( x*x + y*y + z*z );
76
- return d;
77
-
78
- };
79
-
80
- Math.clamp = function (v, min, max) {
81
- v = v < min ? min : v;
82
- v = v > max ? max : v;
83
- return v;
84
- }
85
-
86
- Math.norm = function (v, min, max) {
87
- //v = v < min ? min : v;
88
- //v = v > max ? max : v;
89
- return (v - min) / (max - min);
90
- }
91
-
92
- Math.linear = function (a, n0, n1) {
93
- return ((1.0 - a) * (n0)) + (a * (n1));
94
- },
95
-
96
- Math.cubicSCurve = function (a) {
97
- a = (a);
98
- return (a * a * (3.0 - 2.0 * a));
99
- },
100
-
101
- Math.quinticSCurve = function (a) {
102
- a = (a);
103
- var a3 = (a * a * a);
104
- var a4 = (a3 * a);
105
- var a5 = (a4 * a);
106
- return ((6.0 * a5) - (15.0 * a4) + (10.0 * a3));
107
- },
108
-
109
- Math.vectorad = function ( r ) {
110
-
111
- var i = r.length;
112
- while(i--) r[i] *= Math.torad;
113
- return r;
114
-
115
- };
116
-
117
- Math.unwrapDeg = function ( r ) {
118
-
119
- r = r % 360;
120
- if (r > 180) r -= 360;
121
- if (r < -180) r += 360;
122
- return r;
123
-
124
- };
125
-
126
- Math.unwrapRad = function( r ){
127
-
128
- r = r % Math.TwoPI;
129
- if (r > Math.Pi ) r -= Math.TwoPI;
130
- if (r < - Math.Pi ) r += Math.TwoPI;
131
- return r;
132
-
133
- };
134
-
135
- Math.rot2d = function ( v, d, angle ) {
136
-
137
- v = v || { x:0, y:0 };
138
- var n = {};
139
- n.x = d * Math.cos( angle * Math.torad ) + v.x;
140
- n.y = d * Math.sin( angle * Math.torad ) + v.y;
141
- n.z = v.z;
142
- return n;
143
-
144
- }
145
-
146
- Math.dist2d = function ( v1, v2 ) {
147
-
148
- var dx = v2.x - v1.x;
149
- var dy = v2.y - v1.y;
150
- return Math.sqrt( dx * dx + dy * dy );
151
-
152
- }
153
-
154
- // COLOR FUNCTION
155
-
156
- Math.colorDistance = function ( a, b ){
157
-
158
- var xd = a[0] - b[0];
159
- var yd = a[1] - b[1];
160
- var zd = a[2] - b[2];
161
- return Math.sqrt(xd*xd + yd*yd + zd*zd);
162
-
163
- };
164
-
165
- Math.rgbToHex = function( rgb ){
166
-
167
- return '0x' + ( '000000' + ( ( rgb[0] * 255 ) << 16 ^ ( rgb[1] * 255 ) << 8 ^ ( rgb[2] * 255 ) << 0 ).toString( 16 ) ).slice( - 6 );
168
-
169
- };
170
-
171
- Math.hslToRgb = function (h, s, l){
172
-
173
- var r, g, b;
174
- h /= 255., s /= 255., l /= 255.;
175
- if(s == 0){
176
- r = g = b = l; // achromatic
177
- }else{
178
- var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
179
- var p = 2 * l - q;
180
- r = Math.hue2rgb(p, q, h + 1/3);
181
- g = Math.hue2rgb(p, q, h);
182
- b = Math.hue2rgb(p, q, h - 1/3);
183
- }
184
- return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
185
-
186
- };
187
-
188
- Math.hue2rgb = function (p, q, t){
189
-
190
- if(t < 0) t += 1;
191
- if(t > 1) t -= 1;
192
- if(t < 1/6) return p + (q - p) * 6 * t;
193
- if(t < 1/2) return q;
194
- if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;
195
- return p;
196
-
197
- };
198
-
199
- Math.rgbToHsl = function (r, g, b){
200
-
201
- r /= 255, g /= 255, b /= 255;
202
- var max = Math.max(r, g, b), min = Math.min(r, g, b);
203
- var h, s, l = (max + min) * 0.5;
204
-
205
- if(max == min){
206
- h = s = 0; // achromatic
207
- }else{
208
- var d = max - min;
209
- s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
210
- switch(max){
211
- case r: h = (g - b) / d + (g < b ? 6 : 0); break;
212
- case g: h = (b - r) / d + 2; break;
213
- case b: h = (r - g) / d + 4; break;
214
- }
215
- h /= 6;
216
- }
217
-
218
- return [Math.round(h * 255), Math.round(s * 255), Math.round(l * 255)];
219
-
220
- };
221
-
222
- Math.orbit = function ( horizontal, vertical, radius, origine, revers ) {
223
-
224
- var p = { x:0, y:0, z:0 };
225
- if( origine === undefined ) origine = { x:0, y:0, z:0 };
226
- var lat = vertical * Math.torad;
227
- var lon = horizontal * Math.torad;
228
- if(revers){
229
- p.x = radius * Math.cos(lat) * Math.cos(lon);
230
- p.z = radius * Math.cos(lat) * Math.sin(lon);
231
- p.y = radius * Math.sin(lat);
232
- }else{
233
- p.x = radius * Math.sin(lat) * Math.cos(lon);
234
- p.z = radius * Math.sin(lat) * Math.sin(lon);
235
- p.y = radius * Math.cos(lat);
236
- }
237
-
238
- if( origine !== undefined ){
239
- p.x += origine.x;
240
- p.y += origine.y;
241
- p.z += origine.z;
242
- }
243
-
244
- return p;
245
-
246
- }
247
-
248
- Math.sphericalToUv = function ( v ) {
249
-
250
- var p = { u:0, v:0 };
251
- p.u = 0.5 + ( Math.atan2( v.x, v.z ) / Math.TwoPI );
252
- p.v = 0.5 + ( Math.asin( v.y ) / Math.Pi );
253
- return p;
254
-
255
- }
256
-
257
- Math.spherical = function ( v ) {
258
-
259
- var p = { lat:0, lon:0 };
260
- var r = Math.sqrt( v.x* v.x + v.y* v.y+ v.z* v.z );
261
- p.lat = Math.asin( v.y / r ) * Math.todeg;
262
- p.lon = Math.atan2( v.z, v.x ) * Math.todeg;
263
- return p;
264
-
265
- }
266
-
267
- // EXTRA NOISE
268
-
269
- Math.perlin = null;
270
-
271
- Math.noise = function ( v, o ) {
272
-
273
- if( Math.perlin === null ) Math.perlin = new SimplexNoise();
274
-
275
- o = o || {};
276
-
277
- var level = o.level || [ 1, 0.2, 0.05 ];
278
- var frequency = o.frequency || [ 0.016, 0.05, 0.2 ];
279
-
280
- var i, f, c=0, d=0;
281
-
282
- for(i=0; i<level.length; i++){
283
-
284
- f = frequency[i];
285
- c += level[i] * ( 0.5 + Math.perlin.noise3d( v.x*f, v.y*f, v.z*f ) * 0.5 );
286
- d += level[i];
287
-
288
- }
289
-
290
- c/=d;
291
-
292
- return c;
293
-
294
- }
295
-
296
- /*
297
- Math.Kalman = function ( R, Q, A, B, C ) {
298
-
299
- this.R = R===undefined ? 1:R; // noise power desirable
300
- this.Q = Q===undefined ? 1:Q; // noise power estimated
301
-
302
- this.A = A===undefined ? 1:A;// State vector
303
- this.C = C===undefined ? 0:B;//Control vector
304
- this.B = B===undefined ? 1:C;// Measurement vector
305
- this.cov = NaN;
306
- this.x = NaN; // estimated signal without noise
307
-
308
- }
309
-
310
- Math.Kalman.prototype = {
311
-
312
- filter: function(z, u){
313
-
314
- u = u || 0;
315
-
316
- if (isNaN(this.x)) {
317
- this.x = (1 / this.C) * z;
318
- this.cov = (1 / this.C) * this.Q * (1 / this.C);
319
- }
320
- else {
321
-
322
- // Compute prediction
323
- const predX = (this.A * this.x) + (this.B * u);
324
- const predCov = ((this.A * this.cov) * this.A) + this.R;
325
-
326
- // Kalman gain
327
- const K = predCov * this.C * (1 / ((this.C * predCov * this.C) + this.Q));
328
-
329
- // Correction
330
- this.x = predX + K * (z - (this.C * predX));
331
- this.cov = predCov - (K * this.C * predCov);
332
- }
333
-
334
- return this.x;
335
-
336
- },
337
-
338
- lastMeasurement: function(){
339
- return this.x;
340
- },
341
-
342
- setMeasurementNoise: function(noise){
343
- this.Q = noise;
344
- },
345
-
346
- setProcessNoise: function(noise){
347
- this.R = noise;
348
- },
349
-
350
-
351
-
352
- }*/
353
-
354
- /*Math.amp = function (smoothness, levels){
355
- //if(amp!=null) return amp;
356
- var divider = 0;
357
- for(var i = 0; i < levels; i++ ){
358
- divider += Math.pow(smoothness, i);
359
- }
360
- amp = Math.pow( smoothness, levels-1 ) / divider;
361
- return amp;
362
- }*/
363
-
364
- /*Math.spherical = function ( lat, y, lon, radius ) {
365
-
366
- var p = { x:0, y:0, z:0 };
367
- var phi = lat * Math.torad;
368
- var theta = lon * Math.torad;
369
- p.x = (radius+y) * Math.cos(phi) * Math.cos(theta);
370
- p.y = (radius+y) * Math.sin(phi) * Math.cos(theta);
371
- p.z = (radius+y) * Math.sin(theta);
372
- return p;
373
-
374
- }*/
375
-
376
- // PERLIN for terrain
377
- /*
378
- var ARRAY8
379
- if(!ARRAY8) ARRAY8 = (typeof Uint8Array !== 'undefined') ? Uint8Array : Array;
380
-
381
-
382
- function Perlin(random) {
383
- this.F2 = 0.5 * (Math.sqrt(3.0) - 1.0);
384
- this.G2 = (3.0 - Math.sqrt(3.0)) / 6.0;
385
- if (!random) random = Math.random;
386
- this.p = new ARRAY8(256);
387
- this.perm = new ARRAY8(512);
388
- this.permMod12 = new ARRAY8(512);
389
- for (var i = 0; i < 256; i++) {
390
- this.p[i] = random() * 256;
391
- }
392
- for (i = 0; i < 512; i++) {
393
- this.perm[i] = this.p[i & 255];
394
- this.permMod12[i] = this.perm[i] % 12;
395
- }
396
- };
397
-
398
- Perlin.prototype = {
399
- grad3: new Float32Array([1, 1, 0, -1, 1, 0, 1, -1, 0, -1, -1, 0, 1, 0, 1, -1, 0, 1, 1, 0, -1, -1, 0, -1, 0, 1, 1, 0, -1, 1, 0, 1, -1, 0, -1, -1]),
400
- noise: function (xin, yin) {
401
- var permMod12 = this.permMod12, perm = this.perm, grad3 = this.grad3;
402
- var n0=0, n1=0, n2=0;
403
- var s = (xin + yin) * this.F2;
404
- var i = Math.floor(xin + s);
405
- var j = Math.floor(yin + s);
406
- var t = (i + j) * this.G2;
407
- var X0 = i - t;
408
- var Y0 = j - t;
409
- var x0 = xin - X0;
410
- var y0 = yin - Y0;
411
- var i1, j1;
412
- if (x0 > y0) {
413
- i1 = 1;
414
- j1 = 0;
415
- }
416
- else {
417
- i1 = 0;
418
- j1 = 1;
419
- }
420
- var x1 = x0 - i1 + this.G2;
421
- var y1 = y0 - j1 + this.G2;
422
- var x2 = x0 - 1.0 + 2.0 * this.G2;
423
- var y2 = y0 - 1.0 + 2.0 * this.G2;
424
- var ii = i & 255;
425
- var jj = j & 255;
426
- var t0 = 0.5 - x0 * x0 - y0 * y0;
427
- if (t0 >= 0) {
428
- var gi0 = permMod12[ii + perm[jj]] * 3;
429
- t0 *= t0;
430
- n0 = t0 * t0 * (grad3[gi0] * x0 + grad3[gi0 + 1] * y0);
431
- }
432
- var t1 = 0.5 - x1 * x1 - y1 * y1;
433
- if (t1 >= 0) {
434
- var gi1 = permMod12[ii + i1 + perm[jj + j1]] * 3;
435
- t1 *= t1;
436
- n1 = t1 * t1 * (grad3[gi1] * x1 + grad3[gi1 + 1] * y1);
437
- }
438
- var t2 = 0.5 - x2 * x2 - y2 * y2;
439
- if (t2 >= 0) {
440
- var gi2 = permMod12[ii + 1 + perm[jj + 1]] * 3;
441
- t2 *= t2;
442
- n2 = t2 * t2 * (grad3[gi2] * x2 + grad3[gi2 + 1] * y2);
443
- }
444
- // return values in the interval [-1,1].
445
- return 70.0 * (n0 + n1 + n2);
446
- }
447
- };*/