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

Using the Babylon.js standard material


Babylon.js allows you to create materials, which means that it can create the custom materials with custom shaders; however, it provides a standard material with already-developed shaders that are designed to be adapted by many customizations.

In fact, when you add a light to a Babylon.js scene, the light properties such as diffuse color, are sent to the materials of the scene to compute the light contributions on the meshes.

The standard material and its common properties

In Babylon.js, each mesh has a material and the meshes can share the same material. Creating a standard material and assigning it to a mesh with Babylon.js is as easy as writing the following:

myMesh.material = new BABYLON.StandardMaterial("materialName", scene); 

Simply create a new StandardMaterial object by giving a name to the material and the scene where you want to add the material and assign it the.material property of a mesh. Once the material is created, you can start modifying...