Canvas for Three.js Projects

Is it really necessary to use the html Element canvas for a Three.Js Project?

        body {
        canvas {
            height: 100%;

On the website is it included, but in the examples I can not see the use of canvas …

Thanks for your replies

A canvas is giving the actual WebGL context, you can’t use it without, there is a canvas in every example.


When you instantiate WebGLRenderer, you can pass in a canvas dom element. But if you don’t, it will be created automatically, then you must attach it to an element of the dom (document.body generally) :

renderer = new THREE.WebGLRenderer();
document.body.appendChild( renderer.domElement );
1 Like

Oh, I see. Now I understand!
Thanks a lot!!