O'Reilly logo

WebGL Game Development by Sumeet Arora

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. Physics and Terrains

In a game, we generally do not like to control our animations, typically in a case where a bullet or a grenade is involved. We want force, impulse, and gravity to control the motion in a game. This is what this chapter is about—physics simulation. We will discuss how physics engines control component trajectories as well as work with collision detection in a game. However, before we dive deep into physics, we want to extend the terrain (ground) of our game scene. We will cover the following topics in this chapter:

  • A simple terrain: plane geometry
  • JavaScript 3D physics engines: JigLibJS
  • Adding gravity and a rigid body to the game scene
  • Forces, impulse, and collision detection: grenade and bullet animation revisited

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required