3

I am in the process of learning BabylonJS.

How do you add a 3D model into an already existing BabylonJS scene? I have a scene of a building and I want to add a grand piano into the interior of the building. The piano is a 3d model in OBJ and FBX form.

Thanks!

user3704706
  • 41
  • 1
  • 2
  • 5

3 Answers3

2

You've got to use the Assets Manager.

const assetsManager = new BABYLON.AssetsManager(scene);
const meshTask = assetsManager.addMeshTask('piano task', '', './assets/', 'piano.obj');
meshTask.onSuccess = (task) => {
    const pianoMesh = task.loadedMeshes[0];
    // Do something with the mesh here
}
assetsManager.load();

If your mesh is in the .OBJ format, then you'll need to use babylonjs-loaders.

Ivan Rubinson
  • 3,001
  • 4
  • 19
  • 48
1

Hello you have several options:

David Catuhe
  • 1,747
  • 1
  • 10
  • 9
0

I do not know if your question is of some importance still for you but you could also try the very good FBX2glTf converter

https://github.com/facebookincubator/FBX2glTF

It can even handle blend shapes, materials, draco-compression etc. It's easy to build and works very fast. Maybe you give that thing a try.

goetzmoritz
  • 453
  • 1
  • 5
  • 23