aarroyoc Posted February 1, 2017 Share Posted February 1, 2017 Hi, I tried to load a mesh from Blender. I've used the exporter but when I loaded it, the onsuccess callback has a an array of zero meshes. I'm doing: BABYLON.SceneLoader.ImportMesh("sectarian", "/data/", "untitled.babylon", scene, function (meshes, ps, skeletons) { console.dir(meshes); }); And untitled.babylon is attached. I'm using Babylon 2.4 and meshes is an array of 0 elements. I've checked and the babylon file is correctly loaded from the server. What should I do in order to load the mesh? Am I missing something? Thanks untitled.babylon Quote Link to comment Share on other sites More sharing options...
jpdev Posted February 1, 2017 Share Posted February 1, 2017 Hi aarroyoc, You babylon file only contains a cube named "Cube". I have put your file on my server, and this playground loads the only mesh in it: http://babylonjs-playground.com/#2G9IR#0 You can confirm, that there reallly is only a cube in it (and no "sectarian") by opening it in a text editor - it's json and human readable. Quote Link to comment Share on other sites More sharing options...
aarroyoc Posted February 1, 2017 Author Share Posted February 1, 2017 Hi jpdev, You were right!! I didn't know what the first parameter was for so I put a random name. Now it works. Thanks! Quote Link to comment Share on other sites More sharing options...
Dad72 Posted February 1, 2017 Share Posted February 1, 2017 Or just leave the first parameter (name) empty. Babylon automatically get it for you. Like here: http://babylonjs-playground.com/#2G9IR#1 Quote Link to comment Share on other sites More sharing options...
dbawel Posted February 1, 2017 Share Posted February 1, 2017 @Dad72 - Brilliant! I wasn't aware we didn't need to define the object name. Of course this would only work if your scene contained a single mesh. Also, you will most likely want to use your mesh in a seperate function or operation again in your script, so I might advise to always define the name of your imported mesh - especially if it contains children in Blender which you wish to import and clone or instance. DB Quote Link to comment Share on other sites More sharing options...
Dad72 Posted February 1, 2017 Share Posted February 1, 2017 Even if the name is not in the ImportMesh function, it is still possible to use it. see here: http://babylonjs-playground.com/#2G9IR#2 So no need to define the name. I do not even know why this setting exists for ImportMesh because if we set a different name, the object does not load. Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted February 2, 2017 Share Posted February 2, 2017 i believe the "name" parameter is there incase you only want one mesh from a file containing several meshes, e.g. BABYLON.SceneLoader.ImportMesh("", "/assets/", "myFile.babylon", scene, function (newMeshes, particles, skeletons) if your file have two meshes, leaving the name field empty, loads both meshes, respectively at newMeshes[0] and newMeshes[1], Dad72 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted February 2, 2017 Share Posted February 2, 2017 Ah, yes, well seen. I understand its usefulness now. Thanks for information aWeirdo 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.