VertexAnimationBaker hangs if the scene is not rendered

It’s more of a user error, but it would have been really useful if an error were thrown…

VertexAnimationBaker.bakeVertexData hangs if called on a scene that’s not rendered yet. There’s no error, just… the promise never resolves.

My engine loads a scene, does some initialization, then passes the scene to the renderer. Well, part of the initialization is to bake vertex animation textures… But the scene is not rendered yet, so the baker just hangs.

Edit: I thought it was because there was no camera, or scene.isReady() was false, or the scene wasn’t in scene.getEngine().scenes, or something from the asset container wasn’t added to the scene… But no, all those are checked, yet bakeVertexData still hangs.

I know now that it’s better to reuse the same scene, and use asset containers to load/unload assets, but that’s a future change.

You should use the same scene the mesh is defined in.

I don’t think the scene has to be rendered prior to calling the function, but the engine render loop must be setup.

I am using the same scene: mesh.getScene(). Everything from the asset container has been added to the scene, and the scene isReady (if that matters), and is attached to the engine. I can even see it if I call render() on it.

I still don’t know what the root cause is, but the baker calls _executeAnimationFrame, which calls _scene.beginAnimation, with a onAnimationEnd callback… This callback is never called.

I tried different meshes and ranges, but they all hang. Only when I use a different scene does bakeVertexData complete. Obviously that’s not a solution, but it’s a clue that there’s something about the scene… I just can’f figure out what.

If you are able to setup a repro in the Playground we could have a look, it seems wrong to me that it does not work with your setup.

1 Like