11three.js自适应窗口大小
2018-04-20 本文已影响5人
狂暴机甲
添加一个监控事件 window.addEventListener

function onResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
window.addEventListener('resize', onResize, false);