Numa Posted January 13, 2017 Share Posted January 13, 2017 Hi guys, something weird is happening. I load a model (using the glTF loader), it's showing up fine, but as soon as I rotate the arcRotateCamera, it disappears. If I resize my window, it comes back. Edit: an additional clue, the model comes up with flipped normals so I flipped them back once the model is loaded, but the new normals only show up after I have resized the window, you can see that in the gif below. Edit2: this doesn't happen with the OBJ loader Any ideas? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted January 13, 2017 Share Posted January 13, 2017 Interesting. Sorry for slow replies. Have you got the latest gfx drivers for your "stuff"? And, are you seeing this same symptom in all the major browsers? Which version of BJS, and are you running any "extra" scripts? Can you publish, so others can browse it? hmm. (beard scratch) Hey, you asked for ideas. No mention of needing GOOD ideas. Quote Link to comment Share on other sites More sharing options...
jerome Posted January 13, 2017 Share Posted January 13, 2017 maybe its bounding box isn't right ? just try mesh.refreshBoundingInfo() after your mesh is downloaded Quote Link to comment Share on other sites More sharing options...
Numa Posted January 15, 2017 Author Share Posted January 15, 2017 Thanks for the suggestions! it's the same in other browsers, and refreshing the bounding box didn't fix it I'm using the latest 2.5 version and the latest gltf loader. I have a ton of other scripts, it's a pretty big project It might be pretty hard to isolate it into a playground example. Any other ideas? Why would resizing the window refresh the model? Could it have something to do with the gltf loader creating a different camera, maybe? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted January 16, 2017 Share Posted January 16, 2017 http://cgit.drupalcode.org/sandbox-ideogram_nl-2504447/tree/examples/webgl_loader_gltf.html?id=e5902b1ddb397cea8764732fca7ac411e67303ea There sure is a ton of camera stuff... happening in that loader. hmm. You might be on the right track, Petaluma Numa. Quote Link to comment Share on other sites More sharing options...
Numa Posted January 16, 2017 Author Share Posted January 16, 2017 Ok so I'm half way there I think. Thanks @Wingnut that code helped:) To get the model to show, I need to do 2 things: 1. resize the window 2. rotate the camera (I guess it refreshes the view somehow?) calling engine.setSize(x,y) after loading the file takes care of 1. Now how do I fake a camera rotate? Is there any secret function to re-render everything? or just the camera? Thanks! Quote Link to comment Share on other sites More sharing options...
Numa Posted January 17, 2017 Author Share Posted January 17, 2017 Ok, I "fixed" it, more like horrible hacked it. I resize the engine to fake a window resize, and I use camera.setTarget to a slightly different position to fake a camera movement. Now it gets refreshed and everything looks fine. I wonder however, what the hell is going on?! And is there a quicker way to refresh the scene maybe? If I get a moment I'll try to make a playground for it. Thanks! Wingnut 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 17, 2017 Share Posted January 17, 2017 Do you mind testing with the latest v2.6 alpha and the very latest gltf loader? (just in case) Ping @Luaacro Quote Link to comment Share on other sites More sharing options...
julien-moreau Posted January 17, 2017 Share Posted January 17, 2017 Hi @Numa, Happy that you use the gltf loader =D Would be perfect if you can create a playground for it or, to go faster, share your gltf file as I can determine if the problem comes from the loader or not Thanks Quote Link to comment Share on other sites More sharing options...
Numa Posted January 28, 2017 Author Share Posted January 28, 2017 Sorry for the late response. I tested with all new versions and the problem was still there. HOWEVER here is what I discovered: My scene creation code is quite big so I moved it to a separate script called sceneManager.js, there I do all my things, instantiating the engine, creating the scene, camera etc etc. It seems to be a bad idea. I found out that removing var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas, true, { stencil: true }); from the file and putting it directly in the html page fixed the problem. This works fine: <body> <canvas id="renderCanvas"></canvas> <!-- Babylon Files --> <script src="http://cdn.babylonjs.com/2-5/babylon.js"></script> <script src="js/babylon.objFileLoader.js"></script> <script src="js/babylon.glTFFileLoader.js"></script> <script src="js/babylon.canvas2d.js"></script> <!-- Init engine --> <script> var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas, true, { stencil: true }); </script> <!-- Create scene --> <script src="sceneManager.js"></script> <!-- plenty of other things --> </body> is that... expected? Can someone explain? Thanks Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 30, 2017 Share Posted January 30, 2017 This is expected because the script is executed BEFORE the canvas was created. Numa and Wingnut 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.