BabylonJS Scene
Basic Scene with a cube
Last updated
Was this helpful?
Basic Scene with a cube
Last updated
Was this helpful?
We will create our BabylonJS scene on Babylon Playground. Find out more about the editor on chapter.
We will implement the 3D concepts we discussed in chapter.
To create a basic BabylonJS scene, we initialize a scene, create camera, light and a mesh and return the scene object.
Arc Rotate Camera acts like a satellite in orbit around a target and always points towards the target position. In our case, it is pointing towards the box. Where ever you move your camera, it will still point to towards the box.
Arc Rotate Camera parameters are: name you want to give to your camera, alpha(radians) the longitudinal rotation, beta beta (radians) the latitudinal rotation, radius(the distance from the target position), target position(center where the box will be created as a default), scene(optional argument). In this code example scene is not given as an argument and defaults to the scene object on the playground.
A hemispheric light is an easy way to simulate an ambient environment light. In our case, we are doing the bare minimum, just giving a name to the light and set it's location.
Setting y location to 1 while our main object is in the center (0,0,0) location will move the light above the object.
We are creating a Box Mesh by calling BABYLON.MeshBuilder.CreateBox method with the minimum requirements, a name and an options empty object.
Continue exploring how to create a 3D scene with other libraries
Navigate to the code sample playground:
Keep working with BabylonJS and dive deeper into WebXR on the :
Read more on :
Browse :