I‘m using React Three Fiber
and drei
. I'm wondering how to limit the maximum panning distance with the MapControls
.
There are some solutions online on how to archive it with plain three.js
but nothing using the MapControls
or OrbitControls
from drei
and r3f
.
I tried this but once I reach the limit the camera glitches weirdly.
function Controls() {
const { camera } = useThree();
useFrame(() => {
camera.position.x = THREE.MathUtils.clamp(camera.position.x, -90, 90)
camera.position.y = THREE.MathUtils.clamp(camera.position.y, -90, 90)
})
return (
<MapControls />
)
}
Thanks for your help
Alexander