Pryme8 Posted November 15, 2017 Share Posted November 15, 2017 https://pryme8.github.io/TileMaster/editor/ So If you go ahead and create a new project, then add a stage, then add a plane. You will see the bug. Notice you see no change and if you have the console open you will see NAN outputs for the aspectRatio. Now the second you resize the scene it fixes this and starts correctly outputting the aspectRatiohttps://github.com/Pryme8/TileMaster/blob/gh-pages/editor/js/tm.editor.js#L394 Is where the function is used andhttps://github.com/Pryme8/TileMaster/blob/gh-pages/editor/js/tm.editor.js#L34 Is where it fires from... the odd part is technically I fire the resize manually before anything happens so shouldn't this work? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 15, 2017 Share Posted November 15, 2017 AFAIC, the only way to get NAN would be to call getAspectRatio too early (when the canvas is not yet attached to the DOM). https://github.com/BabylonJS/Babylon.js/blob/master/src/Engine/babylon.engine.ts#L1294 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted November 15, 2017 Author Share Posted November 15, 2017 its after DOM creation, I added this._core.engine.resize(); to the _buildMesh function and that "fixed" it but proves that there is a bug somewhere. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 15, 2017 Share Posted November 15, 2017 Somewhere When I step into getAspectRatio I see that the engine.getRenderingCanvas().width === 0 Not good Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted November 15, 2017 Author Share Posted November 15, 2017 so did i find a bug?!?! woot! Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted November 15, 2017 Author Share Posted November 15, 2017 Why does :https://github.com/BabylonJS/Babylon.js/blob/master/src/Engine/babylon.engine.ts#L1294 not just use https://github.com/BabylonJS/Babylon.js/blob/master/src/Engine/babylon.engine.ts#L1319 and do something like: var rect = this.getRenderingCanvasClientRect(); return rect.width / rect.height; ? Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted November 15, 2017 Author Share Posted November 15, 2017 for the time being i replaced the line:var aspectRatio = engine.getAspectRatio(c); with: var rect = engine.getRenderingCanvasClientRect(); var aspectRatio = rect.width/rect.height; and it seems to be adequate as a work around so no rush on this problem... but I am kinda wondering what the root cause of it is still. *EDIT* that did not fix it actually, but I made a work around. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 15, 2017 Share Posted November 15, 2017 It is not a bug on my side I'm not responsible to set the canvas.width Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted December 13, 2017 Author Share Posted December 13, 2017 Im bringing this topic back... there is something odd in this behavior. So basically my scenes are broken until I fire a engine.resize(); I am thinking this is because the canvas elements are set to display:none initially and are enabled later. But here is where things get odd, if I do a engine resize prior to the display of the canvas its like nothing effectively happens. I am forced then to do this:https://github.com/Pryme8/TileMaster/blob/gh-pages/editor/js/tm.editor.js#L104 which seem really kinda dumb... I mean it works but if I nerf these lines when you select a tile it displays it in the preview block like its a single pxl from the center of the tile is the only one that displays over the whole canvas. But if I include these lines everything "works"http://pryme8.github.io/TileMaster/editor I am focused on the sheetEditor part if your looking for the working example. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 15, 2017 Share Posted December 15, 2017 This is expected. The engine cannot resize until the canvas has an actual size. I don't know how to do it differently unfortunately Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted December 15, 2017 Author Share Posted December 15, 2017 Ok so doing a manual resize after the canvas is being displayed on the dom would be the best work around? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 15, 2017 Share Posted December 15, 2017 correct 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.