Viewer V2 difference in animation behavior between versions

Here is the example with 7.38.0 - https://codepen.io/eldinor/pen/yyLKoab
The model has 2 animations, everything works as expected.

The same code with 7.53.2 - https://codepen.io/eldinor/pen/EaxEwxM
The first animation works as expected. Then, if you click on “Hide Posts” button, the second animation will not play until you manually resize the window.

I wonder what could be the reason and a workaround? @ryantrem

cc @ryantrem

This happens because the Viewer now suspends rendering the scene by default when it believes there are no changes frame to frame. This reduces power consumption on mobile devices, and also allows us to render a final frame at full resolution even for complex models, which increases perceived rendering quality. It does a lot of internal tracking to make this work, so if you bypass the Viewer APIs and go straight to the Babylon.js APIs, you will need to handle this in your code in one of two ways:

  1. Disable the automatic suspension of rendering the scene by adding the render-when-idle attribute. You will lose some of the benefits mentioned above, but the regular render loop that renders the scene will run continuously.
  2. After you make a change directly to the scene through the Babylon API, you can call viewerElem.viewerDetails.markSceneMutated() and this will tell the Viewer that something has changed and it needs to resume rendering the scene. It will auto suspend again when it thinks it is in an idle state.
2 Likes

Thanks, it works now :slight_smile: - https://codepen.io/eldinor/pen/XJWEENd

1 Like