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
package/src/core/V2.js ADDED
@@ -0,0 +1,131 @@
1
+ export class V2 {
2
+
3
+ constructor( x = 0, y = 0 ) {
4
+
5
+ this.x = x;
6
+ this.y = y;
7
+
8
+ }
9
+
10
+ set ( x, y ) {
11
+
12
+ this.x = x;
13
+ this.y = y;
14
+ return this;
15
+
16
+ }
17
+
18
+ divide ( v ) {
19
+
20
+ this.x /= v.x;
21
+ this.y /= v.y;
22
+ return this;
23
+
24
+ }
25
+
26
+ multiply ( v ) {
27
+
28
+ this.x *= v.x;
29
+ this.y *= v.y;
30
+ return this;
31
+
32
+ }
33
+
34
+ multiplyScalar ( scalar ) {
35
+
36
+ this.x *= scalar;
37
+ this.y *= scalar;
38
+ return this;
39
+
40
+ }
41
+
42
+ divideScalar ( scalar ) {
43
+
44
+ return this.multiplyScalar( 1 / scalar );
45
+
46
+ }
47
+
48
+ length () {
49
+
50
+ return Math.sqrt( this.x * this.x + this.y * this.y );
51
+
52
+ }
53
+
54
+ angle () {
55
+
56
+ // computes the angle in radians with respect to the positive x-axis
57
+
58
+ var angle = Math.atan2( this.y, this.x );
59
+
60
+ if ( angle < 0 ) angle += 2 * Math.PI;
61
+
62
+ return angle;
63
+
64
+ }
65
+
66
+ addScalar ( s ) {
67
+
68
+ this.x += s;
69
+ this.y += s;
70
+ return this;
71
+
72
+ }
73
+
74
+ negate () {
75
+
76
+ this.x *= -1;
77
+ this.y *= -1;
78
+ return this;
79
+
80
+ }
81
+
82
+ neg () {
83
+
84
+ this.x = -1;
85
+ this.y = -1;
86
+ return this;
87
+
88
+ }
89
+
90
+ isZero () {
91
+
92
+ return ( this.x === 0 && this.y === 0 );
93
+
94
+ }
95
+
96
+ copy ( v ) {
97
+
98
+ this.x = v.x;
99
+ this.y = v.y;
100
+
101
+ return this;
102
+
103
+ }
104
+
105
+ equals ( v ) {
106
+
107
+ return ( ( v.x === this.x ) && ( v.y === this.y ) );
108
+
109
+ }
110
+
111
+ nearEquals ( v, n ) {
112
+
113
+ return ( ( v.x.toFixed(n) === this.x.toFixed(n) ) && ( v.y.toFixed(n) === this.y.toFixed(n) ) );
114
+
115
+ }
116
+
117
+ lerp ( v, alpha ) {
118
+
119
+ if( v === null ){
120
+ this.x -= this.x * alpha;
121
+ this.y -= this.y * alpha;
122
+ } else {
123
+ this.x += ( v.x - this.x ) * alpha;
124
+ this.y += ( v.y - this.y ) * alpha;
125
+ }
126
+
127
+ return this;
128
+
129
+ }
130
+
131
+ }
package/src/core/add.js CHANGED
@@ -4,7 +4,8 @@ import { Button } from '../proto/Button.js';
4
4
  import { Circular } from '../proto/Circular.js';
5
5
  import { Color } from '../proto/Color.js';
6
6
  import { Fps } from '../proto/Fps.js';
7
- import { Group } from '../proto/Group.js';
7
+ import { Graph } from '../proto/Graph.js';
8
+ import { Group } from '../proto/Group.js';
8
9
  import { Joystick } from '../proto/Joystick.js';
9
10
  import { Knob } from '../proto/Knob.js';
10
11
  import { List } from '../proto/List.js';
@@ -12,79 +13,73 @@ import { Numeric } from '../proto/Numeric.js';
12
13
  import { Slide } from '../proto/Slide.js';
13
14
  import { TextInput } from '../proto/TextInput.js';
14
15
  import { Title } from '../proto/Title.js';
