Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ScreenSizer #1760

Merged
merged 3 commits into from
Jan 30, 2024
Merged

feat: add ScreenSizer #1760

merged 3 commits into from
Jan 30, 2024

Conversation

RodrigoHamuy
Copy link
Contributor

@RodrigoHamuy RodrigoHamuy commented Dec 19, 2023

I have been using this for a while and though others may find it useful too. The heavy work was done already by PivotControls, so I just wrapped the logic in a separated component for re-usability.

Why

Is a common use-case to need a ThreeJS object to hold roughly the same dimensions in screen space no matter how far from the camera it is. This is tipically required when building custom gizmos, where the gizmos holds the same size in the screen as you zoom in/out.

What

Add ScreenSizer component to render objects that roughly hold the same size independently of camera distance.

Move calculateScaleFactor from ./src/web/pivotControls/index.tsx to ./src/core/calculateScaleFactor as it doesn't have web dependencies and is a dependency of ScreenSizer.

Checklist

  • Documentation updated (example)
  • Storybook entry added (example)
  • Ready to be merged

Demo

Link

screen-sizer.mp4

Copy link

vercel bot commented Dec 19, 2023

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 Jan 30, 2024 11:41pm

Copy link

codesandbox-ci bot commented Dec 19, 2023

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.

Latest deployment of this branch, based on commit a90220c:

Sandbox Source
sleepy-newton-szgmz7 Configuration
Ground reflections and video textures Configuration
arc-x-pmndrs-colors Configuration

@drcmda drcmda merged commit 8f73c46 into pmndrs:master Jan 30, 2024
2 of 4 checks passed
Copy link

🎉 This PR is included in version 9.97.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@RodrigoHamuy RodrigoHamuy deleted the feat/screen-sizer branch January 31, 2024 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants