我正在iOS中使用SceneKit开发3D应用程序,我需要在旋转后翻译我的相机位置。有人可以帮我做这个任务吗?
答案 0 :(得分:3)
我通常通过将一些SCNMatrix4操作串联起来来做到这一点。
let cameraNode = SCNNode()
cameraNode.camera = SCNCamera()
//start off with an identity matrix
var cameraTransform = SCMMatrix4Identity
//rotate by 90degrees about Z axis
cameraTransform = SCNMatrix4Rotate(cameraTransform, Float(M_PI_2), 0, 0, 1)
//translate by 2 units in x direction
cameraTransform = SCNMatrix4Translate(cameraTransform, 2, 0, 0)
//set the camera's transform
cameraNode.transform = cameraTransform