Model-viewer: Force render update prior to toBlob Poster generation?

Created on 16 Sep 2020  路  2Comments  路  Source: google/model-viewer

Description

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?

question

Most helpful comment

All 2 comments

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.

Was this page helpful?
0 / 5 - 0 ratings