pmndrs / drei

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

PivotControls - preventDefault onContext & operate controls only with button 0 #1926

Open romankoho opened 2 months ago

romankoho commented 2 months ago

Describe the feature you'd like:

I'm using PivotControls in a scene with OrbitControls. It happens that I'm close to the control but want to pan the OrbitControls with a right click. In such cases, the browser opens a default menu. I would prefer no reaction on the right (context) click.

pivotControls - onContext

Moreover, I think it is more intuitive if the PivotControls can only be operated with mouse button 0 (left button)

Suggested implementation:

In the single components , , , the event needs to cancel the default behavior:

 onContextMenu={(e) => {
          e.nativeEvent.preventDefault()
  }}

moreover, I would add the check for button = 0 in the onPointerDown event

onPointerDown={(e) => {
          if (e.button !== 0) {
            return
          }
          onPointerDown(e)
        }}