How to use the camera as a texture image in the Three.js file

In three.js, I am trying to create a texture whose image is the current scene when viewed from the camera. Using CubeCamera to create a similar effect is well documented; and with CubeCamera I created an example scene to illustrate my purpose:

http://stemkoski.github.com/Three.js/Camera-Texture-Almost.html

However, I would like to use a regular camera (not CubeCamera) as a texture. How can i do this?

+5
source share
2 answers

Ideally, this will work.

Init:

renderTarget = new THREE.WebGLRenderTarget( 512, 512, { format: THREE.RGBFormat } );

var planelikeGeometry = new THREE.CubeGeometry( 400, 200, 200 );
var plane = new THREE.Mesh( planelikeGeometry, new THREE.MeshBasicMaterial( { map: renderTarget } ) );
plane.position.set(0,100,-500);
scene.add(plane);

Render:

renderer.render( scene, topCamera, renderTarget, true );
renderer.render( scene, topCamera );

And it’s almost so, but we have an unfinished business with inverted textures that destroy this batch here.

, ( ):

http://mrdoob.github.com/three.js/examples/webgl_rtt.html

+5

All Articles