With a RealityView, an entity can be rotated using a gesture detector to the entire view:
RealityView { content in
let loadedEntity = try await ModelEntity(named: modelName,
in: RealityKitContent.realityKitContentBundle)
// Add components to entity
loadedEntity.generateCollisionShapes(recursive: true)
loadedEntity.components.set(InputTargetComponent())
loadedEntity.setParent(anchor)
// Add the anchor which is the parent of the entity
content.add(anchor)
} .gesture(
drag
)
Question
This works for one model, but what if there are two models in the RealityView and each model should have a different rotation? How do we add a gesture to each model independently? Using Model3D?
This should not include building a scene in RealityComposerPro. We are talking about programmatically spawning objects in and allowing gestures.
Original post on figuring out rotation here