martijn
martijn

Reputation: 80

three.js perspectivecamera current angle in degrees

For a project I use a PerspectiveCamera which gets rotated using the vrcontrols from r69. At one point I require the current viewing angle degrees (horizontal & vertical degrees at which direction the camera is looking at). How would I acquire those?

Upvotes: 2

Views: 1608

Answers (1)

Kevin Kuyl
Kevin Kuyl

Reputation: 1265

What you want are also called euler angles. Three.js eulers have a built in function to set them from a quaternion.

var quat = new THREE.Quaternion();
var euler = new THREE.Euler();
euler.setFromQuaternion(quat);

alert('X in degrees: ' + euler.x + '\n' +'Y in degrees: ' + euler.y + '\n' + 'Z in degrees: ' + euler.z);

Upvotes: 2

Related Questions