Skip to content

Instantly share code, notes, and snippets.

@KeyMaster-
Created October 5, 2014 13:22
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save KeyMaster-/80e6f31e580e1186061e to your computer and use it in GitHub Desktop.
Save KeyMaster-/80e6f31e580e1186061e to your computer and use it in GitHub Desktop.
Isometric view in the luxe engine
//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