Janx Posted September 18, 2018 Share Posted September 18, 2018 Hi, I have trouble with the mesh selection phase, which takes too long and therefor causes frame rates around 30 FPS. My scene contains roughly 2000 meshes, most of them empty (just used as containers or transformations). I do not know, if that is considered too much. Anyhow, using freezeActiveMeshes (thanks for adding this) to disable the mesh selection phase solves my problem, because the actual rendering of the scene is quite fast, even with all meshes activated. I therefore want to unfreezeActiveMeshes whenever the scene was changed and to freezeActiveMeshes as soon as possible. I thought using the onAfterActiveMeshesEvaluationObservable was a good idea to get informed when the mesh selection phase is completed, but using freezeActiveMeshes in the callback causes the engine to stall completely. You can see this here: https://playground.babylonjs.com/indexStable.html#0WHH9Q#5 Disabe the callback and it works: https://playground.babylonjs.com/indexStable.html#0WHH9Q#6 What is going on? Am I misusing the onAfterActiveMeshesEvaluationObservable? Cheers, jan Quote Link to comment Share on other sites More sharing options...
Gijs Posted September 18, 2018 Share Posted September 18, 2018 Hi, from the error in the console it seems that freezeActiveMeshes causes onAfterActiveMeshesEvaluationObservable to be called, and creating an infinite loop. But regarding the meshes, can't you use a TransformNode instead? trevordev and Janx 2 Quote Link to comment Share on other sites More sharing options...
trevordev Posted September 18, 2018 Share Posted September 18, 2018 To replace onAfterActiveMeshesEvaluationObservable for your scenario you could have a flag that states if a new mesh has been created and use scene.on(Before/After)RenderObservable to check if a freeze is needed. Janx 1 Quote Link to comment Share on other sites More sharing options...
Guest Posted September 18, 2018 Share Posted September 18, 2018 I also recommend to use TransformNode as much as you can for containers as they are not processed by the evaluation phase hence reducing its cost Janx 1 Quote Link to comment Share on other sites More sharing options...
Janx Posted September 19, 2018 Author Share Posted September 19, 2018 Awesome, thanks for the quick support! @Gijs @Deltakosh I was not aware of Transformation Nodes and will start using them right away. @trevordev Thanks for the idea. Looking at the code of freezeActiveMeshes it is absolutely correct, that it notifies the onAfterActiveMeshesEvaluationObservable again. So I came up with a check in the callback whether freeze was already requested: https://playground.babylonjs.com/indexStable.html#0WHH9Q#7 I like this approach a bit more, since than again calling unfreeze is enough to update the scene. trevordev and Gijs 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.