私はこのようなコードを持っています:
@objc func handleTap(_ sender: UITapGestureRecognizer) {
let tapLocation = sender.location(in: arView)
let hitResult0 = scnView?.hitTest(tapLocation)
if let hitResult = arView?.entity(at: tapLocation) {
// ...
}
}
hitResultの精度が悪い。WheelbarrowHandles
別の小さいエンティティをタップしても
、同じエンティティ ( ) が返されます。hitResult0は、タップ位置に近いすべてのオブジェクトを (多く) 与えます。
モデル読み込み中:
self.theModel = try! Entity.load(named: "wheelborrow")
self.theModel?.generateCollisionShapes(recursive: true)
衝突形状の生成が悪いのでしょうか?
更新しました
私は世代の代わりに次をやろうとしました:
modelEntity.collision = CollisionComponent(shapes: [ShapeResource.generateConvex(from: modelEntity.model!.mesh)])
そしてそれは動作します。