Post

Replies

Boosts

Views

Activity

Reply to RealityView update closure
The documentation is particularly bad about RealityView. There is no clear guidance on what you should do in the make/update/attachment closure, the order in which these closures are executed, etc. Based on my experience - you can't expect change to environment objects to trigger the update closure. This is REALLY SURPRISING. My workaround is to use another view that wraps the reality view and listens to that environment object, which also passes the listened object as a prop to the reality view. In a reality view, any change in @State or a prop should trigger the update closure. The update closure is also called multiple times at the beginning of the lifecycle, which I have no idea why. That was not documented anywhere. When does the entities in the attachment closure become visible to the other closures? Also no clue. If someone from Apple is reading - this RealityView is the single most important concept introduced in RealityKit2. It's the entrance to everything and really worth more documentation and more examples.
Jul ’23
Reply to How to get grounding shadow to work in VisionOS?
I still couldn't get shadows working for usdz models, but grounding shadow does work for procedural meshes generated using code like the following: let sphereEntity = ModelEntity(mesh: MeshResource.generateSphere(radius: 0.05), materials: [SimpleMaterial(color: .blue, roughness: 0, isMetallic: true)]) sphereEntity.setPosition([0, 0.1, 0], relativeTo: root) sphereEntity.components.set(GroundingShadowComponent(castsShadow: true)) sphereEntity.components.set(TraceComponent(anchor: root, width: 1))
Aug ’23