2
我正在學習ARKit並嘗試將物體放置在檢測到的平面上。但它不能正常工作,飛機和3D物體之間有空間。ARKIT:在飛機上放置物體無法正常工作
這裏是我的飛機檢測代碼:
func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
position = SCNVector3Make(anchor.transform.columns.3.x, anchor.transform.columns.3.y, anchor.transform.columns.3.z)
guard let planeAnchor = anchor as? ARPlaneAnchor else { return }
let plane = SCNPlane(width: CGFloat(planeAnchor.extent.x), height: CGFloat(planeAnchor.extent.z))
planeNode = SCNNode(geometry: plane)
planeNode.position = position
planeNode.transform = SCNMatrix4MakeRotation(-Float.pi/2.0, 1.0, 0.0, 0.0)
node.addChildNode(planeNode)
}
然後3D模型得到相同的位置:
object.position = position
但是當我運行的應用程序有物體之間的空間大飛機。我沒弄清楚爲什麼?
仍然無法不幸:( – Sam
使用SCNSphere幾何與半徑10cm和紅色工作了第一材料放置測試節點,那麼你可以更容易地將它正確放置,然後,在你調試它之後,你可以使用任何你需要的其他對象。 –