Created
March 20, 2012 13:48
-
-
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
This file contains 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
/** | |
* `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