Need help with three-d?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

asny
375 Stars 30 Forks MIT License 2.4K Commits 21 Opened issues

Description

A renderer written in Rust which compiles to both desktop (OpenGL) and web (WebAssembly + WebGL).

Services available

!
?

Need anything else?

Contributors list

three-d

crates.io Docs.rs Continuous integration MIT licensed

What is it?

A 3D renderer which enables out-of-the-box build to both desktop (Rust + OpenGL) and web (Rust to WebAssembly + WebGL2). This makes it possible to develop a 3D application on desktop and easily deploy it on both desktop and web!

The crate consist of three main modules for drawing,

context
,
core
and
renderer
, and two optional utility modules,
io
and
window
:

| Module | Description
| :---------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |

context
| Low-level rendering module - requires a solid understanding of graphics concepts. Gives you complete control over both setup and rendering.
|
core
| Mid-level rendering module - requires at least some knowledge about graphics concepts. Use this if you want to write your own shaders and but don't want to spend time on setup and error handling. Can be combined with low-level calls in the

context
module as long as any graphics state changes are reset.
|
renderer
| High-level rendering module - requires no knowledge about graphics concepts. Use this if you just want to draw something on the screen. Features include methods for rendering different types of standard objects with different types of shading. Can be combined seamlessly with the mid-level features in the
core
module and also with calls in the
context
module as long as the graphics state is reset. | |
io
| Contains functionality to load any type of asset runtime on both desktop and web as well as parsers for different image and 3D model formats. Also includes functionality to save data which is limited to desktop. |
window
| Contains functionality for creating a window on both cross-platform desktop (requires the
"glutin-window"
feature) and web (requires the
"canvas"
feature). Also contain render loop, event handling and camera control functionality. Can be replaced by anything that provides an OpenGL or WebGL2 graphics context.

Supported browsers

Chrome, Firefox, Edge and Safari (Safari might requires enabling the "WebGL 2.0" experimental feature).

Examples

Several examples covering most features can be found here and the examples from the latest release are also live at asny.github.io/three-d/. Take a look at the triangle example for a gentle introduction.

Lighting example Statues example PBR example Spider example

Build

Desktop:

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

$ cargo run --example triangle --release

Web:

Prerequisites: - A server that properly defines the

application/wasm
mime type (for example http-server) - wasm-pack

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

Other

Feature requests and bug reports are more than welcome, just open an issue or start a discussion. Contributions are highly appreciated, please feel free to reach out or simply create a pull request against the development branch.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.