Created
October 5, 2014 13:22
-
-
Save KeyMaster-/80e6f31e580e1186061e to your computer and use it in GitHub Desktop.
Isometric view in the luxe engine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Rotate the camera such that z points up and x to the right | |
var o:Quaternion = new Quaternion().setFromEuler(new Vector().set_xyz(-90, 0, 0).radians()); | |
//Rotate by Arctan(sin(45°)) (grabbed from wikipedia) around x, to get the top-down part | |
var q:Quaternion = new Quaternion().setFromEuler(new Vector().set_xyz(Math.atan(Math.sin(45 * Maths.DEG2RAD)), 0, 0)); | |
//Rotate around z by -45° to get the side-on part | |
var p:Quaternion = new Quaternion().setFromEuler(new Vector().set_xyz(0, 0, -45).radians()); | |
//Combine the rotations and apply to the camera | |
//Quaterions are combined through multiplication, order of rotation is "from the inside out" | |
//Order of rotation here is o, then q, the p | |
//Meaning, first rotate around -90° around x, then back by Atan(sin(45°)) around x, finally -45° around z | |
Luxe.camera.rotation = p.multiply(q.multiply(o)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment