babaorhum Posted March 14, 2017 Share Posted March 14, 2017 Hello every one, Thanks you fr your help, trying to import a mesh from blender to my scene but failed... Here's my code : var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas, true); var createScene = function() { // This creates a basic Babylon Scene object (non-mesh) var scene = new BABYLON.Scene(engine); // The first parameter can be used to specify which mesh to import. Here we import all meshes BABYLON.SceneLoader.ImportMesh("", "scenes/", "untitled.babylon", scene, function (newMeshes) { // Set the target of the camera to the first imported mesh camera.target = newMeshes[0]; }); scene.registerBeforeRender(animate); var LinesRed = BABYLON.Mesh.CreateLines("LinesRed", [ new BABYLON.Vector3(boxRed.position.x, boxRed.position.y, boxRed.position.z), new BABYLON.Vector3(planeRed.position.x, planeRed.position.y, planeRed.position.z), ], scene); // Our built-in 'ground' shape. Params: name, width, depth, subdivs, scene var ground = BABYLON.Mesh.CreateGround("ground1", 15, 15, 5, scene); return scene; }; var scene = createScene(); engine.runRenderLoop(function() { scene.render(); }); // Resize window.addEventListener("resize", function() { engine.resize(); }); }); At first I kept my previous light, camera and so on but nothing showed up I used the importmesh from teh playground, it appears on sandbox Do I have to delete the camera, light from blender and keep it on my code because i only want the mesh Here is the browser console Thank you all Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 14, 2017 Share Posted March 14, 2017 It would be nice if you could put your code in the tag bbcode made for that. it makes it difficult to read as it is. I personally not even look at the code when it's like that. But I say this to you. You will probably have more help. reproduce your code on the playground would be even better. I wouldn't say the title of the topic "ImportMesh ..." We do not know what the problem with a single word. babaorhum 1 Quote Link to comment Share on other sites More sharing options...
babaorhum Posted March 14, 2017 Author Share Posted March 14, 2017 @Dad72, Thx for your advice I edited the topic but regarding the playgroung the skull example works fine so how could I make myself understood? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 14, 2017 Share Posted March 14, 2017 Your code is ok, it should work. but you use your code locally, with C: / ... You must use a local web server. for http: // in place of C: / ... Just look at the error of your console. it explicitly states. babaorhum 1 Quote Link to comment Share on other sites More sharing options...
babaorhum Posted March 14, 2017 Author Share Posted March 14, 2017 Thanks for the reply, Why cannot I do it it locally as i did with my previous babylon? So I must have to get my hands in visualstudio? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 14, 2017 Share Posted March 14, 2017 No you can use a local web server as EasyPHP or WAMP server for example. These are servers to create local web page (that integrate apache). Why like this ? ImportMesh uses XmlHttpRequest (XHR) to load a file so you have to go through a web server for this. babaorhum 1 Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted March 14, 2017 Share Posted March 14, 2017 Actually, using a relative path to the html is the way to go. Using this, you can use both Firefox & Edge without a server. Just double click the html file. 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.