简体   繁体   中英

SceneKit Moving a Camera around another Node

I would like to move the camera around a SCNNode nodeA. What I'have done so far is:

self.cameraNode.constraints = [SCNLookAtConstraint(target: nodeA)]

now if I increment the position.x of the camera the camera still look toward the nodeA. How to move the camera around the nodeA (like the moon around the hearth)?

The camera should move along a circular orbit (just a circle, I'm not interested in elliptical orbit)

Add the moon as the child node of the earth . That way translating the earth won't affect the moon 's relative position. You can find an example in the SceneKit Slides for WWDC 2014 sample code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM