Sign in to follow this  
pathogen

OnPickTrigger Action with PointerLock

Recommended Posts

When the pointer is locked the OnPick* Actions are very awkward because the cursor is hidden and thus accurate picking is not an option. 

It is possible to achieve accurate picking using the scene.onPointerObservable and any of the picking methods which allow for an X and Y coordinate to be supplied (I just use the screen center X and Y and a visible 'cross hair').

However it seems like this would be better to incorporate directly into the OnPick* Actions when optional X and Y arguments are supplied.

Thoughts?

Share this post


Link to post
Share on other sites

babylon js is a framework which supports a wide range of different types of games, so some features, like game logic & behaivior, is left to the developer :),

you could do something like this;

var screenWidth = canvas.offsetWidth, screenHeight = canvas.offsetHeight;

//on pointerDown or up

//supply your own PointerLock variable(s)
if(mouseLock) 
  var pick = scene.pick(screenWidth / 2, screenHeight / 2);
else
  var pick = scene.pick(scene.pointerX, scene.pointerY);

if (pick.hit) {
  // ...
} 

 

Share this post


Link to post
Share on other sites

Oh yes, this is exactly what I have been doing. I just noticed that it seems everything is moving towards using the Actions and when I attempted to move some of my code to the Actions I noticed this discrepancy. Upon checking the Babylon source on Github I am reasonably sure that no matter which type of picking, they all eventually use the same function, and that function does have x and y parameters.

Share this post


Link to post
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.

Guest
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.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.