[Mesh] how import meshes and saving file size? (Possible .obj?)

Now i’m used ‘SceneLoader.ImportMesh( )’. but ‘.babylon’ file size is bigger than ‘.obj’ file.

How import .obj file?

else,

How export only selected meshes in Blender3D’s scene?

Plz tutorial PG or documents. :pray:

Hi Ned,
You’ll need to add the babylonjs-loaders package and import it.
See here: Load from any file type - glTF, OBJ, STL, etc. - Babylon.js Documentation

Edit: Also consider that your .babylon file will be gzipped when being transferred from your server (hopefully) so they can be quite compact.

First, thank you!

I saw this document.

I’m wrote ‘import { OBJFileLoader } from ‘babylonjs-loaders’;’
But, i don’t know next.

If example has ‘abc.obj’. and meshes is [‘apple, banana’].
How import this .obj file?

plz & thank you again. :pray:

No need for the qualified import, just put import 'babylonjs-loaders' at the top of your file and then just use the same import you did before, but change the file name from x.babylon to x.obj.

For instance, this is how I loaded a .glb file in a project:

BABYLON.SceneLoader.ImportMesh('', 'assets/', 'terrain.glb', this.scene, (meshes) => {
			for (let mesh of meshes) {
				mesh.position = new BABYLON.Vector3(0, -10, 0);
				mesh.checkCollisions = true;
				mesh.setEnabled(true);
			}
		});

Notice I have the empty mesh names as the first parameter so I’m importing all meshes in this file. If you want the ['apple', 'banana'] meshes specifically then replace the empty string with that array.

Also consider that all the meshes are returned as an array in the first argument in the callback, so you can filter the meshes in there as well.

1 Like

Thank you!!
I’m success import .obj file.
But need to setting that triangle of meshes, when exporting from blender.
if not then broken meshes.

I love your answer! :+1:

1 Like