How to import geometry that I have already prepared


#21

Yes, its on my drive, because I`m studying,

I see everything is locked to send code by text, so I`m sending screen of those part for what I have questions,

What does it means in code “./” ???

Do I need to write instead of word “scene” smth that should be on my drive?


#22

Arguments for append, Babylon.js/sceneLoader.ts at master · BabylonJS/Babylon.js · GitHub

Append adds stuff to a scene already created by you. The variable scene should have a value BEFORE callingAppend.

I do not know what the function createScene is, but looks like you are assigning the variable scene AFTER calling Append. That cannot be good.


#23

Ok, maybe import mesh will add geometry created by me?

samples attached


#24

Hello there, I was confused with this too at the beginning - documentation seemed to be fairly complicated and didint cover simplest tasks :slight_smile: 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.


#25

Hello,

Thank you very much for help,

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…!?


#26

It is funny how you are missing exactly the same pieces of information as I did earlier :slight_smile:

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.


#27

Interested to see how to improve doc here.
We have examples here: Babylon.js Documentation (look for loading for instance)

Also there is the asset container doc: Use an AssetContainer - Babylon.js Documentation

Perhaps add one more section on the tutorial? Babylon.js Documentation


#28

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 :slight_smile:


#29

I see you understand me))


#30

Makes sense. Would you see that information in the 101 section?


#31

I think that loaders section in tutorials would be nice. Mainly for people that are good 3D artists but poor programmers.

  1. Load one simple mesh from this file (ideally provide simple example file that WORKS and is imported without errors)

  2. Store loaded meshes in some variable

  3. 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 :wink:


#32

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…


#33

Well this example seems exactly what you are looking for:

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… :smiley: It is a complex story.

My understanding is that we should add a tutorial for the specific task you mentioned


#34

Great idea to add to Babylon 101 a very simple and basic to just import a 3D file, +1.


#35

Note that designers could love the Viewer ! The Babylon.js Viewer - Babylon.js Documentation

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? :slight_smile:


#36

It could be more convenient in case it will work,

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)!?


#37

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…


#38

Could you send me ready code and files that works on your PC, I will try it on my, and it will help me to figure out what I`m doing wrong…!?


#39

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.:wink:

https://www.babylonjs-playground.com/#82XMQB#9

Galen


#40

Due to security reason enforced by the browsers, you cannot serve files directly from your local drives (using scheme like file://)

You have to setup a server locally and serve them from http://localhost
Once done this code will work:

BABYLON.SceneLoader.LoadAssetContainer(“http://localhost/”, “someObject.obj”, scene, function(object) {
var importedMeshes = object.meshes;
for (var i = 0; i < importedMeshes.length; i++) {
scene.addMesh( importedMeshes[i]);
}
});