Hi all. Currently trying to create a mirror to show the exact image that it is in front of it. Used the following relevant code:
const cubeRenderTarget = new THREE.WebGLCubeRenderTarget( 256 );
cubeRenderTarget.texture.type = THREE.HalfFloatType;
export const cubeCamera = new THREE.CubeCamera( 1, 5000, cubeRenderTarget );
...
const firstMesh = object.children[ 0 ].children[ 2 ].clone();
const secondMesh = object.children[ 0 ].children[ 3 ].clone();
const oldMaterialParams1 = firstMesh.material.clone();
const oldGeoParams1 = firstMesh.geometry.clone();
const newMaterial1 = new MeshStandardMaterial( {
envMap: cubeRenderTarget.texture,
roughness: 0,
metalness: 1
} ).clone( oldMaterialParams1 );
const oldMaterialParams2 = secondMesh.material.clone();
const oldGeoParams2 = secondMesh.geometry.clone();
const newMaterial2 = new MeshStandardMaterial( {
envMap: cubeRenderTarget.texture,
roughness: 0,
metalness: 1
} ).clone( oldMaterialParams2 );
object.children[ 0 ].children[ 2 ] = new THREE.Mesh( oldGeoParams1, newMaterial1 );
object.children[ 0 ].children[ 3 ] = new THREE.Mesh( oldGeoParams2, newMaterial2 );
...
cubeCamera.update( this.renderer, scene3D );
I want to reproduce this example:
https://threejs.org/examples/webgl_materials_cubemap_dynamic.html
Thanks in advance.