16
+ import { Select } from '../proto/Select.js';
17
+ import { Selector } from '../proto/Selector.js';
18
+ import { Empty } from '../proto/Empty.js';
19
+ import { Item } from '../proto/Item.js';
20
+ import { Grid } from '../proto/Grid.js';
21
+ import { Pad2D } from '../proto/Pad2D.js';
15
22
 
16
- function getType( name, o ) {
17
23
 
18
- var n = null;
24
+ export const add = function () {
19
25
 
20
- switch( name ){
21
-
22
- case 'Bool': case 'bool': n = new Bool(o); break;
23
- case 'Button': case 'button': n = new Button(o); break;
24
- case 'Circular': case 'circular': n = new Circular(o); break;
25
- case 'Color': case 'color': n = new Color(o); break;
26
- case 'Fps': case 'fps': n = new Fps(o); break;
27
- case 'Group': case 'group': n = new Group(o); break;
28
- case 'Joystick': case 'joystick': n = new Joystick(o); break;
29
- case 'Knob': case 'knob': n = new Knob(o); break;
30
- case 'List': case 'list': n = new List(o); break;
31
- case 'Numeric':case 'Number': case 'numeric':case 'number': n = new Numeric(o); break;
32
- case 'Slide': case 'slide': n = new Slide(o); break;
33
- case 'TextInput':case 'String': case 'textInput':case 'string': n = new TextInput(o); break;
34
- case 'Title': case 'title': n = new Title(o); break;
35
-
36
- }
37
-
38
- return n;
39
- };
40
-
41
- function add (){
42
-
43
- var a = arguments;
26
+ let a = arguments;
44
27
 
45
- var type, o, ref = false;
28
+ let type, o, ref = false, n = null;
46
29
 
47
- if( typeof a[0] === 'string' ){
30
+ if( typeof a[0] === 'string' ){
48
31
 
49
- type = a[0];//[0].toUpperCase() + a[0].slice(1);
50
- o = a[1] || {};
32
+ type = a[0];
33
+ o = a[1] || {};
51
34
 
52
- } else if ( typeof a[0] === 'object' ){ // like dat gui
35
+ } else if ( typeof a[0] === 'object' ){ // like dat gui
53
36
 
54
- ref = true;
55
- if( a[2] === undefined ) [].push.call(a, {});
37
+ ref = true;
38
+ if( a[2] === undefined ) [].push.call(a, {});
56
39
 
57
- type = autoType.apply( this, a );
40
+ type = a[2].type ? a[2].type : 'slide';//autoType.apply( this, a );
58
41
 
59
- o = a[2];
42
+ o = a[2];
43
+ o.name = a[1];
44
+ if( type === 'list' ){ o.list = a[0][a[1]]; }
45
+ else o.value = a[0][a[1]];
60
46
 
61
- o.name = a[1];
62
- o.value = a[0][a[1]];
63
-
64
- }
65
-
66
- var n = getType( type, o );
67
-
68
- if(n !== null ){
69
- if( ref ) n.setReferency( a[0], a[1] );
70
- return n;
71
- }
72
-
47
+ }
73
48
 
74
- };
49
+ let name = type.toLowerCase();
75
50
 
76
- function autoType () {
51
+ if( name === 'group' ) o.add = add;
77
52
 
78
- var a = arguments;
53
+ switch( name ){
79
54
 
80
- var type = 'Slide';
55
+ case 'bool': n = new Bool(o); break;
56
+ case 'button': n = new Button(o); break;
57
+ case 'circular': n = new Circular(o); break;
58
+ case 'color': n = new Color(o); break;
59
+ case 'fps': n = new Fps(o); break;
60
+ case 'graph': n = new Graph(o); break;
61
+ case 'group': n = new Group(o); break;
62
+ case 'joystick': n = new Joystick(o); break;
63
+ case 'knob': n = new Knob(o); break;
64
+ case 'list': n = new List(o); break;
65
+ case 'numeric': case 'number': n = new Numeric(o); break;
66
+ case 'slide': n = new Slide(o); break;
67
+ case 'textInput': case 'string': n = new TextInput(o); break;
68
+ case 'title': case 'text': n = new Title(o); break;
69
+ case 'select': n = new Select(o); break;
70
+ case 'selector': n = new Selector(o); break;
71
+ case 'empty': case 'space': n = new Empty(o); break;
72
+ case 'item': n = new Item(o); break;
73
+ case 'grid': n = new Grid(o); break;
74
+ case 'pad2d': case 'pad': n = new Pad2D(o); break;
81
75
 
82
- if(a[2].type) type = a[2].type;
76
+ }
83
77
 
84
- return type;
78
+ if( n !== null ){
85
79
 
86
- };
80
+ if( ref ) n.setReferency( a[0], a[1] );
81
+ return n;
87
82
 
88
- export { add };
83
+ }
89
84
 
90
- export var REVISION = '1.0';
85
+ }
package/src/proto/Bool.js CHANGED
@@ -1,82 +1,147 @@
1
- import { Tools } from '../core/Tools';
2
- import { Proto } from '../core/Proto';
1
+ import { Proto } from '../core/Proto.js';
3
2
 
