立方相机(CubeCamera)

优质
小牛编辑
134浏览
2023-12-01

创建6个渲染到WebGLCubeRenderTarget的摄像机。

代码示例

// Create cube render target
const cubeRenderTarget = new THREE.WebGLCubeRenderTarget( 128, { format: THREE.RGBFormat, 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 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 );

例子

materials / cubemap / dynamic
shading / physical

构造器

CubeCamera( near : Number, far : Number, renderTarget : WebGLCubeRenderTarget )

near -- 近剪切面的距离
far -- 远剪切面的距离
renderTarget -- The destination cube render target.

构造一个包含6个PerspectiveCameras(透视摄像机)的立方摄像机, 并将其拍摄的场景渲染到一个WebGLCubeRenderTarget上。

属性

共有属性请参见其基类Object3D

.renderTarget : WebGLCubeRenderTarget

The destination cube render target.

方法

共有方法请参见其基类Object3D

.update ( renderer : WebGLRenderer, scene : Scene ) : null

renderer -- 当前的WebGL渲染器
scene -- 当前的场景

这个方法用来更新renderTarget(渲染目标对象)。

源代码

src/cameras/CubeCamera.js