Skip to content

Instantly share code, notes, and snippets.

@cecilemuller
Created March 20, 2012 13:48
Show Gist options
  • Save cecilemuller/2135802 to your computer and use it in GitHub Desktop.
Save cecilemuller/2135802 to your computer and use it in GitHub Desktop.
Calculate the Viewpoint orientation to look at a specific target position in VRML or X3D
/**
* `target` is where you want to look at.
*
* `position` is the SFVec3f location of your viewpoint.
*
* `orientation ` is the resulting SFRotation of your viewpoint.
*
* Optionally, modify `new SFVec3f(0, 0, -1)` to change the roll.
*
*/
var orientation = new SFRotation( target.subtract(position), new SFVec3f(0, 0, -1) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment