3D
The support for 3D is less fleshed out than for 2D at the moment, but it is being worked on.
The workflow for 3D is different to 2D, as it would be too inefficient to rebuild 3D meshes every frame, so they are retained. You can create a 3D mesh from a .obj file. Instead of using a set flat/textured/patterned material like in 2D, you can use any shader/material you want on 3D objects. There are built-in functions for creating generic flat/physically shaded materials of different colors, or you can create your own.
#![allow(unused)]
fn main() {
let program = include_program!(
"./material_shader/outline_vertex.glsl",
"./material_shader/outline_fragment.glsl"
)?;
let material = Material::new(program)
.with_color("outline_color", Color::PURPLE_100)
.with_float("outline_width", 0.3)
.create();
let object = Object3D::from_obj_bytes_with_material(
include_bytes!("../assets/models/suzanne.obj"),
material,
)?;
}
Objects then need to be drawn every frame with object.draw().

Materials
A material is just a collection of a vertex shader, fragment shader, and named
uniforms. Uniforms can be set using material.set_*, and can be used to pass
data from the CPU into the shader.
#![allow(unused)]
fn main() {
let threshold = (time * 0.2).sin() * 0.5 + 0.5;
mat.set_float("dissolve_threshold", threshold);
}
#version 150
in vec3 v_normal;
in vec3 v_position;
in vec2 v_tex_coords;
in vec3 v_world_position;
out vec4 color;
uniform float time;
uniform float dissolve_threshold; // used here
There are some uniforms that are set automatically by the engine, and are availible in all material shaders:
view_proj_matrixmat4model_matrixmat4normal_matrixmat3timein seconds, floatdelta_timein seconds, floatrandomnumber to use as a seed, floatscreen_sizein pixels, vec2camera_posvec3
See: /examples/material_shader/vertex.glsl
See: /examples/material_shader/fragment.glsl
Shapes
In addition to loading shapes from an object, there are also functions for creating simple shapes from some parameters. So far there are only:
cubiod/cube(also_from_extentsand_with_orientation)line_3dandline_3d_flatcube_wireframeandcube_wireframe_flat
Example from shapes_3d.rs:
