我正在使用Three.JS
,我需要一个立方体来适应窗口的大小。立方体将始终尊重窗口的比例 (window.innerWidth
和window.innerHeight
),但会根据显示比例更近或更远来导致 Z 位置。
cube = new THREE.Mesh( new THREE.CubeGeometry( windowWidth, windowHeight, 200, 6, 6, 6, materials ), new THREE.MeshFaceMaterial() );
cube.position.y = ???;
cube.position.z = ???;
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
renderer.setSize( window.innerWidth, window.innerHeight );
camera.updateProjectionMatrix();
cube.position.y = ???;
cube.position.z = ???;
}
你能想出解决办法吗?