What is the best way to import models from blender?

hey guys, so, i’m trying to import models from blender to my project, so i got my scene and everything good, what file should i use? if i download the model with the gltf option, it download with a texture folder, i try to put it inside the public folder and set a the SceneLoader like this SceneLoader.ImportMesh("", "/painted_wooden_chair_02_2k.gltf", scene, function (newMeshes) { newMeshes.forEach(function (newMesh) { newMesh.position = new Vector3(0, 0, 0); newMesh.scaling = new Vector3(0.1, 0.1, 0.1); }); });
but i only got errors, apparently with the URL, but i tried everything still is not working.
what i need is a way that i can get models and resources from the web and import it into my project, whats the best / easiest way to do it? thank you!

Hey! Welcome to babylon.js!

Choose glb or also known as gtTF binary when exporting the mesh. It will contain everything in one file to correctly render your 3d object.

thank you! but is ok the way im importing it in my code?

Basically yes.

Read the docs about multiple techniques you can utilize when loading the assets:

I always go async and don’t use the callback version of the loader functions. It’s cleaner.

  1. mark createScene as async
  2. use the async version of the loader function
  3. await it
  4. access stuff from your file

If you have any questions after reading the docs just ask.

thank you! will try

1 Like

sorry, i still can’t make it work,

maybe is the way im trying to put the root URL, but i tried in different ways, without the /public, still same, inside the public folder there is the .gltf file, the bin file and the texture folder with all the texture, im not sure what im doing wrong

Wrong URL :slight_smile: textures is missing



EDIT: Ooops sorry no… My bad

  1. export in glb - it produces one file including the textures
  2. remove /public/ from the URL - the public directory should be mapped to the root of your webapp

I would create a directory public/assets/models and put the glb file there. The URL then will be assets/models/you3dmodel.glb

You can then create more directiories in public like images, sounds, etc. to better organize your files.

thank you so much for the help, i will try follow the instructions and comment here the updates!

Let me know immediately. I’ll be here for the next 15 minutes.

is super weird, already exported the file as .glb so it has inside texture and everything, i also created the folders as you recommended and still same error, allow me to put screenshot.

in console. same error
apparently is something about root url not being a string but is actually a string with the route to the file

hey man! so following the docs and the examples, i was able to notice that the second parameter they are passing is the root url without the file itself, the third parameter was the name of the file, so should be like this

i was able to import the mesh succefully, i appreciate that you took the time to answer me and try to help me! we can close the post as solved!


Glad to help you! Anytime again :slight_smile: !