File tree Expand file tree Collapse file tree 5 files changed +293
-15
lines changed
extensions/behavior/graph-nodes Expand file tree Collapse file tree 5 files changed +293
-15
lines changed Original file line number Diff line number Diff line change @@ -818,6 +818,8 @@ declare module 'babylonjs-editor/editor/gui/tree' {
818
818
}
819
819
export default class Tree {
820
820
name : string ;
821
+ wholerow : boolean ;
822
+ keyboard : boolean ;
821
823
element : JSTree ;
822
824
onClick : < T > ( id : string , data : T ) => void ;
823
825
onDblClick : < T > ( id : string , data : T ) => void ;
Original file line number Diff line number Diff line change @@ -146,14 +146,30 @@ export default class Edition {
146
146
} ;
147
147
148
148
const folder = parent . addFolder ( name ) ;
149
- /*
150
- TODO: Fix CSS Issue with color element
151
- folder.addColor(target, 'color').name('Color').onChange((value: number[]) => {
152
- this.getController('r', folder).setValue(value[0] / 255);
153
- this.getController('g', folder).setValue(value[1] / 255);
154
- this.getController('b', folder).setValue(value[2] / 255);
155
- });
156
- */
149
+ const picker = {
150
+ callback : ( ) => {
151
+ const input = document . createElement ( 'input' ) ;
152
+ input . type = 'color' ;
153
+ input . value = color . toHexString ( ) ;
154
+ input . addEventListener ( 'input' , ev => {
155
+ const result = Color3 . FromHexString ( input . value ) ;
156
+ color . r = result . r ;
157
+ color . g = result . g ;
158
+ color . b = result . b ;
159
+ this . updateDisplay ( ) ;
160
+ } ) ;
161
+ input . addEventListener ( 'change' , ev => {
162
+ const result = Color3 . FromHexString ( input . value ) ;
163
+ color . r = result . r ;
164
+ color . g = result . g ;
165
+ color . b = result . b ;
166
+ this . updateDisplay ( ) ;
167
+ } ) ;
168
+ input . click ( ) ;
169
+ }
170
+ } ;
171
+
172
+ folder . add ( picker , 'callback' ) . name ( 'Color Picker' ) ;
157
173
folder . add ( color , 'r' ) . min ( 0 ) . max ( 1 ) . step ( 0.01 ) . onChange ( ( ) => callback && callback ( ) ) ;
158
174
folder . add ( color , 'g' ) . min ( 0 ) . max ( 1 ) . step ( 0.01 ) . onChange ( ( ) => callback && callback ( ) ) ;
159
175
folder . add ( color , 'b' ) . min ( 0 ) . max ( 1 ) . step ( 0.01 ) . onChange ( ( ) => callback && callback ( ) ) ;
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ export interface ContextMenuItem {
20
20
export default class Tree {
21
21
// Public members
22
22
public name : string ;
23
+ public wholerow : boolean = false ;
24
+ public keyboard : boolean = false ;
23
25
public element : JSTree = null ;
24
26
25
27
public onClick : < T > ( id : string , data : T ) => void ;
@@ -166,6 +168,17 @@ export default class Tree {
166
168
* @param parentId the parent id
167
169
*/
168
170
public build ( parentId : string ) : void {
171
+ const plugins = [
172
+ 'contextmenu' , 'dnd' , 'search' ,
173
+ 'state' , 'types'
174
+ ] ;
175
+
176
+ if ( this . wholerow )
177
+ plugins . push ( 'wholerow' )
178
+
179
+ if ( this . keyboard )
180
+ plugins . push ( 'hotkeys' ) ;
181
+
169
182
this . element = $ ( '#' + parentId ) . jstree ( {
170
183
core : {
171
184
check_callback : true ,
@@ -178,10 +191,7 @@ export default class Tree {
178
191
return this . onCanDrag && this . onCanDrag ( node . id , node . data ) ;
179
192
}
180
193
} ,
181
- plugins : [
182
- 'contextmenu' , 'dnd' , 'search' ,
183
- 'state' , 'types'
184
- ] ,
194
+ plugins : plugins ,
185
195
search : {
186
196
show_only_matches : true ,
187
197
show_only_matches_children : true
Original file line number Diff line number Diff line change @@ -7,8 +7,12 @@ export abstract class LiteGraphNode {
7
7
public mode : number ;
8
8
public color : string ;
9
9
public bgColor : string ;
10
+ public readonly type : string ;
11
+
10
12
public properties : { [ index : string ] : string | number | boolean } ;
13
+ public outputs : any [ ] ;
11
14
15
+ public pos : number [ ] ;
12
16
public size : number [ ] = [ 60 , 20 ] ;
13
17
public shape : string = 'round' ;
14
18
@@ -83,6 +87,9 @@ export abstract class LiteGraphNode {
83
87
84
88
public onDrawBackground ? ( ctx : CanvasRenderingContext2D ) : void ;
85
89
90
+ public onGetOutputs ? ( ) : string [ ] [ ] ;
91
+ public onGetInputs ? ( ) : string [ ] [ ] ;
92
+
86
93
/**
87
94
* Returns the target node
88
95
* @param name the name of the node
You can’t perform that action at this time.
0 commit comments