pub trait Renderer {
// Required methods
fn viewport(&self) -> (f64, f64);
fn set_camera(&mut self, camera: Camera);
fn clear(&self, color: &str);
fn project(&self, world: Vec3) -> Option<ScreenPoint>;
fn line(
&self,
a: ScreenPoint,
b: ScreenPoint,
color: &str,
alpha: f64,
width: f64,
);
fn point(&self, p: ScreenPoint, radius: f64, color: &str, alpha: f64);
fn fill_polygon(&self, points: &[ScreenPoint], color: &str, alpha: f64);
}Expand description
An immediate-mode renderer for line/point 3D scenes.
Colors are CSS color strings (e.g. "#67e8f9", "rgba(...)") so the CPU
backend can pass them straight to Canvas 2D; a GPU backend parses them.
Required Methods§
Sourcefn set_camera(&mut self, camera: Camera)
fn set_camera(&mut self, camera: Camera)
Set the active camera used for Renderer::project.
Sourcefn project(&self, world: Vec3) -> Option<ScreenPoint>
fn project(&self, world: Vec3) -> Option<ScreenPoint>
Project a world-space point to screen space (CPU-side cull/fade helper).
Sourcefn line(
&self,
a: ScreenPoint,
b: ScreenPoint,
color: &str,
alpha: f64,
width: f64,
)
fn line( &self, a: ScreenPoint, b: ScreenPoint, color: &str, alpha: f64, width: f64, )
Draw a screen-space line segment.
Sourcefn point(&self, p: ScreenPoint, radius: f64, color: &str, alpha: f64)
fn point(&self, p: ScreenPoint, radius: f64, color: &str, alpha: f64)
Draw a filled screen-space disc (billboarded point).
Sourcefn fill_polygon(&self, points: &[ScreenPoint], color: &str, alpha: f64)
fn fill_polygon(&self, points: &[ScreenPoint], color: &str, alpha: f64)
Fill a screen-space polygon (e.g. a depth-shaded quad).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl Renderer for NativeRenderer
Available on non-WebAssembly only.