Skip to content

Commit 0688cb0

Browse files
committed
Examples: Improved transpiler UX.
1 parent a5cbfc6 commit 0688cb0

File tree

1 file changed

+54
-14
lines changed

1 file changed

+54
-14
lines changed

examples/webgpu_tsl_transpiler.html

Lines changed: 54 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,56 @@
1010
<style>
1111
#source {
1212
position: absolute;
13-
top: 0;
13+
top: 50px;
1414
left: 0;
1515
width: 50%;
16-
height: 100%;
16+
height: calc(100% - 50px);
1717
}
1818
#result {
1919
position: absolute;
20-
top: 0;
20+
top: 50px;
2121
right: 0;
2222
width: 50%;
23-
height: 100%;
23+
height: calc(100% - 50px);
24+
}
25+
#source-dropdown {
26+
position: absolute;
27+
top: 10px;
28+
left: 10px;
29+
z-index: 100;
30+
}
31+
#result-dropdown {
32+
position: absolute;
33+
top: 10px;
34+
left: calc(50% + 10px);
35+
z-index: 100;
36+
}
37+
select {
38+
background: #333;
39+
color: white;
40+
border: 1px solid #555;
41+
padding: 5px 10px;
42+
}
43+
label {
44+
color: white;
45+
font-family: Arial, sans-serif;
46+
font-size: 14px;
2447
}
2548
</style>
2649

50+
<div id="source-dropdown">
51+
<label for="decoder-select">Encoder:</label>
52+
<select id="decoder-select">
53+
<option value="GLSL">GLSL</option>
54+
</select>
55+
</div>
56+
<div id="result-dropdown">
57+
<label for="encoder-select">Decoder:</label>
58+
<select id="encoder-select">
59+
<option value="TSL">TSL</option>
60+
<option value="WGSL">WGSL</option>
61+
</select>
62+
</div>
2763
<div id="source"></div>
2864
<div id="result"></div>
2965
<script src="https://cdn.jsdelivr.net/npm/[email protected]/min/vs/loader.js"></script>
@@ -46,8 +82,6 @@
4682
import WGSLEncoder from 'three/addons/transpiler/WGSLEncoder.js';
4783
import TSLEncoder from 'three/addons/transpiler/TSLEncoder.js';
4884

49-
import { GUI } from 'three/addons/libs/lil-gui.module.min.js';
50-
5185
init();
5286

5387
function init() {
@@ -124,6 +158,7 @@
124158
language: 'c',
125159
theme: 'vs-dark',
126160
automaticLayout: true,
161+
wordWrap: 'on',
127162
minimap: { enabled: false }
128163
} );
129164

@@ -132,6 +167,7 @@
132167
language: 'javascript',
133168
theme: 'vs-dark',
134169
automaticLayout: true,
170+
wordWrap: 'on',
135171
readOnly: true,
136172
minimap: { enabled: false }
137173
} );
@@ -192,20 +228,24 @@
192228

193229
} );
194230

195-
// gui
196-
197-
const gui = new GUI();
231+
// dropdowns
198232

199-
gui.add( options, 'decoder', [ 'GLSL' ] );
200-
gui.add( options, 'encoder', [ 'TSL', 'WGSL' ] ).onChange( ( encoder => {
233+
const decoderSelect = document.getElementById( 'decoder-select' );
234+
const encoderSelect = document.getElementById( 'encoder-select' );
201235

202-
const language = encoderLanguages[ encoder ];
236+
decoderSelect.addEventListener( 'change', () => {
237+
options.decoder = decoderSelect.value;
238+
build();
239+
} );
203240

241+
encoderSelect.addEventListener( 'change', () => {
242+
options.encoder = encoderSelect.value;
243+
244+
const language = encoderLanguages[ encoderSelect.value ];
204245
window.monaco.editor.setModelLanguage( result.getModel(), language );
205246

206247
build();
207-
208-
} ) );
248+
} );
209249

210250
} );
211251

0 commit comments

Comments
 (0)