How to insert ThreeJS scene into DIV

You should place <script src="js/scene.js"></script> into the <head> tag. Inside your JavaScript, do something like this:

// get a reference to your canvas container

const container = document.getElementById( 'CanvasFrame' );

// create your renderer

const renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );

// apply the internal canvas of the renderer to the DOM

container.appendChild( renderer.domElement );
2 Likes