Crates.io | limelight-yew |
lib.rs | limelight-yew |
version | 0.1.0 |
source | src |
created_at | 2021-12-15 18:38:20.902657 |
updated_at | 2021-12-15 18:38:20.902657 |
description | Scaffolding for creating WebGL2-rendered Yew components with limelight |
homepage | |
repository | https://github.com/drifting-in-space/limelight |
max_upload_size | |
id | 498475 |
size | 14,867 |
limelight-yew
Provides scaffolding for building Yew components that use
limelight to render to a
canvas. Apps can implement LimelightController
, which can then be wrapped
in LimelightComponent
and used as a Yew component directly.
For example, the primitive scene demo (code)
is implemented as a class Primitives
, which implements std::default::Default
and LimelightController
.
It is then initialized through Yew like so:
yew::start_app::<LimelightComponent<Primitives>>();
Implementors of LimelightController
are only required to implement one function,
fn draw(&mut self, renderer: &mut Renderer, _ts: f64) -> Result<limelight_yew::ShouldRequestAnimationFrame>
. This function is called every
animation frame to tell the controller to draw its content using the provided Renderer
.
Implementors may optionally implement other functions like handle_zoom
and handle_drag
to
respond to mouse interactions with the component.
All methods return either a bool
(aliased to ShouldRequestAnimationFrame
) or a Result<bool>
.
These methods should return true
if they would like to
trigger a redraw. For handle_
methods, this usually
means that they modified buffers or uniforms that should
be reflected in the image. For draw
, returning Ok(true)
is the intended way to create an animation loop if the
draw
call itself updates uniforms or buffers.