4
- function Bool ( o ){
3
+ export class Bool extends Proto {
5
4
 
6
- Proto.call( this, o );
5
+ constructor( o = {} ) {
7
6
 
8
- this.value = o.value || false;
7
+ super( o )
8
+
9
+ this.value = o.value || false
10
+ this.model = o.mode !== undefined ? o.mode : 0
11
+
12
+ this.onName = o.rename || this.txt
13
+ if( o.onName ) o.onname = o.onName
14
+ if( o.onname ) this.onName = o.onname
9
15
 
10
- this.buttonColor = Tools.colors.button;
16
+ this.inh = o.inh || Math.floor( this.h*0.8 )
17
+ this.inw = o.inw || 36
11
18
 
12
- this.inh = o.inh || this.h;
19
+ let cc = this.colors
20
+
21
+ if( this.model === 0 ){
22
+ let t = Math.floor(this.h*0.5)-((this.inh-2)*0.5);
23
+ this.c[2] = this.dom( 'div', this.css.basic + 'background:'+ cc.inputBg +'; height:'+(this.inh-2)+'px; width:'+this.inw+'px; top:'+t+'px; border-radius:10px; border:2px solid '+ cc.back )
24
+ this.c[3] = this.dom( 'div', this.css.basic + 'height:'+(this.inh-6)+'px; width:16px; top:'+(t+2)+'px; border-radius:10px; background:'+ cc.button+';' )
25
+ } else {
26
+ this.p = 0
27
+ if( this.c[1] !== undefined ) this.c[1].textContent = '';
28
+ this.c[2] = this.dom( 'div', this.css.txt + this.css.button + 'top:1px; background:'+cc.button+'; height:'+(this.h-2)+'px; border:1px solid '+cc.border+'; border-radius:'+this.radius+'px;' )
29
+ }
13
30
 
14
- var t = ~~ (this.h*0.5)-((this.inh-2)*0.5);
31
+ this.stat = -1
15
32
 
16
- this.c[2] = Tools.dom( 'div', Tools.css.basic + 'background:'+ Tools.colors.boolbg +'; height:'+(this.inh-2)+'px; width:36px; top:'+t+'px; border-radius:20px; pointer-events:auto; cursor:pointer; transition:0.1s ease-out;' );
17
- this.c[3] = Tools.dom( 'div', Tools.css.basic + 'opasity:0, background:'+ Tools.colors.boolbg +'; height:'+(this.inh-6)+'px; width:'+(this.inh-6)+'px; top:'+(t+2)+'px; border-radius:20px; ' );
18
- this.c[4] = Tools.dom( 'div', Tools.css.basic + 'border:1px solid '+Tools.colors.border+'; height:'+(this.inh-4)+'px; width:16px; top:'+(t+1)+'px; border-radius:20px; background:'+this.buttonColor+'; transition:margin 0.1s ease-out;' );
33
+ this.init()
34
+ this.update()
19
35
 
20
- if(this.value){
21
- this.c[4].style.marginLeft = '18px';
22
- this.c[2].style.background = this.fontColor;
23
- this.c[2].style.borderColor = this.fontColor;
24
36
  }
25
37
 
26
- this.c[2].events = [ 'click' ];
38
+ // ----------------------
39
+ // EVENTS
40
+ // ----------------------
27
41
 
28
- this.init();
42
+ mousedown ( e ) {
29
43
 
30
- };
44
+ this.value = !this.value
45
+ this.update( true )
46
+ return this.mousemove( e )
47
+
48
+ }
31
49
 
32
- Bool.prototype = Object.create( Proto.prototype );
33
- Bool.prototype.constructor = Bool;
50
+ mousemove ( e ) {
51
+
52
+ this.cursor('pointer')
53
+ return this.mode( true )
54
+
55
+ }
34
56
 
35
- Bool.prototype.handleEvent = function( e ) {
57
+ reset () {
36
58
 
37
- e.preventDefault();
59
+ this.cursor()
60
+ return this.mode()
38
61
 
39
- switch( e.type ) {
40
- case 'click': this.click(e); break;
41
62
  }
42
63
 
43
- };
64
+ // ----------------------
65
+ // MODE
66
+ // ----------------------
67
+
68
+ mode ( over ) {
69
+
70
+ let change = false
71
+ let cc = this.colors, s, s2, n, v = this.value
72
+
73
+ if( over ) n = v ? 4 : 3
74
+ else n = v ? 2 : 1
75
+
76
+ if( this.stat !== n ){
77
+
78
+ this.stat = n
79
+
80
+ if( this.model !== 0 ){
81
+
82
+ s = this.s[2]
44
83
 
45
- Bool.prototype.click = function( e ){
84
+ switch( n ){
46
85
 
47
- if(this.value) this.value = false;
48
- else this.value = true;
49
- this.update();
50
- this.send();
86
+ case 1: s.color = cc.text; s.background = cc.button; break;
87
+ case 2: s.color = cc.textSelect; s.background = cc.select; break;
88
+ case 3: s.color = cc.textOver; s.background = cc.overoff; break;
89
+ case 4: s.color = cc.textOver; s.background = cc.over; break;
51
90
 
52
- };
91
+ }
53
92
 
54
- Bool.prototype.rSize = function(){
93
+ this.c[2].innerHTML = v ? this.onName : this.name
55
94
 
56
- Proto.prototype.rSize.call( this );
57
- var s = this.s;
58
- s[2].left = this.sa + 'px';
59
- s[3].left = this.sa+1+ 'px';
60
- s[4].left = this.sa+1 + 'px';
95
+ } else {
61
96
 
62
- };
97
+ s = this.s[2]
98
+ s2 = this.s[3]
63
99
 
64
- Bool.prototype.update = function() {
100
+ switch( n ){
65
101
 
66
- var s = this.s;
102
+ case 1: s.background = s.borderColor = cc.back; s2.background = cc.button; break;
103
+ case 2: s.background = s.borderColor = cc.select; s2.background = cc.button; break;
104
+ case 3: s.background = s.borderColor = cc.back; s2.background = cc.overoff; break;
105
+ case 4: s.background = s.borderColor = cc.select; s2.background = cc.over; break;
67
106
 
68
- if(this.value){
69
- s[4].marginLeft = '18px';
70
- s[2].background = this.fontColor;
71
- s[2].borderColor = this.fontColor;
72
- s[4].borderColor = this.fontColor;
73
- } else {
74
- s[4].marginLeft = '0px';
75
- s[2].background = Tools.colors.boolbg;
76
- s[2].borderColor = Tools.colors.boolbg;
77
- s[4].borderColor = Tools.colors.border;
107
+ }
108
+
109
+ this.s[3].marginLeft = v ? '17px' : '2px'
110
+ this.c[1].textContent = v ? this.onName : this.name
111
+
112
+ }
113
+
114
+ change = true
115
+
116
+ }
117
+
118
+ return change
119
+
120
+ }
121
+
122
+ // ----------------------
123
+
124
+ update ( up ) {
125
+
126
+ this.mode()
127
+ if( up ) this.send()
128
+
78
129
  }
130
+
131
+ rSize () {
132
+
133
+ super.rSize()
134
+
135
+ let s = this.s
136
+ let w = (this.w - 10 ) - this.inw
137
+ if( this.model === 0 ){
138
+ s[2].left = w + 'px'
139
+ s[3].left = w + 'px'
140
+ } else {
141
+ s[2].left = this.sa + 'px'
142
+ s[2].width = (this.w- 20) + 'px'
143
+ }
79
144
 
80
- };
145
+ }
81
146
 
82
- export { Bool };
147
+ }