Jump to content

Screen to world


Recommended Posts

Hi there, 

I believe that's how you go from world to screen coordinates:

var screenPoint = BABYLON.Vector3.Project(worldPoint, 

To go from screen to world I found the Unproject function, is there any example of how to use it? And do those functions take the camera radius into account?

Link to comment
Share on other sites

Here is an example of getting the 3D position of your scene from where you click your mouse on the canvas area. Hope it helps.

canvas.addEventListener("pointerdown", function (evt) {
    var pickResult = scene.pick(evt.clientX, evt.clientY, function (mesh) {
        return mesh;
    if (pickResult.hit) {
        console.debug("3D position", pickResult.pickedPoint);
}, false);


Link to comment
Share on other sites

It looks like sprites don't get hit by rays?

(open console to see logs)



edit: I found pickSprite but it doesn't return the hit point hehe. 


All I want to do is draw a line from a point on a sprite to the center of the scene. How do I get that point on the sprite converted to the 3d world? I've got a feeling I'm missing something really obvious.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...