Forum Discussion
Sincostan90
10 years agoHonored Guest
Object Picking in WebVR based application
Hey guys,
I am developing an web-application that uses WebVR (DK1) to achieve vr ability in browsers. I would like to pick objects by my line-of-sight (looking at them). Traditional object picking via ray casting is already implemented, but I don't know which values are necessary for x and y, in the past it was the mouse:
I am developing an web-application that uses WebVR (DK1) to achieve vr ability in browsers. I would like to pick objects by my line-of-sight (looking at them). Traditional object picking via ray casting is already implemented, but I don't know which values are necessary for x and y, in the past it was the mouse:
Vector3f origin = unproject(x, y, 0, viewportWidth, viewportHeight, modelView);
Vector3f direction = unproject(x, y, 1, viewportWidth, viewportHeight, modelView).sub(origin);
Ray ray = new Ray(origin, direction);
// process intersections
3 Replies
- AnonymousI can't tell what, if any, WebGL library you're using but I'm guessing you'd want the origin to be the position of the camera and the direction to be the camera's quaternion/euler vector. If that doesn't work, you could try using 0.5, 0.5 or viewportWidth / 2, viewportHeight / 2 in place of x, y.
- AnonymousAlso, if you're interested, the Three.js WebGL library already has support for WebVR and there are boilerplate projects for it that help you get started and libraries that provide features like object picking and reticles.
- Sincostan90Honored Guest
viewportWidth / 2, viewportHeight / 2
works well (stupid me).
Thank you
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 1 year ago
- 1 year ago
- 1 year agoAnonymous
- 3 years ago