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/Fps.js DELETED
@@ -1,327 +0,0 @@
1
- import { Roots } from '../core/Roots.js';
2
- import { Proto } from '../core/Proto.js';
3
-
4
- export class Fps extends Proto {
5
-
6
- constructor( o = {} ) {
7
-
8
- super( o );
9
-
10
- this.round = Math.round;
11
-
12
- //this.autoHeight = true;
13
-
14
- this.baseH = this.h;
15
- this.hplus = o.hplus || 50;
16
-
17
- this.res = o.res || 40;
18
- this.l = 1;
19
-
20
- this.precision = o.precision || 0;
21
-
22
-
23
- this.custom = o.custom || false;
24
- this.names = o.names || ['FPS', 'MS'];
25
- let cc = o.cc || ['220,220,220', '255,255,0'];
26
-
27
- // this.divid = [ 100, 100, 100 ];
28
- // this.multy = [ 30, 30, 30 ];
29
-
30
- this.adding = o.adding || false;
31
-
32
- this.range = o.range || [ 165, 100, 100 ];
33
-
34
- this.alpha = o.alpha || 0.25;
35
-
36
- this.values = [];
37
- this.points = [];
38
- this.textDisplay = [];
39
-
40
- if(!this.custom){
41
-
42
- this.now = Roots.getTime()
43
- this.startTime = 0;//this.now()
44
- this.prevTime = 0;//this.startTime;
45
- this.frames = 0;
46
-
47
- this.ms = 0;
48
- this.fps = 0;
49
- this.mem = 0;
50
- this.mm = 0;
51
-
52
- this.isMem = ( self.performance && self.performance.memory ) ? true : false;
53
-
54
- // this.divid = [ 100, 200, 1 ];
55
- // this.multy = [ 30, 30, 30 ];
56
-
57
- if( this.isMem ){
58
-
59
- this.names.push('MEM');
60
- cc.push('0,255,255');
61
-
62
- }
63
-
64
- this.txt = o.name || 'Fps'
65
-
66
- }
67
-
68
-
69
- let fltop = Math.floor(this.h*0.5)-6;
70
-
71
- this.c[1].textContent = this.txt;
72
- this.c[0].style.cursor = 'pointer';
73
- this.c[0].style.pointerEvents = 'auto';
74
-
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 +';';
76
-
77
- if( this.radius !== 0 ) panelCss += 'border-radius:' + this.radius+'px;';
78
-
79
- this.c[2] = this.dom( 'path', this.css.basic + panelCss , {} );
80
-
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' );
85
-
86
-
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'});
92
-
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;' );
95
-
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);');
98
-
99
- this.isShow = false;
100
-
101
- let s = this.s;
102
-
103
- s[1].marginLeft = '10px';
104
- s[1].lineHeight = this.h-4;
105
- s[1].color = this.colors.text;
106
- s[1].fontWeight = 'bold';
107
-
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;
110
-
111
-
112
-
113
-
114
- let j = 0;
115
-
116
- for( j=0; j<this.names.length; j++ ){
117
-
118
- let base = [];
119
- let i = this.res+1;
120
- while( i-- ) base.push(50);
121
-
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] +" ");
128
-
129
- }
130
-
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
- }
135
-
136
-
137
- this.init();
138
-
139
- //if( this.isShow ) this.show();
140
-
141
- }
142
-
143
- // ----------------------
144
- // EVENTS
145
- // ----------------------
146
-
147
- mousedown ( e ) {
148
-
149
- if( this.isShow ) this.close();
150
- else this.open();
151
-
152
- }
153
-
154
- // ----------------------
155
-
156
- /*mode: function ( mode ) {
157
-
158
- let s = this.s;
159
-
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;
173
-
174
- }
175
- },*/
176
-
177
- tick ( v ) {
178
-
179
- this.values = v;
180
- if( !this.isShow ) return;
181
- this.drawGraph();
182
- this.upText();
183
-
184
- }
185
-
186
- makePath ( point ) {
187
-
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;
193
-
194
- }
195
-
196
- upText ( val ) {
197
-
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
-
202
- }
203
-
204
- drawGraph () {
205
-
206
- let svg = this.c[2];
207
- let i = this.names.length, v, old = 0, n = 0;
208
-
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 );
232
-
233
- this.s[0].height = this.h +'px';
234
- this.s[2].display = 'block';
235
- this.s[4].display = 'block';
236
- this.isShow = true;
237
-
238
- if( !this.custom ) Roots.addListen( this );
239
-
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;
257
-
258
- if( !this.custom ) Roots.removeListen( this );
259
-
260
- this.c[4].innerHTML = '';
261
-
262
- }
263
-
264
-
265
- ///// AUTO FPS //////
266
-
267
- begin () {
268
-
269
- this.startTime = this.now();
270
-
271
- }
272
-
273
- end () {
274
-
275
- let time = this.now();
276
- this.ms = time - this.startTime;
277
-
278
- this.frames ++;
279
-
280
- if ( time > this.prevTime + 1000 ) {
281
-
282
- this.fps = this.round( ( this.frames * 1000 ) / ( time - this.prevTime ) );
283
-
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
- }
296
-
297
- }
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
-
306
- }
307
-
308
- listening () {
309
-
310
- if( !this.custom ) this.startTime = this.end();
311
-
312
- }
313
-
314
- rSize () {
315
-
316
- let s = this.s;
317
- let w = this.w;
318
-
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
- }
326
-
327
- }
@@ -1,310 +0,0 @@
1
- import { Proto } from '../core/Proto.js';
2
- import { V2 } from '../core/V2.js';
3
-
4
- export class Graph extends Proto {
5
-
6
- constructor( o = {} ) {
7
-
8
- super( o );
9
-
10
- this.value = o.value !== undefined ? o.value : [0,0,0];
11
- this.lng = this.value.length;
12
-
13
- this.precision = o.precision !== undefined ? o.precision : 2;
14
- this.multiplicator = o.multiplicator || 1;
15
- this.neg = o.neg || false;
16
-
17
- this.line = o.line !== undefined ? o.line : true;
18
-
19
- //if(this.neg)this.multiplicator*=2;
20
-
21
- this.autoWidth = o.autoWidth !== undefined ? o.autoWidth : true;
22
- this.isNumber = false;
23
-
24
- this.isDown = false;
25
-
26
- this.h = o.h || 128 + 10;
27
- this.rh = this.h - 10;
28
- this.top = 0;
29
-
30
- this.c[0].style.width = this.w +'px';
31
-
32
- if( this.c[1] !== undefined ) { // with title
33
-
34
- this.c[1].style.width = this.w +'px';
35
-
36
- if(!this.autoWidth){
37
- this.c[1].style.width = '100%';
38
- this.c[1].style.justifyContent = 'center'
39
- }
40
-
41
-
42
- //this.c[1].style.background = '#ff0000';
43
- //this.c[1].style.textAlign = 'center';
44
- this.top = 10;
45
- this.h += 10;
46
-
47
- }
48
-
49
- this.gh = this.rh - 28;
50
- this.gw = this.w - 28;
51
-
52
- //this.c[2] = this.dom( 'div', this.css.txt + 'justify-content:center; text-align: justify; column-count:'+this.lng+'; top:'+(this.h-20)+'px; width:100%; color:'+ this.colors.text );
53
-
54
- //let colum = 'column-count:'+this.lng+'; column:'+this.lng+'; break-inside: column; top:'
55
- this.c[2] = this.dom( 'div', this.css.txt + 'display:block; text-align:center; padding:0px 0px; top:'+(this.h-20)+'px; left:14px; width:'+this.gw+'px; color:'+ this.colors.text );
56
-
57
- //this.c[2].textContent = this.value;
58
- this.c[2].innerHTML = this.valueToHtml();
59
-
60
- let svg = this.dom( 'svg', this.css.basic , { viewBox:'0 0 '+this.w+' '+this.rh, width:this.w, height:this.rh, preserveAspectRatio:'none' } );
61
- this.setCss( svg, { width:this.w, height:this.rh, left:0, top:this.top });
62
-
63
- this.dom( 'path', '', { d:'', stroke:this.colors.text, 'stroke-width':2, fill:'none', 'stroke-linecap':'butt' }, svg );
64
- this.dom( 'rect', '', { x:10, y:10, width:this.gw+8, height:this.gh+8, stroke:'rgba(0,0,0,0.3)', 'stroke-width':1 , fill:'none'}, svg );
65
-
66
- this.iw = ((this.gw-(4*(this.lng-1)))/this.lng);
67
- let t = [];
68
- this.cMode = [];
69
-
70
- this.v = [];
71
-
72
- for( let i = 0; i < this.lng; i++ ){
73
-
74
- t[i] = [ 14 + (i*this.iw) + (i*4), this.iw ];
75
- t[i][2] = t[i][0] + t[i][1];
76
- this.cMode[i] = 0;
77
-
78
- if( this.neg ) this.v[i] = ((1+(this.value[i] / this.multiplicator))*0.5);
79
- else this.v[i] = this.value[i] / this.multiplicator;
80
-
81
- this.dom( 'rect', '', { x:t[i][0], y:14, width:t[i][1], height:1, fill:this.colors.text, 'fill-opacity':0.3 }, svg );
82
-
83
- }
84
-
85
- this.tmp = t;
86
- this.c[3] = svg;
87
-
88
- //console.log(this.w)
89
-
90
- this.init();
91
-
92
- if( this.c[1] !== undefined ){
93
- this.c[1].style.top = 0 +'px';
94
- this.c[1].style.height = 20 +'px';
95
- this.s[1].lineHeight = (20-5)+'px'
96
- }
97
-
98
- this.update( false );
99
-
100
- }
101
-
102
- setValue ( value ) {
103
-
104
- this.value = value;
105
- this.lng = this.value.length;
106
- for (var i = 0; i < this.lng; i++) {
107
- if (this.neg) this.v[i] = (1 + value[i] / this.multiplicator) * 0.5;
108
- else this.v[i] = value[i] / this.multiplicator;
109
- }
110
- this.update();
111
-
112
- }
113
-
114
- valueToHtml() {
115
-
116
- let i = this.lng, n=0, r = '<table style="width:100%;"><tr>'
117
- let w = 100 / this.lng
118
- let style = 'width:'+ w +'%;'//' text-align:center;'
119
- while(i--){
120
- if(n===this.lng-1) r += '<td style='+style+'>' + this.value[n] + '</td></tr></table>'
121
- else r += '<td style='+style+'>' + this.value[n] + '</td>'
122
- n++
123
- }
124
- return r
125
- }
126
-
127
- updateSVG () {
128
-
129
- if( this.line ) this.setSvg( this.c[3], 'd', this.makePath(), 0 );
130
-
131
- for(let i = 0; i<this.lng; i++ ){
132
-
133
- this.setSvg( this.c[3], 'height', this.v[i]*this.gh, i+2 );
134
- this.setSvg( this.c[3], 'y', 14 + (this.gh - this.v[i]*this.gh), i+2 );
135
- if( this.neg ) this.value[i] = ( ((this.v[i]*2)-1) * this.multiplicator ).toFixed( this.precision ) * 1;
136
- else this.value[i] = ( (this.v[i] * this.multiplicator) ).toFixed( this.precision ) * 1;
137
-
138
- }
139
-
140
- //this.c[2].textContent = this.value;
141
- this.c[2].innerHTML = this.valueToHtml();
142
-
143
- }
144
-
145
- testZone ( e ) {
146
-
147
- let l = this.local;
148
- if( l.x === -1 && l.y === -1 ) return '';
149
-
150
- let i = this.lng;
151
- let t = this.tmp;
152
-
153
- if( l.y>this.top && l.y<this.h-20 ){
154
- while( i-- ){
155
- if( l.x>t[i][0] && l.x<t[i][2] ) return i;
156
- }
157
- }
158
-
159
- return ''
160
-
161
- }
162
-
163
- mode ( n, name ) {
164
-
165
- if( n === this.cMode[name] ) return false;
166
-
167
- let a;
168
-
169
- switch(n){
170
- case 0: a=0.3; break;
171
- case 1: a=0.6; break;
172
- case 2: a=1; break;
173
- }
174
-
175
- this.reset();
176
-
177
- this.setSvg( this.c[3], 'fill-opacity', a, name + 2 );
178
- this.cMode[name] = n;
179
-
180
- return true;
181
-
182
-
183
-
184
- }
185
-
186
- // ----------------------
187
- // EVENTS
188
- // ----------------------
189
-
190
- reset () {
191
-
192
- let nup = false;
193
- //this.isDown = false;
194
-
195
- let i = this.lng;
196
- while(i--){
197
- if( this.cMode[i] !== 0 ){
198
- this.cMode[i] = 0;
199
- this.setSvg( this.c[3], 'fill-opacity', 0.3, i + 2 );
200
- nup = true;
201
- }
202
- }
203
-
204
- return nup;
205
-
206
- }
207
-
208
- mouseup ( e ) {
209
-
210
- this.isDown = false;
211
- if( this.current !== -1 ) return this.reset();
212
-
213
- }
214
-
215
- mousedown ( e ) {
216
-
217
- this.isDown = true;
218
- return this.mousemove( e );
219
-
220
- }
221
-
222
- mousemove ( e ) {
223
-
224
- let nup = false;
225
-
226
- let name = this.testZone(e);
227
-
228
- if( name === '' ){
229
-
230
- nup = this.reset();
231
- //this.cursor();
232
-
233
- } else {
234
-
235
- nup = this.mode( this.isDown ? 2 : 1, name );
236
- //this.cursor( this.current !== -1 ? 'move' : 'pointer' );
237
- if(this.isDown){
238
- this.v[name] = this.clamp( 1 - (( e.clientY - this.zone.y - this.top - 10 ) / this.gh) , 0, 1 );
239
- this.update( true );
240
- }
241
-
242
- }
243
-
244
- return nup;
245
-
246
- }
247
-
248
- // ----------------------
249
-
250
- update ( up ) {
251
-
252
- this.updateSVG();
253
-
254
- if( up ) this.send();
255
-
256
- }
257
-
258
- makePath () {
259
-
260
- let p = "", h, w, wn, wm, ow, oh;
261
- //let g = this.iw*0.5
262
-
263
- for(let i = 0; i<this.lng; i++ ){
264
-
265
- h = 14 + (this.gh - this.v[i]*this.gh);
266
- w = (14 + (i*this.iw) + (i*4));
267
-
268
- wm = w + this.iw*0.5;
269
- wn = w + this.iw;
270
-
271
- if(i===0) p+='M '+w+' '+ h + ' T ' + wm +' '+ h;
272
- else p += ' C ' + ow +' '+ oh + ',' + w +' '+ h + ',' + wm +' '+ h;
273
- if(i === this.lng-1) p+=' T ' + wn +' '+ h;
274
-
275
- ow = wn
276
- oh = h
277
-
278
- }
279
-
280
- return p;
281
-
282
- }
283
-
284
- rSize () {
285
-
286
- super.rSize();
287
-
288
- let s = this.s;
289
- if( this.c[1] !== undefined ) s[1].width = this.w + 'px';
290
- s[3].width = this.w + 'px';
291
-
292
- let gw = this.w - 28;
293
- let iw = ((gw-(4*(this.lng-1)))/this.lng);
294
-
295
- let t = [];
296
-
297
- s[2].width = gw + 'px'
298
-
299
- for( let i = 0; i < this.lng; i++ ){
300
-
301
- t[i] = [ 14 + (i*iw) + (i*4), iw ];
302
- t[i][2] = t[i][0] + t[i][1];
303
-
304
- }
305
-
306
- this.tmp = t;
307
-
308
- }
309
-
310
- }