In our existing code packets, we have a terrain which is a simple plain, with no bumps or plateaus or dips. Hence, we use an object of the jigLib.Plain
class to represent it in our physics world. This section intends to end what we started with a true physics terrain. The following screenshot shows you the terrain that we will be targeting to initialize in the physics world. It has a bump that starts from the center of the terrain:
We can easily add this bump to the geometry, but it will take some effort to simulate it in our physics world. So, first we add this bump to our geometry. Open PlaneGeometry.js
from the primitive
folder in your text editor. In our previous code, we set the z axis value to 0
as shown in the following code:
this.vertices.push(x); this.vertices.push(- y); this.vertices.push(0);
The preceding code simply denoted that the geometry had no bumps, and all segments had a height of 0. However, now we simply add some logic to calculate the...