I have my
EngineView as a child of a parent
View but changing the size of this parent view doesn’t seem to trigger
I have my
Maybe @ryantrem knows why it’s not called?
For some additional context, can you explain your use case?
Beyond that, my understanding is that with Babylon.js in the browser, a canvas may be stretched through layout (e.g. flexbox etc.), but to change the actual resolution, you need to manually set the Canvas’s width/height and then call engine.resize(), and that’s what fires the onResizeObservable.
On the native side, when the underlying view changes size (e.g. in the case of React Native when the containing View changes size due to layout such as flexbox), we don’t just stretch the view, we resize the rendering output from bgfx automatically. I think if native worked the same as web, then the rendering surface would just stretch on a layout resize, and JS code would have to detect a size change, and manually trigger an engine resize.
If we didn’t care about differences in Babylon API usage, we could still automatically resize, but call into the JS side to trigger the observable to fire, maybe by calling setSize or resize, but I can’t quite recall how these pieces work together (for example, I see resize already being called in the nativeEngine.js constructor, but it looks like that would end up accessing window.innerWidth/innerHeight, which I don’t think exist in the context of Babylon Native).
@bghgary do you remember how these parts work? Any thoughts on how we might make the engine resizing consistent with BJS in the browser, or more immediately the best way to have onResizeObservable notify when the resolution changes?
@ryantrem thanks for clarifying how things work in Babylon Native. I’ll experiment a bit more and get back to you if I have any further questions.
It’s not a showstopper for us as I can instead use the condition that triggers
engine.resize() but I thought you’d want to know.
Ok, thanks, we will keep an eye out on this. Do you mind filing an issue on GitHub to track it?