我已经使用(https://developer.apple.com/documentation/arkit/scanning_and_detecting_3d_objects)扫描了对象!并保存到文档目录。后来,我读取,检测并在其上放置了3D对象,但其方向与检测到的对象方向不符。我不能怎么做,也不能使用referenceObject范围或ARReeferenceObject的中心属性。
您能帮助我根据检测到的对象的旋转来旋转3D对象吗?
func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
if let objectAnchor = anchor as? ARObjectAnchor
{
let referenceObject = objectAnchor.referenceObject
let imageName = referenceObject.name ?? "no name"
//TODO : overlay 3D Object
let overlayNode = self.getArrowNode(withImageName: imageName)
overlayNode.opacity = 1
overlayNode.position = SCNVector3Make(anchor.transform.columns.3.x,anchor.transform.columns.3.y, anchor.transform.columns.3.z)
sceneView.scene.rootNode.addChildNode(overlayNode)
DispatchQueue.main.async{
self.label.text = "3D Object Detected: \"\(imageName)\""
}
}
}