Hackup inspired by Daniel Roux's Blupi character (see his sample code used to learn how to write a game in JavaScript), but with Blazor. Basically, the code uses Blazor.Extensions.Canvas
and requestAnimationFrame()
to call into Blazor.
function renderJS(timeStamp) {
theInstance.invokeMethodAsync('RenderInBlazor', timeStamp);
window.requestAnimationFrame(renderJS);
}
[JSInvokable]
public async ValueTask RenderInBlazor(float timeStamp)
{
// ...
}