Post

Replies

Boosts

Views

Activity

WorldTrackingProvider's queryDeviceAnchor is not giving correct deviceAnchor
I'm constructing a RealityView where I'd like to display content in front of user's face. When testing, I found that the deviceAnchor I initially get was wrong, so I implement following code to wait until the deviceAnchor I get from worldTrackingProvider has the correct value: private let arkitSession = ARKitSession() private let worldTrackingProvider = WorldTrackingProvider() var body: some View { RealityView { content, attachments in Task { do { // init worldTrackingProvider try await arkitSession.run([worldTrackingProvider]) // wait until deviceAnchor returns correct info var deviceAnchor : DeviceAnchor? // continuously get deviceAnchor and check until it's valid while (deviceAnchor == nil || !checkDeviceAnchorValid(Transform(matrix: deviceAnchor!.originFromAnchorTransform).translation)) { deviceAnchor = worldTrackingProvider.queryDeviceAnchor(atTimestamp: CACurrentMediaTime()) } let cameraTransform = Transform(matrix: deviceAnchor!.originFromAnchorTransform) // ...codes that update my entity's translation } catch { print("Error: \(error)") } } } } private func checkDeviceAnchorValid(_ translation: SIMD3<Float>) -> Bool { // codes that check if the `deviceAnchor` has a valid translation. } However, I found that sometimes I can't get out from the while loop defined above. Not because my rules inside checkDeviceAnchorValid func are too strict, but because the translation I get from deviceAnchor is always invalid(it is [0,0,0] and never changed) Why is this happening? Is this a known issue? I wonder if I can get recalled when the worldTrackingProvider returns the correct deviceAnchor,
2
0
799
Jan ’24
popover on visionOS can't be rotated in 3D space?
In my visionOS project, I have a view that is rotated a little bit using rotation3DEffect. On that view, there is a popover. But its content is not rotated. I tried to fix this by adding an additional rotation3DEffect modifier to the content view. But this way the view is detached from its container, and the container is still not rotated. How can I get the same rotation effect on the content of this popover? Can I hide the container of a popover or rotate it together with my view?
0
1
323
Jan ’24
How Can I Create an Emissive Video Material in RealityKit?
From this WWDC session video, apple suggests that any objects that appear to emit lights should shine color onto nearby objects. But when I was trying to construct an cinema immersive space with videoMaterial and some other entities. I find that videoMaterial is not emissive and the nearby entity doesn't reflect any lights from the screen Entity where my videoMaterial is attached to. What is the right way to achieve an effect similar to the TV app that is displayed in the video?
0
0
394
Nov ’23
collision between entities that has anchor is not working properly?
Hi, I'm new to realitykit and still learning. I'm trying to implement a feature on visionOS that triggers specific logic when the user's head comes into contact with another entity. When two entities are added directly to the realityView, I am able to subscribe to their collision event correctly, but when I add one of the entities to an anchorEntity that is anchored on the user's head, I am unable to receive the collision subscription. , and I found that if an entity declares that it obeys the hasAnchor protocol, it cannot participate in collision detection normally either. Why does this happen? Is this a feature or a bug? Here is how I subscribe to collision events: collisionSubscription = content.subscribe(to: CollisionEvents.Began.self, on: nil, componentType: nil) { collisionEvent in print("💥 Collision between \(collisionEvent.entityA.name) and \(collisionEvent.entityB.name)") } the following two entity collides fine: @State private var anotherEntity : Entity = CollisionEntity(model: MeshResource.generateSphere(radius: 1), materials: [SimpleMaterial(color: .white, isMetallic: false)], position: [-2,1,0]) @State private var headEntity : Entity = CollisionEntity(model: MeshResource.generateSphere(radius: 0.5), materials: [SimpleMaterial(color: .yellow, isMetallic: false)], position: [0, -0.35, -3]) but with anchoring, I can't get collision notifications @State private var anotherEntity : Entity = CollisionEntity(model: MeshResource.generateSphere(radius: 1), materials: [SimpleMaterial(color: .white, isMetallic: false)], position: [-2,1,0]) @State private var headEntity : Entity = { let headAnchor = AnchorEntity(.head) headAnchor.addChild( CollisionEntity(model: MeshResource.generateSphere(radius: 0.5), materials: [SimpleMaterial(color: .yellow, isMetallic: false)], position: [0, -0.35, -3])) return headAnchor } Any information or suggestion are welcomed, thanks!
2
0
876
Oct ’23
multiple window layout?
Hi there, we are exploring the new layouts for our app on Vision OS. We figured that the tab overview New Safari provides is pretty amazing. it doesn't looks like it is created through opening mulitple windows since all the tabs that displayed cannot be resized. Also the little curve that all this tabs formed gives user a nice surrounding feeling. Wondering is this multiple window style achieved?
2
1
552
Sep ’23