Is there any way to detect if an entity is being looked at in a RealityView. I know it is possible to add a "HoverEffectComponent()" which will highlight the entity a little when you gaze on it, but there doesn't seem to be any way to call a function from this. There is also no GazeGesture or anything similar.
Detecting Gaze/Look on Entity in RealityKit on visionOS
On visionOS, where you look stays private. So your app can specify how RealityKit entities will behave visually on hover (for example, with HoverEffectComponent) but your app can not be notified when a hover event occurs (e.g. a callback function) for privacy reasons.
That being said, in visionOS 2 we have introduced new ways to customize hover behavior with RealityKit's HoverEffectComponent and SwiftUI:
- Now you can access hover state in a ShaderGraphMaterial, with the
HoverState
node. Check out the session Build a spatial drawing app with RealityKit to see a worked example of a complex shader-backed hover effect. - SwiftUI has also added new APIs to customize the look of your UI content on hover. Check out the session Create custom hover effects in visionOS for details.
Is it correct to say then that if I want to select, say a control, by looking at it -- that is some ModelEntity or Entity that I've created in my scene that I cannot do so?
If we wanted to use some kind of ModelEntity as a control we would have to use some other gesture like a pinch, or raycast?