Raycasting for WebVR Gaze Interaction

Hello guys

I recently found Playcanvas. It is a great tool and with some unity background it is understandable within minutes.
But i got into trouble when it comes to raycast coding.

I would like to achieve a simple camera to object raycast for simple gaze interaction.
In the API i just found two classes regarding raycasts.

  • Ray
  • RaycastResult

In some other scripts and old demos i figured out that people will work with

context.systems.rigidbody.raycastFirst

Could somebody help me out with this and provide me a simple code example?

Thank you in advance,
Lukas

There are two types of raycasting available in PlayCanvas. One is using the physics engine which comes with it’s own overhead of size but allows you to use custom meshes.

The other is to use the shapes (which is limited to AABB, OBB and Sphere) which is built into the core engine.

You can find examples of both here: https://developer.playcanvas.com/en/tutorials/?tags=raycast

WebVR Lab also has a larger working example of the latter for teleporting and interacting with objects: https://developer.playcanvas.com/en/tutorials/webvr-lab/

A last resort option is to create your own which a few developers have done in order to use custom meshes without the physics library overhead.

Thank you. I slowly get back on track. This example was very helpful.

https://developer.playcanvas.com/en/tutorials/simple-shape-raycasting/