Threejs画布大小基于容器 [英] Threejs canvas size based on container

查看:91
本文介绍了Threejs画布大小基于容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何根据其容器计算画布大小?避免滚动.

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.

推荐答案

嗯,这并不难.设置渲染的大小会起作用.

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

这篇关于Threejs画布大小基于容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