naim Posted March 17, 2017 Share Posted March 17, 2017 Hello! For start, sorry for my English, I'm a french developer.I am a newbie on this forum, and I come to an issue with the displaying of a file. stl. so, my web page html/javascript is served by an express (nodejs) server.All is running good with another html page for import file. obj.for file.stl, without success... i push the stl file in join's file, he's named bane-test.stl this is my code for loading stl file in web browser, some help is welcome <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Babylon.js sample code</title> <!-- Babylon.js --> <!-- Latest compiled and minified CSS --> <script src="http://cdn.babylonjs.com/2-5/babylon.js"></script> <script src="http://cdn.babylonjs.com/2-5/babylon.max.js"></script> <script src="http://cdn.babylonjs.com/2-5/babylon.noworker.js"></script> <script src="http://cdn.babylonjs.com/2-5/babylon.core.js"></script> <script src="babylon.stlFileLoader.js"></script> </head> <body> <body> <canvas id="renderCanvas"></canvas> <script> var canvas = document.getElementById('renderCanvas'); // load the 3D engine var engine = new BABYLON.Engine(canvas, true); BABYLON.SceneLoader.Load("", "bane-test.stl", engine, function (newScene) { var scene = new BABYLON.Scene(engine); // Create Light new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene); // Create cam var cam = new BABYLON.ArcRotateCamera("ArcRotateCamera", 1, 0.8, 15, new BABYLON.Vector3(0, 3, 0), scene); cam.attachControl(canvas); scene.clearColor = new BABYLON.Color4(0, 0, 0, 0); newScene.activeCamera.attachControl(canvas, false); engine.runRenderLoop(function () { newScene.render(); }); }); /* var loader = BABYLON.SceneLoader.Load("/", "bane-test.stl", engine, function (scene) { console.log("passe here "); }); */ </script> </body> </html> </body> </html> Thanks a lot for your help. bane-test.stl Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 17, 2017 Share Posted March 17, 2017 Hello you should not create a new scene but instead use the one provided by SceneLoader. So something along these lines: BABYLON.SceneLoader.Load("", "bane-test.stl", engine, function (newScene) { // Create Light new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), newScene); newScene.clearColor = new BABYLON.Color4(0, 0, 0, 0); newScene.activeCamera.attachControl(canvas, false); engine.runRenderLoop(function () { newScene.render(); }); }); Quote Link to comment Share on other sites More sharing options...
naim Posted March 17, 2017 Author Share Posted March 17, 2017 thanks, i try this right now. Quote Link to comment Share on other sites More sharing options...
naim Posted March 17, 2017 Author Share Posted March 17, 2017 So my viewer is empty, there is no mesh display. i put a screen shot of console output and of page in browser my code update with your tips <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Babylon.js sample code</title> <!-- Babylon.js --> <!-- Latest compiled and minified CSS --> <script src="http://cdn.babylonjs.com/2-5/babylon.js"></script> <script src="http://cdn.babylonjs.com/2-5/babylon.max.js"></script> <script src="http://cdn.babylonjs.com/2-5/babylon.noworker.js"></script> <script src="http://cdn.babylonjs.com/2-5/babylon.core.js"></script> <script src="babylon.stlFileLoader.js"></script> </head> <body> <body> <canvas id="renderCanvas"></canvas> <script> var canvas = document.getElementById('renderCanvas'); // load the 3D engine var engine = new BABYLON.Engine(canvas, true); BABYLON.SceneLoader.Load("", "bane-test.stl", engine, function (newScene) { // Create Light new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), newScene); newScene.clearColor = new BABYLON.Color4(0, 0, 0, 0); newScene.activeCamera.attachControl(canvas, false); engine.runRenderLoop(function () { newScene.render(); }); }); </script> </body> </html> </body> </html> outputStl.tiff Quote Link to comment Share on other sites More sharing options...
naim Posted March 17, 2017 Author Share Posted March 17, 2017 52 minutes ago, Deltakosh said: I try too with the exemple on babylon site web i'm clocked on this issue since several hours... but wit hhe objFile importer all is allright, only stl who seem like more simple of using. HERE THE CONSOLE OUTPUT >BJS - [18:56:04]: Babylon.js engine (v2.5) launched babylon.core.js:2 >GET http://localhost:8000/bane-test.stl.manifest?1489773364476 500 (Internal Server Error)t.checkManifestFile @ babylon.core.js:2t @ babylon.core.js:2t.Append @ babylon.core.js:17t.Load @ babylon.core.js:17(anonymous function) @ (index):41 favicon.ico:1 >GET http://localhost:8000/favicon.ico 500 (Internal Server Error) >content_script.build.js:4 HIDDEN <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Babylon.js sample code</title> <!-- Babylon.js --> <!-- Latest compiled and minified CSS --> <script src="http://cdn.babylonjs.com/2-5/babylon.js"></script> <script src="http://cdn.babylonjs.com/2-5/babylon.max.js"></script> <script src="http://cdn.babylonjs.com/2-5/babylon.noworker.js"></script> <script src="http://cdn.babylonjs.com/2-5/babylon.core.js"></script> <script src="babylon.stlFileLoader.js"></script> </head> <body> <body> <canvas id="renderCanvas"></canvas> <script> var canvas = document.getElementById('renderCanvas'); var engine = new BABYLON.Engine(canvas, true); BABYLON.SceneLoader.Load("", "bane-test.stl", engine, function (newScene) { new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), newScene); newScene.activeCamera.attachControl(canvas, false); engine.runRenderLoop(function () { newScene.render(); }); }); </script> </body> </html> </body> </html> Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 20, 2017 Share Posted March 20, 2017 Can you call scene.debugLayer.show() before calling engine.runRenderLoop? This will help you figure out why scene is empty. (How many vertices, meshes are loaded?) 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.