Skip to content

Latest commit

 

History

History
 
 

examples

Examples

Build

Native:

Build and run an example, in this case 'triangle':

$ cargo run --example triangle --release

WebAssembly:

Prerequisites:

Build and generate web output (webassembly, javascript and html files) into the pkg folder:

$ wasm-pack build examples/triangle --target web --out-name web --out-dir ../../pkg

Start the server and go to http://localhost:8080 in a browser:

$ http-server

A note on async

All of the examples builds to both native (desktop, mobile or whatever target specified) and WebAssembly (wasm) that can be run in a browser. Because they should run in a browser and to keep the same code for native and wasm, all loading happens async. If your application is native only, you can avoid the async runtime (tokio or async-std) and use three_d_asset::load instead of three_d_asset::load_async.

Triangle [code] [demo]

This is the recommended starting point for a gentle introduction to three-d.

Triangle example

Triangle core [code] [demo]

This is the same as the Triangle example, except it only uses the core module and not the renderer module.

Triangle core example

Mandelbrot [code] [demo]

Mandelbrot example

Shapes2D [code] [demo]

Shapes2d example

Shapes [code] [demo]

Shapes example

Instanced Draw Order [code] [demo]

This example shows how depth ordering is currently working for InstancedMesh objects with transparency.

Instanced Draw Order

Instanced Shapes [code] [demo]

Instanced Shapes example

Screen [code] [demo]

Screen example

Multisample [code] [demo]

Screen example

Sprites [code] [demo]

Sprites example

Texture [code] [demo]

Texture example

Animation [code] [demo]

Animation example

Picking [code] [demo]

Picking example

Environment [code] [demo]

Environment example

PBR [code] [demo]

PBR example

Lighting [code] [demo]

Lighting example

Lights [code] [demo]

Lights example

Image [code] [demo]

Image example

Point cloud [code] [demo]

Point cloud example

Fog [code] [demo]

Fog example

Terrain [code] [demo]

Terrain example

Fireworks [code] [demo]

Fireworks example

Statues [code] [demo]

Statues example

Wireframe [code] [demo]

Wireframe example

Forest [code] [demo]

Forest example

Volume [code] [demo]

Volume example

Normals [code] [demo]

Normals example

Logo [code] [demo]

Logo example

Winit window [code] [demo]

Shows how to easily combine a custom winit window with three-d rendering.

Winit window example

Multiwindow [code] [demo]

Shows how to create multiple winit windows and render with three-d.

Headless [code]

This example does not create a window but render directly to a render target and saves the result to disk. Therefore, this example does not work on web.