On Xcode 26 and visionOS 26, apple provides observable property for Entity, so we can easily interact with Entity between RealityScene and SwiftUI, but there is a issue:
It's fine to observe Entity's position and scale properties in Slider, but can't observe orientation properties in Slider.
MacBook Air M2 / Xcode 26 beta6
Hello @Tinn_Vision , thank you for your question!
The error you are seeing is caused by the type of property you are attempting to observe. An Entity's position is represented by the type SIMD3<Float>
, while its orientation is represented by the type simd_quatf
. For SIMD3<Float>
, x
is a stored property, while for simd_quatf
, angle
is a computed property. This means the slider would have no way of setting the value of angle
when a person slides the handle. For this reason, I would consider the error you are seeing to be expected behavior. You can review the Swift documentation for properties for more information.
simd_quatf
is a Quaternion, and while the implementation details are complex, it does not store values like the number of degrees the entity has rotated around an axis. If you'd like to make a slider that spins an entity around the Y axis, for example, you'd need to store that observed slider value someplace else, and then convert that value to a rotation, depending on what you need for your app. I'd be happy to help you implement this if you share more details about what you are trying to achieve.
One thing to note: a Quaternion can represent either an entity's current orientation in space, or it can represent a rotation that can be applied to a Transform, depending on how it is used. It is in these latter scenarios where the computed properties angle
and axis
are most useful: angle
will represent the angle in radians that the Quaternion will rotate a transform around some axis
, which may or may not be aligned with the X, Y, Z axis (probably not!). Again, Quaternions are a complex topic, but understanding the implementation details shouldn't be necessary to use them successfully.
Let me know if you have any more questions! Thank you!