uil 4.0.0 → 4.0.1

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 (43) hide show
  1. package/README.md +1 -1
  2. package/package.json +2 -5
  3. package/examples/js/BufferGeometryUtils.js +0 -921
  4. package/examples/js/SimplexNoise.js +0 -324
  5. package/examples/js/controls/OrbitControls.js +0 -1215
  6. package/examples/js/controls/OrbitControls_.js +0 -1042
  7. package/examples/js/libs/sea3d.min.js +0 -373
  8. package/examples/js/libs/three.min.js +0 -6
  9. package/examples/js/math.js +0 -447
  10. package/examples/js/objects/Landscape.js +0 -778
  11. package/examples/js/objects/Lensflare.js +0 -372
  12. package/examples/js/objects/SuperSky.js +0 -297
  13. package/examples/js/objects/Water.js +0 -329
  14. package/src/Uil.js +0 -6
  15. package/src/Uil_dev.js +0 -15
  16. package/src/core/Gui.js +0 -807
  17. package/src/core/Proto.js +0 -679
  18. package/src/core/Roots.js +0 -864
  19. package/src/core/Tools.js +0 -830
  20. package/src/core/V2.js +0 -131
  21. package/src/core/add.js +0 -85
  22. package/src/polyfills.js +0 -85
  23. package/src/proto/Bool.js +0 -147
  24. package/src/proto/Button.js +0 -357
  25. package/src/proto/Circular.js +0 -230
  26. package/src/proto/Color.js +0 -411
  27. package/src/proto/Empty.js +0 -15
  28. package/src/proto/Fps.js +0 -327
  29. package/src/proto/Graph.js +0 -310
  30. package/src/proto/Grid.js +0 -297
  31. package/src/proto/Group.js +0 -430
  32. package/src/proto/Item.js +0 -120
  33. package/src/proto/Joystick.js +0 -241
  34. package/src/proto/Knob.js +0 -262
  35. package/src/proto/List.js +0 -789
  36. package/src/proto/Numeric.js +0 -417
  37. package/src/proto/Pad2D.js +0 -268
  38. package/src/proto/Rubric.js +0 -0
  39. package/src/proto/Select.js +0 -178
  40. package/src/proto/Selector.js +0 -13
  41. package/src/proto/Slide.js +0 -267
  42. package/src/proto/TextInput.js +0 -181
  43. package/src/proto/Title.js +0 -61
