Skip to content
Advertisement

Threejs canvas size based on container

How can I calculate canvas size based on its container? To avoid scrolling.

If I set the size based on window the canvas is too big.

Advertisement

Answer

Well,that’s not difficult.Set your render’s size will work.

container = document.getElementById('container');
renderer.setSize($(container).width(), $(container).height());
container.appendChild(renderer.domElement);
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement