pmndrs / drei

🥉 useful helpers for react-three-fiber
https://drei.pmnd.rs/
MIT License
7.85k stars 641 forks source link

fix: move useVideoTexture to /web #1918

Closed jorjordandan closed 2 months ago

jorjordandan commented 2 months ago

fixes #1917. Moves useVideoTexture to /web. Also fix reference from faceControls.

Why

Currently, useVideo texture imports hls.js. This import triggers a check to navigator, which causes an error because navigator doesn't exist on react native. It's not possible to dynamically import it without making it into an async function which would cause other issues.

What

I've moved useVideoTexture from core to web, since it does not work on native anyways.

Checklist

Also fixed one reference to useVideoTexture from faceControls.

vercel[bot] commented 2 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
drei ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 12, 2024 9:21pm
codesandbox-ci[bot] commented 2 months ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

CodyJasonBennett commented 2 months ago

Continued in #1919. Thanks for the help!

netgfx commented 2 months ago

@CodyJasonBennett Thanks for this, I tried something similar but keep in mind that the hlsRef on the useEffect is null so I think this cleanup:

return () => {
    if (hlsRef.current) {
      hlsRef.current.destroy()
      hlsRef.current = null
    }
  }

will never run.

CodyJasonBennett commented 2 months ago

If hlsRef is ever non-null before unmount, that will run. #1919 doesn't alter cleanup behavior.