styke
styke

Reputation: 2174

ThreeJS - How to output canvas into specific div?

It seems that the canvas is simply inserted into the body, at the bottom of the flow. I was wondering which bit of code do I need to change to get it to insert into a specific div?

Upvotes: 3

Views: 2609

Answers (2)

Tapio
Tapio

Reputation: 3456

You could create the canvas yourself and put it to your desired location. Then pass it to the renderer constructor like this: renderer = new THREE.WebGLRenderer({ canvas: myCanvasElem }); See the docs.

Upvotes: 3

EliSherer
EliSherer

Reputation: 1647

It is usually this line:

container = document.createElement( 'div' );

//later in that file
container.appendChild( renderer.domElement );

change the first line to:

container = document.getElementById( 'mycustomdiv' );

Upvotes: 4

Related Questions