lexgui 0.4.0 → 0.4.2
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 +1 -1
- package/build/components/audio.js +9 -18
- package/build/components/nodegraph.js +84 -78
- package/build/lexgui.css +222 -218
- package/build/lexgui.js +1230 -1196
- package/build/lexgui.min.css +7 -1
- package/build/lexgui.min.js +1 -1
- package/build/lexgui.module.js +1230 -1198
- package/build/lexgui.module.min.js +1 -1
- package/changelog.md +27 -1
- package/package.json +28 -22
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# lexgui.js
|
|
2
2
|
|
|
3
|
-
**lexgui.js** is a lightweight JavaScript library
|
|
3
|
+
**lexgui.js** is a lightweight JavaScript library for building web interfaces. No bloated frameworks, no unnecessary complexity, just pure HTML, CSS, and JavaScript magic. It gives you an easy API for crafting dynamic, interactive editor interfaces without the headache of big libraries.
|
|
4
4
|
|
|
5
5
|
NPM Package: [npmjs.com/package/lexgui](https://www.npmjs.com/package/lexgui)
|
|
6
6
|
|
|
@@ -23,7 +23,13 @@ let Widget = LX.Widget;
|
|
|
23
23
|
|
|
24
24
|
Panel.prototype.addKnob = function( name, value, min, max, callback, options = {} ) {
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
if( value.constructor == Number )
|
|
27
|
+
{
|
|
28
|
+
value = LX.clamp( value, min, max );
|
|
29
|
+
value = options.precision ? LX.round( value, options.precision ) : value;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let widget = this._createWidget( Widget.KNOB, name, value, options );
|
|
27
33
|
|
|
28
34
|
widget.onGetValue = () => {
|
|
29
35
|
return innerKnobCircle.value;
|
|
@@ -35,15 +41,6 @@ Panel.prototype.addKnob = function( name, value, min, max, callback, options = {
|
|
|
35
41
|
|
|
36
42
|
let element = widget.domEl;
|
|
37
43
|
|
|
38
|
-
// Add reset functionality
|
|
39
|
-
if( widget.name ) {
|
|
40
|
-
Panel._add_reset_property( element.domName, function() {
|
|
41
|
-
this.style.display = "none";
|
|
42
|
-
innerSetValue( innerKnobCircle.iValue );
|
|
43
|
-
Panel._dispatch_event( innerKnobCircle, "change" );
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
44
|
const snapEnabled = ( options.snap && options.snap.constructor == Number );
|
|
48
45
|
const ticks = [];
|
|
49
46
|
if( snapEnabled )
|
|
@@ -77,13 +74,6 @@ Panel.prototype.addKnob = function( name, value, min, max, callback, options = {
|
|
|
77
74
|
let knobMarker = document.createElement( 'div' );
|
|
78
75
|
knobMarker.className = "knobmarker";
|
|
79
76
|
innerKnobCircle.appendChild( knobMarker );
|
|
80
|
-
|
|
81
|
-
if( value.constructor == Number )
|
|
82
|
-
{
|
|
83
|
-
value = LX.clamp( value, min, max );
|
|
84
|
-
value = options.precision ? LX.round( value, options.precision ) : value;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
77
|
innerKnobCircle.value = innerKnobCircle.iValue = value;
|
|
88
78
|
|
|
89
79
|
let mustSnap = false;
|
|
@@ -202,7 +192,8 @@ Panel.prototype.addKnob = function( name, value, min, max, callback, options = {
|
|
|
202
192
|
element.appendChild( container );
|
|
203
193
|
|
|
204
194
|
// Remove branch padding and margins
|
|
205
|
-
if( !widget.name )
|
|
195
|
+
if( !widget.name )
|
|
196
|
+
{
|
|
206
197
|
element.className += " noname";
|
|
207
198
|
container.style.width = "100%";
|
|
208
199
|
}
|
|
@@ -83,7 +83,7 @@ class GraphEditor {
|
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
85
|
* @param {*} options
|
|
86
|
-
*
|
|
86
|
+
*
|
|
87
87
|
*/
|
|
88
88
|
|
|
89
89
|
constructor( area, options = {} ) {
|
|
@@ -93,7 +93,16 @@ class GraphEditor {
|
|
|
93
93
|
const useSidebar = options.sidebar ?? true;
|
|
94
94
|
|
|
95
95
|
this._sidebar = area.addSidebar( m => {
|
|
96
|
-
|
|
96
|
+
|
|
97
|
+
}, {
|
|
98
|
+
headerIcon: "More",
|
|
99
|
+
headerTitle: "Create",
|
|
100
|
+
headerSubtitle: "Press to rename",
|
|
101
|
+
onHeaderPressed: () => this._showRenameGraphDialog(),
|
|
102
|
+
footerIcon: "Plus",
|
|
103
|
+
footerTitle: "Create",
|
|
104
|
+
footerSubtitle: "Graph or Function",
|
|
105
|
+
onFooterPressed: (e) => this._onSidebarCreate( e )
|
|
97
106
|
});
|
|
98
107
|
|
|
99
108
|
this.base_area = area;
|
|
@@ -111,20 +120,17 @@ class GraphEditor {
|
|
|
111
120
|
this._sidebarActive = useSidebar;
|
|
112
121
|
|
|
113
122
|
// Set sidebar state depending on options..
|
|
114
|
-
|
|
123
|
+
LX.doAsync( () => {
|
|
124
|
+
this._sidebar.toggleCollapsed( !this._sidebarActive );
|
|
125
|
+
}, 50 );
|
|
115
126
|
|
|
116
127
|
// Bind resize
|
|
117
128
|
|
|
118
129
|
area.onresize = ( bb ) => {
|
|
119
|
-
|
|
130
|
+
|
|
120
131
|
};
|
|
121
132
|
|
|
122
133
|
area.addOverlayButtons( [
|
|
123
|
-
{
|
|
124
|
-
name: "Toggle Sidebar",
|
|
125
|
-
icon: "fa fa-table-columns",
|
|
126
|
-
callback: () => this._toggleSideBar(),
|
|
127
|
-
},
|
|
128
134
|
[
|
|
129
135
|
{
|
|
130
136
|
name: "Start Graph",
|
|
@@ -163,12 +169,7 @@ class GraphEditor {
|
|
|
163
169
|
icon: "fa fa-diagram-project",
|
|
164
170
|
callback: (value, event) => this.currentGraph.export()
|
|
165
171
|
}
|
|
166
|
-
]
|
|
167
|
-
{
|
|
168
|
-
name: "",
|
|
169
|
-
class: "graph-title",
|
|
170
|
-
callback: (value, event) => this._showRenameGraphDialog()
|
|
171
|
-
}
|
|
172
|
+
]
|
|
172
173
|
], { float: "htc" } );
|
|
173
174
|
|
|
174
175
|
this.root.addEventListener( 'keydown', this._processKeyDown.bind( this ), true );
|
|
@@ -252,7 +253,7 @@ class GraphEditor {
|
|
|
252
253
|
this.main = null;
|
|
253
254
|
|
|
254
255
|
// Back pattern
|
|
255
|
-
|
|
256
|
+
|
|
256
257
|
const f = 15.0;
|
|
257
258
|
this._patternSize = new LX.vec2( f );
|
|
258
259
|
this._circlePatternSize = f * 0.04;
|
|
@@ -288,11 +289,11 @@ class GraphEditor {
|
|
|
288
289
|
*/
|
|
289
290
|
|
|
290
291
|
static registerCustomNode( type, baseClass ) {
|
|
291
|
-
|
|
292
|
+
|
|
292
293
|
if ( !baseClass.prototype ) {
|
|
293
294
|
throw "Cannot register a simple object, it must be a class with a prototype!";
|
|
294
295
|
}
|
|
295
|
-
|
|
296
|
+
|
|
296
297
|
// Get info from path
|
|
297
298
|
const pos = type.lastIndexOf( "/" );
|
|
298
299
|
|
|
@@ -335,7 +336,8 @@ class GraphEditor {
|
|
|
335
336
|
|
|
336
337
|
var baseClass = GraphEditor.NODE_TYPES[ type ];
|
|
337
338
|
|
|
338
|
-
if
|
|
339
|
+
if( !baseClass )
|
|
340
|
+
{
|
|
339
341
|
console.warn( `GraphNode type [${ type }] not registered.` );
|
|
340
342
|
return null;
|
|
341
343
|
}
|
|
@@ -345,7 +347,9 @@ class GraphEditor {
|
|
|
345
347
|
const node = new baseClass( title );
|
|
346
348
|
|
|
347
349
|
if( node.onCreate )
|
|
350
|
+
{
|
|
348
351
|
node.onCreate();
|
|
352
|
+
}
|
|
349
353
|
|
|
350
354
|
node.type = type;
|
|
351
355
|
node.title = title;
|
|
@@ -358,16 +362,18 @@ class GraphEditor {
|
|
|
358
362
|
}
|
|
359
363
|
|
|
360
364
|
// Extra options
|
|
361
|
-
if ( options )
|
|
365
|
+
if ( options )
|
|
366
|
+
{
|
|
362
367
|
for (var i in options) {
|
|
363
368
|
node[ i ] = options[ i ];
|
|
364
369
|
}
|
|
365
370
|
}
|
|
366
371
|
|
|
367
|
-
if ( node.onNodeCreated )
|
|
372
|
+
if ( node.onNodeCreated )
|
|
373
|
+
{
|
|
368
374
|
node.onNodeCreated();
|
|
369
375
|
}
|
|
370
|
-
|
|
376
|
+
|
|
371
377
|
return node;
|
|
372
378
|
}
|
|
373
379
|
|
|
@@ -380,7 +386,9 @@ class GraphEditor {
|
|
|
380
386
|
|
|
381
387
|
// Nothing to do, already there...
|
|
382
388
|
if( this.currentGraph && graph.id == this.currentGraph.id )
|
|
389
|
+
{
|
|
383
390
|
return;
|
|
391
|
+
}
|
|
384
392
|
|
|
385
393
|
this.clear();
|
|
386
394
|
|
|
@@ -471,6 +479,8 @@ class GraphEditor {
|
|
|
471
479
|
|
|
472
480
|
this._sidebar.add( graph.name, { icon: "fa fa-diagram-project", className: graph.id, callback: (e) => { this.setGraph( graph ) } } );
|
|
473
481
|
|
|
482
|
+
this._sidebar.update();
|
|
483
|
+
|
|
474
484
|
this._sidebar.select( graph.name );
|
|
475
485
|
|
|
476
486
|
return graph;
|
|
@@ -522,6 +532,8 @@ class GraphEditor {
|
|
|
522
532
|
|
|
523
533
|
this._sidebar.add( func.name, { icon: "fa fa-florin-sign", className: func.id, callback: (e) => { this.setGraph( func ) } } );
|
|
524
534
|
|
|
535
|
+
this._sidebar.update();
|
|
536
|
+
|
|
525
537
|
this._sidebar.select( func.name );
|
|
526
538
|
}
|
|
527
539
|
|
|
@@ -596,7 +608,7 @@ class GraphEditor {
|
|
|
596
608
|
nodeContainer.classList.add( 'lexgraphnode' );
|
|
597
609
|
nodeContainer.style.left = "0";
|
|
598
610
|
nodeContainer.style.top = "0";
|
|
599
|
-
|
|
611
|
+
|
|
600
612
|
this._translateNode( nodeContainer, node.position );
|
|
601
613
|
|
|
602
614
|
var color;
|
|
@@ -712,11 +724,11 @@ class GraphEditor {
|
|
|
712
724
|
// {
|
|
713
725
|
// var nodeProperties = document.createElement( 'div' );
|
|
714
726
|
// nodeProperties.classList.add( 'lexgraphnodeproperties' );
|
|
715
|
-
|
|
727
|
+
|
|
716
728
|
// for( let p of node.properties )
|
|
717
729
|
// {
|
|
718
730
|
// var panel = new LX.Panel();
|
|
719
|
-
|
|
731
|
+
|
|
720
732
|
// p.signal = "@" + LX.UTILS.uidGenerator() + node.title;
|
|
721
733
|
|
|
722
734
|
// switch( p.type )
|
|
@@ -735,7 +747,7 @@ class GraphEditor {
|
|
|
735
747
|
// // prop.classList.add( 'lexgraphnodeproperty' );
|
|
736
748
|
// nodeProperties.appendChild( panel.root );
|
|
737
749
|
// }
|
|
738
|
-
|
|
750
|
+
|
|
739
751
|
// nodeContainer.appendChild( nodeProperties );
|
|
740
752
|
// }
|
|
741
753
|
|
|
@@ -993,7 +1005,7 @@ class GraphEditor {
|
|
|
993
1005
|
return;
|
|
994
1006
|
|
|
995
1007
|
this.lastMouseDown = LX.getTime();
|
|
996
|
-
|
|
1008
|
+
|
|
997
1009
|
this._generatingLink = {
|
|
998
1010
|
index: parseInt( el.dataset[ 'index' ] ),
|
|
999
1011
|
io: el,
|
|
@@ -1043,7 +1055,7 @@ class GraphEditor {
|
|
|
1043
1055
|
}
|
|
1044
1056
|
|
|
1045
1057
|
_getAllDOMNodes( includeGroups, exclude ) {
|
|
1046
|
-
|
|
1058
|
+
|
|
1047
1059
|
var elements = null;
|
|
1048
1060
|
|
|
1049
1061
|
if( includeGroups )
|
|
@@ -1165,7 +1177,7 @@ class GraphEditor {
|
|
|
1165
1177
|
// Allow change name if input
|
|
1166
1178
|
if( node.constructor.category == 'inputs' )
|
|
1167
1179
|
{
|
|
1168
|
-
panel.addText( 'Name', node.title, (v) => {
|
|
1180
|
+
panel.addText( 'Name', node.title, (v) => {
|
|
1169
1181
|
node.title = v;
|
|
1170
1182
|
dom.querySelector( '.lexgraphnodeheader' ).innerText = v;
|
|
1171
1183
|
} );
|
|
@@ -1272,7 +1284,7 @@ class GraphEditor {
|
|
|
1272
1284
|
this.currentGraph.nodes.splice( idx, 1 );
|
|
1273
1285
|
|
|
1274
1286
|
// Delete connected links..
|
|
1275
|
-
|
|
1287
|
+
|
|
1276
1288
|
for( let key in this.currentGraph.links )
|
|
1277
1289
|
{
|
|
1278
1290
|
if( !key.includes( nodeId ) )
|
|
@@ -1500,7 +1512,7 @@ class GraphEditor {
|
|
|
1500
1512
|
return;
|
|
1501
1513
|
|
|
1502
1514
|
var key = e.key ?? e.detail.key;
|
|
1503
|
-
|
|
1515
|
+
|
|
1504
1516
|
switch( key ) {
|
|
1505
1517
|
case 'Escape':
|
|
1506
1518
|
this.unSelectAll();
|
|
@@ -1550,7 +1562,7 @@ class GraphEditor {
|
|
|
1550
1562
|
_processMouse( e ) {
|
|
1551
1563
|
|
|
1552
1564
|
const rect = this.root.getBoundingClientRect();
|
|
1553
|
-
|
|
1565
|
+
|
|
1554
1566
|
this._mousePosition = new LX.vec2( e.clientX - rect.x , e.clientY - rect.y );
|
|
1555
1567
|
|
|
1556
1568
|
const snapPosition = new LX.vec2( this._mousePosition.x, this._mousePosition.y );
|
|
@@ -1571,7 +1583,7 @@ class GraphEditor {
|
|
|
1571
1583
|
|
|
1572
1584
|
this._processMouseDown( e );
|
|
1573
1585
|
}
|
|
1574
|
-
|
|
1586
|
+
|
|
1575
1587
|
else if( e.type == 'mouseup' )
|
|
1576
1588
|
{
|
|
1577
1589
|
if( ( LX.getTime() - this.lastMouseDown ) < 200 ) {
|
|
@@ -1606,7 +1618,7 @@ class GraphEditor {
|
|
|
1606
1618
|
else if ( e.type == 'contextmenu' ) {
|
|
1607
1619
|
|
|
1608
1620
|
e.preventDefault();
|
|
1609
|
-
|
|
1621
|
+
|
|
1610
1622
|
if( ( LX.getTime() - this.lastMouseDown ) < 300 ) {
|
|
1611
1623
|
this._processContextMenu( e );
|
|
1612
1624
|
}
|
|
@@ -1743,7 +1755,7 @@ class GraphEditor {
|
|
|
1743
1755
|
}
|
|
1744
1756
|
|
|
1745
1757
|
_processContextMenu( e, autoConnect ) {
|
|
1746
|
-
|
|
1758
|
+
|
|
1747
1759
|
LX.addContextMenu( null, e, m => {
|
|
1748
1760
|
|
|
1749
1761
|
var eventPosition = null;
|
|
@@ -1889,7 +1901,7 @@ class GraphEditor {
|
|
|
1889
1901
|
|
|
1890
1902
|
pattern.appendChild( circle );
|
|
1891
1903
|
}
|
|
1892
|
-
|
|
1904
|
+
|
|
1893
1905
|
var svg = document.createElementNS( 'http://www.w3.org/2000/svg', 'svg' );
|
|
1894
1906
|
svg.classList.add( "background-svg" );
|
|
1895
1907
|
svg.style.width = "100%";
|
|
@@ -1919,7 +1931,7 @@ class GraphEditor {
|
|
|
1919
1931
|
const patternSize = this._patternSize.mul( this.currentGraph.scale );
|
|
1920
1932
|
const circlePatternSize = this._circlePatternSize * this.currentGraph.scale;
|
|
1921
1933
|
const patternPosition = this.currentGraph.translation.mul( this.currentGraph.scale );
|
|
1922
|
-
|
|
1934
|
+
|
|
1923
1935
|
let pattern = this._background.querySelector( 'pattern' );
|
|
1924
1936
|
pattern.setAttribute( 'x', patternPosition.x );
|
|
1925
1937
|
pattern.setAttribute( 'y', patternPosition.y );
|
|
@@ -1940,7 +1952,7 @@ class GraphEditor {
|
|
|
1940
1952
|
const dh = h - h * this.currentGraph.scale;
|
|
1941
1953
|
|
|
1942
1954
|
this._domNodes.style.transform = `
|
|
1943
|
-
translate(` + ( patternPosition.x - dw ) + `px, ` + ( patternPosition.y - dh ) + `px)
|
|
1955
|
+
translate(` + ( patternPosition.x - dw ) + `px, ` + ( patternPosition.y - dh ) + `px)
|
|
1944
1956
|
scale(` + this.currentGraph.scale + `)
|
|
1945
1957
|
`;
|
|
1946
1958
|
this._domLinks.style.transform = this._domNodes.style.transform;
|
|
@@ -1983,7 +1995,7 @@ class GraphEditor {
|
|
|
1983
1995
|
const src_nodeId = src_nodeContainer.dataset[ 'id' ];
|
|
1984
1996
|
const src_node = this.nodes[ src_nodeId ].data;
|
|
1985
1997
|
const src_ioIndex = this._generatingLink.index
|
|
1986
|
-
|
|
1998
|
+
|
|
1987
1999
|
// Info about dst node
|
|
1988
2000
|
const dst_nodeContainer = e.target.offsetParent;
|
|
1989
2001
|
const dst_nodeId = dst_nodeContainer.dataset[ 'id' ];
|
|
@@ -2032,14 +2044,14 @@ class GraphEditor {
|
|
|
2032
2044
|
srcDom.links = srcDom.links ?? [ ];
|
|
2033
2045
|
srcDom.links[ dst_ioIndex ] = srcDom.links[ dst_ioIndex ] ?? [ ];
|
|
2034
2046
|
srcDom.links[ dst_ioIndex ].push( dst_nodeId );
|
|
2035
|
-
|
|
2047
|
+
|
|
2036
2048
|
var dstDom = e.target.parentElement;
|
|
2037
2049
|
dstDom.links = dstDom.links ?? [ ];
|
|
2038
2050
|
dstDom.links[ src_ioIndex ] = dstDom.links[ src_ioIndex ] ?? [ ];
|
|
2039
2051
|
dstDom.links[ src_ioIndex ].push( src_nodeId );
|
|
2040
2052
|
|
|
2041
2053
|
// Call this using the io target to set the connection to the center of the input DOM element..
|
|
2042
|
-
|
|
2054
|
+
|
|
2043
2055
|
let path = this._updatePreviewLink( null, e.target.parentElement );
|
|
2044
2056
|
|
|
2045
2057
|
// Store link
|
|
@@ -2282,8 +2294,8 @@ class GraphEditor {
|
|
|
2282
2294
|
}
|
|
2283
2295
|
|
|
2284
2296
|
// Update output links
|
|
2285
|
-
|
|
2286
|
-
|
|
2297
|
+
|
|
2298
|
+
|
|
2287
2299
|
for( let output of nodeDOM.querySelectorAll( '.iooutput' ) )
|
|
2288
2300
|
{
|
|
2289
2301
|
if( !output.links )
|
|
@@ -2424,7 +2436,7 @@ class GraphEditor {
|
|
|
2424
2436
|
let pos = this._getNodePosition( nodeEl );
|
|
2425
2437
|
let size = new LX.vec2( nodeEl.offsetWidth, nodeEl.offsetHeight );
|
|
2426
2438
|
|
|
2427
|
-
if( ( !( pos.x < lt.x && ( pos.x + size.x ) < lt.x ) && !( pos.x > rb.x && ( pos.x + size.x ) > rb.x ) ) &&
|
|
2439
|
+
if( ( !( pos.x < lt.x && ( pos.x + size.x ) < lt.x ) && !( pos.x > rb.x && ( pos.x + size.x ) > rb.x ) ) &&
|
|
2428
2440
|
( !( pos.y < lt.y && ( pos.y + size.y ) < lt.y ) && !( pos.y > rb.y && ( pos.y + size.y ) > rb.y ) ) )
|
|
2429
2441
|
{
|
|
2430
2442
|
if( remove )
|
|
@@ -2630,7 +2642,7 @@ class GraphEditor {
|
|
|
2630
2642
|
|
|
2631
2643
|
_addUndoStep( deleteRedo = true ) {
|
|
2632
2644
|
|
|
2633
|
-
if( deleteRedo )
|
|
2645
|
+
if( deleteRedo )
|
|
2634
2646
|
{
|
|
2635
2647
|
// Remove all redo steps
|
|
2636
2648
|
this._redoSteps.length = 0;
|
|
@@ -2710,13 +2722,6 @@ class GraphEditor {
|
|
|
2710
2722
|
}
|
|
2711
2723
|
}
|
|
2712
2724
|
|
|
2713
|
-
_toggleSideBar( force ) {
|
|
2714
|
-
|
|
2715
|
-
this._sidebarActive = force ?? !this._sidebarActive;
|
|
2716
|
-
this._sidebarDom.classList.toggle( 'hidden', !this._sidebarActive );
|
|
2717
|
-
this._graphContainer.style.width = this._sidebarActive ? "calc( 100% - 64px )" : "100%";
|
|
2718
|
-
}
|
|
2719
|
-
|
|
2720
2725
|
_onSidebarCreate( e ) {
|
|
2721
2726
|
|
|
2722
2727
|
LX.addContextMenu(null, e, m => {
|
|
@@ -2740,7 +2745,7 @@ class GraphEditor {
|
|
|
2740
2745
|
const newNameKey = name.replace( /\s/g, '' ).replaceAll( '.', '' );
|
|
2741
2746
|
|
|
2742
2747
|
// Change graph name button
|
|
2743
|
-
const nameDom =
|
|
2748
|
+
const nameDom = this._sidebar.root.querySelectorAll(".lexsidebarheader span")[ 1 ];
|
|
2744
2749
|
console.assert( nameDom );
|
|
2745
2750
|
nameDom.innerText = name;
|
|
2746
2751
|
|
|
@@ -2750,8 +2755,9 @@ class GraphEditor {
|
|
|
2750
2755
|
if( sidebarItem )
|
|
2751
2756
|
{
|
|
2752
2757
|
sidebarItem.name = newNameKey;
|
|
2753
|
-
sidebarItem.
|
|
2754
|
-
sidebarItem.
|
|
2758
|
+
sidebarItem.dom.id = newNameKey;
|
|
2759
|
+
sidebarItem.dom.querySelector(".lexsidebarentrydesc").innerText = name;
|
|
2760
|
+
sidebarItem.dom.querySelector("a").innerText = name;
|
|
2755
2761
|
}
|
|
2756
2762
|
|
|
2757
2763
|
// Change registered nodes function
|
|
@@ -2772,7 +2778,7 @@ class GraphEditor {
|
|
|
2772
2778
|
|
|
2773
2779
|
_addGlobalActions() {
|
|
2774
2780
|
|
|
2775
|
-
|
|
2781
|
+
|
|
2776
2782
|
}
|
|
2777
2783
|
}
|
|
2778
2784
|
|
|
@@ -2787,7 +2793,7 @@ class Graph {
|
|
|
2787
2793
|
|
|
2788
2794
|
/**
|
|
2789
2795
|
* @param {*} options
|
|
2790
|
-
*
|
|
2796
|
+
*
|
|
2791
2797
|
*/
|
|
2792
2798
|
|
|
2793
2799
|
constructor( name, options = {} ) {
|
|
@@ -2798,7 +2804,7 @@ class Graph {
|
|
|
2798
2804
|
this.nodes = [ ];
|
|
2799
2805
|
this.groups = [ ];
|
|
2800
2806
|
this.links = { };
|
|
2801
|
-
|
|
2807
|
+
|
|
2802
2808
|
this.scale = 1.0;
|
|
2803
2809
|
this.translation = new LX.vec2( 0, 0 );
|
|
2804
2810
|
}
|
|
@@ -2916,7 +2922,7 @@ class Graph {
|
|
|
2916
2922
|
*/
|
|
2917
2923
|
|
|
2918
2924
|
serialize( prettify = true ) {
|
|
2919
|
-
|
|
2925
|
+
|
|
2920
2926
|
var o = { };
|
|
2921
2927
|
|
|
2922
2928
|
o.id = this.id;
|
|
@@ -2993,7 +2999,7 @@ LX.Graph = Graph;
|
|
|
2993
2999
|
|
|
2994
3000
|
class GraphNode {
|
|
2995
3001
|
|
|
2996
|
-
constructor() {
|
|
3002
|
+
constructor() {
|
|
2997
3003
|
|
|
2998
3004
|
this.inputs = [ ];
|
|
2999
3005
|
this.outputs = [ ];
|
|
@@ -3159,7 +3165,7 @@ class GraphFunction extends Graph {
|
|
|
3159
3165
|
|
|
3160
3166
|
LX.GraphFunction = GraphFunction;
|
|
3161
3167
|
|
|
3162
|
-
/*
|
|
3168
|
+
/*
|
|
3163
3169
|
************ PREDEFINED NODES ************
|
|
3164
3170
|
|
|
3165
3171
|
Nodes can override the following methods:
|
|
@@ -3232,7 +3238,7 @@ class NodeAdd extends GraphNode
|
|
|
3232
3238
|
this.addProperty( "A", "float", 0 );
|
|
3233
3239
|
this.addProperty( "B", "float", 0 );
|
|
3234
3240
|
}
|
|
3235
|
-
|
|
3241
|
+
|
|
3236
3242
|
onExecute() {
|
|
3237
3243
|
var a = this.getInput( 0 ) ?? this.properties[ 0 ].value;
|
|
3238
3244
|
var b = this.getInput( 1 ) ?? this.properties[ 1 ].value;
|
|
@@ -3252,7 +3258,7 @@ class NodeSubstract extends GraphNode
|
|
|
3252
3258
|
this.addProperty( "A", "float", 0 );
|
|
3253
3259
|
this.addProperty( "B", "float", 0 );
|
|
3254
3260
|
}
|
|
3255
|
-
|
|
3261
|
+
|
|
3256
3262
|
onExecute() {
|
|
3257
3263
|
var a = this.getInput( 0 ) ?? this.properties[ 0 ].value;
|
|
3258
3264
|
var b = this.getInput( 1 ) ?? this.properties[ 1 ].value;
|
|
@@ -3272,7 +3278,7 @@ class NodeMultiply extends GraphNode
|
|
|
3272
3278
|
this.addProperty( "A", "float", 0 );
|
|
3273
3279
|
this.addProperty( "B", "float", 0 );
|
|
3274
3280
|
}
|
|
3275
|
-
|
|
3281
|
+
|
|
3276
3282
|
onExecute() {
|
|
3277
3283
|
var a = this.getInput( 0 ) ?? this.properties[ 0 ].value;
|
|
3278
3284
|
var b = this.getInput( 1 ) ?? this.properties[ 1 ].value;
|
|
@@ -3292,7 +3298,7 @@ class NodeDivide extends GraphNode
|
|
|
3292
3298
|
this.addProperty( "A", "float", 0 );
|
|
3293
3299
|
this.addProperty( "B", "float", 0 );
|
|
3294
3300
|
}
|
|
3295
|
-
|
|
3301
|
+
|
|
3296
3302
|
onExecute() {
|
|
3297
3303
|
var a = this.getInput( 0 ) ?? this.properties[ 0 ].value;
|
|
3298
3304
|
var b = this.getInput( 1 ) ?? this.properties[ 1 ].value;
|
|
@@ -3310,7 +3316,7 @@ class NodeSqrt extends GraphNode
|
|
|
3310
3316
|
this.addOutput( null, "float" );
|
|
3311
3317
|
this.addProperty( "Value", "float", 0 );
|
|
3312
3318
|
}
|
|
3313
|
-
|
|
3319
|
+
|
|
3314
3320
|
onExecute() {
|
|
3315
3321
|
var a = this.getInput( 0 ) ?? this.properties[ 0 ].value;
|
|
3316
3322
|
this.setOutput( 0, Math.sqrt( a ) );
|
|
@@ -3352,7 +3358,7 @@ class NodeAnd extends GraphNode
|
|
|
3352
3358
|
this.addInput( null, "bool" );
|
|
3353
3359
|
this.addOutput( null, "bool" );
|
|
3354
3360
|
}
|
|
3355
|
-
|
|
3361
|
+
|
|
3356
3362
|
onExecute() {
|
|
3357
3363
|
var a = this.getInput( 0 ), b = this.getInput( 1 );
|
|
3358
3364
|
if( a == undefined || b == undefined )
|
|
@@ -3370,7 +3376,7 @@ class NodeOr extends GraphNode
|
|
|
3370
3376
|
this.addInput( null, "bool" );
|
|
3371
3377
|
this.addOutput( null, "bool" );
|
|
3372
3378
|
}
|
|
3373
|
-
|
|
3379
|
+
|
|
3374
3380
|
onExecute() {
|
|
3375
3381
|
var a = this.getInput( 0 ), b = this.getInput( 1 );
|
|
3376
3382
|
if( a == undefined || b == undefined )
|
|
@@ -3388,7 +3394,7 @@ class NodeEqual extends GraphNode
|
|
|
3388
3394
|
this.addInput( null, "float" );
|
|
3389
3395
|
this.addOutput( null, "bool" );
|
|
3390
3396
|
}
|
|
3391
|
-
|
|
3397
|
+
|
|
3392
3398
|
logicOp( a, b ) {
|
|
3393
3399
|
return a == b;
|
|
3394
3400
|
}
|
|
@@ -3456,7 +3462,7 @@ class NodeSelect extends GraphNode
|
|
|
3456
3462
|
this.addInput( "Condition", "bool" );
|
|
3457
3463
|
this.addOutput( null, "any" );
|
|
3458
3464
|
}
|
|
3459
|
-
|
|
3465
|
+
|
|
3460
3466
|
onExecute() {
|
|
3461
3467
|
var a = this.getInput( 0 ), b = this.getInput( 1 ), cond = this.getInput( 2 );
|
|
3462
3468
|
if( a == undefined || b == undefined || cond == undefined )
|
|
@@ -3477,7 +3483,7 @@ class NodeCompare extends GraphNode
|
|
|
3477
3483
|
this.addProperty( "Condition", "select", 'Equal', [ 'Equal', 'Not Equal', 'Less', 'Less Equal', 'Greater', 'Greater Equal' ] );
|
|
3478
3484
|
this.addOutput( null, "any" );
|
|
3479
3485
|
}
|
|
3480
|
-
|
|
3486
|
+
|
|
3481
3487
|
onExecute() {
|
|
3482
3488
|
var a = this.getInput( 0 ), b = this.getInput( 1 ), TrueVal = this.getInput( 2 ), FalseVal = this.getInput( 3 );;
|
|
3483
3489
|
var cond = this.properties[ 0 ].value;
|
|
@@ -3508,7 +3514,7 @@ class NodeKeyDown extends GraphNode
|
|
|
3508
3514
|
this.addOutput( null, "bool" );
|
|
3509
3515
|
this.addProperty( "Key", "string", " " );
|
|
3510
3516
|
}
|
|
3511
|
-
|
|
3517
|
+
|
|
3512
3518
|
onExecute() {
|
|
3513
3519
|
this.setOutput( 0, !!this.editor.keys[ this.properties[ 0 ].value ] );
|
|
3514
3520
|
}
|
|
@@ -3526,7 +3532,7 @@ class NodeString extends GraphNode
|
|
|
3526
3532
|
this.addOutput( null, "string" );
|
|
3527
3533
|
this.addProperty( null, "string", "text" );
|
|
3528
3534
|
}
|
|
3529
|
-
|
|
3535
|
+
|
|
3530
3536
|
onExecute() {
|
|
3531
3537
|
this.setOutput( 0, this.properties[ 0 ].value );
|
|
3532
3538
|
}
|
|
@@ -3540,7 +3546,7 @@ class NodeFloat extends GraphNode
|
|
|
3540
3546
|
this.addOutput( null, "float" );
|
|
3541
3547
|
this.addProperty( null, "float", 0.0 );
|
|
3542
3548
|
}
|
|
3543
|
-
|
|
3549
|
+
|
|
3544
3550
|
onExecute() {
|
|
3545
3551
|
this.setOutput( 0, this.properties[ 0 ].value );
|
|
3546
3552
|
}
|
|
@@ -3554,7 +3560,7 @@ class NodeVector2 extends GraphNode
|
|
|
3554
3560
|
this.addOutput( "Value", "vec2" );
|
|
3555
3561
|
this.addProperty( "Value", "vec2", [ 0, 0 ] );
|
|
3556
3562
|
}
|
|
3557
|
-
|
|
3563
|
+
|
|
3558
3564
|
onExecute() {
|
|
3559
3565
|
this.setOutput( 0, this.properties[ 0 ].value );
|
|
3560
3566
|
}
|
|
@@ -3568,7 +3574,7 @@ class NodeVector3 extends GraphNode
|
|
|
3568
3574
|
this.addOutput( "Value", "vec3" );
|
|
3569
3575
|
this.addProperty( "Value", "vec3", [ 0, 0, 0 ] );
|
|
3570
3576
|
}
|
|
3571
|
-
|
|
3577
|
+
|
|
3572
3578
|
onExecute() {
|
|
3573
3579
|
this.setOutput( 0, this.properties[ 0 ].value );
|
|
3574
3580
|
}
|
|
@@ -3582,7 +3588,7 @@ class NodeVector4 extends GraphNode
|
|
|
3582
3588
|
this.addOutput( "Value", "vec4" );
|
|
3583
3589
|
this.addProperty( "Value", "vec4", [ 0, 0, 0, 0 ] );
|
|
3584
3590
|
}
|
|
3585
|
-
|
|
3591
|
+
|
|
3586
3592
|
onExecute() {
|
|
3587
3593
|
this.setOutput( 0, this.properties[ 0 ].value );
|
|
3588
3594
|
}
|
|
@@ -3601,7 +3607,7 @@ class NodeSetVariable extends GraphNode
|
|
|
3601
3607
|
this.addOutput( null, "any" );
|
|
3602
3608
|
this.addProperty( "Name", "string", "" );
|
|
3603
3609
|
}
|
|
3604
|
-
|
|
3610
|
+
|
|
3605
3611
|
onExecute() {
|
|
3606
3612
|
var varName = this.getInput( 0 );
|
|
3607
3613
|
if( varName == undefined )
|