Is it possible to force a render update prior to using toBlob Poster generation?
When updating certain properties (EG Camera orbit, or the size of Model Viewer itself) and immediately calling toBlob to generate a Poster image, the generated image is of the previous state, not the freshly updated state. Presumably, this is due to a frame update cycle delay? One workaround is to set a timeout to delay the image capture. But is there a more elegant and immediate way to force the renderer to update and redraw with the latest properties?
Yes, the natural way to achieve this in general on a browser is to call requestAnimationFrame(); you'll see many examples of us doing this in our tests for the same reason. We have a little helper you can copy that resolves its promise inside the callback, so you can easily await it.
Amazing. Thanks. Like this?
Most helpful comment
Amazing. Thanks. Like this?
https://github.com/google/model-viewer/blob/bb82a5b2097b467c7047447327cebc4080e35fcd/packages/modelviewer.dev/src/tester.ts#L97-L108