Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 14.3 — A Triangle in Raw WebGPU
3D Web · Example 2 of 2

A WGSL mistake, and where its message goes

With WebGPU: the uncaptured error event line, error at line 2, column 10: no matching constructor for 'vec4<f32>(…)', then uncaptured error event: [Invalid ShaderModule "glow shader"] is invalid due to a previous error. Without, it says so.

WebGPU draws the same triangle with other ideas: ask for an adapter and a device (both asynchronous), write both shaders in one WGSL module, fix every setting in advance in a pipeline, record commands into an encoder, and submit them at once. Errors are checked and reported in detail.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 4 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Clear to Lumen blue instead of the stage colour.

02

Print the adapter's largest texture size and largest uniform binding.

Explain it without notes

01

List the objects you create to draw one triangle with WebGPU, in order, and what each is for.

02

What can requestAdapter() return, and how should a page react?

A WGSL mistake, and where its message goes

Preview

Press Run to see the page.

Console

Nothing logged yet.