Hello. Sorry for my poor english.
I´m a fully noob with 3D and Scenekit. I´m using Scenekit for a simple task, show a interactive 3D model and let to the user control the camera. I´m using the property allowsCameraControl.
The problem I want to animate the default camera to some point of interest of 3D model (for example with a button). I´m using this:
[SCNTransaction begin];
[SCNTransaction setAnimationDuration:0.5];
[SCNTransaction setCompletionBlock:^{
[SCNTransaction begin];
[SCNTransaction setAnimationDuration:0.5];
((SCNView *)self.view).pointOfView.position = SCNVector3Make(-2.978351,0.515628,8.975238);
((SCNView *)self.view).pointOfView.rotation = SCNVector4Make(-0.440378,0.106008,0.891532,2.689772);
[SCNTransaction commit];
}];
The transaction is working only if the user moved the camera with gestures before, the name for the camera is "kSCNFreeViewCameraNameCamera" in this case. If the user did not move the camera with gestures, the camera move too but no animation or transaction, the name for the camera is "default camera" in this case.
Do you know what is wrong?
Thanks.
OK then. I might not have tried to get the camera node this way.
I overlooked your code; the completion block is called when the transaction is finished, therefore, you must not put your animation code in it!
Your code should look like this instead:
[SCNTransaction begin];
[SCNTransaction setAnimationDuration:0.5];
((SCNView *)self.view).pointOfView.position = SCNVector3Make(-2.978351,0.515628,8.975238);
((SCNView *)self.view).pointOfView.rotation = SCNVector4Make(-0.440378,0.106008,0.891532,2.689772);
[SCNTransaction commit];