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

Simulate physics


Physics simulation is pretty different from the collisions system since it does not occur on the cameras but on the objects of the scene itself. In other words, if physics is enabled (and configured) on a box, the box will interact with other meshes in the scene and try to represent the real physical movements.

For example, let's take a sphere in the air. If you apply physics to the sphere, the sphere will fall until it collides with another mesh and according to the given parameters, it will bounce and roll in the scene.

Note

The example files reproduce the behavior of a sphere that falls on the box in the middle of the scene.

Enable physics in Babylon.js

In Babylon.js, physics simulations can be only done using plugins. Two plugins are available for use: the Cannon.js framework and the Oimo.js framework. These two frameworks are included in the Babylon.js GitHub repository in the dist folder.

Each scene has its own physics simulations system and can be enabled by the following...