Graphics Reference
In-Depth Information
recipe, so if you haven't read the
How it works…
section from the
Using a cubemap
to create reflective materials
recipe, please do that first. The main difference is that
for this recipe, we create a cubemap on the fly with
THREE.CubeCamera
instead of
using a static one. When you instantiate
THREE.CubeCamera
, you're really creat-
ing six
THREE.PerspectiveCamera
objects—one for each side of the cubemap.
Whenever you call
updateCubeMap
, as we do in this recipe in the
render
loop,
Three.js just renders the scene using these six cameras and uses the render results
as the cubemap to be used.
There's more…
In this recipe, we showed you how to make one mesh reflect the complete scene.
If you create separate
THREE.CubeCamera
objects for each of the meshes in the
scene, you can create a dynamic cubemap for all the objects. Keep in mind, though,
that this is a rather computationally-intensive process. Instead of rendering the scene
once, you incur six additional render passes for each cube camera you use.
See also
• For a static cubemap, you can use the steps explained in the previous re-
cipe,which is the
Using a cubemap to create reflective materials
recipe