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

Chapter 4. Using Materials to Customize 3D Objects Appearance

The objects that we call materials are essential in 3D rendering. They are used to render objects on the screen and how they are rendered. This means that the materials are used to apply textures and transformations such as waves, for example, manage transparency and more. In other words, materials are interfaces that are used to easily customize the 3D object's appearance.

The following is an example with Babylon.js:

myMesh.material = new BABYLON.StandardMaterial("material", scene); 
// Done! Now customize everything you want here 
myMesh.material.diffuseTexture = diffuseTexture; 
myMesh.material.transparency = 0.5; 
// Etc. 

We will be covering the following topics in this chapter:

  • Discussing the awesome theory behind the materials
  • Using the Babylon.js standard material
  • Using textures with materials