Prevent Virtual Objects running into physical walls in response to TranslationGesture in RealityKit

Viewed 47

Im using RealityKit to place virtual objects in a room and using gestures to drag and rotate them in the physical space.

After placing a virtual object(chair) from a USDZ onto a horizontal Plane, I setup gestures something like:

modelEntity.generateCollisionShapes(recursive: true)
arView?.installGestures([.translation, .rotation], for: modelEntity)

Translation and Rotation seem to work fine, but when I drag the virtual object towards a wall, it seems to "go into" the wall instead of stopping at the wall. Is there a way to achieve this in RealityKit? Do I need to implement my own GestureRecognizers and perform raycast on each pan gesture callback?

0 Answers
Related