Getting Started - Chapter 2 - Ground

Grounding the World

At the moment we have a box floating in space. To make the scene more world like let's add ground and think of our box as a building set on the ground.

Adding a ground is simple using

const ground = BABYLON.MeshBuilder.CreateGround("ground", {width:10, height:10});

As we need to create a ground large enough, to put some buildings (boxes) on, the options parameter has two properties set, width in the x direction and height in the z direction. (Yes, we agree, since y is vertical it would make more sense for the properties to be width and depth.)

Adding a Ground Playground

The immediate thing to note is that the ground cuts through the middle of the box. This is because when they are created meshes are positioned at the origin.

We need to move the box up half its height using

box.position.y = 0.5; //box created with default size so height is 1
Adjusting the Box position.

Currently our world is silent. Let's add some sound.