4

So I read today about babylonJS and I was blown away by it. I'm trying to figure out how to load an entire 3d scene into babylon. I've managed to export a 3d model of spider man and have the .babylon file but then what? In the document it only states
"Importing scene from 3D assets
Babylon.js can load scenes from a file format called .babylon. This file format is based on JSON and contains all required data to create a complete scene."

Any ideas on how to achieve this? Thanks

climboid
  • 6,932
  • 14
  • 44
  • 71

1 Answers1

5

Once you have a .babylon file, you can call the SceneLoader.Load function:

BABYLON.SceneLoader.Load("", "scene.babylon", engine, function (newScene) {

});

the Load function takes the following parameters:

  • scene folder (can be empty to use the same folder as your page)
  • scene file name
  • a reference to the engine
  • a callback to give you the loaded scene (in my case, I use this callback to attach the camera to the canvas and to launch my render loop)
  • a callback for progress report

More details here: https://www.eternalcoding.com/?p=313

Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
David Catuhe
  • 1,747
  • 1
  • 10
  • 9
  • What about adding only one model to an already loaded scene? Looks like `BABYLON.SceneLoader.ImportMeshes`. These are loading from a remote server, ie making http request. [How about loading them from local file system?](https://stackoverflow.com/questions/56124526/loading-local-files-into-a-babylonjs-scene-directly) – sçuçu May 14 '19 at 06:52