Graphics Reference
In-Depth Information
var sphere = new
THREE.Mesh(sphereGeometry,
dynamicEnvMaterial);
sphere.name='sphere';
scene.add(sphere);
var cylinder = new
THREE.Mesh(cylinderGeometry, envMaterial);
cylinder.name='cylinder';
scene.add(cylinder);
cylinder.position.set(10,0,0);
var cube = new THREE.Mesh(cubeGeometry,
envMaterial);
cube.name='cube';
scene.add(cube);
cube.position.set(-10,0,0);
5. The last step we need to take is that in the render loop, we update
cubeCamera like this:
function render() {
sphere.visible = false;
cubeCamera.updateCubeMap( renderer,
scene );
sphere.visible = true;
renderer.render(scene, camera);
...
requestAnimationFrame(render);
}
When you've taken all these steps, you'll end up with a sphere in the middle of the
scene that not only reflects the environment, but also the other objects in the scene.
How it works...
In the Using a cubemap to create reflective materials recipe we explained how a
cubemap is used to create reflective objects. The same principle also applies to this
Search WWH ::




Custom Search