Jump to content

Recommended Posts

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 (nodejsserver.
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

Link to comment
Share on other sites

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();
              });
          });

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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>

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...