react-xr icon indicating copy to clipboard operation
react-xr copied to clipboard

pointer-events raycaster support layers

Open bbohlender opened this issue 8 months ago • 3 comments

for react-three/xr use the default raycaster (if not possible make sure to use its layers)

bbohlender avatar Apr 13 '25 12:04 bbohlender

Thanks! In Triplex I'm using a custom raycaster to side step the event system for the selection system, code is here: https://github.com/trytriplex/triplex/blob/main/packages/renderer/src/features/selection-three-fiber/resolver.tsx#L165

Currently it uses the default layers defined on Canvas to enable / disable userland events. This solution doesn't work with xr right now (but would if it starts using its raycaster / layers!).

itsdouges avatar Apr 14 '25 05:04 itsdouges

I'm happy to contribute this. Where would I start?

itsdouges avatar May 14 '25 11:05 itsdouges

Awesome!

The steps should be

  1. in pmndrs/pointer-events: adding a layers option to here: https://github.com/pmndrs/xr/blob/4ec7f30ab1a2617923b74ecc84d9473bedaeae84/packages/pointer-events/src/intersections/index.ts#L43

  2. in pmndrs/pointer-events: syncing the layers with the raycasters for all the Intersectors

  3. in r3/xr: automatically providing the layers configured for the default raycaster in r3f to the interesection options at useLinesPointer, useRayPointer, ... and in the PointerEvents component when setting up forwardHtmlEvents

bbohlender avatar May 14 '25 11:05 bbohlender