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
package/src/proto/Item.js DELETED
@@ -1,120 +0,0 @@
1
- import { Proto } from '../core/Proto.js';
2
-
3
- export class Item extends Proto {
4
-
5
- constructor( o = {} ) {
6
-
7
- super( o );
8
-
9
- this.p = 100;
10
- this.value = this.txt;
11
- this.status = 1;
12
-
13
- this.itype = o.itype || 'none';
14
- this.val = this.itype;
15
-
16
- this.graph = this.svgs[ this.itype ];
17
-
18
- let fltop = Math.floor(this.h*0.5)-7;
19
-
20
- this.c[2] = this.dom( 'path', this.css.basic + 'position:absolute; width:14px; height:14px; left:5px; top:'+fltop+'px;', { d:this.graph, fill:this.colors.text, stroke:'none'});
21
-
22
- this.s[1].marginLeft = 20 + 'px';
23
-
24
- this.init();
25
-
26
- }
27
-
28
- // ----------------------
29
- // EVENTS
30
- // ----------------------
31
-
32
- mousemove ( e ) {
33
-
34
- this.cursor('pointer');
35
-
36
- //up = this.modes( this.isDown ? 3 : 2, name );
37
-
38
- }
39
-
40
- mousedown ( e ) {
41
-
42
- if( this.isUI ) this.main.resetItem();
43
-
44
- this.selected( true );
45
-
46
- this.send();
47
-
48
- return true;
49
-
50
- }
51
-
52
- uiout () {
53
-
54
- if( this.isSelect ) this.mode(3);
55
- else this.mode(1);
56
-
57
- }
58
-
59
- uiover () {
60
-
61
- if( this.isSelect ) this.mode(4);
62
- else this.mode(2);
63
-
64
- }
65
-
66
- update () {
67
-
68
- }
69
-
70
- /*rSize () {
71
-
72
- super.rSize();
73
-
74
- }*/
75
-
76
- mode ( n ) {
77
-
78
- let change = false;
79
-
80
- if( this.status !== n ){
81
-
82
- this.status = n;
83
- let s = this.s, cc = this.colors
84
-
85
- switch( n ){
86
-
87
- case 1: this.status = 1; s[1].color = cc.text; s[0].background = 'none'; break;
88
- case 2: this.status = 2; s[1].color = cc.textOver; s[0].background = cc.back; break;
89
- case 3: this.status = 3; s[1].color = cc.textSelect; s[0].background = cc.select; break;
90
- case 4: this.status = 4; s[1].color = cc.textOver; s[0].background = cc.over; break;
91
-
92
- }
93
-
94
- change = true;
95
-
96
- }
97
-
98
- return change;
99
-
100
- }
101
-
102
- reset () {
103
-
104
- this.cursor();
105
- // return this.mode( 1 );
106
-
107
- }
108
-
109
- selected ( b ){
110
-
111
- if( this.isSelect ) this.mode(1);
112
-
113
- this.isSelect = b || false;
114
-
115
- if( this.isSelect ) this.mode(3);
116
-
117
- }
118
-
119
-
120
- }
@@ -1,241 +0,0 @@
1
- import { Proto } from '../core/Proto.js';
2
- import { V2 } from '../core/V2.js';
3
-
4
- export class Joystick extends Proto {
5
-
6
- constructor( o = {} ) {
7
-
8
- super( o );
9
-
10
- this.autoWidth = false;
11
-
12
- this.value = [0,0];
13
-
14
- this.minw = this.w
15
- this.diam = o.diam || this.w
16
-
17
- this.joyType = 'analogique';
18
- this.model = o.mode !== undefined ? o.mode : 0;
19
-
20
- this.precision = o.precision || 2;
21
- this.multiplicator = o.multiplicator || 1;
22
-
23
- this.pos = new V2();
24
- this.tmp = new V2();
25
-
26
- this.interval = null;
27
-
28
- //this.radius = this.w * 0.5;
29
- //this.distance = this.radius*0.25;
30
- this.distance = (this.diam*0.5)*0.25;
31
-
32
- this.h = o.h || this.w + 10;
33
- this.top = 0;
34
-
35
- this.c[0].style.width = this.w +'px';
36
-
37
- if( this.c[1] !== undefined ) { // with title
38
-
39
- this.c[1].style.width = '100%';
40
- this.c[1].style.justifyContent = 'center';
41
- this.top = 10;
42
- this.h += 10;
43
-
44
- }
45
-
46
- let cc = this.colors
47
-
48
- this.c[2] = this.dom( 'div', this.css.txt + 'justify-content:center; top:'+(this.h-20)+'px; width:100%; color:'+ cc.text );
49
- this.c[2].textContent = this.value;
50
-
51
- this.c[3] = this.getJoystick( this.model );
52
- this.setSvg( this.c[3], 'viewBox', '0 0 '+this.diam+' '+this.diam );
53
- this.setCss( this.c[3], { width:this.diam, height:this.diam, left:0, top:this.top });
54
-
55
-
56
- this.ratio = 128/this.w;
57
-
58
- this.init();
59
-
60
- this.update(false);
61
-
62
- }
63
-
64
- mode ( mode ) {
65
-
66
- let cc = this.colors
67
-
68
- switch(mode){
69
- case 0: // base
70
- if(this.model===0){
71
- this.setSvg( this.c[3], 'fill', 'url(#gradIn)', 4 );
72
- this.setSvg( this.c[3], 'stroke', '#000', 4 );
73
- } else {
74
- this.setSvg( this.c[3], 'stroke', 'rgba(100,100,100,0.25)', 2 );
75
- //this.setSvg( this.c[3], 'stroke', 'rgb(0,0,0,0.1)', 3 );
76
- this.setSvg( this.c[3], 'stroke', '#666', 4 );
77
- this.setSvg( this.c[3], 'fill', 'none', 4 );
78
- }
79
-
80
- break;
81
- case 1: // over
82
- if(this.model===0){
83
- this.setSvg( this.c[3], 'fill', 'url(#gradIn2)', 4 );
84
- this.setSvg( this.c[3], 'stroke', 'rgba(0,0,0,0)', 4 );
85
- } else {
86
- this.setSvg( this.c[3], 'stroke', 'rgba(48,138,255,0.25)', 2 );
87
- //this.setSvg( this.c[3], 'stroke', 'rgb(0,0,0,0.3)', 3 );
88
- this.setSvg( this.c[3], 'stroke', cc.select, 4 );
89
- this.setSvg( this.c[3], 'fill', 'rgba(48,138,255,0.25)', 4 );
90
- }
91
- break;
92
- case 2: // edit
93
- break;
94
-
95
- }
96
- }
97
-
98
- // ----------------------
99
- // EVENTS
100
- // ----------------------
101
-
102
- addInterval (){
103
- if( this.interval !== null ) this.stopInterval();
104
- if( this.pos.isZero() ) return;
105
- this.interval = setInterval( function(){ this.update(); }.bind(this), 10 );
106
-
107
- }
108
-
109
- stopInterval (){
110
-
111
- if( this.interval === null ) return;
112
- clearInterval( this.interval );
113
- this.interval = null;
114
-
115
- }
116
-
117
- reset () {
118
-
119
- this.addInterval();
120
- this.mode(0);
121
-
122
- }
123
-
124
- mouseup ( e ) {
125
-
126
- this.addInterval();
127
- this.isDown = false;
128
-
129
- }
130
-
131
- mousedown ( e ) {
132
-
133
- this.isDown = true;
134
- this.mousemove( e );
135
- this.mode( 2 );
136
-
137
- }
138
-
139
- mousemove ( e ) {
140
-
141
- this.mode(1);
142
-
143
- if( !this.isDown ) return;
144
-
145
- //this.tmp.x = this.radius - ( e.clientX - this.zone.x );
146
- //this.tmp.y = this.radius - ( e.clientY - this.zone.y - this.top );
147
-
148
- this.tmp.x = (this.w*0.5) - ( e.clientX - this.zone.x );
149
- this.tmp.y = (this.diam*0.5) - ( e.clientY - this.zone.y - this.top );
150
-
151
- let distance = this.tmp.length();
152
-
153
- if ( distance > this.distance ) {
154
- let angle = Math.atan2(this.tmp.x, this.tmp.y);
155
- this.tmp.x = Math.sin( angle ) * this.distance;
156
- this.tmp.y = Math.cos( angle ) * this.distance;
157
- }
158
-
159
- this.pos.copy( this.tmp ).divideScalar( this.distance ).negate();
160
-
161
- this.update();
162
-
163
- }
164
-
165
- setValue ( v ) {
166
-
167
- if(v===undefined) v=[0,0];
168
-
169
- this.pos.set( v[0] || 0, v[1] || 0 );
170
- this.updateSVG();
171
-
172
- }
173
-
174
- update ( up ) {
175
-
176
- if( up === undefined ) up = true;
177
-
178
- if( this.interval !== null ){
179
-
180
- if( !this.isDown ){
181
-
182
- this.pos.lerp( null, 0.3 );
183
-
184
- this.pos.x = Math.abs( this.pos.x ) < 0.01 ? 0 : this.pos.x;
185
- this.pos.y = Math.abs( this.pos.y ) < 0.01 ? 0 : this.pos.y;
186
-
187
- if( this.isUI && this.main.isCanvas ) this.main.draw();
188
-
189
- }
190
-
191
- }
192
-
193
- this.updateSVG();
194
-
195
- if( up ) this.send();
196
-
197
-
198
- if( this.pos.isZero() ) this.stopInterval();
199
-
200
- }
201
-
202
- updateSVG () {
203
-
204
- //let x = this.radius - ( -this.pos.x * this.distance );
205
- //let y = this.radius - ( -this.pos.y * this.distance );
206
-
207
- let x = (this.diam*0.5) - ( -this.pos.x * this.distance );
208
- let y = (this.diam*0.5) - ( -this.pos.y * this.distance );
209
-
210
- if(this.model === 0){
211
-
212
- let sx = x + ((this.pos.x)*5) + 5;
213
- let sy = y + ((this.pos.y)*5) + 10;
214
-
215
- this.setSvg( this.c[3], 'cx', sx*this.ratio, 3 );
216
- this.setSvg( this.c[3], 'cy', sy*this.ratio, 3 );
217
- } else {
218
- this.setSvg( this.c[3], 'cx', x*this.ratio, 3 );
219
- this.setSvg( this.c[3], 'cy', y*this.ratio, 3 );
220
- }
221
-
222
-
223
-
224
- this.setSvg( this.c[3], 'cx', x*this.ratio, 4 );
225
- this.setSvg( this.c[3], 'cy', y*this.ratio, 4 );
226
-
227
- this.value[0] = ( this.pos.x * this.multiplicator ).toFixed( this.precision ) * 1;
228
- this.value[1] = ( this.pos.y * this.multiplicator ).toFixed( this.precision ) * 1;
229
-
230
- this.c[2].textContent = this.value;
231
-
232
- }
233
-
234
- clear () {
235
-
236
- this.stopInterval();
237
- super.clear();
238
-
239
- }
240
-
241
- }
package/src/proto/Knob.js DELETED
@@ -1,262 +0,0 @@
1
- import { Proto } from '../core/Proto.js';
2
- import { Tools } from '../core/Tools.js';
3
- import { V2 } from '../core/V2.js';
4
-
5
- export class Knob extends Proto {
6
-
7
- constructor( o = {} ) {
8
-
9
- super( o );
10
-
11
- this.isCyclic = o.cyclic || false;
12
- this.model = o.stype || 0;
13
- if( o.mode !== undefined ) this.model = o.mode;
14
-
15
- this.autoWidth = false;
16
-
17
- this.setTypeNumber( o );
18
-
19
- this.minw = this.w
20
- this.diam = o.diam || this.w
21
-
22
- this.mPI = Math.PI * 0.8;
23
- this.toDeg = 180 / Math.PI;
24
- this.cirRange = this.mPI * 2;
25
-
26
- this.offset = new V2();
27
-
28
- this.h = o.h || this.w + 10;
29
- this.top = 0;
30
-
31
- this.c[0].style.width = this.w +'px'
32
-
33
- if(this.c[1] !== undefined) {
34
-
35
- this.c[1].style.width = '100%'
36
- this.c[1].style.justifyContent = 'center'
37
- this.top = 10;
38
- this.h += 10;
39
-
40
- }
41
-
42
- this.percent = 0;
43
-
44
- this.cmode = 0;
45
- let cc = this.colors
46
-
47
- this.c[2] = this.dom( 'div', this.css.txt + 'justify-content:center; top:'+(this.h-20)+'px; width:100%; color:'+ cc.text );
48
-
49
- this.c[3] = this.getKnob();
50
- this.setSvg( this.c[3], 'fill', cc.button, 0 )
51
- this.setSvg( this.c[3], 'stroke', cc.text, 1 )
52
- this.setSvg( this.c[3], 'stroke', cc.text, 3 )
53
- this.setSvg( this.c[3], 'd', this.makeGrad(), 3 )
54
-
55
- this.setSvg( this.c[3], 'viewBox', '0 0 ' + this.diam + ' ' + this.diam )
56
- this.setCss( this.c[3], { width:this.diam, height:this.diam, left:0, top:this.top })
57
-
58
- if ( this.model > 0 ) {
59
-
60
- Tools.dom( 'path', '', { d: '', stroke:cc.text, 'stroke-width': 2, fill: 'none', 'stroke-linecap': 'round' }, this.c[3] ); //4
61
-
62
- if ( this.model == 2) {
63
-
64
- Tools.addSVGGlowEffect();
65
- this.setSvg( this.c[3], 'style', 'filter: url("#UILGlow");', 4 );
66
-
67
- }
68
-
69
- }
70
-
71
- this.r = 0;
72
-
73
- this.init();
74
-
75
- this.update();
76
-
77
- }
78
-
79
- mode ( mode ) {
80
-
81
- let cc = this.colors
82
-
83
- if( this.cmode === mode ) return false;
84
-
85
- switch( mode ) {
86
- case 0: // base
87
- this.s[2].color = cc.text;
88
- this.setSvg( this.c[3], 'fill', cc.button, 0);
89
- //this.setSvg( this.c[3], 'stroke','rgba(255,0,0,0.2)', 2);
90
- this.setSvg( this.c[3], 'stroke', cc.text, 1 );
91
- break;
92
- case 1: // down
93
- this.s[2].color = cc.textOver;
94
- this.setSvg( this.c[3], 'fill', cc.select, 0);
95
- //this.setSvg( this.c[3], 'stroke','rgba(0,0,0,0.6)', 2);
96
- this.setSvg( this.c[3], 'stroke', cc.textOver, 1 );
97
- break;
98
- }
99
-
100
- this.cmode = mode;
101
- return true;
102
-
103
- }
104
-
105
- testZone ( e ) {
106
-
107
- let l = this.local;
108
- if( l.x === -1 && l.y === -1 ) return '';
109
- if( l.y <= this.c[ 1 ].offsetHeight ) return 'title';
110
- else if ( l.y > this.h - this.c[ 2 ].offsetHeight ) return 'text';
111
- else return 'knob';
112
-
113
- }
114
-
115
- // ----------------------
116
- // EVENTS
117
- // ----------------------
118
-
119
- mouseup ( e ) {
120
-
121
- this.isDown = false;
122
- this.sendEnd()
123
- return this.mode(0)
124
-
125
- }
126
-
127
- mousedown ( e ) {
128
-
129
- this.isDown = true
130
- this.old = this.value
131
- this.oldr = null
132
- this.mousemove( e )
133
- return this.mode(1)
134
-
135
- }
136
-
137
- mousemove ( e ) {
138
-
139
- if( !this.isDown ) return;
140
-
141
- let off = this.offset;
142
-
143
- //off.x = this.radius - ( e.clientX - this.zone.x );
144
- //off.y = this.radius - ( e.clientY - this.zone.y - this.top );
145
-
146
- off.x = (this.w*0.5) - ( e.clientX - this.zone.x );
147
- off.y = (this.diam*0.5) - ( e.clientY - this.zone.y - this.top );
148
-
149
- this.r = - Math.atan2( off.x, off.y );
150
-
151
- if( this.oldr !== null ) this.r = Math.abs(this.r - this.oldr) > Math.PI ? this.oldr : this.r;
152
-
153
- this.r = this.r > this.mPI ? this.mPI : this.r;
154
- this.r = this.r < -this.mPI ? -this.mPI : this.r;
155
-
156
- let steps = 1 / this.cirRange;
157
- let value = (this.r + this.mPI) * steps;
158
-
159
- let n = ( ( this.range * value ) + this.min ) - this.old;
160
-
161
- if(n >= this.step || n <= this.step){
162
- n = Math.floor( n / this.step );
163
- this.value = this.numValue( this.old + ( n * this.step ) );
164
- this.update( true );
165
- this.old = this.value;
166
- this.oldr = this.r;
167
- }
168
-
169
- }
170
-
171
- wheel ( e ) {
172
-
173
- let name = this.testZone( e );
174
-
175
- if( name === 'knob' ) {
176
-
177
- let v = this.value - this.step * e.delta;
178
-
179
- if ( v > this.max ) {
180
- v = this.isCyclic ? this.min : this.max;
181
- } else if ( v < this.min ) {
182
- v = this.isCyclic ? this.max : this.min;
183
- }
184
-
185
- this.setValue( v );
186
- this.old = v;
187
- this.update( true );
188
-
189
- return true;
190
-
191
- }
192
- return false;
193
-
194
- }
195
-
196
- makeGrad () {
197
-
198
- let d = '', step, range, a, x, y, x2, y2, r = 64;
199
- let startangle = Math.PI + this.mPI;
200
- let endangle = Math.PI - this.mPI;
201
- //let step = this.step>5 ? this.step : 1;
202
-
203
- if(this.step>5){
204
- range = this.range / this.step;
205
- step = ( startangle - endangle ) / range;
206
- } else {
207
- step = (( startangle - endangle ) / r)*2;
208
- range = r*0.5;
209
- }
210
-
211
- for ( let i = 0; i <= range; ++i ) {
212
-
213
- a = startangle - ( step * i );
214
- x = r + Math.sin( a ) * ( r - 20 );
215
- y = r + Math.cos( a ) * ( r - 20 );
216
- x2 = r + Math.sin( a ) * ( r - 24 );
217
- y2 = r + Math.cos( a ) * ( r - 24 );
218
- d += 'M' + x + ' ' + y + ' L' + x2 + ' '+y2 + ' ';
219
-
220
- }
221
-
222
- return d;
223
-
224
- }
225
-
226
- update ( up ) {
227
-
228
- this.c[2].textContent = this.value;
229
- this.percent = (this.value - this.min) / this.range;
230
-
231
- let sa = Math.PI + this.mPI;
232
- let ea = ( ( this.percent * this.cirRange ) - ( this.mPI ) );
233
-
234
- let sin = Math.sin( ea );
235
- let cos = Math.cos( ea );
236
-
237
- let x1 = ( 25 * sin ) + 64;
238
- let y1 = -( 25 * cos ) + 64;
239
- let x2 = ( 20 * sin ) + 64;
240
- let y2 = -( 20 * cos ) + 64;
241
-
242
- this.setSvg( this.c[3], 'd', 'M ' + x1 +' ' + y1 + ' L ' + x2 +' ' + y2, 1 );
243
-
244
- if ( this.model > 0 ) {
245
-
246
- let x1 = 36 * Math.sin( sa ) + 64;
247
- let y1 = 36 * Math.cos( sa ) + 64;
248
- let x2 = 36 * sin + 64;
249
- let y2 = -36 * cos + 64;
250
- let big = ea <= Math.PI - this.mPI ? 0 : 1;
251
- this.setSvg( this.c[3], 'd', 'M ' + x1 + ',' + y1 + ' A ' + 36 + ',' + 36 + ' 1 ' + big + ' 1 ' + x2 + ',' + y2, 4 );
252
-
253
- let color = Tools.pack( Tools.lerpColor( Tools.unpack( Tools.ColorLuma( this.colors.text, -0.75) ), Tools.unpack( this.colors.text ), this.percent ) );
254
- this.setSvg( this.c[3], 'stroke', color, 4 );
255
-
256
- }
257
-
258
- if( up ) this.send();
259
-
260
- }
261
-
262
- }