how to add entities to a volume or immersive view programmatically?

I have created two scenes, one immersive and one volumetric using Reality Composer Pro. In my test app I can view both and they render correctly.

However, I would like to add entities programmatically. I am trying this;

var body: some View {
     RealityView { content in
     if let scene = try? await Entity(named: "Scene", in:     realityKitContentBundle) {
        viewModel.rootEntity = scene
        content.add(scene)

        var anchorEntity = AnchorEntity(world: [0, 0, -0.5])  
        let sphere = MeshResource.generateSphere(radius: 2.0)
        let material = SimpleMaterial(color: .red, roughness: 0.5, isMetallic: true)
        let modelEntity = ModelEntity(mesh: sphere, materials: [material])
        anchorEntity.addChild(modelEntity)
        content.add(anchorEntity)
    }
   }
 }

However, the sphere does not appear in the volume. I also tried it in the immersive space and it does not appear there either.

What am I missing?

It seems that the answer is that you have to both add an entity and set the entities parent to make it visible;

  content.add(anchorEntity)
  anchorEntity.setParent(content)
  modelEntity.setParent(content)
how to add entities to a volume or immersive view programmatically?
 
 
Q