Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Three.js Transform 3D coordinates to screen coordinates and back in perspective projection -
projector = new THREE.Projector(),
p3D = new THREE.Vector3(25, 15, 9),
p2D = projector.projectVector(p3D, camera);
p3D = projector.unprojectVector(p2D, camera);
//need extra steps to convert p2D to window's coordinates
p2D.x = (p2D.x + 1)/2 * window.innerWidth;
p2D.y = - (p2D.y - 1)/2 * window.innerHeight;
var popout = document.getElementById('popout'); = p2D.x + 'px'; = p2D.y + 'px';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.