@@ -1,357 +0,0 @@
1
- import { Proto } from '../core/Proto.js';
2
-
3
- export class Button extends Proto {
4
-
5
- constructor( o = {} ) {
6
-
7
- super( o )
8
-
9
- this.value = o.value || '';
10
-
11
- this.values = o.value || this.txt
12
- if( o.values ) this.values = o.values
13
-
14
-
15
-
16
- this.onName = o.onName || '';
17
-
18
- this.on = false;
19
-
20
- this.customSize = o.forceWidth || -1;
21
-
22
- if( typeof this.values === 'string' ) this.values = [ this.values ];
23
-
24
- this.isDown = false
25
- this.neverlock = true
26
- this.isLoadButton = o.loader || false
27
- this.isDragButton = o.drag || false
28
- this.res = 0
29
-
30
- if( this.isDragButton ) this.isLoadButton = true
31
-
32
- this.lng = this.values.length;
33
- this.tmp = []
34
- this.stat = []
35
-
36
- let sel, cc = this.colors;
37
-
38
- for( let i = 0; i < this.lng; i++ ){
39
-
40
- sel = false
41
- if( this.values[i] === this.value && this.isSelectable ) sel = true
42
-
43
- this.c[i+2] = this.dom( 'div', this.css.txt + this.css.button + 'top:1px; height:'+(this.h-2)+'px; border:'+cc.borderSize+'px solid '+cc.border+'; border-radius:'+this.radius+'px;' );
44
- this.c[i+2].style.background = sel ? cc.select : cc.button
45
- this.c[i+2].style.color = sel ? cc.textSelect : cc.text
46
- this.c[i+2].innerHTML = this.values[i];
47
- this.stat[i] = sel ? 3:1;
48
-
49
- }
50
-
51
- if( !o.value || !o.values ){
52
- if( this.c[1] !== undefined ) this.c[1].textContent = '';
53
- this.p = o.p !== undefined ? o.p : 0
54
- } else {
55
- if( !this.txt ) this.p = 0
56
- }
57
-
58
- //
59
-
60
- if( this.isLoadButton ) this.initLoader();
61
- if( this.isDragButton ){
62
- this.lng ++;
63
- this.initDrager();
64
- }
65
-
66
- if( this.onName !== '' ) this.values[0] = this.on;
67
-
68
- this.init();
69
-
70
- }
71
-
72
- onOff ( ){
73
-
74
- this.on = !this.on;
75
- this.c[2].innerHTML = this.on ? this.onName : this.txt
76
-
77
- }
78
-
79
- testZone ( e ) {
80
-
81
- let l = this.local;
82
- if( l.x === -1 && l.y === -1 ) return -1
83
-
84
- let i = this.lng
85
- let t = this.tmp
86
-
87
- while( i-- ){
88
- if( l.x>t[i][0] && l.x<t[i][2] ) return i
89
- }
90
-
91
- return -1
92
-
93
- }
94
-
95
- // ----------------------
96
- // EVENTS
97
- // ----------------------
98
-
99
- mouseup ( e ) {
100
-
101
- if( !this.isDown ) return false
102
-
103
- this.isDown = false
104
- if( this.res !== -1 ){
105
- if( this.value === this.values[this.res] && this.unselectable ) this.value = ''
106
- else this.value = this.values[this.res]
107
- if( !this.isLoadButton ) this.send()
108
- }
109
-
110
- return this.mousemove( e )
111
-
112
- }
113
-
114
- mousedown ( e ) {
115
-
116
- if( this.isDown ) return false
117
- this.isDown = true
118
- return this.mousemove( e )
119
-
120
- }
121
-
122
- mousemove ( e ) {
123
-
124
- let up = false
125
- this.res = this.testZone( e )
126
-
127
- if( this.res !== -1 ){
128
- this.cursor('pointer')
129
- up = this.modes( this.isDown ? 3 : 2, this.res )
130
- } else {
131
- up = this.reset()
132
- }
133
-
134
- return up
135
-
136
- }
137
-
138
- // ----------------------
139
-
140
- modes ( N = 1, id = -1 ) {
141
-
142
- let i = this.lng, w, n, r = false
143
-
144
- while( i-- ){
145
-
146
- n = N
147
- w = this.isSelectable ? this.values[ i ] === this.value : false
148
-
149
- if( i === id ){
150
- if( w && n === 2 ) n = 3
151
- } else {
152
- n = 1
153
- if( w ) n = 4
154
- }
155
-
156
- //if( this.mode( n, i ) ) r = true
157
- r = this.mode( n, i )
158
-
159
- }
160
-
161
- return r
162
-
163
- }
164
-
165
- mode ( n, id ) {
166
-
167
- let change = false;
168
- let cc = this.colors, s = this.s
169
- let i = id+2
170
-
171
- if( this.stat[id] !== n ){
172
-
173
- this.stat[id] = n;
174
-
175
- switch( n ){
176
-
177
- case 1: s[i].color = cc.text; s[i].background = cc.button; break;
178
- case 2: s[i].color = cc.textOver; s[i].background = cc.overoff; break;
179
- case 3: s[i].color = cc.textOver; s[i].background = cc.over; break;
180
- case 4: s[i].color = cc.textSelect; s[i].background = cc.select; break;
181
-
182
- }
183
-
184
- change = true;
185
-
186
- }
187
-
188
- return change
189
-
190
- }
191
-
192
- // ----------------------
193
-
194
- reset () {
195
-
196
- this.res = -1
197
- this.cursor()
198
- return this.modes()
199
-
200
- }
201
-
202
- // ----------------------
203
-
204
- dragover ( e ) {
205
-
206
- e.preventDefault();
207
-
208
- this.s[4].borderColor = this.colors.select;
209
- this.s[4].color = this.colors.select;
210
-
211
- }
212
-
213
- dragend ( e ) {
214
-
215
- e.preventDefault();
216
-
217
- this.s[4].borderColor = this.color.text;
218
- this.s[4].color = this.color.text;
219
-
220
- }
221
-
222
- drop ( e ) {
223
-
224
- e.preventDefault();
225
-
226
- this.dragend(e);
227
- this.fileSelect( e.dataTransfer.files[0] );
228
-
229
- }
230
-
231
- initDrager () {
232
-
233
- this.c[4] = this.dom( 'div', this.css.txt +' text-align:center; line-height:'+(this.h-8)+'px; border:1px dashed '+this.color.text+'; top:2px; height:'+(this.h-4)+'px; border-radius:'+this.radius+'px; pointer-events:auto;' );// cursor:default;
234
- this.c[4].textContent = 'DRAG';
235
-
236
- this.c[4].addEventListener( 'dragover', function(e){ this.dragover(e); }.bind(this), false );
237
- this.c[4].addEventListener( 'dragend', function(e){ this.dragend(e); }.bind(this), false );
238
- this.c[4].addEventListener( 'dragleave', function(e){ this.dragend(e); }.bind(this), false );
239
- this.c[4].addEventListener( 'drop', function(e){ this.drop(e); }.bind(this), false );
240
-
241
- //this.c[2].events = [ ];
242
- //this.c[4].events = [ 'dragover', 'dragend', 'dragleave', 'drop' ];
243
-
244
-
245
- }
246
-
247
- initLoader () {
248
-
249
- this.c[3] = this.dom( 'input', this.css.basic +'top:0px; opacity:0; height:'+(this.h)+'px; pointer-events:auto; cursor:pointer;' );//
250
- this.c[3].name = 'loader';
251
- this.c[3].type = "file";
252
-
253
- this.c[3].addEventListener( 'change', function(e){ this.fileSelect( e.target.files[0] ); }.bind(this), false );
254
- //this.c[3].addEventListener( 'mousedown', function(e){ }.bind(this), false );
255
-
256
- //this.c[2].events = [ ];
257
- //this.c[3].events = [ 'change', 'mouseover', 'mousedown', 'mouseup', 'mouseout' ];
258
-
259
- //this.hide = document.createElement('input');
260
-
261
- }
262
-
263
- fileSelect ( file ) {
264
-
265
- let dataUrl = [ 'png', 'jpg', 'mp4', 'webm', 'ogg' ];
266
- let dataBuf = [ 'sea', 'z', 'hex', 'bvh', 'BVH', 'glb' ];
267
-
268
- //if( ! e.target.files ) return;
269
-
270
- //let file = e.target.files[0];
271
-
272
- //this.c[3].type = "null";
273
- // console.log( this.c[4] )
274
-
275
- if( file === undefined ) return;
276
-
277
- let reader = new FileReader();
278
- let fname = file.name;
279
- let type = fname.substring(fname.lastIndexOf('.')+1, fname.length );
280
-
281
- if( dataUrl.indexOf( type ) !== -1 ) reader.readAsDataURL( file );
282
- else if( dataBuf.indexOf( type ) !== -1 ) reader.readAsArrayBuffer( file );//reader.readAsArrayBuffer( file );
283
- else reader.readAsText( file );
284
-
285
- // if( type === 'png' || type === 'jpg' || type === 'mp4' || type === 'webm' || type === 'ogg' ) reader.readAsDataURL( file );
286
- //else if( type === 'z' ) reader.readAsBinaryString( file );
287
- //else if( type === 'sea' || type === 'bvh' || type === 'BVH' || type === 'z') reader.readAsArrayBuffer( file );
288
- //else if( ) reader.readAsArrayBuffer( file );
289
- //else reader.readAsText( file );
290
-
291
- reader.onload = function (e) {
292
-
293
- if( this.callback ) this.callback( e.target.result, fname, type );
294
- //this.c[3].type = "file";
295
- //this.send( e.target.result );
296
- }.bind(this);
297
-
298
- }
299
-
300
- label ( string, n ) {
301
-
302
- n = n || 2;
303
- this.c[n].textContent = string;
304
-
305
- }
306
-
307
- icon ( string, y = 0, n = 2 ) {
308
-
309
- //if(y) this.s[n].margin = ( y ) +'px 0px';
310
- this.s[n].padding = ( y ) +'px 0px';
311
- this.c[n].innerHTML = string;
312
-
313
- return this
314
-
315
- }
316
-
317
- rSize () {
318
-
319
- super.rSize();
320
-
321
- let s = this.s;
322
- let w = this.sb;
323
- let d = this.sa;
324
-
325
- let i = this.lng;
326
- let dc = 3;
327
- let size = Math.floor( ( w-(dc*(i-1)) ) / i );
328
-
329
- if( this.customSize !== -1 ){
330
- size = this.customSize
331
- // d = (this.s-size)*0.5
332
-
333
- }
334
-
335
- while( i-- ){
336
-
337
- this.tmp[i] = [ Math.floor( d + ( size * i ) + ( dc * i )), size ];
338
- this.tmp[i][2] = this.tmp[i][0] + this.tmp[i][1];
339
-
340
- s[i+2].left = this.tmp[i][0] + 'px';
341
- s[i+2].width = this.tmp[i][1] + 'px';
342
-
343
- }
344
-
345
- if( this.isDragButton ){
346
- s[4].left = (d+size+dc) + 'px';
347
- s[4].width = size + 'px';
348
- }
349
-
350
- if( this.isLoadButton ){
351
- s[3].left = d + 'px';
352
- s[3].width = size + 'px';
353
- }
354
-
355
- }
356
-
357
- }
@@ -1,230 +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 Circular 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
- this.minw = this.w
17
- this.diam = o.diam || this.w
18
-
19
- this.setTypeNumber( o )
20
-
21
- this.twoPi = Tools.TwoPI
22
- this.pi90 = Tools.pi90
23
-
24
- this.offset = new V2()
25
-
26
- this.h = o.h || this.w + 10
27
- this.top = 0
28
-
29
- this.c[0].style.width = this.w +'px'
30
-
31
- if(this.c[1] !== undefined) {
32
-
33
- this.c[1].style.width = '100%'
34
- this.c[1].style.justifyContent = 'center'
35
- this.top = 10
36
- this.h += 10
37
-
38
- }
39
-
40
-
41
-
42
- this.percent = 0
43
- this.cmode = 0
44
- let cc = this.colors
45
-
46
- this.c[2] = this.dom( 'div', this.css.txt + 'justify-content:center; top:'+(this.h-20)+'px; width:100%; color:'+ cc.text )
47
-
48
- // svg
49
-
50
- this.c[3] = this.getCircular()
51
-
52
- this.setSvg( this.c[3], 'stroke', cc.back, 0 )
53
- this.setSvg( this.c[3], 'd', this.makePath(), 1 )
54
- this.setSvg( this.c[3], 'stroke', cc.text, 1 )
55
-
56
- this.setSvg( this.c[3], 'viewBox', '0 0 '+this.diam+' '+this.diam )
57
- this.setCss( this.c[3], { width:this.diam, height:this.diam, left:0, top:this.top })
58
-
59
- this.init()
60
- this.update()
61
-
62
- }
63
-
64
- mode ( mode ) {
65
-
66
- if( this.cmode === mode ) return false;
67
-
68
- let cc = this.colors
69
- let color
70
-
71
- switch( mode ){
72
- case 0: // base
73
-
74
- this.s[2].color = cc.text;
75
- this.setSvg( this.c[3], 'stroke', cc.back, 0);
76
- color = this.model > 0 ? Tools.pack( Tools.lerpColor( Tools.unpack( Tools.ColorLuma( cc.text, -0.75) ), Tools.unpack( cc.text ), this.percent ) ) : cc.text;
77
- this.setSvg( this.c[3], 'stroke', color, 1 );
78
-
79
- break;
80
- case 1: // down
81
-
82
- this.s[2].color = cc.textOver;
83
- this.setSvg( this.c[3], 'stroke', cc.backoff, 0);
84
- color = this.model > 0 ? Tools.pack( Tools.lerpColor( Tools.unpack( Tools.ColorLuma( cc.text, -0.75) ), Tools.unpack( cc.text ), this.percent ) ) : cc.textOver
85
- this.setSvg( this.c[3], 'stroke', color, 1 );
86
-
87
- break;
88
- }
89
-
90
- this.cmode = mode;
91
- return true;
92
-
93
- }
94
-
95
- reset () {
96
-
97
- this.isDown = false;
98
-
99
- }
100
-
101
- testZone ( e ) {
102
-
103
- let l = this.local;
104
- if( l.x === -1 && l.y === -1 ) return '';
105
-
106
- if( l.y <= this.c[ 1 ].offsetHeight ) return 'title';
107
- else if ( l.y > this.h - this.c[ 2 ].offsetHeight ) return 'text';
108
- else return 'circular';
109
-
110
- }
111
-
112
- // ----------------------
113
- // EVENTS
114
- // ----------------------
115
-
116
- mouseup ( e ) {
117
-
118
- this.isDown = false;
119
- this.sendEnd();
120
- return this.mode(0);
121
-
122
- }
123
-
124
- mousedown ( e ) {
125
-
126
- this.isDown = true;
127
- this.old = this.value;
128
- this.oldr = null;
129
- this.mousemove( e );
130
- return this.mode(1);
131
-
132
- }
133
-
134
- mousemove ( e ) {
135
-
136
- if( !this.isDown ) return;
137
-
138
- //console.log('over')
139
-
140
- let off = this.offset;
141
- off.x = (this.w*0.5) - ( e.clientX - this.zone.x );
142
- off.y = (this.diam*0.5) - ( e.clientY - this.zone.y - this.top );
143
-
144
- this.r = off.angle() - this.pi90;
145
- this.r = (((this.r%this.twoPi)+this.twoPi)%this.twoPi);
146
-
147
- if( this.oldr !== null ){
148
-
149
- let dif = this.r - this.oldr;
150
- this.r = Math.abs(dif) > Math.PI ? this.oldr : this.r;
151
-
152
- if( dif > 6 ) this.r = 0;
153
- if( dif < -6 ) this.r = this.twoPi;
154
-
155
- }
156
-
157
- let steps = 1 / this.twoPi;
158
- let value = this.r * steps;
159
-
160
- let n = ( ( this.range * value ) + this.min ) - this.old;
161
-
162
- if(n >= this.step || n <= this.step){
163
- n = ~~ ( n / this.step );
164
- this.value = this.numValue( this.old + ( n * this.step ) );
165
- this.update( true );
166
- this.old = this.value;
167
- this.oldr = this.r;
168
- }
169
-
170
- }
171
-
172
- wheel ( e ) {
173
-
174
- let name = this.testZone( e );
175
-
176
- if( name === 'circular' ) {
177
-
178
- let v = this.value - this.step * e.delta;
179
-
180
- if ( v > this.max ) {
181
- v = this.isCyclic ? this.min : this.max;
182
- } else if ( v < this.min ) {
183
- v = this.isCyclic ? this.max : this.min;
184
- }
185
-
186
- this.setValue( v );
187
- this.old = v;
188
- this.update( true );
189
-
190
- return true;
191
-
192
- }
193
- return false;
194
-
195
- }
196
-
197
- // ----------------------
198
-
199
- makePath () {
200
-
201
- let r = 40;
202
- let d = 24;
203
- let a = this.percent * this.twoPi - 0.001;
204
- let x2 = (r + r * Math.sin(a)) + d;
205
- let y2 = (r - r * Math.cos(a)) + d;
206
- let big = a > Math.PI ? 1 : 0;
207
- return "M " + (r+d) + "," + d + " A " + r + "," + r + " 0 " + big + " 1 " + x2 + "," + y2;
208
-
209
- }
210
-
211
- update ( up ) {
212
-
213
- this.c[2].textContent = this.value;
214
- this.percent = ( this.value - this.min ) / this.range;
215
-
216
- this.setSvg( this.c[3], 'd', this.makePath(), 1 );
217
-
218
- if ( this.model > 0 ) {
219
-
220
- let cc = this.colors
221
- let color = Tools.pack( Tools.lerpColor( Tools.unpack( Tools.ColorLuma( cc.text, -0.75) ), Tools.unpack( cc.text ), this.percent ) );
222
- this.setSvg( this.c[3], 'stroke', color, 1 );
223
-
224
- }
225
-
226
- if( up ) this.send();
227
-
228
- }
229
-
230
- }