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

Interactive elements reporting intersections outside of children

Open richardanaya opened this issue 2 years ago • 3 comments

I have a scene with multiple Interactive tags, and they seem to be reporting intersections for elements outside of children of the individual tag. This makes it pretty difficult for me to to interactions with objects that aren't necessarily in the foreground of my scene.

richardanaya avatar Mar 11 '23 01:03 richardanaya

What I do as a work around right now is create a component called

function SemiInteractive(props: { interactable: boolean } & InteractiveProps) {
  if (props.interactable) {
    return <Interactive {...props}>{props.children}</Interactive>;
  }
  return <>{props.children}</>;
}

That turns on and off interactive component to prevent it from stealing access.

richardanaya avatar Mar 11 '23 04:03 richardanaya

@richardanaya could you provide a small repro of illustrating this behaviour? I'm struggling to wrap my head around it and events code is pretty tricky to get right

saitonakamura avatar Mar 17 '23 14:03 saitonakamura

Sure thing, let me think about this a bit more

richardanaya avatar Mar 17 '23 15:03 richardanaya

Interactions in react-three/xr v6 now work just like in the whole react-three ecosystem, which means that the pointer-events concept is used. Here's a tutorial that gives an overview what is possible with the new interactions system. For your use case, you can new use the pointerEvents (none/listener/auto) property on all objects to disable and re-enable pointer events.

bbohlender avatar Jul 17 '24 08:07 bbohlender