Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to assign a id to canvas in the three.js application

I have created a render object in three.js and connect it with DomElment, shown as followed

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 a canvas inside the webgl-container div, but now I want to give a canvas a id, how could I do it

like image 317
user824624 Avatar asked Oct 23 '14 09:10

user824624


1 Answers

Have you tried :

renderer.domElement.id = 'YourIDName';
like image 186
Benedikt Avatar answered Oct 19 '22 15:10

Benedikt