Ios SceneKit摄影机仅在x轴上跟随对象?-敏捷的
如何根据移动球体的x位置移动摄影机,但同时忽略该球体的y和z坐标?以下是我的代码,用于跟踪球体的3维:Ios SceneKit摄影机仅在x轴上跟随对象?-敏捷的,ios,swift,3d,camera,scenekit,Ios,Swift,3d,Camera,Scenekit,如何根据移动球体的x位置移动摄影机,但同时忽略该球体的y和z坐标?以下是我的代码,用于跟踪球体的3维: let cameraNode = SCNNode() cameraNode.camera = SCNCamera() cameraNode.camera?.usesOrthographicProjection = true cameraNode.camera?.orthographicScale = 2 let constraint = SCNLookA
let cameraNode = SCNNode()
cameraNode.camera = SCNCamera()
cameraNode.camera?.usesOrthographicProjection = true
cameraNode.camera?.orthographicScale = 2
let constraint = SCNLookAtConstraint(target: sphere)
constraint.gimbalLockEnabled = true
self.cameraNode.constraints = [constraint]
cameraNode.position = SCNVector3Make(20, 20, 20)
cameraNode.eulerAngles = SCNVector3Make(0, 45, 0)
sphere.addChildNode(cameraNode)
我怎样才能只跟随球体的x位置,而不是y和z位置?从
球体
中取消相机的子对象,使其成为根
的子对象。在任何正在移动球体的代码中,将摄影机的x位置设置为球体的x位置
// code moving sphere
cameraNode.position.x = sphere.position.x
从
sphere
取消相机的子对象,改为root
的子对象。在任何正在移动球体的代码中,将摄影机的x位置设置为球体的x位置
// code moving sphere
cameraNode.position.x = sphere.position.x
是否无法访问“cameraNode.position.x”并直接赋值?是否无法访问“cameraNode.position.x”并直接赋值?