Hi,
I was intrigued by this thread and decided to try and animate an environment in vanilla three.js.
It worked but with very poor performances so I was wondering if my approach was right?
const environment_scene = new RoomEnvironment(); // a scene containing an animated white plane acting as the light source
const pmremGenerator = new THREE.PMREMGenerator( renderer );
let environment_texture = pmremGenerator.fromScene( environment_scene ).texture;
scene.environment = environment_texture;
scene.background = environment_texture;
function loop() {
requestAnimationFrame(loop);
// Recreates the texture (😬)
environment_texture = pmremGenerator.fromScene( environment_scene ).texture;
// and reapplies it
scene.background = environment_texture;
scene.environment = environment_texture;
}
loop();
Recreating the texture each frame obviously seems like the issue here, but I couldn’t find an other way. Did I miss something?
Any guidance would be appreciated!
Thanks!