根据这篇文章,苹果射线投射和命中测试。我应该使用RealityKit提供的射线投射来检测表面,而不是像苹果所说的那样由ARKit提供的命中测试。
但是为了兼容性,命中测试功能仍然存在。
。但是,我找不到一种方法来了解光线投射查询检测到的表面的范围。
所以根据这个代码:
func startRayCasting() {
guard let raycastQuery = arView.makeRaycastQuery(from: arView.center,
allowing: .estimatedPlane,
alignment: .vertical) else {
return
}
guard let result = arView.session.raycast(raycastQuery).first else {
return
}
let transformation = Transform(matrix: result.worldTransform)
let plane = Plane(color: .green, transformation: transformation)
plane.transform = transformation
let raycastAnchor = AnchorEntity(raycastResult: result)
raycastAnchor.addChild(plane)
arView.scene.addAnchor(raycastAnchor)
}我希望我正在创建的飞机能够检测到飞机的大小和位置。然而,这种情况并没有发生。
所以我的问题是,光线投射是否适合探测表面的大小和位置。或者只是为了检查曲面上的2d点位置。
https://stackoverflow.com/questions/58312814
复制相似问题