Hello there, I was confused with this too at the beginning - documentation seemed to be fairly complicated and didint cover simplest tasks Maybe my example code can help you.
This will get you array of imported meshes (object.meshes) and you can do whatever you want with them later. In my example, I have added them to the scene right away, but you can just store them into local variable and use that mesh later.
BABYLON.SceneLoader.LoadAssetContainer(“models/”, “someObject.obj”, scene, function(object) {
var importedMeshes = object.meshes;
for (var i = 0; i < importedMeshes.length; i++) {
scene.addMesh( importedMeshes[i]);
}
});
If you use console.log(object.meshes) and then look at the debugger (F12), you can easily look into the imported array and you will see everyting what is in there.
Could you explain what does it means “models/”, what is this models, I`m asking because after I see “someObject.obj” and this is model too, so for me “models/” and “someObject.obj” is the same things…!?
It is funny how you are missing exactly the same pieces of information as I did earlier
Well that path “models/” is just path to the directory in your filesystem where models are stored.
Just imagine these two string as they are connected “models/someObject.obj”. I dont really know why it is separated in two variables.
index.html
models/someObject.obj
You will probably see error that will tell you that you need to provide also someObject.mtl file which you may or may not have. This file contains materials used for your mesh but it is very possible that you just only want to import mesh and not any materials - then you just create EMPTY file with same name as your object file. In my example it would be someObject.mtl and it would be empty text file placed in the same directory.
From my short but intensive experience I could say that your documentation sometimes miss information for people whose first 3D experience is right now.
For example these importers - when I started I didnt know about file formats I didnt know what is obj file and mtl file and babylon file. I just wanted one simple thing - import one mesh (and only mesh, only geometry and nothing else) from some file that I downloaded somewhere. All examples seemed to be too overwhelming for such simple task and I had to cope with mtl file (and lot of those find on the internet somehow doesnt work) and then it added into scene “on its own” while I wanted to add when I say and not immediately :))
This is nooby I know and sometimes only noob can understand another noob, but for beginners these really simple tasks are often that piece of puzzle they miss.
EDIT: Or maybe I put it out wrong way - documentation ofteen contains that needed info, but it is later on the page and not at the top side which I believe it belongs
I think that loaders section in tutorials would be nice. Mainly for people that are good 3D artists but poor programmers.
Load one simple mesh from this file (ideally provide simple example file that WORKS and is imported without errors)
Store loaded meshes in some variable
Use your loaded mesh as you wish whenever you want
And one side note if I can: People tend to make documentation of their own work in a way that it “promotes itself” - and examples are sometimes too good-looking but too complex (I tend to do exactly this as well). I know that you want to show us what Babylon is capable of, but sometimes, less is more
When I tried to insert very simple geometry in my scene, like sphere cube or plane, I started to understand what Im doing, after I tried to insert more complicated geometry I figured out that I dont understand how it works totaly, so I need very very simple sample to understand it…
Most of the times, people struggle to find information. So we end up updating the doc to accomodate and then new users complain about the new structure, etc… It is a complex story.
My understanding is that we should add a tutorial for the specific task you mentioned
Maybe this one could be linked in the future 101 doc page? @Ivan_Stratiichuk, could you give a try on this tool, and tell us if it’s more convenient for doing first steps into BJS?
Pls explain me what should I write in case if I have my model on my drive, and I don`t have link for my model as it noted on sample (marked by yellow)!?
BABYLON.SceneLoader.LoadAssetContainer(“models/”, “someObject.obj”, scene, function(object) {
var importedMeshes = object.meshes;
for (var i = 0; i < importedMeshes.length; i++) {
scene.addMesh( importedMeshes[i]);
}
});
Could you write this code as it could be in your PC if you would like to import smth on your web page, I need to see how correctly to write directory of my model in my file system…!?
By the way I don`t miss info, I only trying to figure out how this things works, and I see a big mess of how to study it…
Here’s a scene importing and animating several meshes that I modified… initially posted by @Wingnut. The paths to the meshes are still active, obviously.