Post

Replies

Boosts

Views

Activity

How to implement a drag/grab effect for an entity in a RealityView?
I want to implement a simple object-grabbing effect for an entity defined inside a RealityView. I'm not sure what the recommended way is. The following can move the object but the coordinates seem to be messed up. RealityView { self.myEntity = ModelEntity(...) }.gesture( DragGesture(minimumDistance: 0) .onChanged { value in let trans = value.translation3D self.myEntity.move( to: Transform( scale: SIMD3(repeating: 1.0), rotation: simd_quaternion(0, 0, 0, 1), translation: SIMD3<Float>(Float(trans.x), Float(trans.y, -Float(trans.z))), relativeTo: cards[item]) } My wild guess is value.translation3D is defined in view space and move(to..) should use 3D space? I saw RealityCoordinateSpaceConverting but no idea how to use it. Any suggestions/links/examples are appreciated :)
0
0
382
Nov ’23