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

MapControls doesn't work as expected #47

Closed
GuskiS opened this issue Apr 1, 2021 · 4 comments · Fixed by #48
Closed

MapControls doesn't work as expected #47

GuskiS opened this issue Apr 1, 2021 · 4 comments · Fixed by #48
Labels
bug Something isn't working

Comments

@GuskiS
Copy link

GuskiS commented Apr 1, 2021

  • three version: 0.126.1
  • @react-three/fiber version: 6.0.0
  • node version: 12.18.3
  • npm (or yarn) version: 1.22.5
  • browser version: chrome@latest/edge@latest

Problem description:

When visiting https://drei.pmnd.rs/?path=/story/controls-mapcontrols--map-controls-scene-st everything works as expected.

When I tried running drei's storybook locally, I get this:
MapControls

CC: pmndrs/drei#351

@GuskiS GuskiS added the bug Something isn't working label Apr 1, 2021
@hasparus
Copy link
Contributor

hasparus commented Apr 2, 2021

I have the same problem — after updating from react-three-fiber to @react-three/fiber orbit controls don't even respect enabled prop.

@joshuaellis
Copy link
Member

Either of you are welcome to look and make a PR, will be fixed quicker that way.

@hasparus
Copy link
Contributor

hasparus commented Apr 2, 2021

I'm looking for the cause right now. TBH I'm not sure if the problem originates from here.
I compared OrbitControls in three-stdlib and three/examples and didn't found anything suspicious.

I'm not sure what went wrong yet, just wanted to confirm that this problem is happening.

@hasparus
Copy link
Contributor

hasparus commented Apr 2, 2021

Ha! Found the problem. It seems it's an issue with Drei's MapControls component.

I have two copies of MapControls. One accepts props given to MapControls from drei, the other one is created in drei's MapControls useState with default settings.

I commented out <primitive call, and I'm back to one.

image

This is connected to mrdoob/three.js#20575 and pmndrs/drei#169 as MapControls calls connect and registers event handlers, and we end up with side effects in useState (Does React guarantee it's called only once? I don't think so.)

hasparus added a commit to hasparus/three-stdlib that referenced this issue Apr 2, 2021
This should be the only change needed in `three-stdlib` to close pmndrs#47. I'm following with another change in drei.

We don't want to pass domElement to MapControls as it causes a side effect.
joshuaellis pushed a commit that referenced this issue Apr 2, 2021
This should be the only change needed in `three-stdlib` to close #47. I'm following with another change in drei.

We don't want to pass domElement to MapControls as it causes a side effect.
@joshuaellis joshuaellis reopened this Apr 2, 2021
Mercury21th000 pushed a commit to Mercury21th000/three-stdlib that referenced this issue Nov 17, 2024
This should be the only change needed in `three-stdlib` to close pmndrs/three-stdlib#47. I'm following with another change in drei.

We don't want to pass domElement to MapControls as it causes a side effect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants