0

I have a <Html><svg /></Html> element in my react-three-fiber project. This element is grouped with the camera to keep element in front of the camera. When mouse pointer is on this element scroll i not working for ScrollControl and not scrolling. Is there a way to keep scrolling on the background ?

2 Answers 2

1

It is because your HTML elements didn't be in canvas. You can do the following. Add props 'fullpage' and 'zIndexRange={[-100, -2]}'

ex: <Html fullscreen zIndexRange={[-100, -2]}>

Then you can use your scrolling

Sign up to request clarification or add additional context in comments.

1 Comment

Then, I can use scroll without issue. But I can't see HTML elements behind canvas. how should I solve this?
0

I saw the answer at discourse threejs, but i could not find it right now, here is the solution for people here.

function App() {
    const html = useCallback((element) => {
        if (element) element.parentElement.style.pointerEvents = 'none';
    }, []);
    return (
        <Html ref={html} as="div" >
            Hello World
        </Html>
      )
}

1 Comment

This solution can be achieved by adding a declarative style and you can avoid adding ref and useCallback. Just add the style prop to the Html component <Html style={{ pointerEvents: 'none' }} >...</Html>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.