gpt4 book ai didi

swift - 像 SCNARView 中一样计算 worldFront

转载 作者:行者123 更新时间:2023-11-30 11:24:31 24 4
gpt4 key购买 nike

SCNARView中,我可以访问camera节点的一个名为worldFront的属性,它代表相机旋转。我想从 CoreMotion 值计算类似的向量,而不使用 SCNARView,仅使用 CoreMotion 的数据。这样,如果相机面向同一方向,我可以获得等于 SCNARView 中的 worldFront 的向量。有人可以解释一下如何计算这样的值吗?

最佳答案

态度属性可能会有所帮助

func rollCam(motion: CMDeviceMotion) {
let attitude = motion.attitude
let roll = Float(attitude.roll-M_PI/2)
let yaw = Float(attitude.yaw)
let pitch = Float(attitude.pitch)
camNode.eulerAngles = SCNVector3Make(roll, -yaw, pitch)
}

通过这段代码,很久以前,我对 CoreMotion 进行了一些实验。我试图首先检测人类行走,然后(使用 startDeviceMotionUpdates 数据)将相机移动并滚动到“锚定”SCNBox 附近。后来 ARKit 用 ARAnchor 类解决了我的需求

您正在关注什么功能?

关于swift - 像 SCNARView 中一样计算 worldFront,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50916439/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com