Post

Replies

Boosts

Views

Activity

Reply to A question about adding grounding shadow in visionPro
And I think maybe the outlines have something to do with the entity. Here is the code how I rendering shadow: extension Entity { func enumerateHierarchy(_ body: (Entity, UnsafeMutablePointer<Bool>) -> Void) { var stop = false func enumerate(_ body: (Entity, UnsafeMutablePointer<Bool>) -> Void) { guard !stop else { return } body(self, &stop) for child in children { guard !stop else { break } child.enumerateHierarchy(body) } } enumerate(body) } } entity.enumerateHierarchy { child, stop in child.components.set(GroundingShadowComponent(castsShadow: true)) } And it seems that Grounding shadows do require virtual geometry in order to render. When I remove the plane, the grounding shadow disappears.
Topic: Spatial Computing SubTopic: ARKit Tags:
Mar ’25
Reply to A question about adding grounding shadow in visionPro
I am not create the planes underneath each object. Instead, I just create planes based on real world plane. Here is the plane detection and creation code: private let planeTracking = PlaneDetectionProvider(alignments: [.horizontal]) @MainActor func processPlaneAnchor(_ anchorUpdate: AnchorUpdate<PlaneAnchor>) { let anchor = anchorUpdate.anchor if anchor.classification == .window { return } switch anchorUpdate.event { case .added: print("PlaneAnchor added") if let entity = planeMap[anchor.id] { let planeEntity = entity.findEntity(named: "plane") as! ModelEntity planeEntity.model!.mesh = MeshResource.generatePlane(width: anchor.geometry.extent.width, height: anchor.geometry.extent.height) planeEntity.transform = Transform(matrix: anchor.geometry.extent.anchorFromExtentTransform) } else { let entity = Entity() // Add a new entity to represent this plane. var material = PhysicallyBasedMaterial() material.baseColor.tint = UIColor.white.withAlphaComponent(0.0) material.roughness = PhysicallyBasedMaterial.Roughness(floatLiteral: 1.0) material.metallic = PhysicallyBasedMaterial.Metallic(floatLiteral: 0.0) material.blending = .transparent(opacity: 0.0) let planeEntity = ModelEntity(mesh: .generatePlane(width: anchor.geometry.extent.width, height: anchor.geometry.extent.height), materials: [material]) planeEntity.components.set(OpacityComponent(opacity: 0.0)) planeEntity.name = "plane" planeEntity.transform = Transform(matrix: anchor.geometry.extent.anchorFromExtentTransform) entity.addChild(planeEntity) planeMap[anchor.id] = entity rootEntity.addChild(entity) } planeMap[anchor.id]?.transform = Transform(matrix: anchor.originFromAnchorTransform) case .updated: print("PlaneAnchor updated") case .removed: print("PlaneAnchor removed") planeMap[anchor.id]?.removeFromParent() planeMap.removeValue(forKey: anchor.id) } } And there is some strange event: The outlines just sometimes appear, not always, even for the same object. The outlines appears underneach the objects like its shadow, maybe it is not the boarder of the plane.
Topic: Spatial Computing SubTopic: ARKit Tags:
Mar ’25