Scaffolding for creating WebGL2-rendered Yew components with limelight

1 unstable release

0.1.0 Dec 15, 2021

#49 in #webgl

MIT license



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:


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.


~204K SLoC