Bladetrick Posted May 30, 2018 Share Posted May 30, 2018 Hello! This model I'm working with has been through several life changes. heh. It started out as an AutoCAD drawing of a 3d cylinder. I then saved it as the default .dwg file. From there I opened it up in 3ds MAX and exported it to an OBJ file. I've tried loading this model up a couple ways (the babylon viewer, using babylon.scene.loader) but I end up getting the same error. So now i'm thinking its the model export that is the problem. I have attached the OBJ file for your perusal and here is the error I receive in the JS console: HTML1300: Navigation occurred. Viewer.html Babylon.js viewer (v3.3.0-alpha.3) Babylon.js engine (v3.3.0-alpha.3) launched BJS - [15:23:05]: Load Error: There was an error loading the model. Unable to import meshes from Assets/models/TestCylinder3DS.obj: Failed to load scene. [object Object] { [functions]: , __proto__: { [functions]: , __proto__: null }, exception: { [functions]: , __proto__: { }, description: "Error status: 404 Not Found - Unable to load Assets/models/TestCylinder3DS.obj", message: "Error status: 404 Not Found - Unable to load Assets/models/TestCylinder3DS.obj", name: "LoadFileError", request: { } }, message: "Unable to import meshes from Assets/models/TestCylinder3DS.obj: Failed to load scene." } Appreciate your time in this! TestCylinder3DS.obj Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted May 30, 2018 Share Posted May 30, 2018 Make sure you have the obj importer included https://doc.babylonjs.com/how_to/obj Bladetrick 1 Quote Link to comment Share on other sites More sharing options...
Bladetrick Posted May 30, 2018 Author Share Posted May 30, 2018 Its included. Here's what I have: <!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8" /> <script src="https://preview.babylonjs.com/babylon.js"></script> <script src="Assets/scripts/Babylon/babylon.objFileLoader.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> <script type="text/javascript"> var canvas = document.createElement('Canvas'); canvas.id = 'renderCanvas'; document.body.appendChild(canvas); var engine = new BABYLON.Engine(canvas, true); engine.enableOfflineSupport = false; 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); // Move the light with the camera scene.registerBeforeRender(function () { light.position = camera.position; }); return scene; } BABYLON.SceneLoader.Load("/Assets/models/", "TestCylinder3DS.obj", engine, function (createScene) { // ... }); </script> </body> </html> Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted May 30, 2018 Share Posted May 30, 2018 EDIT* my bad let me review 1 second. https://doc.babylonjs.com/how_to/load_from_any_file_type Check your console network report, is the file 404ing? https://doc.babylonjs.com/how_to/how_to_use_assetsmanager <- prehaps I like the asset manager personally. Bladetrick 1 Quote Link to comment Share on other sites More sharing options...
Bladetrick Posted May 30, 2018 Author Share Posted May 30, 2018 i'll give this a whirl in the morning and let you know. thanks for the help so far! Quote Link to comment Share on other sites More sharing options...
Bladetrick Posted May 30, 2018 Author Share Posted May 30, 2018 eh, i couldn't wait till morning. I tried it and received, on the console, a message about not being able to find a plugin to load OBJ files and: error while loading OBJ Loading task Here's my HTML: <!DOCTYPE html> <html> <head> <title>BabylonJS - Assets manager demo</title> <script src="//preview.babylonjs.com/babylon.js"></script> <script src="Assets/scripts/Babylon/AssetsManager.js"></script> <script src="Assets/scripts/Babylon/babylon.objFileLoader.js"></script> <style> html, body { width: 100%; height: 100%; padding: 0; margin: 0; overflow: hidden; } #renderCanvas { width: 100%; height: 100%; touch-action: none; -ms-touch-action: none; } </style> </head> <body> <canvas id="renderCanvas"></canvas> </body> </html> and my AssetsManager.js code: "use strict"; document.addEventListener("DOMContentLoaded", run, false); function run() { if (BABYLON.Engine.isSupported()) { BABYLON.Engine.ShadersRepository = "/Babylon/Shaders/"; var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas, false); // Resize window.addEventListener("resize", function () { engine.resize(); }); // Scene, light and camera var scene = new BABYLON.Scene(engine); var light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(0, 1, 0), scene); var camera = new BABYLON.ArcRotateCamera("Camera", 0, Math.PI / 2, 100, new BABYLON.Vector3(0, 0, 0), scene); camera.attachControl(canvas); // Assets manager var assetsManager = new BABYLON.AssetsManager(scene); var meshTask = assetsManager.addMeshTask("OBJ Loading task", "", "./Assets/models/AH-64", "TestCylinder.obj"); // You can handle success and error on a per-task basis (onSuccess, onError) meshTask.onSuccess = function (task) { task.loadedMeshes[0].position = new BABYLON.Vector3(0, 0, 0); } // But you can also do it on the assets manager itself (onTaskSuccess, onTaskError) assetsManager.onTaskError = function (task) { console.log("error while loading " + task.name); } assetsManager.onFinish = function (tasks) { engine.runRenderLoop(function () { scene.render(); }); }; // Can now change loading background color: engine.loadingUIBackgroundColor = "Purple"; // Just call load to initiate the loading sequence assetsManager.load(); } }; Quote Link to comment Share on other sites More sharing options...
Bladetrick Posted May 31, 2018 Author Share Posted May 31, 2018 I switched testing browsers from IE to chrome. Interestingly, i got more info on the console when trying to run the code. Here's what I found: Babylon.js engine (v3.3.0-alpha.3) launched babylon.objFileLoader.js:682 Unhandled expression at line : <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> babylon.objFileLoader.js:682 Unhandled expression at line : <html xmlns="http://www.w3.org/1999/xhtml"> babylon.objFileLoader.js:682 Unhandled expression at line : <head> babylon.objFileLoader.js:682 Unhandled expression at line : <title>IIS 10.0 Detailed Error - 404.0 - Not Found</title> babylon.objFileLoader.js:682 Unhandled expression at line : <style type="text/css"> babylon.objFileLoader.js:682 Unhandled expression at line : <!-- babylon.objFileLoader.js:682 Unhandled expression at line : body{margin:0;font-size:.7em;font-family:Verdana,Arial,Helvetica,sans-serif;} babylon.objFileLoader.js:682 Unhandled expression at line : code{margin:0;color:#006600;font-size:1.1em;font-weight:bold;} babylon.objFileLoader.js:682 Unhandled expression at line : .config_source code{font-size:.8em;color:#000000;} babylon.objFileLoader.js:682 Unhandled expression at line : pre{margin:0;font-size:1.4em;word-wrap:break-word;} babylon.objFileLoader.js:682 Unhandled expression at line : ul,ol{margin:10px 0 10px 5px;} babylon.objFileLoader.js:682 Unhandled expression at line : ul.first,ol.first{margin-top:5px;} babylon.objFileLoader.js:682 Unhandled expression at line : fieldset{padding:0 15px 10px 15px;word-break:break-all;} babylon.objFileLoader.js:682 Unhandled expression at line : .summary-container fieldset{padding-bottom:5px;margin-top:4px;} babylon.objFileLoader.js:682 Unhandled expression at line : legend.no-expand-all{padding:2px 15px 4px 10px;margin:0 0 0 -12px;} babylon.objFileLoader.js:682 Unhandled expression at line : legend{color:#333333;;margin:4px 0 8px -12px;_margin-top:0px; babylon.objFileLoader.js:682 Unhandled expression at line : font-weight:bold;font-size:1em;} babylon.objFileLoader.js:682 Unhandled expression at line : a:link,a:visited{color:#007EFF;font-weight:bold;} babylon.objFileLoader.js:682 Unhandled expression at line : a:hover{text-decoration:none;} babylon.objFileLoader.js:682 Unhandled expression at line : h1{font-size:2.4em;margin:0;color:#FFF;} babylon.objFileLoader.js:682 Unhandled expression at line : h2{font-size:1.7em;margin:0;color:#CC0000;} babylon.objFileLoader.js:682 Unhandled expression at line : h3{font-size:1.4em;margin:10px 0 0 0;color:#CC0000;} babylon.objFileLoader.js:682 Unhandled expression at line : h4{font-size:1.2em;margin:10px 0 5px 0; babylon.objFileLoader.js:682 Unhandled expression at line : }#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS",Verdana,sans-serif; babylon.objFileLoader.js:682 Unhandled expression at line : color:#FFF;background-color:#5C87B2; babylon.objFileLoader.js:682 Unhandled expression at line : }#content{margin:0 0 0 2%;position:relative;} babylon.objFileLoader.js:682 Unhandled expression at line : .summary-container,.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;} babylon.objFileLoader.js:682 Unhandled expression at line : .content-container p{margin:0 0 10px 0; babylon.objFileLoader.js:682 Unhandled expression at line : }#details-left{width:35%;float:left;margin-right:2%; babylon.objFileLoader.js:682 Unhandled expression at line : }#details-right{width:63%;float:left;overflow:hidden; babylon.objFileLoader.js:682 Unhandled expression at line : }#server_version{width:96%;_height:1px;min-height:1px;margin:0 0 5px 0;padding:11px 2% 8px 2%;color:#FFFFFF; babylon.objFileLoader.js:682 Unhandled expression at line : background-color:#5A7FA5;border-bottom:1px solid #C1CFDD;border-top:1px solid #4A6C8E;font-weight:normal; babylon.objFileLoader.js:682 Unhandled expression at line : font-size:1em;color:#FFF;text-align:right; babylon.objFileLoader.js:682 Unhandled expression at line : }#server_version p{margin:5px 0;} babylon.objFileLoader.js:682 Unhandled expression at line : table{margin:4px 0 4px 0;width:100%;border:none;} babylon.objFileLoader.js:682 Unhandled expression at line : td,th{vertical-align:top;padding:3px 0;text-align:left;font-weight:normal;border:none;} babylon.objFileLoader.js:682 Unhandled expression at line : th{width:30%;text-align:right;padding-right:2%;font-weight:bold;} babylon.objFileLoader.js:682 Unhandled expression at line : thead th{background-color:#ebebeb;width:25%; babylon.objFileLoader.js:682 Unhandled expression at line : }#details-right th{width:20%;} babylon.objFileLoader.js:682 Unhandled expression at line : table tr.alt td,table tr.alt th{} babylon.objFileLoader.js:682 Unhandled expression at line : .highlight-code{color:#CC0000;font-weight:bold;font-style:italic;} babylon.objFileLoader.js:682 Unhandled expression at line : .clear{clear:both;} babylon.objFileLoader.js:682 Unhandled expression at line : .preferred{padding:0 5px 2px 5px;font-weight:normal;background:#006633;color:#FFF;font-size:.8em;} babylon.objFileLoader.js:682 Unhandled expression at line : --> babylon.objFileLoader.js:682 Unhandled expression at line : </style> babylon.objFileLoader.js:682 Unhandled expression at line : </head> babylon.objFileLoader.js:682 Unhandled expression at line : <body> babylon.objFileLoader.js:682 Unhandled expression at line : <div id="content"> babylon.objFileLoader.js:682 Unhandled expression at line : <div class="content-container"> babylon.objFileLoader.js:682 Unhandled expression at line : <h3>HTTP Error 404.0 - Not Found</h3> babylon.objFileLoader.js:682 Unhandled expression at line : <h4>The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.</h4> babylon.objFileLoader.js:682 Unhandled expression at line : </div> babylon.objFileLoader.js:682 Unhandled expression at line : <div class="content-container"> babylon.objFileLoader.js:682 Unhandled expression at line : <fieldset><h4>Most likely causes:</h4> babylon.objFileLoader.js:682 Unhandled expression at line : <ul> <li>The directory or file specified does not exist on the Web server.</li> <li>The URL contains a typographical error.</li> <li>A custom filter or module, such as URLScan, restricts access to the file.</li> </ul> babylon.objFileLoader.js:682 Unhandled expression at line : </fieldset> babylon.objFileLoader.js:682 Unhandled expression at line : </div> babylon.objFileLoader.js:682 Unhandled expression at line : <div class="content-container"> babylon.objFileLoader.js:682 Unhandled expression at line : <fieldset><h4>Things you can try:</h4> babylon.objFileLoader.js:682 Unhandled expression at line : <ul> <li>Create the content on the Web server.</li> <li>Review the browser URL.</li> <li>Check the failed request tracing log and see which module is calling SetStatus. For more information, click <a href="http://go.microsoft.com/fwlink/?LinkID=66439">here</a>. </li> </ul> babylon.objFileLoader.js:682 Unhandled expression at line : </fieldset> babylon.objFileLoader.js:682 Unhandled expression at line : </div> babylon.objFileLoader.js:682 Unhandled expression at line : <div class="content-container"> babylon.objFileLoader.js:682 Unhandled expression at line : <fieldset><h4>Detailed Error Information:</h4> babylon.objFileLoader.js:682 Unhandled expression at line : <div id="details-left"> babylon.objFileLoader.js:682 Unhandled expression at line : <table border="0" cellpadding="0" cellspacing="0"> babylon.objFileLoader.js:682 Unhandled expression at line : <tr class="alt"><th>Module</th><td> IIS Web Core</td></tr> babylon.objFileLoader.js:682 Unhandled expression at line : <tr><th>Notification</th><td> MapRequestHandler</td></tr> babylon.objFileLoader.js:682 Unhandled expression at line : <tr class="alt"><th>Handler</th><td> StaticFile</td></tr> babylon.objFileLoader.js:682 Unhandled expression at line : <tr><th>Error Code</th><td> 0x80070002</td></tr> babylon.objFileLoader.js:682 Unhandled expression at line : </table> babylon.objFileLoader.js:682 Unhandled expression at line : </div> babylon.objFileLoader.js:682 Unhandled expression at line : <div id="details-right"> babylon.objFileLoader.js:682 Unhandled expression at line : <table border="0" cellpadding="0" cellspacing="0"> babylon.objFileLoader.js:682 Unhandled expression at line : <tr class="alt"><th>Requested URL</th><td> http://localhost:57289/Assets/models/TestCylinder.obj</td></tr> babylon.objFileLoader.js:682 Unhandled expression at line : <tr><th>Physical Path</th><td> C:\TEMP\Test Projects\BabylonTestingGround\BabylonTestingGround\Assets\models\TestCylinder.obj</td></tr> babylon.objFileLoader.js:682 Unhandled expression at line : <tr class="alt"><th>Logon Method</th><td> Anonymous</td></tr> babylon.objFileLoader.js:682 Unhandled expression at line : <tr><th>Logon User</th><td> Anonymous</td></tr> babylon.objFileLoader.js:682 Unhandled expression at line : <tr class="alt"><th>Request Tracing Directory</th><td> C:\Users\MendietaCM\Documents\IISExpress\TraceLogFiles\BABYLONTESTINGGROUND</td></tr> babylon.objFileLoader.js:682 Unhandled expression at line : </table> babylon.objFileLoader.js:682 Unhandled expression at line : <div class="clear"></div> babylon.objFileLoader.js:682 Unhandled expression at line : </div> babylon.objFileLoader.js:682 Unhandled expression at line : </fieldset> babylon.objFileLoader.js:682 Unhandled expression at line : </div> babylon.objFileLoader.js:682 Unhandled expression at line : <div class="content-container"> babylon.objFileLoader.js:682 Unhandled expression at line : <fieldset><h4>More Information:</h4> babylon.objFileLoader.js:682 Unhandled expression at line : This error means that the file or directory does not exist on the server. Create the file or directory and try the request again. babylon.objFileLoader.js:682 Unhandled expression at line : <p><a href="http://go.microsoft.com/fwlink/?LinkID=62293&IIS70Error=404,0,0x80070002,15063">View more information »</a></p> babylon.objFileLoader.js:682 Unhandled expression at line : </fieldset> 2babylon.objFileLoader.js:682 Unhandled expression at line : </div> babylon.objFileLoader.js:682 Unhandled expression at line : </body> babylon.objFileLoader.js:682 Unhandled expression at line : </html> Quote Link to comment Share on other sites More sharing options...
Bladetrick Posted May 31, 2018 Author Share Posted May 31, 2018 Actually, would someone mind trying to load the OBJ file I attached before? I'm getting the feeling it might not be right. I tried it as is and also opened it up and removed the .mtl dependency it calls up. Either way it has the same results Quote Link to comment Share on other sites More sharing options...
Bladetrick Posted May 31, 2018 Author Share Posted May 31, 2018 Looks like its a web config issue. my IIS doesn't like OBJ files, i guess: HTTP Error 404.3 - Not Found The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map. Quote Link to comment Share on other sites More sharing options...
Bladetrick Posted May 31, 2018 Author Share Posted May 31, 2018 Ok, I fixed it and can now see my model load up. I just added this to the web.config <staticContent> <mimeMap fileExtension=".obj" mimeType="application/octet-stream" /> </staticContent> Thank you for the help Pryme8 Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Guest Posted May 31, 2018 Share Posted May 31, 2018 Good job! Bladetrick 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted May 31, 2018 Share Posted May 31, 2018 Sorry just saw the new stuff, been a busy day glad you figured it out! Bladetrick 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.