RealityKit - Shadows on placement of AnchorEntity

Hello!
When I expand the AnchorEntity in the following way, I see a shadow falling from the object:
Code Block swift
let anchorEntity = AnchorEntity (plane: .any)
anchorEntity.addChild (parentEntity)

but in my scenario it is necessary to work with ARAnchors in the session (I am implementing a multi-user session and it is necessary to operate on CollaborationData, which, as I understand it, is currently impossible without binding to ARAnchors) and I am trying to write the code like this:
Code Block swift
let anchorEntity = AnchorEntity (plane: .any)
anchorEntity.anchoring = AnchoringComponent (anchor)
anchorEntity.addChild (parentEntity)

or easier
Code Block swift
let anchorEntity = AnchorEntity (anchor: anchor)
anchorEntity.addChild (parentEntity)

then there is no shadow from the placed object.

I figured that the bottom of my object (AnchorEntity) could be placed below the level of the detected flatness and tried to add a few centimeters on the Y axis when calculating the placement point:
Code Block swift
let newTranslate = SIMD4 <Float> (x: transform.columns.3.x, y: transform.columns.3.y + 0.10, z: transform.columns.3.z, w: transform.columns.3.w)
let anchorTransform = simd_float4x4 (columns: (transform.columns.0, transform.columns.1, transform.columns.2, newTranslate))
let anchor = ARAnchor(name: arAnchorName, transform: anchorTransform)
self.arSession.add(anchor: anchor)

This actually lifts my model up 10 centimeters when placed, but there is still no shadow.

Thanks for any help!
Answer from technical support:
Hello Dmitry,

Thank you for contacting Developer Technical Support with this incident.

The only way to get the automatic grounding shadow in RealityKit is to use the “plane” AnchoringComponent.Target. If you use the “anchor” AnchoringComponent.target, you will not receive the automatic grounding shadow on your content, even if it is an ARPlaneAnchor.

You can add your own grounding shadow by using a DirectionalLight with a Shadow and placing a plane beneath your model with an OcclusionMaterial, but you may not be able to achieve the same exact look as the automatic grounding shadows with this approach.

I recommend that you file an enhancement request for expanded automatic grounding shadow support for more Target types using Feedback Assistant.

Best regards,


Greg Chiste

DTS Engineer
 Worldwide Developer Relations
Accepted Answer
Answer from technical support:
Hello Dmitry,

Thank you for contacting Developer Technical Support with this incident.

The only way to get the automatic grounding shadow in RealityKit is to use the “plane” AnchoringComponent.Target. If you use the “anchor” AnchoringComponent.target, you will not receive the automatic grounding shadow on your content, even if it is an ARPlaneAnchor.

You can add your own grounding shadow by using a DirectionalLight with a Shadow and placing a plane beneath your model with an OcclusionMaterial, but you may not be able to achieve the same exact look as the automatic grounding shadows with this approach.

I recommend that you file an enhancement request for expanded automatic grounding shadow support for more Target types using Feedback Assistant.

Best regards,


Greg Chiste

DTS Engineer
 Worldwide Developer Relations
RealityKit - Shadows on placement of AnchorEntity
 
 
Q