Dad72 Posted January 12, 2018 Share Posted January 12, 2018 var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas); var scene = new BABYLON.Scene(engine); scene.clearColor = new BABYLON.Color3(1, 1, 1); var camera = new BABYLON.FreeCamera("camera", new BABYLON.Vector3(-2.15, 0, -3.2), scene); camera.minZ = 0.01; var light = new BABYLON.PointLight("light", new BABYLON.Vector3(0, 5, -5), scene); var pathsToLoadFrom = ["./assets/obj_files_10/", "./assets/obj_files_11/", "./assets/obj_files_12/"]; //document.addEventListener("mousedown", push_path, false); var loader = function(paths){ this.mesh_pos = -5; this.meshs = []; for(let i=0; i<paths.length; i++){ this._run(paths[i]); this.mesh_pos += 1; } return this; }; loader.prototype._run = function(path) { BABYLON.SceneLoader.ImportMesh('', './', path, scene, (meshes) => { for(let i=0; i < meshes.length; i++){ let mesh = meshes[i]; mesh.position.x = this.mesh_pos; this.meshs.push(mesh); } }); }; engine.runRenderLoop(function () { scene.render(); }); var _l = new loader(pathsToLoadFrom); Pryme8 and dbawel 1 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted January 12, 2018 Share Posted January 12, 2018 ^^^^ @Dad72 just did the equivalent should fix the error as well. <3 Quote Link to comment Share on other sites More sharing options...
dbawel Posted January 12, 2018 Author Share Posted January 12, 2018 @Pryme8 At first, line 31 was written BABYLON.SceneLoader.ImportMesh('', './', path, scene, (meshes)=> { , and I received a 403 Forbidden console error that it couldn't load from ././assets/obj_files_10/, so I changed the line to BABYLON.SceneLoader.ImportMesh('', '', path, scene, (meshes)=> { and then the path was correct. But then I get the message in the console: BJS - [12:19:45]: Unable to import meshes from ./assets/obj_files_11/: 403 Forbidden Any Thoughts? DB Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted January 12, 2018 Share Posted January 12, 2018 looks like its trying to load "./assets/obj_files_11/" which is not a OBJ file, load the obj file urls into the array and try again. You can't load folders*, you gotta point to the file. *you can with some hacking* So: var pathsToLoadFrom = ["assets/obj_files_10/file.obj", "assets/obj_files_11/file.obj", "assets/obj_files_12/file.obj"]; and get rid of the ./ in the paths string and leave it in the Loader path declaration. Quote Link to comment Share on other sites More sharing options...
dbawel Posted January 12, 2018 Author Share Posted January 12, 2018 @Pryme8 I was just working on identifying the meshes. Thanks for all of your help. DB Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted January 12, 2018 Share Posted January 12, 2018 Anytime buddy! Sorry I have been so busy lately. Might be moving to Colorado soon for a senior Dev position, if that happens Ill let you know. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 12, 2018 Share Posted January 12, 2018 Thanks @Dad72 and @Pryme8! You guys rock Dad72 and Pryme8 2 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 12, 2018 Share Posted January 12, 2018 Did you try a path without the './' but '' (it is not useful to put ./) BABYLON.SceneLoader.ImportMesh("", "", path, scene, (meshes)=> { same thing here : var pathsToLoadFrom = ["assets/obj_files_10/", "assets/obj_files_11/", "assets/obj_files_12/"]; In fact your mistake is that you use a path in importMesh in the file parameter. you do not call any files. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 12, 2018 Share Posted January 12, 2018 You had to do something like this in the ImportMesh : BABYLON.SceneLoader.ImportMesh('', path, fileOBJ, scene, (meshes) => { var fileOBJ = ???; loader.prototype._run = function(path) { BABYLON.SceneLoader.ImportMesh('', path, fileOBJ, scene, (meshes) => { for(let i=0; i < meshes.length; i++){ let mesh = meshes[i]; mesh.position.x = this.mesh_pos; this.meshs.push(mesh); } }); }; Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 12, 2018 Share Posted January 12, 2018 That's what I did by resuming your code by adding the files. var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas); var scene = new BABYLON.Scene(engine); scene.clearColor = new BABYLON.Color3(1, 1, 1); var camera = new BABYLON.FreeCamera("camera", new BABYLON.Vector3(-2.15, 0, -3.2), scene); camera.minZ = 0.01; var light = new BABYLON.PointLight("light", new BABYLON.Vector3(0, 5, -5), scene); var pathsToLoadFrom = ["assets/obj_files_10/", "assets/obj_files_11/", "assets/obj_files_12/"]; // replace the files here by yours var file = ["files10.obj", "files11.obj", "files12.obj"]; var loader = function(paths, file){ this.mesh_pos = -5; this.meshs = []; for(let i=0; i<paths.length; i++){ this._run(paths[i], file); this.mesh_pos += 1; } return this; }; loader.prototype._run = function(path, file) { BABYLON.SceneLoader.ImportMesh('', path, file, scene, (meshes) => { for(let i=0; i < meshes.length; i++){ let mesh = meshes[i]; mesh.position.x = this.mesh_pos; this.meshs.push(mesh); } }); }; engine.runRenderLoop(function () { scene.render(); }); var _l = new loader(pathsToLoadFrom, file); Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 13, 2018 Share Posted January 13, 2018 Of nothing DB... Always happy to help Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted January 13, 2018 Share Posted January 13, 2018 you can always do an array like this too [ {filePath:'Blah/file', fileName:'coolModel.obj'}, {filePath:'Blah/file-location2', fileName:'coolModel2.obj'} ] and then iterate through that so you don't have two arrays. 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.