Jump to content

Can I pick a sprite with a ray?


olsibob
 Share

Recommended Posts

I'm able to pick sprites with Scene.pickSprite, but is there a way to pick them with scene.pickWithRay? PickWithRay only seems to return meshes (I've set isPickable to true on the sprites and confirmed that they're pickable with Scene.pickSprite).

The use-case is, I'm trying to pick sprites with a 3DoF VR Controller, so I don't have a 2d pointerX and pointerY to work with, only the controller's forward ray.

I'm thinking that my options are:

a. Use Vector3.Project to try to unproject the pickedPoint of pickWithRay (I'm using a skybox, so the ray will always hit something), then put that point into Scene.pickSprite. I tried this quickly, but I think the unprojected point might be off

b. replace the sprites with billboarded mesh instances that can directly be hit with pickWithRay. I suspect this might be the easiest option?

Or is there some easier way to pick a sprite with a ray?

Link to comment
Share on other sites

Wow that was fast! Do you know if it's possible to try this out using npm? I thought I'd be able to do repo#commit:

"dependencies": {

"babylonjs": "git+https://github.com/BabylonJS/Babylon.js.git#685b8f0f4babca6fa1fef13f24991f5cafa107d8"

But the new method doesn't seem to be included

Link to comment
Share on other sites

If you are really keen, you can build it yourself from source to get latest.  Just clone or download, run npm install, and a gulp task
https://doc.babylonjs.com/how_to/how_to_start#gulp
You can use npm link or copy to your node_modules once built.  Only if you can't wait till Friday!  I would imagine it's in the playground already, though...  :)

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.

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

  • Recently Browsing   0 members

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