Threejs canvas size based on container

前端 未结 6 431
借酒劲吻你
借酒劲吻你 2021-02-01 20:58

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.

6条回答
  •  执念已碎
    2021-02-01 21:17

    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);
    

提交回复
热议问题