I wrote VisionOS code that pulls entities from a cloud bucket, which means that I can't use RealityComposer to hook components to them.
I want to use gestures to move, rotate and resize the entities like described in this Apple doc apple developer documentation
The component is loaded on app init
init(){
GestureComponent.registerComponent()
}
and then I attempt to set the entity in a similar way like Apple documentation suggests
RealityView { content in
guard let ent = try? await Entity(named: "Scene", in: realityKitContentBundle) else { return }
ent.generateCollisionShapes(recursive: false)
let inputTarget = InputTargetComponent()
let gesture = GestureComponent()
ent.components.set(inputTarget)
ent.components.set(gesture)
content.add(ent)
}
update: { content in
}
.installGestures()
The GestureComponent is the same as in the documentation and works if set using RealityComposer.
I tried setting the GestureComponent in different ways but none worked
You have to have a
InputTargetComponent
,CollisionComponent
andGestureComponent
You also have to add an
init
to the providedGestureComponent