limelight-yew

Crates.iolimelight-yew
lib.rslimelight-yew
version0.1.0
sourcesrc
created_at2021-12-15 18:38:20.902657
updated_at2021-12-15 18:38:20.902657
descriptionScaffolding for creating WebGL2-rendered Yew components with limelight
homepage
repositoryhttps://github.com/drifting-in-space/limelight
max_upload_size
id498475
size14,867
Paul Butler (paulgb)

documentation

README

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.

Commit count: 120

cargo fmt