![]() ![]() ![]() You may find this property useful:Ĭamera | Babylon.js Documentation () If you are changing your canvas style like that then it will change the canvas aspect ratio - your width and height from different DOM elements. I don’t see how your are using innerHeight could expect to maintain aspect ratio - you may have luck as well with FOV. I would also try to switch away from getElementsByTagName in case you ever have multiple canvases - you get get it directly from your useRef with reactCanvas.current, which is an HTMLCanvasElement. You can copy the code from here:īabylonjs-hook/babylonjs-hook.tsx at master If you are triggering a canvas resize outside of the window resize event then I would suggest connecting to a ResizeObserver on the canvas element itself and calling engine.resize(). It looks like you are taking the main-content (is this a parent div?) and canvas separately and switching from % to px… Additionally, your setState will trigger on the next “React” render, while you are triggering the Babylon Engine to resize (based on the size when the event triggers). This question is not React specific, but I’ll try. This is tested in Chrome and Edge, but doesn’t work for either browser. In a regular window resize (dragging the sides of the window) the aspect ratio is updated to work fine with the current size of the canvas, but when I trigger a maximize/minimize the resize function does not modify the aspect ratio. I’m trying to dynamically modify the size of my canvas and make the BabylonJS engine modify the aspect ratio in the process. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |