Capítulo 17 de 859
A special type of camera that is positioned in 3D space to render its surroundings into a cube render target. The render target can then be used as an environment map for rendering realtime reflections in your scene.
// Create cube render target
const cubeRenderTarget = new THREE.WebGLCubeRenderTarget( 256, { generateMipmaps: true, minFilter: THREE.LinearMipmapLinearFilter } );
// Create cube camera
const cubeCamera = new THREE.CubeCamera( 1, 100000, cubeRenderTarget );
scene.add( cubeCamera );
// Create car
const chromeMaterial = new THREE.MeshLambertMaterial( { color: 0xffffff, envMap: cubeRenderTarget.texture } );
const car = new THREE.Mesh( carGeometry, chromeMaterial );
scene.add( car );
// Update the render target cube
car.visible = false;
cubeCamera.position.copy( car.position );
cubeCamera.update( renderer, scene );
// Render the scene
car.visible = true;
renderer.render( scene, camera );
Constructor
| Signature |
|---|
new CubeCamera( near : number, far : number, renderTarget : WebGLCubeRenderTarget ) |
Properties
| Property | Description |
|---|---|
.activeMipmapLevel : number | The current active mipmap level |
| `.coordinateSystem : WebGLCoordinateSystem | WebGPUCoordinateSystem` |
.renderTarget : WebGLCubeRenderTarget | A reference to the cube render target. |
Methods
| Method | Description |
|---|---|
| `.update( renderer : Renderer | WebGLRenderer, scene : Scene )` |
.updateCoordinateSystem() | Must be called when the coordinate system of the cube camera is changed. |