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.
- package/README.md +57 -0
- package/build/uil.js +7040 -4199
- package/build/uil.min.js +6 -4
- package/build/uil.module.js +7200 -2761
- package/examples/js/BufferGeometryUtils.js +921 -0
- package/examples/js/SimplexNoise.js +324 -0
- package/examples/js/controls/OrbitControls.js +1215 -0
- package/examples/js/controls/OrbitControls_.js +1042 -0
- package/examples/js/libs/sea3d.min.js +373 -0
- package/examples/js/libs/three.min.js +6 -0
- package/examples/js/math.js +447 -0
- package/examples/js/objects/Landscape.js +778 -0
- package/examples/js/objects/Lensflare.js +372 -0
- package/examples/js/objects/SuperSky.js +297 -0
- package/examples/js/objects/Water.js +329 -0
- package/package.json +56 -54
- package/src/Uil.js +2 -17
- package/src/Uil_dev.js +15 -0
- package/src/core/Gui.js +601 -299
- package/src/core/Proto.js +490 -220
- package/src/core/Roots.js +864 -0
- package/src/core/Tools.js +591 -140
- package/src/core/V2.js +131 -0
- package/src/core/add.js +52 -57
- package/src/proto/Bool.js +117 -52
- package/src/proto/Button.js +286 -146
- package/src/proto/Circular.js +162 -130
- package/src/proto/Color.js +331 -289
- package/src/proto/Empty.js +15 -0
- package/src/proto/Fps.js +232 -159
- package/src/proto/Graph.js +310 -0
- package/src/proto/Grid.js +297 -0
- package/src/proto/Group.js +334 -160
- package/src/proto/Item.js +120 -0
- package/src/proto/Joystick.js +159 -185
- package/src/proto/Knob.js +210 -91
- package/src/proto/List.js +661 -249
- package/src/proto/Numeric.js +329 -162
- package/src/proto/Pad2D.js +268 -0
- package/src/proto/Rubric.js +0 -0
- package/src/proto/Select.js +178 -0
- package/src/proto/Selector.js +13 -0
- package/src/proto/Slide.js +191 -185
- package/src/proto/TextInput.js +149 -59
- package/src/proto/Title.js +40 -31
package/src/proto/Fps.js
CHANGED
|
@@ -1,254 +1,327 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Proto } from '../core/Proto';
|
|
1
|
+
import { Roots } from '../core/Roots.js';
|
|
2
|
+
import { Proto } from '../core/Proto.js';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export class Fps extends Proto {
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
constructor( o = {} ) {
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
super( o );
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
this.round = Math.round;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
this.hplus = 50;
|
|
12
|
+
//this.autoHeight = true;
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
this.baseH = this.h;
|
|
15
|
+
this.hplus = o.hplus || 50;
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
this.pa3 = [];
|
|
17
|
+
this.res = o.res || 40;
|
|
18
|
+
this.l = 1;
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
this.c[0].style.pointerEvents = 'auto';
|
|
27
|
+
// this.divid = [ 100, 100, 100 ];
|
|
28
|
+
// this.multy = [ 30, 30, 30 ];
|
|
34
29
|
|
|
35
|
-
|
|
30
|
+
this.adding = o.adding || false;
|
|
36
31
|
|
|
37
|
-
|
|
32
|
+
this.range = o.range || [ 165, 100, 100 ];
|
|
38
33
|
|
|
39
|
-
|
|
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
|
-
|
|
45
|
-
|
|
36
|
+
this.values = [];
|
|
37
|
+
this.points = [];
|
|
38
|
+
this.textDisplay = [];
|
|
46
39
|
|
|
40
|
+
if(!this.custom){
|
|
47
41
|
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
this.now = Roots.getTime()
|
|
43
|
+
this.startTime = 0;//this.now()
|
|
44
|
+
this.prevTime = 0;//this.startTime;
|
|
45
|
+
this.frames = 0;
|
|
50
46
|
|
|
51
|
-
|
|
47
|
+
this.ms = 0;
|
|
48
|
+
this.fps = 0;
|
|
49
|
+
this.mem = 0;
|
|
50
|
+
this.mm = 0;
|
|
52
51
|
|
|
53
|
-
|
|
52
|
+
this.isMem = ( self.performance && self.performance.memory ) ? true : false;
|
|
54
53
|
|
|
55
|
-
|
|
54
|
+
// this.divid = [ 100, 200, 1 ];
|
|
55
|
+
// this.multy = [ 30, 30, 30 ];
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
this.startTime = this.now()
|
|
59
|
-
this.prevTime = this.startTime;
|
|
60
|
-
this.frames = 0
|
|
57
|
+
if( this.isMem ){
|
|
61
58
|
|
|
62
|
-
|
|
59
|
+
this.names.push('MEM');
|
|
60
|
+
cc.push('0,255,255');
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
this.fps = 0;
|
|
66
|
-
this.mem = 0;
|
|
67
|
-
this.mm = 0;
|
|
62
|
+
}
|
|
68
63
|
|
|
69
|
-
|
|
64
|
+
this.txt = o.name || 'Fps'
|
|
70
65
|
|
|
71
|
-
|
|
66
|
+
}
|
|
72
67
|
|
|
73
|
-
this.init();
|
|
74
68
|
|
|
75
|
-
|
|
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
|
-
|
|
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
|
-
|
|
77
|
+
if( this.radius !== 0 ) panelCss += 'border-radius:' + this.radius+'px;';
|
|
83
78
|
|
|
84
|
-
|
|
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
|
-
|
|
97
|
-
|
|
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
|
-
|
|
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
|
-
|
|
99
|
+
this.isShow = false;
|
|
104
100
|
|
|
105
|
-
|
|
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
|
-
|
|
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
|
-
|
|
114
|
+
let j = 0;
|
|
134
115
|
|
|
135
|
-
|
|
116
|
+
for( j=0; j<this.names.length; j++ ){
|
|
136
117
|
|
|
137
|
-
|
|
138
|
-
|
|
118
|
+
let base = [];
|
|
119
|
+
let i = this.res+1;
|
|
120
|
+
while( i-- ) base.push(50);
|
|
139
121
|
|
|
140
|
-
|
|
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
|
-
|
|
143
|
-
this.pa2.push( 8.5 + this.round( ( 1 - (this.ms / 200)) * 30 ) );
|
|
129
|
+
}
|
|
144
130
|
|
|
145
|
-
|
|
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.
|
|
150
|
-
this.pa3.push( 8.5 + this.round( ( 1 - this.mm) * 30 ) );
|
|
137
|
+
this.init();
|
|
151
138
|
|
|
152
|
-
|
|
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
|
-
|
|
149
|
+
if( this.isShow ) this.close();
|
|
150
|
+
else this.open();
|
|
160
151
|
|
|
161
|
-
|
|
152
|
+
}
|
|
162
153
|
|
|
163
|
-
|
|
154
|
+
// ----------------------
|
|
164
155
|
|
|
156
|
+
/*mode: function ( mode ) {
|
|
165
157
|
|
|
166
|
-
|
|
167
|
-
else if( this.isUI ) this.main.calc( this.hplus );
|
|
158
|
+
let s = this.s;
|
|
168
159
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
|
|
174
|
+
}
|
|
175
|
+
},*/
|
|
174
176
|
|
|
175
|
-
|
|
177
|
+
tick ( v ) {
|
|
176
178
|
|
|
177
|
-
|
|
179
|
+
this.values = v;
|
|
180
|
+
if( !this.isShow ) return;
|
|
181
|
+
this.drawGraph();
|
|
182
|
+
this.upText();
|
|
178
183
|
|
|
179
|
-
|
|
184
|
+
}
|
|
180
185
|
|
|
181
|
-
|
|
186
|
+
makePath ( point ) {
|
|
182
187
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
-
|
|
191
|
-
this.c[1].textContent = 'FPS';
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
+
}
|
|
194
195
|
|
|
195
|
-
|
|
196
|
+
upText ( val ) {
|
|
196
197
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
-
|
|
206
|
+
let svg = this.c[2];
|
|
207
|
+
let i = this.names.length, v, old = 0, n = 0;
|
|
207
208
|
|
|
208
|
-
|
|
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
|
-
|
|
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
|
-
|
|
216
|
-
|
|
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
|
-
|
|
258
|
+
if( !this.custom ) Roots.removeListen( this );
|
|
219
259
|
|
|
220
|
-
|
|
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
|
-
|
|
273
|
+
end () {
|
|
223
274
|
|
|
224
|
-
|
|
225
|
-
this.
|
|
275
|
+
let time = this.now();
|
|
276
|
+
this.ms = time - this.startTime;
|
|
226
277
|
|
|
227
|
-
|
|
278
|
+
this.frames ++;
|
|
228
279
|
|
|
229
|
-
|
|
230
|
-
var heapSizeLimit = performance.memory.jsHeapSizeLimit;
|
|
280
|
+
if ( time > this.prevTime + 1000 ) {
|
|
231
281
|
|
|
232
|
-
this.
|
|
282
|
+
this.fps = this.round( ( this.frames * 1000 ) / ( time - this.prevTime ) );
|
|
233
283
|
|
|
234
|
-
this.
|
|
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
|
-
|
|
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
|
-
|
|
310
|
+
if( !this.custom ) this.startTime = this.end();
|
|
311
|
+
|
|
312
|
+
}
|
|
244
313
|
|
|
245
|
-
|
|
246
|
-
}
|
|
314
|
+
rSize () {
|
|
247
315
|
|
|
248
|
-
|
|
316
|
+
let s = this.s;
|
|
317
|
+
let w = this.w;
|
|
249
318
|
|
|
250
|
-
|
|
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
|
+
}
|