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/core/Proto.js DELETED
@@ -1,679 +0,0 @@
1
-
2
- import { Roots } from './Roots.js';
3
- import { Tools } from './Tools.js';
4
- import { V2 } from './V2.js';
5
-
6
- /**
7
- * @author lth / https://github.com/lo-th
8
- */
9
-
10
- export class Proto {
11
-
12
- constructor( o = {} ) {
13
-
14
-
15
-
16
- // disable mouse controle
17
- this.lock = o.lock || false;
18
-
19
- // for button
20
- this.neverlock = false
21
-
22
- // only simple space
23
- this.isSpace = o.isSpace || false
24
-
25
- // if is on gui or group
26
- this.main = o.main || null;
27
- this.isUI = o.isUI || false;
28
- this.group = o.group || null;
29
-
30
- this.isListen = false;
31
-
32
-
33
- //this.parentGroup = null;
34
-
35
- //if( o.select !== undefined ) o.selectable = o.select
36
- this.isSelectable = o.selectable !== undefined ? o.selectable : false
37
- this.unselectable = o.unselect !== undefined ? o.unselect : this.isSelectable
38
-
39
-
40
- this.ontop = o.ontop ? o.ontop : false; // 'beforebegin' 'afterbegin' 'beforeend' 'afterend'
41
-
42
- this.css = this.main ? this.main.css : Tools.css
43
-
44
- this.colors = Tools.defineColor( o, this.main ? ( this.group ? this.group.colors : this.main.colors ) : Tools.colors )
45
-
46
- this.svgs = Tools.svgs
47
-
48
- this.zone = { x:0, y:0, w:0, h:0 }
49
- this.local = new V2().neg()
50
-
51
- this.isCanvasOnly = false
52
- this.isSelect = false
53
-
54
- // percent of title
55
- this.p = o.p !== undefined ? o.p : Tools.size.p;
56
-
57
- this.w = this.isUI ? this.main.size.w : Tools.size.w;
58
- if( o.w !== undefined ) this.w = o.w;
59
-
60
- this.h = this.isUI ? this.main.size.h : Tools.size.h;
61
- if( o.h !== undefined ) this.h = o.h;
62
- if( !this.isSpace ) this.h = this.h < 11 ? 11 : this.h;
63
- else this.lock = true
64
-
65
-
66
- this.autoWidth = o.auto || true;// auto width or flex
67
- this.isOpen = false// open statu
68
-
69
- // radius for toolbox
70
- this.radius = o.radius || this.colors.radius;
71
-
72
- this.transition = o.transition || Tools.transition
73
-
74
- // only for number
75
- this.isNumber = false;
76
- this.noNeg = o.noNeg || false;
77
- this.allEqual = o.allEqual || false;
78
-
79
- // only most simple
80
- this.mono = false;
81
-
82
- // stop listening for edit slide text
83
- this.isEdit = false;
84
-
85
- // no title
86
- this.simple = o.simple || false;
87
- if( this.simple ) this.sa = 0;
88
-
89
-
90
- // define obj size
91
- this.setSize( this.w )
92
-
93
- // title size
94
- if( o.sa !== undefined ) this.sa = o.sa
95
- if( o.sb !== undefined ) this.sb = o.sb
96
- if( this.simple ) this.sb = this.w - this.sa
97
-
98
- // last number size for slide
99
- this.sc = o.sc === undefined ? 47 : o.sc
100
-
101
- // for listening object
102
- this.objectLink = null;
103
- this.isSend = false;
104
- this.val = null;
105
-
106
- this.txt = o.name || '';
107
- this.name = o.rename || this.txt;
108
- this.target = o.target || null;
109
-
110
- // callback
111
- this.callback = o.callback === undefined ? null : o.callback;
112
- this.endCallback = null;
113
- this.openCallback = o.openCallback === undefined ? null : o.openCallback;
114
- this.closeCallback = o.closeCallback === undefined ? null : o.closeCallback;
115
-
116
- // if no callback take one from group or gui
117
- if( this.callback === null && this.isUI && this.main.callback !== null ){
118
- this.callback = this.group ? this.group.callback : this.main.callback;
119
- }
120
-
121
- // elements
122
- this.c = [];
123
-
124
- // style
125
- this.s = [];
126
-
127
-
128
- //this.c[0] = Tools.dom( 'div', this.css.basic + this.css.button +'align-self:stretch; position:relative; height:20px; overflow:hidden;'); //float:left;
129
- //this.c[0] = Tools.dom( 'div', 'order: 1;' ); //
130
- this.useFlex = this.isUI ? this.main.useFlex : false
131
- let flexible = this.useFlex ? 'disply:flex; justify-content:center; align-items:center; text-align:center; flex: 1 100%;' : 'float:left;'
132
-
133
- this.c[0] = Tools.dom( 'div', this.css.basic + flexible + 'position:relative; height:20px;');
134
- //this.c[0] = Tools.dom( 'div', this.css.basic +'position:relative; height:20px; align-self: auto;');
135
-
136
-
137
- this.s[0] = this.c[0].style
138
-
139
- // bottom margin
140
- this.margin = o.margin || 1
141
- if( this.isUI && this.margin ){
142
- this.s[0].boxSizing = 'content-box'
143
- //this.s[0].marginBottom = this.margin + 'px';
144
- if( this.margin*0.5===Math.floor(this.margin*0.5) ){
145
- this.s[0].borderTop = (this.margin*0.5) + 'px solid transparent'
146
- this.s[0].borderBottom = (this.margin*0.5) + 'px solid transparent'
147
- } else {
148
- this.s[0].borderBottom = this.margin + 'px solid transparent'
149
- }
150
-
151
- }
152
-
153
- // with title
154
- if( !this.simple ){
155
- this.c[1] = Tools.dom( 'div', this.css.txt )
156
- this.s[1] = this.c[1].style
157
- this.c[1].textContent = this.name
158
- this.s[1].color = this.lock ? this.colors.titleoff : this.colors.title
159
- }
160
-
161
- if( o.pos ){
162
- this.s[0].position = 'absolute';
163
- for(let p in o.pos){
164
- this.s[0][p] = o.pos[p];
165
- }
166
- this.mono = true;
167
- }
168
-
169
-
170
-
171
-
172
- if( o.css ) this.s[0].cssText = o.css;
173
-
174
-
175
- }
176
-
177
- // ----------------------
178
- // make the node
179
- // ----------------------
180
-
181
- init() {
182
-
183
- this.zone.h = this.h;
184
- this.zone.w = this.w;
185
-
186
- let s = this.s; // style cache
187
- let c = this.c; // div cach
188
-
189
- s[0].height = this.h + 'px';
190
-
191
- if( this.isUI ) s[0].background = this.colors.background
192
-
193
- if(!this.autoWidth && this.useFlex ){
194
- s[0].flex = '1 0 auto'
195
- s[0].minWidth = this.minw+'px'
196
- s[0].textAlign = 'center'
197
- } else {
198
- if( this.isUI ) s[0].width = '100%'
199
- }
200
-
201
- //if( this.autoHeight ) s[0].transition = 'height 0.01s ease-out';
202
- if( c[1] !== undefined && this.autoWidth ){
203
- s[1] = c[1].style;
204
- s[1].height = (this.h-4) + 'px';
205
- s[1].lineHeight = (this.h-8) + 'px';
206
- }
207
-
208
- let frag = Tools.frag;
209
-
210
- for( let i = 1, lng = c.length; i !== lng; i++ ){
211
- if( c[i] !== undefined ) {
212
- frag.appendChild( c[i] );
213
- s[i] = c[i].style;
214
- }
215
- }
216
-
217
- let pp = this.target !== null ? this.target : ( this.isUI ? this.main.inner : document.body );
218
-
219
- if( this.ontop ) pp.insertAdjacentElement( 'afterbegin', c[0] );
220
- else pp.appendChild( c[0] );
221
-
222
- c[0].appendChild( frag );
223
-
224
- this.rSize()
225
-
226
- // ! solo proto
227
- if( !this.isUI ){
228
-
229
- this.c[0].style.pointerEvents = 'auto'
230
- Roots.add( this )
231
-
232
- }
233
-
234
-
235
- if( this.baseH && this.transition && this.isUI ){
236
- this.c[0].style.transition = 'height '+this.transition+'s ease-out';
237
- }
238
-
239
- }
240
-
241
- // from Tools
242
-
243
- dom( type, css, obj, dom, id ) {
244
-
245
- return Tools.dom( type, css, obj, dom, id );
246
-
247
- }
248
-
249
- setSvg( dom, type, value, id, id2 ) {
250
-
251
- Tools.setSvg( dom, type, value, id, id2 );
252
-
253
- }
254
-
255
- setCss( dom, css ) {
256
-
257
- Tools.setCss( dom, css );
258
-
259
- }
260
-
261
- clamp( value, min, max ) {
262
-
263
- return Tools.clamp( value, min, max );
264
-
265
- }
266
-
267
- getColorRing() {
268
-
269
- if( !Tools.colorRing ) Tools.makeColorRing();
270
- return Tools.clone( Tools.colorRing );
271
-
272
- }
273
-
274
- getJoystick( model ) {
275
-
276
- if( !Tools[ 'joystick_'+ model ] ) Tools.makeJoystick( model )
277
- return Tools.clone( Tools[ 'joystick_'+ model ] )
278
-
279
- }
280
-
281
- getCircular( model ) {
282
-
283
- if( !Tools.circular ) Tools.makeCircular( model )
284
- return Tools.clone( Tools.circular )
285
-
286
- }
287
-
288
- getKnob( model ) {
289
-
290
- if( !Tools.knob ) Tools.makeKnob( model )
291
- return Tools.clone( Tools.knob )
292
-
293
- }
294
-
295
- getPad2d( model ) {
296
-
297
- if( !Tools.pad2d ) Tools.makePad( model )
298
- return Tools.clone( Tools.pad2d )
299
-
300
- }
301
-
302
- // from Roots
303
-
304
- cursor( name ) {
305
-
306
- Roots.cursor( name );
307
-
308
- }
309
-
310
-
311
-
312
- /////////
313
-
314
- update() {}
315
-
316
- reset() {}
317
-
318
- /////////
319
-
320
- getDom() {
321
-
322
- return this.c[0]
323
-
324
- }
325
-
326
- uiout() {
327
-
328
- if( this.lock ) return;
329
-
330
- if(this.s) this.s[0].background = this.colors.background;
331
-
332
- }
333
-
334
- uiover() {
335
-
336
- if( this.lock ) return;
337
-
338
- if(this.s) this.s[0].background = this.colors.backgroundOver;
339
-
340
- }
341
-
342
- rename( s ) {
343
-
344
- if( this.c[1] !== undefined) this.c[1].textContent = s;
345
-
346
- }
347
-
348
- listen() {
349
-
350
- this.isListen = Roots.addListen( this );
351
- return this;
352
-
353
- }
354
-
355
- listening() {
356
-
357
- if( this.objectLink === null ) return;
358
- if( this.isSend ) return;
359
- if( this.isEdit ) return;
360
-
361
- this.setValue( this.objectLink[ this.val ] );
362
-
363
- }
364
-
365
- setValue( v ) {
366
-
367
- if( this.isNumber ) this.value = this.numValue( v );
368
- //else if( v instanceof Array && v.length === 1 ) v = v[0];
369
- else this.value = v;
370
- this.update();
371
-
372
- }
373
-
374
- // ----------------------
375
- // update every change
376
- // ----------------------
377
-
378
- onChange( f ) {
379
-
380
- if( this.isSpace ) return
381
- this.callback = f || null
382
- return this
383
-
384
- }
385
-
386
- // ----------------------
387
- // update only on end
388
- // ----------------------
389
-
390
- onFinishChange( f ) {
391
-
392
- if( this.isSpace ) return;
393
- this.callback = null
394
- this.endCallback = f
395
- return this
396
-
397
- }
398
-
399
- // ----------------------
400
- // event on open close
401
- // ----------------------
402
-
403
- onOpen( f ) {
404
-
405
- this.openCallback = f
406
- return this
407
-
408
- }
409
-
410
- onClose( f ) {
411
-
412
- this.closeCallback = f
413
- return this
414
-
415
- }
416
-
417
- // ----------------------
418
- // send back value
419
- // ----------------------
420
-
421
- send( v ) {
422
-
423
- v = v || this.value;
424
- if( v instanceof Array && v.length === 1 ) v = v[0];
425
-
426
- this.isSend = true
427
- if( this.objectLink !== null ) this.objectLink[ this.val ] = v
428
- if( this.callback ) this.callback( v, this.val )
429
- this.isSend = false
430
-
431
- }
432
-
433
- sendEnd( v ) {
434
-
435
- v = v || this.value;
436
- if( v instanceof Array && v.length === 1 ) v = v[0];
437
-
438
- if( this.endCallback ) this.endCallback( v );
439
- if( this.objectLink !== null ) this.objectLink[ this.val ] = v;
440
-
441
- }
442
-
443
- // ----------------------
444
- // clear node
445
- // ----------------------
446
-
447
- clear( nofull ) {
448
-
449
- if( this.isListen ) Roots.removeListen( this );
450
-
451
- Tools.clear( this.c[0] );
452
-
453
- if( !nofull ){
454
-
455
- if( this.target !== null ){
456
-
457
- if( this.group !== null ) this.group.clearOne( this );
458
- else this.target.removeChild( this.c[0] );
459
-
460
- } else {
461
-
462
- if( this.isUI ) this.main.clearOne( this );
463
- else document.body.removeChild( this.c[0] );
464
-
465
- }
466
-
467
- if( !this.isUI ) Roots.remove( this );
468
-
469
- }
470
-
471
- this.c = null;
472
- this.s = null;
473
- this.callback = null;
474
- this.target = null;
475
- this.isListen = false;
476
-
477
- }
478
-
479
- // ----------------------
480
- // change size
481
- // ----------------------
482
-
483
- getWidth() {
484
-
485
- let nw = Roots.getWidth( this )
486
- if(nw) this.w = nw
487
-
488
- }
489
-
490
- setSize( sx ) {
491
-
492
- if( !this.autoWidth ) return;
493
-
494
- this.w = sx;
495
-
496
- if( this.simple ){
497
- this.sb = this.w - this.sa
498
- } else {
499
- let pp = this.w * ( this.p / 100 )
500
- this.sa = Math.floor( pp + 10 )
501
- this.sb = Math.floor( this.w - pp - 20 )
502
- }
503
-
504
- }
505
-
506
- rSize() {
507
-
508
- if( !this.autoWidth ) return;
509
-
510
- if( !this.isUI ) this.s[0].width = this.w + 'px';
511
- if( !this.simple ) this.s[1].width = this.sa + 'px';
512
-
513
- }
514
-
515
- // ----------------------
516
- // for numeric value
517
- // ----------------------
518
-
519
- setTypeNumber( o ) {
520
-
521
- this.isNumber = true;
522
-
523
- this.value = 0;
524
- if( o.value !== undefined ){
525
- if( typeof o.value === 'string' ) this.value = o.value * 1;
526
- else this.value = o.value;
527
- }
528
-
529
- this.min = o.min === undefined ? -Infinity : o.min;
530
- this.max = o.max === undefined ? Infinity : o.max;
531
- this.precision = o.precision === undefined ? 2 : o.precision;
532
-
533
- let s;
534
-
535
- switch(this.precision){
536
- case 0: s = 1; break;
537
- case 1: s = 0.1; break;
538
- case 2: s = 0.01; break;
539
- case 3: s = 0.001; break;
540
- case 4: s = 0.0001; break;
541
- case 5: s = 0.00001; break;
542
- }
543
-
544
- this.step = o.step === undefined ? s : o.step;
545
- this.range = this.max - this.min;
546
- this.value = this.numValue( this.value );
547
-
548
- }
549
-
550
- numValue( n ) {
551
-
552
- if( this.noNeg ) n = Math.abs( n );
553
- return Math.min( this.max, Math.max( this.min, n ) ).toFixed( this.precision ) * 1;
554
-
555
- }
556
-
557
-
558
- // ----------------------
559
- // EVENTS DEFAULT
560
- // ----------------------
561
-
562
- handleEvent( e ) {
563
-
564
- if( this.lock ) return
565
-
566
- if( this.neverlock ) Roots.lock = false
567
-
568
- if( !this[e.type] ) return console.error(e.type, 'this type of event no existe !')
569
-
570
- return this[e.type](e)
571
-
572
- }
573
-
574
- wheel( e ) { return false; }
575
-
576
- mousedown( e ) { return false; }
577
-
578
- mousemove( e ) { return false; }
579
-
580
- mouseup( e ) { return false; }
581
-
582
- keydown( e ) { return false; }
583
-
584
- keyup( e ) { return false; }
585
-
586
-
587
- /*dragstart ( e ) { return false; }
588
- dragover ( e ) { return false; }
589
- dragenter ( e ) { return false; }
590
- dragleave ( e ) { return false; }
591
- dragend ( e ) { return false; }
592
- drop ( e ) { return false; }*/
593
-
594
-
595
- // ----------------------
596
- // object referency
597
- // ----------------------
598
-
599
- setReferency( obj, val ) {
600
-
601
- this.objectLink = obj
602
- this.val = val
603
-
604
- }
605
-
606
- display( v ) {
607
-
608
- v = v || false
609
- this.s[0].display = v ? (this.useFlex? 'flex':'block') : 'none'
610
-
611
- }
612
-
613
- // ----------------------
614
- // resize height
615
- // ----------------------
616
-
617
- open () {
618
-
619
- if( this.isOpen ) return;
620
- this.isOpen = true;
621
- if( this.openCallback ) this.openCallback()
622
-
623
- }
624
-
625
- close () {
626
-
627
- if( !this.isOpen ) return
628
- this.isOpen = false
629
- if( this.closeCallback ) this.closeCallback()
630
-
631
- }
632
-
633
- needZone() {
634
-
635
- Roots.needReZone = true
636
-
637
- }
638
-
639
- rezone() {
640
-
641
- Roots.needReZone = true
642
-
643
- }
644
-
645
- // ----------------------
646
- // INPUT
647
- // ----------------------
648
-
649
- select() {
650
-
651
- }
652
-
653
- unselect() {
654
-
655
- }
656
-
657
- setInput( Input ) {
658
-
659
- Roots.setInput( Input, this );
660
-
661
- }
662
-
663
- upInput( x, down ) {
664
-
665
- return Roots.upInput( x, down );
666
-
667
- }
668
-
669
- // ----------------------
670
- // special item
671
- // ----------------------
672
-
673
- selected( b ){
674
-
675
- this.isSelect = b || false
676
-
677
- }
678
-
679
- }