【发布时间】:2019-01-09 15:47:29
【问题描述】:
问题:
如何创建一个与 ARObjectAnchor.referenceObject 高度和宽度相同的新 SKSpriteNode。
上下文:
我目前正在使用 ARKit 的新对象检测功能,并且有工作代码来检测我扫描的对象。当 ARKit 检测到对象时,它会提供一个类型为 ARObjectAnchor 的新 ARAnchor。
我知道 ARSCNView 提供了一个 projectPoint 方法,但我找不到任何与 ARSKView 等效的函数。如何将 ARObjectAnchor 尺寸映射到新的 Sprite?
这是我处理检测到的对象的方式:
func view(_ view: ARSKView, didAdd node: SKNode, for anchor: ARAnchor) {
if let objectAnchor = anchor as? ARObjectAnchor {
let width = objectAnchor.referenceObject.extent.x
let height = objectAnchor.referenceObject.extent.y
// How to translate above height/width to the below size?
let box = SKSpriteNode(color: .white, size: ???)
node.addChild(box)
}
}
【问题讨论】:
标签: ios swift sprite-kit scenekit arkit