使用 THREE.js 的等距相机

问题描述 投票:0回答:1

如何将相机角度设置为等距投影

three.js
1个回答
58
投票

要获得等轴测视图,您可以使用

OrthographicCamera
。然后您需要正确设置相机的方向。有两种方法可以做到这一点:

方法 1 - 使用

camera.lookAt()

const aspect = window.innerWidth / window.innerHeight;
const d = 20;
const camera = new THREE.OrthographicCamera(
    - d * aspect, d * aspect, d, - d, 1, 1000
);
camera.position.set( 20, 20, 20 ); // all components equal
camera.lookAt( scene.position ); // or the origin

方法 2 - 设置

camera.rotation

的 x 分量
camera.position.set( 20, 20, 20 );
camera.rotation.order = 'YXZ';
camera.rotation.y = - Math.PI / 4;
camera.rotation.x = Math.atan( - 1 / Math.sqrt( 2 ) );

Isometric View Using Orthographic Camera

编辑:更新小提琴:https://jsfiddle.net/vkjew52q/

三.js r.146

© www.soinside.com 2019 - 2024. All rights reserved.