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 with OrthograhicCamera respond to maxDistance not maxZoom, minZoom #1940

Open
talkingtab opened this issue Apr 18, 2024 · 3 comments
Labels
bug Something isn't working dependencies Pull requests that update a dependency file

Comments

@talkingtab
Copy link

i have two parallel versions of the same app: one uses threejs, the other react-three-fiber
I have an OrthographicCamera in each (same parameters) and a MapControl.

In threejs setting minZoom and maxZoom controls how far in and out I can zoom. This fits the source code for OrbitalControls {Orthographic Camera only}.

In the react three fiber version, maxDistance works but not minZoom and maxZoom (This does not fit the threejs source for OrbitalControls that

threejs is 0.163.0 (BOTH), fiber is 8.16.2

Thanks very much! I'm trying to build a new kind of website navigation system from treemap that allow you to zoom in and see more the same way google maps lets you zoom into one house. I'm using zoomToCursor and want to find a way to do unZoomToOrigin. Three, drei and fiber are incredibly good.

@talkingtab
Copy link
Author

Looking into this, it appears that the problem may be that with @react three stdlib which is on version 160 of threejs. I am wondering how hard it is to update three/stdlib and then will drei need updating?

@CodyJasonBennett CodyJasonBennett transferred this issue from pmndrs/react-three-fiber Apr 28, 2024
@CodyJasonBennett CodyJasonBennett added bug Something isn't working dependencies Pull requests that update a dependency file labels Apr 28, 2024
@CodyJasonBennett
Copy link
Member

We'll need to see what exactly enabled that behavior upstream in three. Until then, you can use theirs directly:

import { OrbitControls as OrbitControlsImpl } from 'three/addons'
import { extend, useThree } from '@react-three/fiber'

extend({ OrbitControls: OrbitControlsImpl })

function OrbitControls(props) {
  const gl = useThree((state) => state.gl)
  const camera = useThree((state) => state.camera)
  return <orbitControls {...props} args={[camera, gl.domElement]} />
}

@talkingtab
Copy link
Author

Thank you very much for the help. This is what I ended up doing. I am attempting to use threejs/fiber/drei to replace the "menu" paradigm with a zoomable treemap. I am making it up as I go, but the idea is that like google maps, you can get to anywhere from one screen/gizmo.

Using drei adds a layer of abstraction on top of fiber on top of three so being able to "punch" down to three is a very valuable aid. I ended up importing a copy of threejs OrbitControls.js directly into my code since it is in "examples" and requires only the one file. I highly recommend this technique for anyone who stumbles on this kind of problem.

And thank you to everyone who works on threejs/fiber/three!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Pull requests that update a dependency file
Projects
None yet
Development

No branches or pull requests

2 participants