Threejs: rendering multiple scenes in one webgl renderer
I am trying to include multiple scenes in one webgl renderer according to the code below:
renderer.render (scene1, camera);
renderer.render (scene2, camera);
I ran into a problem when, in the last scene, the object that is passed to the renderer is signed, but the previous one is not. I have confirmed this by replacing these two lines of code. I am a newbie at the age of 3 and would like to know if the above can be achieved? and also if you can lead me to support examples (if any).
Thank!
+4
source to share
1 answer
You can find the minimal solution here: https://jsfiddle.net/mmalex/sqg0d8vx/
var animate = function() {
requestAnimationFrame(animate);
renderer.autoClear = true;
//render scene1
renderer.render(scene1, camera);
//prevent canvas from being erased with next .render call
renderer.autoClear = false;
//just render scene2 on top of scene1
renderer.render(scene2, camera);
};
0
source to share