mout99 Posted July 4, 2017 Share Posted July 4, 2017 Hello, when I try to upload a file. Stl it gives me the following error : SyntaxError: Unexpected token E in JSON at position 0 // 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(); }); }); Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted July 4, 2017 Share Posted July 4, 2017 is it a binary stl? we only support ASCII at the moment. Quote Link to comment Share on other sites More sharing options...
mout99 Posted July 4, 2017 Author Share Posted July 4, 2017 How do I see this? I'm new to this area. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted July 5, 2017 Share Posted July 5, 2017 Try to open it in notepad, if its human readable then its ASCII if it looks like garbley gook then its binary.http://www.meshconvert.com/ if it is binary and you don't have the original file to export it as ASCII. Quote Link to comment Share on other sites More sharing options...
mout99 Posted July 5, 2017 Author Share Posted July 5, 2017 It's already an ASCII, am I right? Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted July 5, 2017 Share Posted July 5, 2017 that's binary, ASCII is readable. Object start Normal ### facet start vertex ### vertex ### vertex ### facet end Object end or something like that. Quote Link to comment Share on other sites More sharing options...
mout99 Posted July 5, 2017 Author Share Posted July 5, 2017 I converted to ASCII with the site you recommended to me and is giving the same error, what can it be? Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted July 5, 2017 Share Posted July 5, 2017 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 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.