Chrislistens Posted August 10, 2017 Share Posted August 10, 2017 Hello everybody, I created a very simple scene (1 simple sphere) with Clara.io, then exported it in .babylon format. This file is named "scene2.babylon" In my folder named "babylontest", I have 2 files : - scene2.babylon - babylon.html (code below) Would anyone know why the code below doesn't work (nothing appears when I load "babylon.html")? Is there a problem with the line "BABYLON.SceneLoader.Load("", "scene2.babylon", engine, function (newScene)" ? Thank you in advance if you can help !!! Cheers, Chris ------------------ <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Using babylon.js - How to load a scene</title> <script src="https://cdn.babylonjs.com/babylon.max.js"></script> <style> html, body { width: 100%; height: 100%; padding: 0; margin: 0; overflow: hidden; } #renderCanvas { width: 100%; height: 100%; } </style> </head> <body> <canvas id="renderCanvas"></canvas> <script> if (BABYLON.Engine.isSupported()) { var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas, true); BABYLON.SceneLoader.Load("", "scene2.babylon", engine, function (newScene) { // Wait for textures and shaders to be ready newScene.executeWhenReady(function () { // Attach camera to canvas inputs newScene.activeCamera.attachControl(canvas); // Once the scene is loaded, just register a render loop to render it engine.runRenderLoop(function() { newScene.render(); }); }); }, function (progress) { // To do: give progress feedback to user }); } </script> </body> </html> babylon.html Quote Link to comment Share on other sites More sharing options...
gryff Posted August 10, 2017 Share Posted August 10, 2017 @Chrislistens Hi and welcome to the forum I tested your HTML code with a simple sphere and plane I created with Blender and it worked fine - just changed the script for BJS to one I have on my local server. 3 hours ago, Chrislistens said: I created a very simple scene (1 simple sphere) with Clara.io Did you include a camera and light? If I remove the camera from my Blender scene then it hangs at the line below when I try to load that with your script: newScene.activeCamera.attachControl(canvas); cheers, gryff Chrislistens 1 Quote Link to comment Share on other sites More sharing options...
Chrislistens Posted August 11, 2017 Author Share Posted August 11, 2017 Hi Gryff, Thank you very much for your answer and the time spent ! yes I included a camera and light, and I precise the .babylon file works when I test it in Sandbox. So I still don't understand what the problem is... Thank you again! Cheers, Chris Quote Link to comment Share on other sites More sharing options...
Chrislistens Posted August 11, 2017 Author Share Posted August 11, 2017 13 hours ago, gryff said: @Chrislistens Hi and welcome to the forum I tested your HTML code with a simple sphere and plane I created with Blender and it worked fine - just changed the script for BJS to one I have on my local server. Did you include a camera and light? If I remove the camera from my Blender scene then it hangs at the line below when I try to load that with your script: newScene.activeCamera.attachControl(canvas); cheers, gryff Hi Gryff, Thank you very much for your answer and the time spent ! yes I included a camera and light, and I precise the .babylon file works when I test it in Sandbox. So I still don't understand what the problem is... Thank you again! Cheers, Chris Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 11, 2017 Share Posted August 11, 2017 Hey! can you share a repro hosted somewhere so we can see the actual issue? Quote Link to comment Share on other sites More sharing options...
gryff Posted August 11, 2017 Share Posted August 11, 2017 @Chrislistens : I gather you still are having problems. Can you post your .babylon file, and if you created the scene at .clara.io can you export it as a .blend file and post that too (if it does not cost you money) cheers, gryff Quote Link to comment Share on other sites More sharing options...
Christoph Posted August 12, 2017 Share Posted August 12, 2017 Just a guess because you wrote "In my folder..." : Did you open babylon.html with your browser from your disk ? Because the way scene data is loaded requires the files to be hosted by a webserver. If open the file from disk this part is going to be missing. Quote Link to comment Share on other sites More sharing options...
Chrislistens Posted August 12, 2017 Author Share Posted August 12, 2017 Thanks a lot to you all for your replies! - Christoph, indeed I open the babylon.html from my disk: I'm going to try to host by a webserver, even if by now I don't know how to do it. - Deltakosh, you can find my 2 files attached. Thanks in advance!! Cheers, Chris babylon.html scene2.babylon Quote Link to comment Share on other sites More sharing options...
Chrislistens Posted August 12, 2017 Author Share Posted August 12, 2017 I also read it's necessary to change MIME types, but didn't figure out how to do that on a Mac... Quote Link to comment Share on other sites More sharing options...
SvenFrankson Posted August 14, 2017 Share Posted August 14, 2017 On 12/08/2017 at 11:55 AM, Chrislistens said: Thanks a lot to you all for your replies! - Christoph, indeed I open the babylon.html from my disk: I'm going to try to host by a webserver, even if by now I don't know how to do it. - Deltakosh, you can find my 2 files attached. Thanks in advance!! Cheers, Chris babylon.html scene2.babylon If you use an IDE, it's likely to have a webserver pluggin available. Otherwise, if you're running on Windows (I don't know for others OS), I think Firefox is fine with the use of your local directory as a webserver (ie : you may open index.html with Firefox, and request other files from the same directory with Javascript), it can be a workaround. Edit : I just tried your file on my Mac. Indeed, it fails to load with Chrome and Safari, but it loads with Firefox. 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.