climboid
climboid

Reputation: 6952

Import a 3d scene into babylonJS

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

Upvotes: 5

Views: 5356

Answers (1)

David Catuhe
David Catuhe

Reputation: 1767

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

Upvotes: 6

Related Questions