How to create your first Scene in Playground
We will create our scenes, save and share them on playground.

BabylonJS Code

To create a basic BabylonJS scene, we initialize a scene, create camera, light and a mesh and return the scene object.
1
const createScene = () => {
2
const scene = new BABYLON.Scene(engine);
3
​
4
const camera = new BABYLON.ArcRotateCamera("camera", -Math.PI / 2, Math.PI / 2.5, 3, new BABYLON.Vector3(0, 0, 0));
5
​
6
const light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(0, 1, 0));
7
​
8
const box = BABYLON.MeshBuilder.CreateBox("box", {});
9
​
10
return scene;
11
}
Copied!
Babylon.js Playground
BabylonJS Playground Demo Link
Scene object gets engine as the input argument. You don't have to worry about the engine when you are working on the playground but when you are working on your local code sample, we will create the engine as well.
Export as PDF
Copy link