pmndrs / drei

🥉 useful helpers for react-three-fiber
https://drei.pmnd.rs/
MIT License
7.85k stars 641 forks source link

enableZoom like orbit controls in CameraControls component #1956

Open dhruvadhia1 opened 1 month ago

dhruvadhia1 commented 1 month ago

What is your question:

i would like to know on how to disable zoom just like enableZoom={false} in OrbitControls but for CamearControls instead.

talkingtab commented 1 month ago

I have been looking at this, and this is only my understanding, so perhaps wrong.

CameraControls are a different style control, one where setting the mouse and touch events enable or disable zoom, dolly, etc. If you look at the camera-controls github repo, you can see this, as well as the ACTION list in src/types.ts. Depending on where you use it you need to set mouseButtons to one of the values in the action list:

<CameraControls mouseButtons={{left: 8, wheel: 16}} />

From types.ts the value for zoom is 16, so now the wheel will zoom. mouseButtons={{}} will result in no controls. I think.