Created
June 7, 2020 14:51
-
-
Save icavalheiro/e708615d613da94e841c9ae9bd3dd5d2 to your computer and use it in GitHub Desktop.
Snipped to convert a Mesh position to the viewport position in Babylonjs
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
const mesh: Mesh // the mesh I want to know the size and position of | |
const worldMatrix = mesh.getWorldMatrix() | |
const transformMatrix = scene.getTransformMatrix() | |
const position = mesh.position | |
const viewport = scene.activeCamera!.viewport | |
const coordinates = Vector3.Project(position, worldMatrix, transformMatrix, viewport) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment