SomeOneNewbid SomeOneNewbid - 25 days ago 8
Swift Question

Send double tap to SCNView

SCNView build camera control has a function,double tap sceneview and roll back camera to start position when allowsCameraControl is enabled.

i went to add a button do the same thing

when user click the button i will roll back camera to start position

there is no class implement UIControl in scenekit

so i can't use sendAction

i can set camera position by scnView.pointOfView

but there is a animation when user scroll the camera, set camera position will fail when animation is running.

is there a good way to reset the camera ??

Answer

NicoS's answer effectively handles the part of your question about making a user action change the camera POV.

As for your issue with undesired animation when setting pointOfView — you can control that animation (and any other implicit animations that happen when you change object properties) using the SCNTransaction class. To make a change with no animation, just do this (Swift 3):

SCNTransaction.begin()
SCNTransaction.animationDuration = 0
// perform your changes...
view.pointOfView = newCameraNode
// ...and anything else you want to happen in the same non-animated update, then...
SCNTransaction.commit()