Book Image

Three.js Cookbook

By : Jos Dirksen
Book Image

Three.js Cookbook

By: Jos Dirksen

Overview of this book

Table of Contents (15 chapters)
Three.js Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Using a dynamic cubemap to create reflective materials


In the Using a cubemap to create reflective materials recipe, we showed how you can create a material that reflects its environment. The only caveat was that other meshes rendered in the scene didn't show up in the reflection; only the cubemap was shown. In this recipe, we will show you how you can create a dynamic cubemap that also reflects other meshes in the scene.

Getting ready

To get ready for this recipe, you need to follow the steps explained in the Getting ready section for the Using a cubemap to create reflective materials recipe. For this recipe, we provide a separate example that you can display by opening 04.11-use-reflections-dynamically.html in your browser.

If you look closely at the central sphere in the preceding, you can see that it not only reflects the environment, but also reflects the cylinder, and if you rotate the scene, you can also see the cube reflection.

How to do it...

To accomplish this, we first need to perform...