Book Image

Babylon.js Essentials

By : Julien Moreau-Mathis
Book Image

Babylon.js Essentials

By: Julien Moreau-Mathis

Overview of this book

Are you familiar with HTML5? Do you want to build exciting games and Web applications? Then explore the exciting world of game and Web development with one of the best frameworks out there: Babylon.JS. Starting from the beginning, the book introduces the required basics for 3D development and the knowledge you need to use the Babylon.js framework. It focuses on the simplicity provided by Babylon.js and uses a combination of theory and practice. All the chapters are provided with example files ready to run; each example file provides the previously learned features of the framework. Finally, developers will be ready to easily understand new features added to the framework in the future.
Table of Contents (15 chapters)
Babylon.js Essentials
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface

Checking collisions in a scene


Starting from the concept, configuring and checking collisions in a scene can be done without mathematical notations. We all have the notion of gravity and ellipsoid, even if the ellipsoid word is not necessarily familiar.

How collisions work in Babylon.js?

Let's start with the following scene (a camera, light, plane, and box):

The goal is to prevent the currently active camera of the scene from crossing the objects in the scene. In other words, we want the camera to stay above the plane and stop moving forward if it collides with the box.

To perform these actions, the collisions system provided by Babylon.js uses a collider. A collider can be represented by the bounding box of a simple object and it looks similar to the following image:

For information, a bounding box simply represents the minimum and maximum positions of a mesh's vertices and it is computed automatically by Babylon.js.

As explained in Chapter 3, Create, Load, and Draw 3D Objects on the Screen...