Update: Revised the question for a broader context. (Original here for reference)
In my project, I am using Three.js WebGLRenderer to render a scene. I need to replace the existing renderer with a new WebGLRenderer by swapping out the canvas and then re-render the same scene in the new renderer.
The process basically involves:
cancelAnimationFrame(this.requestID_);
// all other Three.js objects remain the same (with a new canvas being created by Three.js)
this.createNewRenderer();
this.animate();
The issue I'm facing is that the new renderer only displays an empty background without the scene's meshes. However, if I replace the meshes with freshly calculated ones, the rendering works as intended.
Based on this observation, I suspect the problem lies with the meshes themselves.
I have attempted to solve this by setting the geometry.xxxNeedUpdate and material.needUpdate flags as mentioned in this three.js documentation before and after creating the new renderer. Unfortunately, this approach hasn't resolved the issue either.
What steps can I take to ensure that the meshes are refreshed and displayed correctly in a new WebGLRenderer?