Switching XR teleport feature to use custom intersect implementation

Hi

Is there a way to switch XR teleport feature to use custom intersect / hit test implementation? Julian Ruseico and I have that rust based implementation now functional and I would like to use it with XR teleportation:

https://github.com/tlaukkan/rust-ray-intersect-js

Would it work to take a copy of the WebXRControllerTeleportation feature, modify it and register it with different feature name?

https://github.com/BabylonJS/Babylon.js/blob/8135ac8538be03973f3e0518bea2a3a15b2945da/src/XR/features/WebXRControllerTeleportation.ts

Kind regards,
Tommi

since the ray testing is using the scene ray testing, you could override that to ease up the transition :slight_smile: . you could also create a new version of the feature (naming it the same, increasing the version, keeping it “stable”), this was the default XR helper will take it as the implementation to use.

1 Like

Thank you for the pointers RaananW.

-Tommi

Hi

Just wanted to update. I overwrote the scene.pickWithRay and got it working. This setup works also with Oculus Quest (Oculus Browser) and HTC Vive (Firefox Nightly). I have enabled WebXRPolyfil.

I can have scenes with large meshes and both pointer selection and teleportation work nicely with all the meshes in scene as targets.

It is only necessary to create BVH:s once for static meshes and then use the same BVH for all the instances.

Julian and me were thinking that maybe it could be worth providing the rust ray intersect as alternative picking mechanism in BabylonJS as plugin or implementing it in the core?

Here is our rust implementation as reference:
https://github.com/tlaukkan/rust-ray-intersect-js

Cheers,
Tommi

Hi Tommi,

As we are trying to keep the framework as small and dependency-less as possible, I don’t see that integrated in the core module, but if you manage to create a package that does all of the needed overwrites automatically, it sounds like a wonderful extension!

What are the performance benefits?

1 Like

Sound great :). Here is a thread about performance benefits:

-Tommi

2 Likes