Mouse position when not on canvas #1442
-
Hey, Im having this issue where I'm unable to get the mouse position when the mouse is over a HTML element (that is sitting on top of the canvas). This layering is achieved using CSS positioning and z-index. I've tried a couple of different configurations to get it working but either the HTML element links don't work or the mouse position is not received. This isn't necessarily a react-three-fiber issue but does relate to it, and I wasn't sure where to put it. I've created a basic configuration on codesandbox, check it out. You can see it happening when the cursor is over the nav, the box stops moving. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
this is an easy fix: function App() {
const ref = useRef()
return (
<div className="outerDiv" ref={ref}>
<nav className="nav"> ...
<Canvas className="canvas" onCreated={state => {
state.events.connect(ref.current)
}}> dom events dont work like what you want, if you have a layer on top of another, the inner layer wont get hit. but you can place events on a layer that includes both. |
Beta Was this translation helpful? Give feedback.
this is an easy fix:
dom events dont work like what you want, if you have a layer on top of another, the inner layer wont get hit. but you can place events on a layer that includes both.