How can I extract separate mesh from a obj or glb file?

Hi everyone

i have a obj file which has 5 cubes and i want to know how can i modify each cube separately. is it possible to access each cube separately?

If they are separate objects in the file they will be created as separate meshes, so you can access them either through the scene.meshes array or by name (as long as they have different names) with scene.getMeshByName(...).

1 Like

Hi, they are in one obj file.

Hi @Arash_Bagheri

Whether they are in the same obj/glb file or in separate files, the @Evgeni_Popov’s solution works.
Here is an example with 6 cubes loaded from the same obj file :
https://www.babylonjs-playground.com/#D3888B

1 Like

Did you mean load a separate mesh? If so the first parameter is an empty string for all meshes and the name for just one

https://www.babylonjs-playground.com/#8IMNBM#73

or an array of names if you just wanted a selection.

https://www.babylonjs-playground.com/#8IMNBM#74

For alien.glb mesh names to try out.

AlienHead
Collar
CollarClasp
LeftEye
RightEye
Shirt
ShirtPlate
Teeth

1 Like

tnx a lot.

1 Like