junkpile

21 · wgpu glTF Scene Loader

A standalone Tauri 2 + wgpu 29 example for importing glTF 2.0 scenes into a native Metal, Vulkan, or DirectX 12 render surface.

This begins Junkpile’s mesh and posing sequence. It deliberately focuses on the scene-loading foundation before skeletal animation, morph targets, and compute deformation are added in later examples.

What it demonstrates

Run

npm install
npm run dev:metal

Automatic backend selection:

npm run dev

Other explicit backends:

npm run dev:vulkan
npm run dev:dx12

First test

  1. Launch the project.
  2. Confirm the bundled cube-and-pyramid scene appears.
  3. Drag in the orbit controller and use the mouse wheel to change camera distance.
  4. Switch among Lit PBR, Normals, UV coordinates, and Material IDs.
  5. Click Open glTF / GLB and select another asset.
  6. Check the node, mesh, primitive, material, texture, animation, and skin counts.

For external .gltf files, keep referenced .bin and image files beside the .gltf file. A .glb usually packages those resources into one file.

Current scope

This example renders triangle primitives and the core PBR base-color path. It records animation and skin counts but does not animate or skin the mesh yet. Those capabilities belong to the following examples:

See GLTF-SCENE-GUIDE.md for the complete pipeline explanation.

Important files

src-tauri/src/main.rs       Tauri commands, file picker, native windows
src-tauri/src/scene.rs      glTF import, hierarchy traversal, CPU scene data
src-tauri/src/renderer.rs   wgpu buffers, textures, materials, camera and drawing
src-tauri/src/scene.wgsl    mesh vertex and fragment shaders
src-tauri/assets/           bundled sample GLB
src/                        controls WebView

Dependencies

Known limitations

License

MIT.

21.1 correction

The wgpu 29 vertex state uses a direct slice of wgpu::VertexBufferLayout values:

buffers: &[wgpu::VertexBufferLayout { /* ... */ }],

It must not wrap each layout in Some(...).