Jump to content

Problems loading .stl file


mout99
 Share

Recommended Posts

Hello, when I try to upload a file. Stl it gives me the following error :

SyntaxError: Unexpected token E in JSON at position 0

 

 

Capturar.PNG

 

      // Get the canvas element from our HTML above
  var canvas = document.getElementById("renderCanvas");

  // Load the BABYLON 3D engine
  var engine = new BABYLON.Engine(canvas, true);

    BABYLON.SceneLoader.Load("js/", "stlfilestl.stl", engine, function (newScene) {
      console.log("reklfjsklf");

      var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0.8, 100, BABYLON.Vector3.Zero(), newScene);

   newScene.activeCamera.attachControl(canvas, false);
   engine.runRenderLoop(function () {
       newScene.render();
    });
      });

 

Link to comment
Share on other sites

    BABYLON.SceneLoader.ImportMesh("", "js/", "stlfile.stl", scene, function (meshes) {
    });

constructor is wrong, try using the above with the correct file name.

also set up your scene correctly as well, that script that you are using is wrong.

 

var createScene = function () {
    var scene = new BABYLON.Scene(engine);

    //Adding a light
    var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(20, 20, 100), scene);

    //Adding an Arc Rotate Camera
    var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0.8, 100, BABYLON.Vector3.Zero(), scene);
    camera.attachControl(canvas, false);

    // The first parameter can be used to specify which mesh to import. Here we import all meshes
    BABYLON.SceneLoader.ImportMesh("", "scenes/", "skull.babylon", scene, function (newMeshes) {
        // Set the target of the camera to the first imported mesh
        camera.target = newMeshes[0];
    });

    // Move the light with the camera
    scene.registerBeforeRender(function () {
        light.position = camera.position;
    });

    return scene;
}

is the playground example for loading meshes.

But before you do that you need to review this: http://doc.babylonjs.com/tutorials/creating_a_basic_scene

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