Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable camera panning in SceneKit

Tags:

ios

scenekit

If I am using the default camera control in SceneKit, is there a way to disable the two fingered pan function and leave the others as they are?

I want users to be able to rotate and zoom an object, but not move it at all.

like image 428
Timestretch Avatar asked Nov 01 '25 07:11

Timestretch


1 Answers

The sceneView already has a UIPanGestureRecognizer attached. If you modify its maximumNumberOfTouches to be 1, you can disable the pan gesture.

for reco in sceneView.gestureRecognizers! {
    if let panReco = reco as? UIPanGestureRecognizer {
        panReco.maximumNumberOfTouches = 1
    }
}
like image 142
kaharoth Avatar answered Nov 02 '25 21:11

kaharoth