basjak Posted April 11, 2017 Share Posted April 11, 2017 Hi: I am trying to import mesh using BABYLON.SceneLoader.ImportMesh. there doesn't seem to be any error with the code but the mesh is not loading anf the loader gui lasts forever. I inspect the elements with google crome and it says that cannot find the objects. the assets folder is within the html folder project and the skull.babylon is there so there is nothing wrong (I followed the video tutorial by David, he got it right but I got it wrong ). any help? <!DOCTYPE html> <html> <head> <title>babylon</title> <meta charset="utf-8" /> <script src="javascript/babylon.2.5.js"></script> <style> html, body { overflow: hidden; width: 100%; height: 100%; margin: 0; padding: 0; } #renderCanvas { width: 100%; height: 100%; touch-action: none; } </style> </head> <body> <canvas id="renderCanvas"></canvas> <script> var Canvas = document.getElementById("renderCanvas"); var Engine = new BABYLON.Engine(Canvas, true); var Scene = MakeScene(); Engine.runRenderLoop(function () { Scene.render(); }) window.addEventListener("resize", function () { Engine.resize(); }) function MakeScene() { var scene = new BABYLON.Scene(Engine); scene.clearColor = new BABYLON.Color3(125 / 255.0, 0, 0); var hLight = new BABYLON.HemisphericLight("hLight", new BABYLON.Vector3(0, 1, 0), scene); var aCam = new BABYLON.ArcRotateCamera("aCam", 2 * Math.PI / 3, Math.PI / 3, 30,BABYLON.Vector3.Zero(), scene); aCam.attachControl(Canvas, false); Engine.displayLoadingUI(); //PROBLEM IN HERE, google crome says can'T FIND FOLDER, AND OBJECT SKULL.BABYLON //the folder (asset)and the file are inside the project directory //no comment on error in microsoft edge. BABYLON.SceneLoader.ImportMesh("test", "assets/", "skull.babylon", scene, function (newMeshes) { camera.target = newMeshes[0]; engine.hideLoadingUI(); }); var mGreen = new BABYLON.StandardMaterial("mGreen", scene); mGreen.diffuseColor = BABYLON.Color3.Green(); var obj = BABYLON.Mesh.CreateBox("box", 5, scene); obj.material = mGreen; return scene; } </script> </body> </html> assets.zip Quote Link to comment Share on other sites More sharing options...
Raggar Posted April 11, 2017 Share Posted April 11, 2017 BABYLON.SceneLoader.ImportMesh("test", "assets/", "skull.babylon", scene, function (newMeshes) { Test is not a name you assign the mesh, but a name you specify for the loader to look for, in case you want to import a specific mesh. Null it out instead, like: BABYLON.SceneLoader.ImportMesh("", "assets/", "skull.babylon", scene, function (newMeshes) { To import all the meshes in the file. At least I think it's how it is. Quote Link to comment Share on other sites More sharing options...
basjak Posted April 11, 2017 Author Share Posted April 11, 2017 Quote It worked. I didn't notice that I have to add information to the web.config. <system.webServer> <staticContent> <mimeMap fileExtension=".fx" mimeType="application/fx"/> <mimeMap fileExtension=".babylon" mimeType="application/babylon"/> <mimeMap fileExtension=".babylonmeshdata" mimeType="application/babylonmeshdata"/> </staticContent> </system.webServer> Thanks 4 Quote Link to comment Share on other sites More sharing options...
basjak Posted April 11, 2017 Author Share Posted April 11, 2017 solved. thanks you GameMonetize 1 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.