This is how my model looks like and it's collision shapes (pink color).
My problem with this is that when I try to tap on the bottommost part of my model (the circle), I can't do that, because the uppermost part of the model's CollisionShape is in the way.
This is how i tried to create an accurate collisionShape for my model:
@objc private func placeObject() {
let entity = try! Entity.load(named: "Laryngeal")
let geom = entity.findEntity(named: "Geom")
for children in geom!.children {
let childModelEntity = children as! ModelEntity
childModelEntity.collision = CollisionComponent(shapes: [ShapeResource.generateConvex(from: childModelEntity.model!.mesh)])
}
let modelEntity = ModelEntity()
modelEntity.addChild(entity)
let anchorEntity = AnchorEntity(plane: .horizontal)
anchorEntity.addChild(modelEntity)
arView.installGestures([.all],for: modelEntity)
arView.scene.addAnchor(anchorEntity)
}
So my question is, how can i create the most accurate collisionShape which perfectly fits my model?
Post
Replies
Boosts
Views
Activity
This is my code now:
let entity = try! Entity.load(named: "Hand") //This returns a Entity
//let entity = try! Entity.loadModel(named: "Hand") //This returns a ModelEntity
entity.generateCollisionShapes(recursive: true)
// Anchoring the entity and adding it to the scene
let anchor = AnchorEntity(plane: .horizontal)
anchor.addChild(entity)
self.arView.scene.addAnchor(anchor)
// installing gestures for the Entity
self.arView.installGestures(for: entity) //This only works on ModelEntity apparently
}
Is it possible to somehow installGestures on the Entity object and not only the ModelEntity? Because if I try to installGestures on Entity I get an error: "Entity does not conform to type HasCollision"
How can I access the exact child node's name that the user tapped on?
So for example, if the user taps on the Humerus_l node I could print it's name to the console.
This is how my 3D USDZ model and its Scene graph looks like. I can also convert it into a .rcproject file but I couldn't make it work with that either.