pmndrs / drei

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

Feat/use sprite loader spritesheet grid detection #1971

Closed netgfx closed 4 months ago

netgfx commented 4 months ago

Why

useSpriteLoader now can support multi-rows/columns single spritesheets that don't come with .json descriptor files. It also detects and returns rows and columns as meta information, this is useful in various scenarios

What

I added a function that can detect rows, columns, frame-width and frame-height from the given texture.image and the number of frames of the spritesheet. The solution also heuristically tries to detect empty frames on the spritesheet and exclude them from the total rows and columns count.

Checklist

No changes needed on the API, this function works internally.

vercel[bot] commented 4 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 May 31, 2024 10:25am
codesandbox-ci[bot] commented 4 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.