Post

Replies

Boosts

Views

Activity

Reply to RealityKit SIMD3<Float> precision decreases with distance?
@DTS Engineer Yes I have seen x and z change when only setting y. I also tried setting x and z to stored values and logging the position looked correct. However visually the entity would be drifting on x and z the farther away y was. My use case was dragging an entity up and down and attaching children to it to creating an infinite scroll. If you scroll for a while, the positioning of the parent entity on x and z would appear to change even if the correct values were logged. The workaround was to move the children out of the scroll entity, and just use the y to position them manually. I could imagine you would see the same issue if you just created an entity that was 50 or 100 meters long and tried moving it along one axis though.
1d
Reply to WorldAnchors added and removed immediately
Hello @Vision Pro Engineer If I add a SpatialTrackingSession to your example I can replicate the problem. The world anchor will be added/updated, then immediately removed without calling removeAnchor(). import SwiftUI import RealityKit import ARKit struct TestAnchor: View { @State var spatialTrackingSession = SpatialTrackingSession() @State var worldTrackingProvider = WorldTrackingProvider() @State var arKitSession = ARKitSession() @State var firstWorldAnchorTransform: simd_float4x4? var body: some View { RealityView { content in } update: { content in if let firstWorldAnchorTransform { let entity = ModelEntity(mesh: .generateSphere(radius: 0.2), materials: [SimpleMaterial(color: .red, isMetallic: false)]) entity.setTransformMatrix(firstWorldAnchorTransform, relativeTo: nil) content.add(entity) } else { print("Waiting for world anchor.") } } .task { do { try await arKitSession.run([worldTrackingProvider]) } catch { print("Error starting session", error) } let configuration = SpatialTrackingSession.Configuration(tracking: [.plane]) if let unavailableCapabilities = await spatialTrackingSession.run(configuration) { if unavailableCapabilities.anchor.contains(.plane) { print("plane tracking is unavailable.") } } Task { await processWorldAnchorUpdates() } // For demo purposes only. Don't do this in prod :) // Wait 5 seconds for a world anchor. If one isn't added create one. // Add anchor should only be called the first time you run this. // Delete the app and reinstall it to clear the anchor. Task { try? await Task.sleep(for: .seconds(5)) if firstWorldAnchorTransform == nil { let anchor = WorldAnchor(originFromAnchorTransform: matrix_identity_float4x4) do { try await worldTrackingProvider.addAnchor(anchor) } catch { print("Error adding anchor", error) } } } } } func processWorldAnchorUpdates() async { print("Tracking the world") for await update in worldTrackingProvider.anchorUpdates { print(update) await processWorldAnchorUpdate(update: update) } } func processWorldAnchorUpdate(update:AnchorUpdate<WorldAnchor>) async { print("world anchor updated", update.event, update.anchor.id) if(update.event == .added && firstWorldAnchorTransform == nil) { firstWorldAnchorTransform = update.anchor.originFromAnchorTransform } } }
Jan ’25
Reply to WorldAnchors added and removed immediately
Thank you. Your code works exactly as you would expect. The other full example app from Apple for room tracking also works properly. .removeAnchor() is not used in my project at all. It must be something I am doing. I am also running a SpatialTrackingSession to detect the floor and ceiling anchors. I will try to simplify my code.
Jan ’25