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

Playing 3D sounds


In the previous topic, you added and played 2D sounds in a scene. These 2D sounds can be easily used as soundtracks for your games. To add dynamism to your scenes, as physics and collisions do, you can configure the sounds to be spatialized in a scene. The spatialized sounds, which are called 3D sounds, give give the notion of distance and orientation between the player and the sound. In other words, more the player is far from the sound, more the sound will be attenuated. Also, if the sound position is rather on the right of the player, the right speaker will generate more sound than the left speaker and vice versa.

For example, if the sound is emitted on your right, only the right speaker(s) should play it and the farther you are from the sound, the lower the sound's volume should be.

Creating 3D sounds

You can imagine that, as for the 2D sounds, you can create a spatialized sound using the same BABYLON.Sound constructor. Only the options parameter will change as you have...