How to id to canvas in three.js app

I created a render object in three.js file and connected it to DomElment as shown below.

var renderer = new THREE.WebGLRenderer({
            antialias: true
        });
renderer.setClearColor( 0xAAAAAA, 1 );
renderer.setSize(window.innerWidth, window.innerHeight);
document.getElementById('webgl-container').appendChild(renderer.domElement);

      

So now three.js automatically create the canvas inside the webgl container div, but now I want to give the canvas an id, how can I do that

+3


source to share


1 answer


You tried:



renderer.domElement.id = 'YourIDName';

      

+9


source







All Articles