pmndrs / drei

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

fix: portal material visible default to false #1914

Open justabayet opened 2 months ago

justabayet commented 2 months ago

Why

Issue: performance issue with many MeshPortalMaterial. MeshPortalMaterial visible variable is never set to false without specific interactions.

MeshPortalMaterial is using a variable visible which decides if the texture needs to be updated or not. This variable value is true by default and is updated using useIntersect.

When a scene uses many MeshPortalMaterial they are all getting updated on each frame, until the camera moves around to look at the portals and then look away. This triggers the useIntersect hook which set visible to true when the portal is on sight, and then back to false when it's not on sight anymore.

What

Set visible to false by default.

Checklist

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 10, 2024 5:42pm
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.