Isometric camera with THREE.js

杀马特。学长 韩版系。学妹 提交于 2019-12-17 21:57:07

问题


How can I set the camera angle to something like the isometric projection?


回答1:


To get an isometric view, you can use an OrthographicCamera. You then need to set the camera's orientation properly. There are two ways to do that:

Method 1 - use camera.lookAt()

var aspect = window.innerWidth / window.innerHeight;
var d = 20;
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

method 2 - set the x-component of camera.rotation

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

fiddle: http://jsfiddle.net/q3m2kh5q/

three.js r.73




回答2:


you need to use orbit and track controls , like in here :

http://codepen.io/nireno/pen/cAoGI

Edit:

also you may consider using ortho camera this post here may help you :

Three.js - Orthographic camera

an example can be seen here :

http://threejs.org/examples/canvas_camera_orthographic.html

and here is a link (udacity) explaining the use:

https://www.udacity.com/course/viewer#!/c-cs291/l-158750187/m-169414761



来源:https://stackoverflow.com/questions/23450588/isometric-camera-with-three-js

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!