O'Reilly logo

Babylon.js Essentials by Julien Moreau-Mathis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using textures with materials

This chapter is the right place to introduce the usage of textures. Textures are images (.png,.jpeg, and so on) that graphics libraries are able to apply to meshes. There are several types of texturing methods handled by Babylon.js, such as video textures, cube textures, and so on. Now, let's explain how to use textures with materials.

Load and apply a texture

As you may have already guessed, loading and applying a texture to a mesh can be easy with Babylon.js. The standard material provides a way, as for colors, to apply a diffuse texture (for example, specular, emissive, and ambient textures). Simply set the .diffuseTexture property to the reference of your texture, as follows:

myMaterial.diffuseTexture = myTexture; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required