Dynamically set the renderer DOMelement

Hi, can the renderer DOMelement be set dynamically to route the image to a different canvas?

Something like this: this.renderer.domElement = canvasEl; where canvasEl is set to a different canvas within a loop.

Thanks. Mzedd.

No, the WebGL context belongs to the <canvas> element and you can’t switch it to another canvas. You can, however, just move the entire canvas from one <div> to another.

let div1 = document.querySelector("#firstDiv");
let div2 = document.querySelector("#secondDiv");

// Add canvas to div1

// Remove canvas from div1, and add it inside div2

Many thanks. Great way to get round the issue. Much appreciated.