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,15 @@
1
+ import { Proto } from '../core/Proto.js';
2
+
3
+ export class Empty extends Proto {
4
+
5
+ constructor( o = {} ) {
6
+
7
+ o.isSpace = true
8
+ o.margin = 0
9
+ if(!o.h) o.h = 10
10
+ super( o )
11
+ this.init()
12
+
13
+ }
14
+
15
+ }
package/src/proto/Fps.js CHANGED
@@ -1,254 +1,327 @@
1
- import { Tools } from '../core/Tools';
2
- import { Proto } from '../core/Proto';
1
+ import { Roots } from '../core/Roots.js';
2
+ import { Proto } from '../core/Proto.js';
3
3
 
4
- function Fps ( o ) {
4
+ export class Fps extends Proto {
5
5
 
6
- Proto.call( this, o );
6
+ constructor( o = {} ) {
7
7
 
8
- this.round = Math.round;
8
+ super( o );
9
9
 
10
- this.autoHeight = true;
10
+ this.round = Math.round;
11
11
 
12
- this.baseH = this.h;
13
- this.hplus = 50;
12
+ //this.autoHeight = true;
14
13
 
15
- this.res = o.res || 40;
16
- this.l = 1;
14
+ this.baseH = this.h;
15
+ this.hplus = o.hplus || 50;
17
16
 
18
- this.pa1 = [];
19
- this.pa2 = [];
20
- this.pa3 = [];
17
+ this.res = o.res || 40;
18
+ this.l = 1;
21
19
 
22
- var i = this.res+1;
23
- while(i--){
24
- this.pa1.push(50);
25
- this.pa2.push(50);
26
- this.pa3.push(50);
27
- }
20
+ this.precision = o.precision || 0;
21
+
28
22
 
29
- var fltop = Math.floor(this.h*0.5)-6;
23
+ this.custom = o.custom || false;
24
+ this.names = o.names || ['FPS', 'MS'];
25
+ let cc = o.cc || ['220,220,220', '255,255,0'];
30
26
 
31
- this.c[1].textContent = 'FPS';
32
- this.c[0].style.cursor = 'pointer';
33
- this.c[0].style.pointerEvents = 'auto';
27
+ // this.divid = [ 100, 100, 100 ];
28
+ // this.multy = [ 30, 30, 30 ];
34
29
 
35
- var panelCss = 'display:none; left:10px; top:'+ this.h + 'px; height:'+(this.hplus - 8)+'px; background: rgba(0, 0, 0, 0.2);' + 'border:1px solid rgba(255, 255, 255, 0.2); ';
30
+ this.adding = o.adding || false;
36
31
 
37
- this.c[2] = Tools.dom( 'path', Tools.css.basic + panelCss , { fill:'rgba(200,200,200,0.3)', 'stroke-width':1, stroke:this.fontColor, 'vector-effect':'non-scaling-stroke' });
32
+ this.range = o.range || [ 165, 100, 100 ];
38
33
 
39
- this.c[2].setAttribute('viewBox', '0 0 '+this.res+' 42' );
40
- this.c[2].setAttribute('height', '100%' );
41
- this.c[2].setAttribute('width', '100%' );
42
- this.c[2].setAttribute('preserveAspectRatio', 'none' );
34
+ this.alpha = o.alpha || 0.25;
43
35
 
44
- Tools.dom( 'path', null, { fill:'rgba(255,255,0,0.3)', 'stroke-width':1, stroke:'#FF0', 'vector-effect':'non-scaling-stroke' }, this.c[2] );
45
- Tools.dom( 'path', null, { fill:'rgba(0,255,255,0.3)', 'stroke-width':1, stroke:'#0FF', 'vector-effect':'non-scaling-stroke' }, this.c[2] );
36
+ this.values = [];
37
+ this.points = [];
38
+ this.textDisplay = [];
46
39
 
40
+ if(!this.custom){
47
41
 
48
- // bottom line
49
- this.c[3] = Tools.dom( 'div', Tools.css.basic + 'width:100%; bottom:0px; height:1px; background: rgba(255, 255, 255, 0.2);');
42
+ this.now = Roots.getTime()
43
+ this.startTime = 0;//this.now()
44
+ this.prevTime = 0;//this.startTime;
45
+ this.frames = 0;
50
46
 
51
- this.c[4] = Tools.dom( 'path', Tools.css.basic + 'position:absolute; width:10px; height:10px; left:4px; top:'+fltop+'px;', { d:'M 3 8 L 8 5 3 2 3 8 Z', fill:this.fontColor, stroke:'none'});
47
+ this.ms = 0;
48
+ this.fps = 0;
49
+ this.mem = 0;
50
+ this.mm = 0;
52
51
 
53
- this.isShow = o.show || false;
52
+ this.isMem = ( self.performance && self.performance.memory ) ? true : false;
54
53
 
55
- this.c[1].style.marginLeft = '10px';
54
+ // this.divid = [ 100, 200, 1 ];
55
+ // this.multy = [ 30, 30, 30 ];
56
56
 
57
- this.now = ( self.performance && self.performance.now ) ? self.performance.now.bind( performance ) : Date.now;
58
- this.startTime = this.now()
59
- this.prevTime = this.startTime;
60
- this.frames = 0
57
+ if( this.isMem ){
61
58
 
62
- this.isMem = false;
59
+ this.names.push('MEM');
60
+ cc.push('0,255,255');
63
61
 
64
- this.ms = 0;
65
- this.fps = 0;
66
- this.mem = 0;
67
- this.mm = 0;
62
+ }
68
63
 
69
- if ( self.performance && self.performance.memory ) this.isMem = true;
64
+ this.txt = o.name || 'Fps'
70
65
 
71
- this.c[0].events = [ 'click', 'mousedown', 'mouseover', 'mouseout' ];
66
+ }
72
67
 
73
- this.init();
74
68
 
75
- //if( this.isShow ) this.show();
69
+ let fltop = Math.floor(this.h*0.5)-6;
76
70
 
77
- }
71
+ this.c[1].textContent = this.txt;
72
+ this.c[0].style.cursor = 'pointer';
73
+ this.c[0].style.pointerEvents = 'auto';
78
74
 
79
- Fps.prototype = Object.create( Proto.prototype );
80
- Fps.prototype.constructor = Fps;
75
+ let panelCss = 'display:none; left:10px; top:'+ this.h + 'px; height:'+(this.hplus - 8)+'px; box-sizing:border-box; background: rgba(0, 0, 0, 0.2); border:1px solid '+ this.colors.border +';';
81
76
 
82
- Fps.prototype.handleEvent = function( e ) {
77
+ if( this.radius !== 0 ) panelCss += 'border-radius:' + this.radius+'px;';
83
78
 
84
- e.preventDefault();
85
- switch( e.type ) {
86
- case 'click': this.click(e); break;
87
- case 'mouseover': this.mode(1); break;
88
- case 'mousedown': this.mode(2); break;
89
- case 'mouseout': this.mode(0); break;
90
- }
79
+ this.c[2] = this.dom( 'path', this.css.basic + panelCss , {} );
91
80
 
92
- }
81
+ this.c[2].setAttribute('viewBox', '0 0 '+this.res+' 50' );
82
+ this.c[2].setAttribute('height', '100%' );
83
+ this.c[2].setAttribute('width', '100%' );
84
+ this.c[2].setAttribute('preserveAspectRatio', 'none' );
93
85
 
94
- Fps.prototype.click = function( e ){
95
86
 
96
- if( this.isShow ) this.hide();
97
- else this.show();
87
+ //this.dom( 'path', null, { fill:'rgba(255,255,0,0.3)', 'stroke-width':1, stroke:'#FF0', 'vector-effect':'non-scaling-stroke' }, this.c[2] );
88
+ //this.dom( 'path', null, { fill:'rgba(0,255,255,0.3)', 'stroke-width':1, stroke:'#0FF', 'vector-effect':'non-scaling-stroke' }, this.c[2] );
89
+
90
+ // arrow
91
+ this.c[3] = this.dom( 'path', this.css.basic + 'position:absolute; width:10px; height:10px; left:4px; top:'+fltop+'px;', { d:this.svgs.arrow, fill:this.colors.text, stroke:'none'});
98
92
 
99
- };
93
+ // result test
94
+ this.c[4] = this.dom( 'div', this.css.txt + 'position:absolute; left:10px; top:'+(this.h+2) +'px; display:none; width:100%; text-align:center;' );
100
95
 
101
- Fps.prototype.mode = function( mode ){
96
+ // bottom line
97
+ if( o.bottomLine ) this.c[4] = this.dom( 'div', this.css.basic + 'width:100%; bottom:0px; height:1px; background: rgba(255, 255, 255, 0.2);');
102
98
 
103
- var s = this.s;
99
+ this.isShow = false;
104
100
 
105
- switch(mode){
106
- case 0: // base
107
- s[1].color = this.fontColor;
108
- //s[1].background = 'none';
109
- break;
110
- case 1: // over
111
- s[1].color = '#FFF';
112
- //s[1].background = UIL.SELECT;
113
- break;
114
- case 2: // edit / down
115
- s[1].color = this.fontColor;
116
- //s[1].background = UIL.SELECTDOWN;
117
- break;
101
+ let s = this.s;
118
102
 
119
- }
120
- }
103
+ s[1].marginLeft = '10px';
104
+ s[1].lineHeight = this.h-4;
105
+ s[1].color = this.colors.text;
106
+ s[1].fontWeight = 'bold';
121
107
 
122
- Fps.prototype.makePath = function ( point ) {
108
+ if( this.radius !== 0 ) s[0].borderRadius = this.radius+'px';
109
+ if( this.colors.gborder!=='none') s[0].border = '1px solid ' + this.colors.gborder;
123
110
 
124
- var p = '';
125
- p += 'M ' + (-1) + ' ' + 50;
126
- for ( var i = 0; i < this.res + 1; i ++ ) { p += ' L ' + i + ' ' + point[i]; }
127
- p += ' L ' + (this.res + 1) + ' ' + 50;
128
111
 
129
- return p;
130
112
 
131
- };
132
113
 
133
- Fps.prototype.drawGraph = function( ){
114
+ let j = 0;
134
115
 
135
- var svg = this.c[2];
116
+ for( j=0; j<this.names.length; j++ ){
136
117
 
137
- this.pa1.shift();
138
- this.pa1.push( 8.5 + this.round( ( 1 - (this.fps / 100)) * 30 ) );
118
+ let base = [];
119
+ let i = this.res+1;
120
+ while( i-- ) base.push(50);
139
121
 
140
- Tools.setSvg( svg, 'd', this.makePath( this.pa1 ), 0 );
122
+ this.range[j] = ( 1 / this.range[j] ) * 49;
123
+
124
+ this.points.push( base );
125
+ this.values.push(0);
126
+ // this.dom( 'path', null, { fill:'rgba('+cc[j]+',0.5)', 'stroke-width':1, stroke:'rgba('+cc[j]+',1)', 'vector-effect':'non-scaling-stroke' }, this.c[2] );
127
+ this.textDisplay.push( "<span style='color:rgb("+cc[j]+")'> " + this.names[j] +" ");
141
128
 
142
- this.pa2.shift();
143
- this.pa2.push( 8.5 + this.round( ( 1 - (this.ms / 200)) * 30 ) );
129
+ }
144
130
 
145
- Tools.setSvg( svg, 'd', this.makePath( this.pa2 ), 1 );
131
+ j = this.names.length;
132
+ while(j--){
133
+ this.dom( 'path', null, { fill:'rgba('+cc[j]+','+this.alpha+')', 'stroke-width':1, stroke:'rgba('+cc[j]+',1)', 'vector-effect':'non-scaling-stroke' }, this.c[2] );
134
+ }
146
135
 
147
- if ( this.isMem ) {
148
136
 
149
- this.pa3.shift();
150
- this.pa3.push( 8.5 + this.round( ( 1 - this.mm) * 30 ) );
137
+ this.init();
151
138
 
152
- Tools.setSvg( svg, 'd', this.makePath( this.pa3 ), 2 );
139
+ //if( this.isShow ) this.show();
153
140
 
154
141
  }
155
142
 
156
- }
143
+ // ----------------------
144
+ // EVENTS
145
+ // ----------------------
157
146
 
147
+ mousedown ( e ) {
158
148
 
159
- Fps.prototype.show = function(){
149
+ if( this.isShow ) this.close();
150
+ else this.open();
160
151
 
161
- this.h = this.hplus + this.baseH;
152
+ }
162
153
 
163
- Tools.setSvg( this.c[4], 'd','M 5 8 L 8 3 2 3 5 8 Z');
154
+ // ----------------------
164
155
 
156
+ /*mode: function ( mode ) {
165
157
 
166
- if( this.parentGroup !== null ){ this.parentGroup.calc( this.hplus );}
167
- else if( this.isUI ) this.main.calc( this.hplus );
158
+ let s = this.s;
168
159
 
169
- this.s[0].height = this.h +'px';
170
- this.s[2].display = 'block';
171
- this.isShow = true;
160
+ switch(mode){
161
+ case 0: // base
162
+ s[1].color = this.colors.text;
163
+ //s[1].background = 'none';
164
+ break;
165
+ case 1: // over
166
+ s[1].color = '#FFF';
167
+ //s[1].background = UIL.SELECT;
168
+ break;
169
+ case 2: // edit / down
170
+ s[1].color = this.colors.text;
171
+ //s[1].background = UIL.SELECTDOWN;
172
+ break;
172
173
 
173
- Tools.addListen( this );
174
+ }
175
+ },*/
174
176
 
175
- }
177
+ tick ( v ) {
176
178
 
177
- Fps.prototype.hide = function(){
179
+ this.values = v;
180
+ if( !this.isShow ) return;
181
+ this.drawGraph();
182
+ this.upText();
178
183
 
179
- this.h = this.baseH;
184
+ }
180
185
 
181
- Tools.setSvg( this.c[4], 'd','M 3 8 L 8 5 3 2 3 8 Z');
186
+ makePath ( point ) {
182
187
 
183
- if( this.parentGroup !== null ){ this.parentGroup.calc( -this.hplus );}
184
- else if( this.isUI ) this.main.calc( -this.hplus );
185
-
186
- this.s[0].height = this.h +'px';
187
- this.s[2].display = 'none';
188
- this.isShow = false;
188
+ let p = '';
189
+ p += 'M ' + (-1) + ' ' + 50;
190
+ for ( let i = 0; i < this.res + 1; i ++ ) { p += ' L ' + i + ' ' + point[i]; }
191
+ p += ' L ' + (this.res + 1) + ' ' + 50;
192
+ return p;
189
193
 
190
- Tools.removeListen( this );
191
- this.c[1].textContent = 'FPS';
192
-
193
- }
194
+ }
194
195
 
195
- Fps.prototype.rSize = function(){
196
+ upText ( val ) {
196
197
 
197
- this.s[0].width = this.width + 'px';
198
- this.s[1].width = this.width + 'px';
199
- this.s[2].left = 10 + 'px';
200
- this.s[2].width = (this.width-20) + 'px';
198
+ let v = val || this.values, t = '';
199
+ for( let j=0, lng =this.names.length; j<lng; j++ ) t += this.textDisplay[j] + (v[j]).toFixed(this.precision) + '</span>';
200
+ this.c[4].innerHTML = t;
201
201
 
202
- }
202
+ }
203
203
 
204
- //////////////////
204
+ drawGraph () {
205
205
 
206
- Fps.prototype.begin = function(){
206
+ let svg = this.c[2];
207
+ let i = this.names.length, v, old = 0, n = 0;
207
208
 
208
- this.startTime = this.now();
209
-
210
- }
209
+ while( i-- ){
210
+ if( this.adding ) v = (this.values[n]+old) * this.range[n];
211
+ else v = (this.values[n] * this.range[n]);
212
+ this.points[n].shift();
213
+ this.points[n].push( 50 - v );
214
+ this.setSvg( svg, 'd', this.makePath( this.points[n] ), i+1 );
215
+ old += this.values[n];
216
+ n++;
217
+
218
+ }
219
+
220
+ }
221
+
222
+ open () {
223
+
224
+ super.open()
225
+
226
+ this.h = this.hplus + this.baseH;
227
+
228
+ this.setSvg( this.c[3], 'd', this.svgs.arrowDown );
229
+
230
+ if( this.group !== null ){ this.group.calc( this.hplus );}
231
+ else if( this.isUI ) this.main.calc( this.hplus );
211
232
 
212
- Fps.prototype.end = function(){
233
+ this.s[0].height = this.h +'px';
234
+ this.s[2].display = 'block';
235
+ this.s[4].display = 'block';
236
+ this.isShow = true;
213
237
 
238
+ if( !this.custom ) Roots.addListen( this );
214
239
 
215
- var time = this.now();
216
- this.ms = time - this.startTime;
240
+ }
241
+
242
+ close () {
243
+
244
+ super.close()
245
+
246
+ this.h = this.baseH;
247
+
248
+ this.setSvg( this.c[3], 'd', this.svgs.arrow );
249
+
250
+ if( this.group !== null ){ this.group.calc( -this.hplus );}
251
+ else if( this.isUI ) this.main.calc( -this.hplus );
252
+
253
+ this.s[0].height = this.h +'px';
254
+ this.s[2].display = 'none';
255
+ this.s[4].display = 'none';
256
+ this.isShow = false;
217
257
 
218
- this.frames ++;
258
+ if( !this.custom ) Roots.removeListen( this );
219
259
 
220
- if ( time > this.prevTime + 1000 ) {
260
+ this.c[4].innerHTML = '';
261
+
262
+ }
263
+
264
+
265
+ ///// AUTO FPS //////
266
+
267
+ begin () {
268
+
269
+ this.startTime = this.now();
270
+
271
+ }
221
272
 
222
- this.fps = this.round( ( this.frames * 1000 ) / ( time - this.prevTime ) );
273
+ end () {
223
274
 
224
- this.prevTime = time;
225
- this.frames = 0;
275
+ let time = this.now();
276
+ this.ms = time - this.startTime;
226
277
 
227
- if ( this.isMem ) {
278
+ this.frames ++;
228
279
 
229
- var heapSize = performance.memory.usedJSHeapSize;
230
- var heapSizeLimit = performance.memory.jsHeapSizeLimit;
280
+ if ( time > this.prevTime + 1000 ) {
231
281
 
232
- this.mem = this.round( heapSize * 0.000000954 );
282
+ this.fps = this.round( ( this.frames * 1000 ) / ( time - this.prevTime ) );
233
283
 
234
- this.mm = heapSize / heapSizeLimit;
284
+ this.prevTime = time;
285
+ this.frames = 0;
286
+
287
+ if ( this.isMem ) {
288
+
289
+ let heapSize = performance.memory.usedJSHeapSize;
290
+ let heapSizeLimit = performance.memory.jsHeapSizeLimit;
291
+
292
+ this.mem = this.round( heapSize * 0.000000954 );
293
+ this.mm = heapSize / heapSizeLimit;
294
+
295
+ }
235
296
 
236
297
  }
237
298
 
299
+ this.values = [ this.fps, this.ms , this.mm ];
300
+
301
+ this.drawGraph();
302
+ this.upText( [ this.fps, this.ms, this.mem ] );
303
+
304
+ return time;
305
+
238
306
  }
239
307
 
240
- this.drawGraph();
241
- this.c[1].innerHTML = 'FPS ' + this.fps + '<font color="yellow"> MS '+ ( this.ms | 0 ) + '</font><font color="cyan"> MB '+ this.mem + '</font>';
308
+ listening () {
242
309
 
243
- return time;
310
+ if( !this.custom ) this.startTime = this.end();
311
+
312
+ }
244
313
 
245
-
246
- }
314
+ rSize () {
247
315
 
248
- Fps.prototype.listening = function(){
316
+ let s = this.s;
317
+ let w = this.w;
249
318
 
250
- this.startTime = this.end();
319
+ s[0].width = w + 'px';
320
+ s[1].width = w + 'px';
321
+ s[2].left = 10 + 'px';
322
+ s[2].width = (w-20) + 'px';
323
+ s[4].width = (w-20) + 'px';
324
+
325
+ }
251
326
 
252
- }
253
-
254
- export { Fps };
327
+ }