【发布时间】:2021-05-11 22:30:47
【问题描述】:
使用光线投射和点击手势,我已成功在我的arview 中放置了多个对象(实体和锚点)。
现在,我正在尝试使用屏幕中心获取离我们最近的entity,以便在它附近放置一个对象。所以我们可以想象,每当一个锚点靠近手机屏幕的中心时,就会“生成”一个新的对象
为此,我尝试使用raycast,但我的代码:
func session(_ session: ARSession, didUpdate frame: ARFrame) {
//
if let hitEntity = arView.entity(
at: self.arView.center
) {
print("hitEntity IS FOUND !")
print(hitEntity.name) // this is the object I previously placed
guard let result = arView.raycast(from: self.arView.center, allowing: .estimatedPlane, alignment: .any).first else { return }
// here result is the surface behind/below the object, and not the object I want
return;
}
}
result 在表面上触发,但我无法获得 object(实体)而不是背后表面的世界变换。
你有什么想法吗?
谢谢
【问题讨论】:
标签: swift arkit realitykit