Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Isometric camera with THREE.js

Tags:

three.js

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

like image 428
Daniel Ribeiro Avatar asked May 03 '14 22:05

Daniel Ribeiro


2 Answers

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

const aspect = window.innerWidth / window.innerHeight;
const 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 ) );

Isometric View Using Orthographic Camera

EDIT: updated fiddle: https://jsfiddle.net/vkjew52q/

three.js r.146

like image 173
WestLangley Avatar answered Nov 16 '22 04:11

WestLangley


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

like image 1
ProllyGeek Avatar answered Nov 16 '22 05:11

ProllyGeek