lexgui 0.1.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/LICENSE +21 -0
- package/README.md +31 -0
- package/build/components/codeeditor.js +1865 -0
- package/build/components/nodegraph.js +534 -0
- package/build/components/timeline.js +4599 -0
- package/build/lexgui.css +2925 -0
- package/build/lexgui.js +7292 -0
- package/build/lexgui.module.js +7289 -0
- package/demo.js +778 -0
- package/examples/area_tabs.html +101 -0
- package/examples/asset_view.html +180 -0
- package/examples/code_editor.html +61 -0
- package/examples/dialogs.html +104 -0
- package/examples/index.html +84 -0
- package/examples/node_graph.html +59 -0
- package/examples/overlay_area.html +51 -0
- package/examples/previews/area_tabs.png +0 -0
- package/examples/previews/asset_view.png +0 -0
- package/examples/previews/code_editor.png +0 -0
- package/examples/previews/dialogs.png +0 -0
- package/examples/previews/overlay_area.png +0 -0
- package/package.json +37 -0
package/demo.js
ADDED
|
@@ -0,0 +1,778 @@
|
|
|
1
|
+
import { LX } from 'lexgui';
|
|
2
|
+
import 'lexgui/components/codeeditor.js';
|
|
3
|
+
import 'lexgui/components/timeline.js';
|
|
4
|
+
|
|
5
|
+
console.log(LX, LX.CodeEditor, LX.Timeline)
|
|
6
|
+
|
|
7
|
+
// Init library and get main area
|
|
8
|
+
let area = LX.init();
|
|
9
|
+
|
|
10
|
+
// Change global properties after init
|
|
11
|
+
// LX.DEFAULT_NAME_WIDTH = "10%";
|
|
12
|
+
// LX.DEFAULT_SPLITBAR_SIZE = 16;
|
|
13
|
+
// LX.OPEN_CONTEXTMENU_ENTRY = 'mouseover';
|
|
14
|
+
|
|
15
|
+
// LX.message("Im in another position", null, { position: [10, 10] });
|
|
16
|
+
// LX.message("Welcome to Lexgui", "Welcome!");
|
|
17
|
+
|
|
18
|
+
// Change some theme colors...
|
|
19
|
+
// LX.setThemeColor('global-color-primary', "#211");
|
|
20
|
+
// LX.setThemeColor('global-selected', "#a74");
|
|
21
|
+
// LX.setThemeColor('global-text', "#f21");
|
|
22
|
+
|
|
23
|
+
// menu bar
|
|
24
|
+
area.addMenubar( m => {
|
|
25
|
+
|
|
26
|
+
// {options}: callback, icon, short
|
|
27
|
+
|
|
28
|
+
m.add( "Scene/New Scene", () => { console.log("New scene created!") });
|
|
29
|
+
m.add( "Scene/Open Scene", { icon: "fa-solid fa-folder-open", short: "S", callback: () => { console.log("Opening SCENE Dialog") } } );
|
|
30
|
+
m.add( "Scene/Open Recent/hello.scene", name => { console.log("Opening " + name) });
|
|
31
|
+
m.add( "Scene/Open Recent/goodbye.scene", name => { console.log("Opening " + name) });
|
|
32
|
+
m.add( "Project/Project Settings" );
|
|
33
|
+
m.add( "Project/Export", { icon: "fa-solid fa-download" });
|
|
34
|
+
m.add( "Project/Export/DAE", { icon: "fa-solid fa-cube", short: "D", callback: () => { console.log("Exporting DAE...") }} );
|
|
35
|
+
m.add( "Project/Export/GLTF", { short: "G" } );
|
|
36
|
+
m.add( "Editor/Autosave", { type: 'checkbox', icon: "fa fa-floppy-disk", callback: (v, name) => { console.log(name + ": " + v ) } });
|
|
37
|
+
m.add( "Editor/Test", () => LX.prompt("Editor", "Test?"));
|
|
38
|
+
m.add( "Editor/Settings", { icon: "fa-solid fa-gears", callback: () => {
|
|
39
|
+
const dialog = new LX.Dialog( "Settings", p => {
|
|
40
|
+
p.addText("A Text", "Testing first widget");
|
|
41
|
+
p.sameLine(3);
|
|
42
|
+
p.addLabel("Buttons:");
|
|
43
|
+
p.addButton(null, "Click me", () => {
|
|
44
|
+
console.log( p.getValue("A Text") );
|
|
45
|
+
});
|
|
46
|
+
p.addButton(null, "Click me v2!", () => {
|
|
47
|
+
console.log( p.getValue("A Text") );
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}} );
|
|
51
|
+
m.add( "Editor/Write BML", { icon: "fa-solid fa-gears", callback: () => {
|
|
52
|
+
|
|
53
|
+
new LX.PocketDialog( "BML Instruction", p => {
|
|
54
|
+
|
|
55
|
+
let htmlStr = "Write in the text area below the bml instructions to move the avatar from the web application. A sample of BML instructions can be tested through the helper tabs in the right panel.";
|
|
56
|
+
p.addTextArea(null, htmlStr, null, {disabled: true, fitHeight: true});
|
|
57
|
+
|
|
58
|
+
p.addButton(null, "Click here to see BML instructions and attributes", () => {
|
|
59
|
+
window.open("https://github.com/upf-gti/SignON-realizer/blob/SiGMLExperiments/docs/InstructionsBML.md");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
htmlStr = "Note: In 'speech', all text between '%' is treated as actual words. An automatic translation from words (dutch) to phonemes (arpabet) is performed.";
|
|
63
|
+
htmlStr += "\n\nNote: Each instruction is inside '{}'. Each instruction is separated by a coma ',' except que last one.";
|
|
64
|
+
p.addTextArea(null, htmlStr, null, {disabled: true, fitHeight: true});
|
|
65
|
+
|
|
66
|
+
htmlStr = 'An example: { "type":"speech", "start": 0, "text": "%hallo%.", "sentT": 1, "sentInt": 0.5 }, { "type": "gesture", "start": 0, "attackPeak": 0.5, "relax": 1, "end": 2, "locationBodyArm": "shoulder", "lrSym": true, "hand": "both", "distance": 0.1 }';
|
|
67
|
+
p.addTextArea(null, htmlStr, null, {disabled: true, fitHeight: true});
|
|
68
|
+
|
|
69
|
+
const area = new LX.Area({ height: "250px" });
|
|
70
|
+
p.attach( area.root );
|
|
71
|
+
|
|
72
|
+
window.editor = new LX.CodeEditor(area, {
|
|
73
|
+
highlight: 'JSON',
|
|
74
|
+
skip_info: true
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
p.addButton(null, "Send", () => {
|
|
78
|
+
console.log(":)")
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
}, { size: ["30%", null], float: "right", draggable: false});
|
|
82
|
+
}} );
|
|
83
|
+
m.add( "Editor/Open AssetView", { icon: "fa-solid fa-rect", callback: () => {
|
|
84
|
+
createAssetDialog();
|
|
85
|
+
}} );
|
|
86
|
+
m.add( "Help/Search Help", { icon: "fa-solid fa-magnifying-glass", short: "F1", callback: () => { window.open("./docs/") }});
|
|
87
|
+
m.add( "Help/Support LexGUI/Please", { icon: "fa-solid fa-heart" } );
|
|
88
|
+
m.add( "Help/Support LexGUI/Do it" );
|
|
89
|
+
m.add( "Timeline/Shortcuts", { disabled: true });
|
|
90
|
+
m.add( "Timeline/Shortcuts/Play-Pause", { short: "SPACE" });
|
|
91
|
+
m.add( "Timeline/Shortcuts/Zoom", { short: "Wheel" });
|
|
92
|
+
m.add( "Timeline/Shortcuts/Change time", { short: "Left Click+Drag" });
|
|
93
|
+
m.add( "Timeline/Shortcuts/Move keys", { short: "Hold CTRL" });
|
|
94
|
+
m.add( "Timeline/Shortcuts/Add keys", { short: "Right Click" });
|
|
95
|
+
m.add( "Timeline/Shortcuts/Delete keys");
|
|
96
|
+
m.add( "Timeline/Shortcuts/Delete keys/Single", { short: "DEL" });
|
|
97
|
+
m.add( "Timeline/Shortcuts/Delete keys/Multiple", { short: "Hold LSHIFT" });
|
|
98
|
+
m.add( "Timeline/Shortcuts/Key Selection");
|
|
99
|
+
m.add( "Timeline/Shortcuts/Key Selection/Single", { short: "Left Click" });
|
|
100
|
+
m.add( "Timeline/Shortcuts/Key Selection/Multiple", { short: "Hold LSHIFT" });
|
|
101
|
+
m.add( "Timeline/Shortcuts/Key Selection/Box", { short: "Hold LSHIFT+Drag" });
|
|
102
|
+
m.addButtons( [
|
|
103
|
+
{
|
|
104
|
+
title: "Play",
|
|
105
|
+
icon: "fa-solid fa-play",
|
|
106
|
+
callback: (domEl) => {
|
|
107
|
+
console.log("play!");
|
|
108
|
+
domEl.classList.toggle('fa-play'), domEl.classList.toggle('fa-stop');
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
title: "Pause",
|
|
113
|
+
icon: "fa-solid fa-pause",
|
|
114
|
+
disabled: true,
|
|
115
|
+
callback: (domEl) => { console.log("pause!") }
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
icon: "fa-solid fa-magnifying-glass",
|
|
119
|
+
callback: (domEl) => { console.log("glass!") }
|
|
120
|
+
}
|
|
121
|
+
]);
|
|
122
|
+
|
|
123
|
+
m.getButton("Play");
|
|
124
|
+
m.setButtonIcon("Github", "fa-brands fa-github", () => {window.open("https://github.com/jxarco/lexgui.js/")})
|
|
125
|
+
m.setButtonImage("lexgui.js", "images/icon.png", () => {window.open("https://jxarco.github.io/lexgui.js/")}, {float: "left"})
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// split main area
|
|
129
|
+
var [left, right] = area.split({ sizes:["80%","20%"], minimizable: true });
|
|
130
|
+
|
|
131
|
+
// split left area
|
|
132
|
+
var [up, bottom] = left.split({ type: 'vertical', sizes:["50%", null], minimizable: true });
|
|
133
|
+
|
|
134
|
+
var kfTimeline = null;
|
|
135
|
+
var clipsTimeline = null;
|
|
136
|
+
var curvesTimeline = null;
|
|
137
|
+
|
|
138
|
+
bottom.onresize = bounding => {
|
|
139
|
+
if(kfTimeline) kfTimeline.resize( [ bounding.width, bounding.height ] );
|
|
140
|
+
if(clipsTimeline) clipsTimeline.resize( [ bounding.width, bounding.height ] );
|
|
141
|
+
if(curvesTimeline) curvesTimeline.resize( [ bounding.width, bounding.height ] );
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// another menu bar
|
|
145
|
+
bottom.addMenubar( m => {
|
|
146
|
+
m.add( "Information", e => {
|
|
147
|
+
console.log(e);
|
|
148
|
+
var el = document.getElementById('kf-timeline');
|
|
149
|
+
if(el)
|
|
150
|
+
el.style.display = 'none';
|
|
151
|
+
el = document.getElementById('clips-timeline');
|
|
152
|
+
if(el)
|
|
153
|
+
el.style.display = 'none';
|
|
154
|
+
el = document.getElementById('curves-timeline');
|
|
155
|
+
if(el)
|
|
156
|
+
el.style.display = 'none';
|
|
157
|
+
var bottomPanel = document.getElementById('bottom-panel');
|
|
158
|
+
bottomPanel.style.display = 'block';
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
m.add( "Keyframes Timeline", e => {
|
|
162
|
+
console.log(e);
|
|
163
|
+
let el = document.getElementById('bottom-panel');
|
|
164
|
+
if(el)
|
|
165
|
+
el.style.display = 'none';
|
|
166
|
+
el = document.getElementById('clips-timeline');
|
|
167
|
+
if(el)
|
|
168
|
+
el.style.display = 'none';
|
|
169
|
+
el = document.getElementById('curves-timeline');
|
|
170
|
+
if(el)
|
|
171
|
+
el.style.display = 'none';
|
|
172
|
+
var timeline = document.getElementById('kf-timeline');
|
|
173
|
+
if(timeline) {
|
|
174
|
+
timeline.style.display = 'block';
|
|
175
|
+
kfTimeline.resize();
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
kfTimeline = new LX.KeyFramesTimeline("kf-timeline", { width: m.root.clientWidth, height: m.parent.root.parentElement.clientHeight - m.root.clientHeight });
|
|
179
|
+
bottom.attach(kfTimeline.root);
|
|
180
|
+
kfTimeline.setSelectedItems(["Item 1", "Item 2", "Item 3"]);
|
|
181
|
+
kfTimeline.setAnimationClip({tracks: [{name: "Item 1.position", values: [0,1,0, 1], times: [0, 0.1, 0.2, 0.3]}, {name: "Item 1.scale", values: [0,1,0, 0.5], times: [0, 0.1, 0.2, 0.3]}, {name: "Item 2", values: [0,1,0,1], times: [0.1, 0.2, 0.3, 0.8]}, {name: "Item 3.position", values: [0,1,0], times: [0, 0.1, 0.2, 0.3]}, {name: "Item 3.scale", values: [0,1,0], times: [0, 0.1, 0.2, 0.3]}], duration: 1});
|
|
182
|
+
|
|
183
|
+
kfTimeline.addButtons([
|
|
184
|
+
{ icon: 'fa fa-wand-magic-sparkles', name: 'autoKeyEnabled' },
|
|
185
|
+
{ icon: 'fa fa-filter', name: "optimize", callback: (value, event) => { kfTimeline.onShowOptimizeMenu(event);}},
|
|
186
|
+
{ icon: 'fa-regular fa-rectangle-xmark', name: 'unselectAll', callback: (value, event) => { kfTimeline.unSelectAllKeyFrames();}}
|
|
187
|
+
]);
|
|
188
|
+
|
|
189
|
+
kfTimeline.draw(0);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
m.add( "Clips Timeline", e => {
|
|
194
|
+
console.log(e);
|
|
195
|
+
let el = document.getElementById('bottom-panel');
|
|
196
|
+
if(el)
|
|
197
|
+
el.style.display = 'none';
|
|
198
|
+
|
|
199
|
+
el = document.getElementById('kf-timeline');
|
|
200
|
+
if(el)
|
|
201
|
+
el.style.display = 'none';
|
|
202
|
+
el = document.getElementById('curves-timeline');
|
|
203
|
+
if(el)
|
|
204
|
+
el.style.display = 'none';
|
|
205
|
+
var ctimeline = document.getElementById('clips-timeline');
|
|
206
|
+
if(ctimeline) {
|
|
207
|
+
ctimeline.style.display = 'block';
|
|
208
|
+
clipsTimeline.resize();
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
clipsTimeline = new LX.ClipsTimeline("clips-timeline", {width: m.root.clientWidth, height: m.parent.root.parentElement.clientHeight - m.root.clientHeight});
|
|
212
|
+
bottom.attach(clipsTimeline.root);
|
|
213
|
+
var clip = {id:"Clip1", start:0, duration:1, type:""};
|
|
214
|
+
clipsTimeline.addClip(clip);
|
|
215
|
+
var clip = {id:"Clip2", start:0, fadein: 0.5, fadeout: 0.8, duration:1, type:""};
|
|
216
|
+
clipsTimeline.addClip(clip);
|
|
217
|
+
var clip = {id:"Clip3", start:0, fadein: 0.5, fadeout: 0.8, duration:1, type:""};
|
|
218
|
+
clipsTimeline.addClip(clip);
|
|
219
|
+
var clip = {id:"Clip4", start:0, fadein: 0.5, fadeout: 0.8, duration:1, type:""};
|
|
220
|
+
clipsTimeline.addClip(clip);
|
|
221
|
+
var clip = {id:"Clip5", start:0, fadein: 0.5, fadeout: 0.8, duration:1, type:""};
|
|
222
|
+
clipsTimeline.addClip(clip);
|
|
223
|
+
|
|
224
|
+
// clipsTimeline.setAnimationClip({tracks: [{clips: [clip]}], duration: 2});
|
|
225
|
+
clipsTimeline.selectedItems = ["Clip1"];
|
|
226
|
+
|
|
227
|
+
clipsTimeline.draw(0);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
m.add( "Curves Timeline", e => {
|
|
232
|
+
console.log(e);
|
|
233
|
+
let el = document.getElementById('bottom-panel');
|
|
234
|
+
if(el)
|
|
235
|
+
el.style.display = 'none';
|
|
236
|
+
el = document.getElementById('kf-timeline');
|
|
237
|
+
if(el)
|
|
238
|
+
el.style.display = 'none';
|
|
239
|
+
el = document.getElementById('clips-timeline');
|
|
240
|
+
if(el)
|
|
241
|
+
el.style.display = 'none';
|
|
242
|
+
|
|
243
|
+
var timeline = document.getElementById('curves-timeline');
|
|
244
|
+
if(timeline) {
|
|
245
|
+
timeline.style.display = 'block';
|
|
246
|
+
curvesTimeline.resize();
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
curvesTimeline = new LX.CurvesTimeline("curves-timeline", {width: m.root.clientWidth, height: m.parent.root.parentElement.clientHeight - m.root.clientHeight, range: [-1,1]});
|
|
250
|
+
curvesTimeline.setSelectedItems(["Item 1", "Item 2", "Item 3"]);
|
|
251
|
+
curvesTimeline.setAnimationClip({tracks: [{name: "Item 1.position", values: [0,1,0,-1], times: [0, 0.1, 0.2, 0.3]}, {name: "Item 1.scale", values: [0,1,0, 0.5], times: [0, 0.1, 0.2, 0.3]}, {name: "Item 2", values: [0,1,0,1], times: [0.1, 0.2, 0.3, 0.8]}, {name: "Item 3.position", values: [0,0,0,1], times: [0, 0.1, 0.2, 0.3]}, {name: "Item 3.scale", values: [0,1,0], times: [0, 0.1, 0.2, 0.3]}], duration: 1});
|
|
252
|
+
bottom.attach(curvesTimeline.root);
|
|
253
|
+
curvesTimeline.draw(0);
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
bottom.onresize = bounding => {
|
|
258
|
+
if(clipsTimeline)
|
|
259
|
+
clipsTimeline.resize( );
|
|
260
|
+
|
|
261
|
+
if(kfTimeline)
|
|
262
|
+
kfTimeline.resize();
|
|
263
|
+
|
|
264
|
+
if(curvesTimeline)
|
|
265
|
+
curvesTimeline.resize();
|
|
266
|
+
}
|
|
267
|
+
} );
|
|
268
|
+
|
|
269
|
+
var bottomPanel = bottom.addPanel({id: "bottom-panel"});
|
|
270
|
+
fillBottomPanel( bottomPanel );
|
|
271
|
+
|
|
272
|
+
// split right area
|
|
273
|
+
var [rup, rbottom] = right.split({type: 'vertical', sizes:["70%","30%"]});
|
|
274
|
+
|
|
275
|
+
// Get new content area to fill it
|
|
276
|
+
const topTabs = up.addTabs();
|
|
277
|
+
|
|
278
|
+
// add canvas to left upper part
|
|
279
|
+
var canvas = document.createElement('canvas');
|
|
280
|
+
canvas.style.width = "100%";
|
|
281
|
+
canvas.style.height = "100%";
|
|
282
|
+
|
|
283
|
+
const resizeCanvas = ( bounding ) => {
|
|
284
|
+
canvas.width = bounding.width;
|
|
285
|
+
canvas.height = bounding.height;
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
topTabs.add( "Canvas", canvas, { selected: true, onCreate: resizeCanvas } );
|
|
289
|
+
topTabs.add( "Debug", document.createElement('div'));
|
|
290
|
+
|
|
291
|
+
// add on resize event to control canvas size
|
|
292
|
+
topTabs.area.onresize = resizeCanvas;
|
|
293
|
+
|
|
294
|
+
topTabs.area.addOverlayButtons( [
|
|
295
|
+
[
|
|
296
|
+
{
|
|
297
|
+
name: "Select",
|
|
298
|
+
icon: "fa fa-arrow-pointer",
|
|
299
|
+
callback: (value, event) => console.log(value),
|
|
300
|
+
selectable: true
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
name: "Move",
|
|
304
|
+
icon: "fa-solid fa-arrows-up-down-left-right",
|
|
305
|
+
img: "https://webglstudio.org/latest/imgs/mini-icon-gizmo.png",
|
|
306
|
+
callback: (value, event) => console.log(value),
|
|
307
|
+
selectable: true
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
name: "Rotate",
|
|
311
|
+
icon: "fa-solid fa-rotate-right",
|
|
312
|
+
callback: (value, event) => console.log(value),
|
|
313
|
+
selectable: true
|
|
314
|
+
}
|
|
315
|
+
],
|
|
316
|
+
{
|
|
317
|
+
name: "Lit",
|
|
318
|
+
options: ["Lit", "Unlit", "Wireframe"],
|
|
319
|
+
callback: (value, event) => console.log(value)
|
|
320
|
+
},
|
|
321
|
+
[
|
|
322
|
+
{
|
|
323
|
+
name: "Enable Snap",
|
|
324
|
+
icon: "fa fa-table-cells",
|
|
325
|
+
callback: (value, event) => console.log(value),
|
|
326
|
+
selectable: true
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
name: 10,
|
|
330
|
+
options: [10, 100, 1000],
|
|
331
|
+
callback: value => console.log(value)
|
|
332
|
+
}
|
|
333
|
+
], {
|
|
334
|
+
name: "Button 4",
|
|
335
|
+
img: "https://webglstudio.org/latest/imgs/mini-icon-gizmo.png",
|
|
336
|
+
callback: (value, event) => console.log(value)
|
|
337
|
+
}
|
|
338
|
+
], { float: "htc" } );
|
|
339
|
+
|
|
340
|
+
// add panels
|
|
341
|
+
var sidePanel = rup.addPanel();
|
|
342
|
+
fillPanel( sidePanel );
|
|
343
|
+
|
|
344
|
+
const bottomTabs = rbottom.addTabs({ fit: true });
|
|
345
|
+
var sideBottomPanel = new LX.Panel();
|
|
346
|
+
var sideBottomPanelH = new LX.Panel();
|
|
347
|
+
fillRightBottomPanel( sideBottomPanel, 'Vertical' );
|
|
348
|
+
fillRightBottomPanel( sideBottomPanelH, 'Horizontal' );
|
|
349
|
+
|
|
350
|
+
bottomTabs.add( "Panel V", sideBottomPanel );
|
|
351
|
+
bottomTabs.add( "Panel H", sideBottomPanelH );
|
|
352
|
+
|
|
353
|
+
function loop(dt) {
|
|
354
|
+
|
|
355
|
+
var ctx = canvas.getContext("2d");
|
|
356
|
+
|
|
357
|
+
// Get values from panel widgets (e.g. color value)
|
|
358
|
+
ctx.fillStyle = sidePanel.getValue('Background');
|
|
359
|
+
|
|
360
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
361
|
+
ctx.font = sidePanel.getValue('Font Size') + "px Monospace";
|
|
362
|
+
|
|
363
|
+
ctx.fillStyle = sidePanel.getValue('Font Color');
|
|
364
|
+
|
|
365
|
+
const text = sidePanel.getValue('Text');
|
|
366
|
+
const pos2D = sidePanel.getValue('2D Position');
|
|
367
|
+
ctx.fillText(text, pos2D[0], pos2D[1]);
|
|
368
|
+
|
|
369
|
+
if(kfTimeline)
|
|
370
|
+
kfTimeline.draw();
|
|
371
|
+
|
|
372
|
+
if(clipsTimeline)
|
|
373
|
+
clipsTimeline.draw();
|
|
374
|
+
|
|
375
|
+
if(curvesTimeline)
|
|
376
|
+
curvesTimeline.draw();
|
|
377
|
+
|
|
378
|
+
requestAnimationFrame(loop);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// createAssetDialog();
|
|
382
|
+
|
|
383
|
+
requestAnimationFrame(loop);
|
|
384
|
+
|
|
385
|
+
// **** **** **** **** **** **** **** **** **** **** **** ****
|
|
386
|
+
|
|
387
|
+
function fillPanel( panel ) {
|
|
388
|
+
|
|
389
|
+
// Add data tree
|
|
390
|
+
|
|
391
|
+
let sceneData = {
|
|
392
|
+
'id': 'root',
|
|
393
|
+
'children': [
|
|
394
|
+
{
|
|
395
|
+
'id': 'node_1',
|
|
396
|
+
'children': [
|
|
397
|
+
{
|
|
398
|
+
'id': 'node_1_1',
|
|
399
|
+
'icon': 'fa-solid fa-cube',
|
|
400
|
+
'children': [],
|
|
401
|
+
'actions': [
|
|
402
|
+
{
|
|
403
|
+
'name': 'Open script',
|
|
404
|
+
'icon': 'fa-solid fa-scroll',
|
|
405
|
+
'callback': function(node) {
|
|
406
|
+
console.log(node.id + ": Script opened!")
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
]
|
|
410
|
+
}
|
|
411
|
+
]
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
'id': 'node_2',
|
|
415
|
+
'icon': 'fa-solid fa-circle-play',
|
|
416
|
+
'children': []
|
|
417
|
+
}
|
|
418
|
+
]
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
// This is optional!
|
|
422
|
+
const treeIcons = [
|
|
423
|
+
{
|
|
424
|
+
'name':'Add node',
|
|
425
|
+
'icon': 'fa-solid fa-plus',
|
|
426
|
+
'callback': () => { console.log("Node added!") }
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
'name':'Instantiate scene',
|
|
430
|
+
'icon': 'fa-solid fa-link',
|
|
431
|
+
'callback': () => { console.log("Scene instantiated!") }
|
|
432
|
+
}
|
|
433
|
+
];
|
|
434
|
+
|
|
435
|
+
window.tree = panel.addTree("Scene Tree", sceneData, {
|
|
436
|
+
icons: treeIcons,
|
|
437
|
+
// filter: false,
|
|
438
|
+
onevent: (event) => {
|
|
439
|
+
console.log(event.string());
|
|
440
|
+
|
|
441
|
+
switch(event.type) {
|
|
442
|
+
case LX.TreeEvent.NODE_SELECTED:
|
|
443
|
+
if(event.multiple)
|
|
444
|
+
console.log("Selected: ", event.node);
|
|
445
|
+
else
|
|
446
|
+
console.log(event.node.id + " selected");
|
|
447
|
+
break;
|
|
448
|
+
case LX.TreeEvent.NODE_DELETED:
|
|
449
|
+
if(event.multiple)
|
|
450
|
+
console.log("Deleted: ", event.node);
|
|
451
|
+
else
|
|
452
|
+
console.log(event.node.id + " deleted");
|
|
453
|
+
break;
|
|
454
|
+
case LX.TreeEvent.NODE_DBLCLICKED:
|
|
455
|
+
console.log(event.node.id + " dbl clicked");
|
|
456
|
+
break;
|
|
457
|
+
case LX.TreeEvent.NODE_CONTEXTMENU:
|
|
458
|
+
LX.addContextMenu( event.multiple ? "Selected Nodes" : event.node.id, event.value, m => {
|
|
459
|
+
|
|
460
|
+
// {options}: callback, color
|
|
461
|
+
|
|
462
|
+
m.add( "Select Children", () => console.log("select children") );
|
|
463
|
+
m.add( "Clone", { callback: () => console.log("Clone"), color: "#0d5" } );
|
|
464
|
+
m.add( "Components/Transform");
|
|
465
|
+
m.add( "Components/MeshRenderer");
|
|
466
|
+
m.add( "Move before sibling" );
|
|
467
|
+
m.add( "Move after sibling" );
|
|
468
|
+
m.add( "Move to parent" );
|
|
469
|
+
m.add( "Delete" );
|
|
470
|
+
});
|
|
471
|
+
break;
|
|
472
|
+
case LX.TreeEvent.NODE_DRAGGED:
|
|
473
|
+
console.log(event.node.id + " is now child of " + event.value.id);
|
|
474
|
+
break;
|
|
475
|
+
case LX.TreeEvent.NODE_RENAMED:
|
|
476
|
+
console.log(event.node.id + " is now called " + event.value);
|
|
477
|
+
break;
|
|
478
|
+
case LX.TreeEvent.NODE_VISIBILITY:
|
|
479
|
+
console.log(event.node.id + " visibility: " + event.value);
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
// add widgets to panel branch
|
|
486
|
+
panel.branch("Preferences", {icon: "fa-solid fa-gear"});
|
|
487
|
+
panel.addButton(null, "Click me, Im Full Width...");
|
|
488
|
+
panel.addDropdown("Best Engine", ["Godot", "Unity", "Unreal Engine"], "Godot", (value, event) => {
|
|
489
|
+
console.log(value);
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
panel.addDropdown("Best Logo", [{value:"Godot", src: "https://pbs.twimg.com/profile_images/1631591220630757377/nKSCjeS3_400x400.png"}, {value: "Unity", src: "https://logos-world.net/wp-content/uploads/2023/01/Unity-Logo.png"}, {value:"Unreal Engine", src: "https://cdn2.unrealengine.com/ue-logo-stacked-unreal-engine-w-677x545-fac11de0943f.png"}], "Godot", (value, event) => {
|
|
493
|
+
console.log(value);
|
|
494
|
+
}, {filter: true});
|
|
495
|
+
|
|
496
|
+
panel.addDropdown("Best Gif", [{value:"Godot", src: "https://i.redd.it/4vepr95bye861.gif"}, {value: "Unity", src: "https://i.gifer.com/origin/db/db3cb258e9bbb78c5851a000742e5468_w200.gif"}, {value:"Unreal Engine", src: "https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/0/d/e0deb23c10cc7852c6ab91c28083e27f9c8228f8.gif"}], "Godot", (value, event) => {
|
|
497
|
+
console.log(value);
|
|
498
|
+
}, {filter: true});
|
|
499
|
+
|
|
500
|
+
panel.addVector3("Im a Vec3", [0.1, 0.4, 0.5], (value, event) => {
|
|
501
|
+
console.log(value);
|
|
502
|
+
});
|
|
503
|
+
panel.addLayers("Layers", 10, (value, event) => {
|
|
504
|
+
console.log(value);
|
|
505
|
+
});
|
|
506
|
+
panel.addArray("Array", ['GPTeam', 'Blat Panthers', 'Blat Bunny'], (value, event) => {
|
|
507
|
+
console.log(value);
|
|
508
|
+
});
|
|
509
|
+
panel.addTags("Game Tags", "2d, karate, ai, engine, ps5, console", (value, event) => {
|
|
510
|
+
console.log(value);
|
|
511
|
+
});
|
|
512
|
+
panel.addComboButtons("Alignment", [
|
|
513
|
+
{
|
|
514
|
+
value: 'left',
|
|
515
|
+
icon: 'fa fa-align-left',
|
|
516
|
+
callback: (value, event) => {
|
|
517
|
+
console.log(value);
|
|
518
|
+
}
|
|
519
|
+
}, {
|
|
520
|
+
value: 'center',
|
|
521
|
+
icon: 'fa fa-align-center',
|
|
522
|
+
callback: (value, event) => {
|
|
523
|
+
console.log(value);
|
|
524
|
+
}
|
|
525
|
+
}, {
|
|
526
|
+
value: 'right',
|
|
527
|
+
icon: 'fa fa-align-right',
|
|
528
|
+
callback: (value, event) => {
|
|
529
|
+
console.log(value);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
], {selected: "center"});
|
|
533
|
+
panel.addList(null, ['GPTeam', 'Blat Bunny', ['Blat Panthers', 'fa-solid fa-paw']], 'Blat Panthers', (value, event) => {
|
|
534
|
+
console.log(value);
|
|
535
|
+
});
|
|
536
|
+
const opacityValues = [
|
|
537
|
+
[0.2, 0.3146875],
|
|
538
|
+
[0.417313915857606, 0.8946875000000003],
|
|
539
|
+
[0.5495145631067961, 0.6746875],
|
|
540
|
+
[1, 1]
|
|
541
|
+
];
|
|
542
|
+
panel.addCurve("Opacity", opacityValues, (value, event) => {
|
|
543
|
+
console.log(value);
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
// another branch
|
|
547
|
+
panel.branch("Canvas", {icon: "fa-solid fa-palette", filter: true});
|
|
548
|
+
panel.addColor("Background", "#b7a9b1");
|
|
549
|
+
panel.addText("Text", "Lexgui.js @jxarco", null, {placeholder: "e.g. ColorPicker", icon: "fa fa-font"});
|
|
550
|
+
panel.addColor("Font Color", [1, 0.1, 0.6], (value, event) => {
|
|
551
|
+
console.log("Font Color: ", value);
|
|
552
|
+
});
|
|
553
|
+
panel.addNumber("Font Size", 36, (value, event) => {
|
|
554
|
+
console.log(value);
|
|
555
|
+
}, { min: 1, max: 48, step: 1});
|
|
556
|
+
panel.addVector2("2D Position", [250, 350], (value, event) => {
|
|
557
|
+
console.log(value);
|
|
558
|
+
}, { min: 0, max: 1024 });
|
|
559
|
+
panel.addSeparator();
|
|
560
|
+
panel.addTitle("Configuration (Im a title)");
|
|
561
|
+
panel.addCheckbox("Toggle me", true, (value, event) => {
|
|
562
|
+
console.log(value);
|
|
563
|
+
}, { suboptions: (p) => {
|
|
564
|
+
p.addText(null, "Suboption 1");
|
|
565
|
+
p.addNumber("Suboption 2", 12);
|
|
566
|
+
} });
|
|
567
|
+
panel.addFile("Image", data => { console.log(data) }, {} );
|
|
568
|
+
panel.merge();
|
|
569
|
+
|
|
570
|
+
// This is outside a branch
|
|
571
|
+
panel.addText("Im out :(", "", null, { placeholder: "Alone..." });
|
|
572
|
+
panel.addVector4("Im a Vec4", [0.3, 0.3, 0.5, 1], (value, event) => {
|
|
573
|
+
console.log(value);
|
|
574
|
+
});
|
|
575
|
+
panel.addButton(null, "Click me, Im Full Width...");
|
|
576
|
+
panel.addButton("Test Button", "Reduced width...");
|
|
577
|
+
panel.addBlank(12);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
function fillRightBottomPanel( panel, tab ) {
|
|
581
|
+
|
|
582
|
+
panel.clear();
|
|
583
|
+
|
|
584
|
+
panel.branch("Bottom", {icon: "fa-solid fa-table-list"});
|
|
585
|
+
|
|
586
|
+
if(tab == 'Horizontal')
|
|
587
|
+
{
|
|
588
|
+
panel.addTabs([
|
|
589
|
+
{
|
|
590
|
+
name: "First tab",
|
|
591
|
+
icon: "fa-brands fa-discord",
|
|
592
|
+
callback: p => {
|
|
593
|
+
p.addTitle("Discord tab");
|
|
594
|
+
p.addButton(null, "Connect");
|
|
595
|
+
}
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
name: "Second tab",
|
|
599
|
+
icon: "fa-brands fa-twitter",
|
|
600
|
+
callback: p => {
|
|
601
|
+
p.addTitle("Twitter tab");
|
|
602
|
+
p.addText("Tweet", "", null, {placeholder: "Tyler Rake 2"});
|
|
603
|
+
}
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
name: "Third tab",
|
|
607
|
+
icon: "fa-brands fa-github",
|
|
608
|
+
callback: p => {
|
|
609
|
+
p.addTitle("Github tab");
|
|
610
|
+
p.addButton(null, "Go", () => {window.open("https://github.com/jxarco/lexgui.js/")});
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
], { vertical: false /*, showNames: true */});
|
|
614
|
+
|
|
615
|
+
panel.addText(null, "Widgets below are out the tabs", null, { disabled: true })
|
|
616
|
+
|
|
617
|
+
// update panel values uising widget name
|
|
618
|
+
panel.addNumber("HeadRoll Value", 0, (value, event) => {
|
|
619
|
+
panel.setValue('HeadRoll', value);
|
|
620
|
+
}, { min: -1, max: 1, step: 0.1 });
|
|
621
|
+
panel.addProgress("HeadRoll", 0, { min: -1, max: 1, showValue: true, editable: true, callback: (value, event) => {
|
|
622
|
+
panel.setValue('HeadRoll Value', value);
|
|
623
|
+
} });
|
|
624
|
+
}
|
|
625
|
+
else if(tab == 'Vertical')
|
|
626
|
+
{
|
|
627
|
+
panel.addTabs([
|
|
628
|
+
{
|
|
629
|
+
name: "First tab",
|
|
630
|
+
icon: "fa-brands fa-discord",
|
|
631
|
+
callback: (p, content) => {
|
|
632
|
+
p.addTitle("Discord tab");
|
|
633
|
+
p.addButton("Apply", "Add button to branch", (value, event) => {
|
|
634
|
+
p.queue( content );
|
|
635
|
+
p.addButton(null, "Hello");
|
|
636
|
+
p.clearQueue();
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
name: "Second tab",
|
|
642
|
+
icon: "fa-brands fa-twitter",
|
|
643
|
+
callback: p => {
|
|
644
|
+
p.addTitle("Twitter tab");
|
|
645
|
+
p.addText("Tweet", "", null, {placeholder: "Tyler Rake 2"});
|
|
646
|
+
}
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
name: "Third tab",
|
|
650
|
+
icon: "fa-brands fa-github",
|
|
651
|
+
callback: p => {
|
|
652
|
+
p.addTitle("Github tab");
|
|
653
|
+
p.addButton(null, "Go", (value, event) => {window.open("https://github.com/jxarco/lexgui.js/")});
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
]);
|
|
657
|
+
|
|
658
|
+
/************** */
|
|
659
|
+
// Custom Widget
|
|
660
|
+
|
|
661
|
+
LX.ADD_CUSTOM_WIDGET( 'Shader', {
|
|
662
|
+
// icon: "fa-dice-d6",
|
|
663
|
+
default: {
|
|
664
|
+
'position': [0, 0],
|
|
665
|
+
'velocity': [0, 0, 0],
|
|
666
|
+
'color': [0, 0, 0, 0],
|
|
667
|
+
'hex_color': '#000',
|
|
668
|
+
'high_res': false
|
|
669
|
+
}
|
|
670
|
+
});
|
|
671
|
+
|
|
672
|
+
const shaderInstance = {
|
|
673
|
+
'hex_color': '#f5f505',
|
|
674
|
+
'high_res': true
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
panel.addShader( "PBR Shader", shaderInstance, (instance) => { console.log(instance) } );
|
|
678
|
+
panel.addShader( "Empty", null );
|
|
679
|
+
|
|
680
|
+
/************** */
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
panel.merge();
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
function fillBottomPanel( panel ) {
|
|
687
|
+
|
|
688
|
+
// add widgets to panel branch
|
|
689
|
+
panel.branch("Information", {icon: "fa fa-circle-info"});
|
|
690
|
+
panel.addText("Camera", "Canon EOS 80D", null, {disabled: true});
|
|
691
|
+
panel.addText("Serial number", "194E283DD", (value, event) => {
|
|
692
|
+
console.log(value);
|
|
693
|
+
});
|
|
694
|
+
panel.addTextArea("Notes", "", (value, event) => {
|
|
695
|
+
console.log(value);
|
|
696
|
+
}, { placeholder: 'Some notes...' });
|
|
697
|
+
panel.addButton("Apply", "Add button to branch", (value, event) => {
|
|
698
|
+
const branch = panel.getBranch("Information");
|
|
699
|
+
panel.queue( branch.content );
|
|
700
|
+
panel.addButton(null, "Hello");
|
|
701
|
+
panel.clearQueue();
|
|
702
|
+
});
|
|
703
|
+
|
|
704
|
+
panel.branch("A collapsed branch", {closed: true});
|
|
705
|
+
panel.addText(null, "Nothing here", null, {disabled: true});
|
|
706
|
+
panel.merge();
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
function createAssetDialog() {
|
|
710
|
+
|
|
711
|
+
let dialog = new LX.Dialog('Non Manual Features lexemes', (p) => {
|
|
712
|
+
|
|
713
|
+
const previewActions = [
|
|
714
|
+
{
|
|
715
|
+
name: 'Print Clip',
|
|
716
|
+
type: 'clip',
|
|
717
|
+
callback: ( item ) => {
|
|
718
|
+
console.log(item);
|
|
719
|
+
}
|
|
720
|
+
},
|
|
721
|
+
{
|
|
722
|
+
name: 'Print Image',
|
|
723
|
+
type: 'image',
|
|
724
|
+
callback: ( item ) => {
|
|
725
|
+
console.log(item);
|
|
726
|
+
}
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
name: 'Common',
|
|
730
|
+
callback: ( item ) => {
|
|
731
|
+
console.log(item);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
];
|
|
735
|
+
|
|
736
|
+
var assetView = new LX.AssetView({
|
|
737
|
+
skip_browser: true,
|
|
738
|
+
skip_navigation: true,
|
|
739
|
+
preview_actions: previewActions
|
|
740
|
+
});
|
|
741
|
+
|
|
742
|
+
p.attach( assetView );
|
|
743
|
+
let assetData = [];
|
|
744
|
+
const values = ['brow_lowerer.png', 'godot_pixelart.png', 'godot_canvas.png' ];
|
|
745
|
+
|
|
746
|
+
for(let i = 0; i < values.length; i++){
|
|
747
|
+
let data = {
|
|
748
|
+
id: values[i],
|
|
749
|
+
type: i == 0 ? "clip" : "image",
|
|
750
|
+
src: "data/" + values[i].toLowerCase(),
|
|
751
|
+
}
|
|
752
|
+
assetData.push(data);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
assetView.load( assetData, (e,v) => {
|
|
756
|
+
switch(e.type) {
|
|
757
|
+
case LX.AssetViewEvent.ASSET_SELECTED:
|
|
758
|
+
if(e.multiple)
|
|
759
|
+
console.log("Selected: ", e.item);
|
|
760
|
+
else
|
|
761
|
+
console.log(e.item.id + " selected");
|
|
762
|
+
break;
|
|
763
|
+
case LX.AssetViewEvent.ASSET_DELETED:
|
|
764
|
+
console.log(e.item.id + " deleted");
|
|
765
|
+
break;
|
|
766
|
+
case LX.AssetViewEvent.ASSET_CLONED:
|
|
767
|
+
console.log(e.item.id + " cloned");
|
|
768
|
+
break;
|
|
769
|
+
case LX.AssetViewEvent.ASSET_RENAMED:
|
|
770
|
+
console.log(e.item.id + " is now called " + e.value);
|
|
771
|
+
break;
|
|
772
|
+
}
|
|
773
|
+
})
|
|
774
|
+
},{ title:'Lexemes', close: true, minimize: false, size: ["80%"], scroll: true, resizable: true, draggable: true });
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
}
|
|
778
|
+
LX.popup("Hello! I'm a popup :)", null, {position: ["50px", "100px"]})
|