-
Notifications
You must be signed in to change notification settings - Fork 703
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 support for click element selector to PointerLockControls #285
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/pmndrs/drei/9y1aqusyn |
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 48da7af:
|
I'm gonna move this to a draft until we're ready for merge.
That's because the root story is passed to "set up" you could bypass and render a complete scene in the story: export default {
title: 'Controls/PointerLockControls',
component: PointerLockControlsScene,
/*
* you could remove this decorator and move it into a component
* that renders the external HTML you're talking about.
*/
decorators: [(storyFn) => <Setup cameraPosition={[0, 0, 10]} controls={false}>{storyFn()}</Setup>],
} |
Added the story - this is ready for review now from my side. |
🎉 This PR is included in version 3.3.0-beta.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 3.3.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Why
When several elements that "activate" the experience are present on the screen (e.g. a 'Enter VR button', a 'Click here to play' button, etc.), it conflicts with PointerLockControl's top-level
document.addEventListener
element binding.What
This PR adds support for binding the control activation to an element found with a selector (e.g.
#instructions
). The default ofdocument
is unchanged, so this is not a breaking change. I also removed thetarget
prop as it has no effect for PointerLockControls (while it's present for most controls, it's only applicable for OrbitControls and TrackballControls - this is addressed in #286)Checklist
Not yet ready to merge as there are a few things to discuss, however.
1. Usually all props are spread over into theUpdate: I used the prop spread method from TransformControls to solve this.primitive
, but in this case theselector
prop is only used on thedrei
side. I've introduced aninternalProps
variable, that removes thedrei
-only props before passing them onwards, but I'm wondering if there's an existing general principle I should uphold here.2. How should a story for this be written? A realistic example depends on an HTML element that generally lives outside of the canvas, but the stories all live within the canvas.Update: Done following Josh’s feedback.