G’day.
I am facing the problem of an infinite loop for my BabylonJS canvas. I have a flex-layout containing the canvas and another component. The canvas has flex-grow 1 and the other component has a fixed size. I install a ResizeObserver on the canvas and call engine.resize() when it is triggered. The canvas seems to be getting bigger with every cycle of the infinite loop.![]()
Before, I had the canvas in another component with width: 100% and height: 100%, which worked without a problem. ChatGPT told me the ResizeObserver should be installed on the parent but I don’t get why and it also didn’t help.
I managed to put a stop to the infinite loop by doing this:
new ResizeObserver(() => {
if (canvas.clientWidth != engine.getRenderWidth(false) || canvas.clientHeight != engine.getRenderHeight(false)) {
engine.resize();
}
}).observe(canvas);
But still, calling engine.resize() seems to somehow mess up layout rules. With this, approach the canvas grows way bigger than it should and pushes the other component out of sight.
Can you guys help? ![]()