As I said in the title When my sphere reflects it drags the frame from before so instead of the live reflection of the cube I end up getting a full circle around the sphere.
here is my setup for the shapes.
var cubeGeometry = new THREE.BoxGeometry(1, 1, 1);
var sphereGeometry = new THREE.SphereGeometry(3, 64, 64);
var smallSphereGeometry = new THREE.SphereGeometry(1, 64, 64);
var cubeCamera = new THREE.CubeCamera(0.1, 5000, 512);
scene.add(cubeCamera);
var mirrorShpereMaterial = new THREE.MeshBasicMaterial({envMap:cubeCamera.renderTarget });
var material1 = new THREE.MeshBasicMaterial({ color: 0xffff00, wireframe: false});
var cube = new THREE.Mesh(cubeGeometry, material1);
var sphere = new THREE.Mesh(sphereGeometry, mirrorShpereMaterial);
var smallSphere = new THREE.Mesh(smallSphereGeometry, material);
cube.position.x = 5;
then I add all the shapes to the scene and I attach the cube to the small sphere and rotate the small sphere to get the orbit effect.
next the render function
function render(){
var delta = clock.getDelta();
renderer.clear();
sphere.visible = false;
cubeCamera.updateCubeMap( renderer, scene );
sphere.visible
composer.render(delta);
requestAnimationFrame( render );
smallSphere.rotation.y += 0.05;
cube.rotation.z += 0.05;
cube.rotation.x += 0.05;
}
var clock = new THREE.Clock()
controls.update();
render();
from what I understand the part here that should make the reflection dynamic the when i set the sphere to invisible the camera should then take a snapshot and update the material with the new position of the cube, but when I run it it doesn't update the new position it adds the new position while keeping all previous positions still on the sphere. So I'm wondering if I'm missing something here or how to do this differently.
Aucun commentaire:
Enregistrer un commentaire