'RealityKit won't show more than one DirectionalLight

I'm trying to create a simple 3D scene in RealityKit with two lights lighting a mesh from opposite sides. Everything seems to be working but both lights won't work at once. If I comment out light01, then light02 shows up fine. Obviously from the type of project, you can tell I'm pretty new at this. What have I missed?

func makeUIView(context: Context) -> ARView {

    //Configure ARView
    let arView = ARView(frame: .zero, cameraMode: .nonAR, 
                   automaticallyConfigureSession: true)
    
    //Set background color
    arView.environment.background = .color(.black)
    
    let light01 = DirectionalLight()
    light01.light.color = .red
    light01.light.intensity = 30000
    light01.light.isRealWorldProxy = true
    light01.shadow?.maximumDistance = 10.0
    light01.shadow?.depthBias = 5.0
    light01.orientation = simd_quatf(angle: -.pi/1.5, axis: [0,1,0])
    let light01Anchor = AnchorEntity(world: [0, 20, 0])
    light01Anchor.addChild(light01)
    arView.scene.addAnchor(light01Anchor)
    
    //NOT WORKING
    let light02 = DirectionalLight()
    light02.light.color = .green
    light02.light.intensity = 20000
    light02.light.isRealWorldProxy = true
    light02.shadow?.maximumDistance = 10.0
    light02.shadow?.depthBias = 5.0
    light02.orientation = simd_quatf(angle: .pi/1.5, axis: [0,1,0])
    let light02Anchor = AnchorEntity(world: [0, 40, 0])
    light02Anchor.addChild(light02)
    arView.scene.addAnchor(light02Anchor)      
    
    //Create plane for floor
    let floorMesh = MeshResource.generatePlane(width: 10, depth: 10)
    let floorMaterial = SimpleMaterial(color: .white, isMetallic: false)
    let floorEntity = ModelEntity(mesh: floorMesh, 
                             materials: [floorMaterial])
    let floorAnchor = AnchorEntity(world: [0, 0, 0])
    floorAnchor.addChild(floorEntity)
    arView.scene.addAnchor(floorAnchor)      

    let sphereMesh = MeshResource.generateSphere(radius: 1.5)
    let sphereMaterial = SimpleMaterial(color: .white, 
                                    roughness: 0.9, 
                                   isMetallic: false)
    let sphereEntity = ModelEntity(mesh: sphereMesh, 
                              materials: [sphereMaterial])
    let sphereAnchor = AnchorEntity(world: [0, 1.5, -4])
    sphereAnchor.addChild(sphereEntity)
    arView.scene.addAnchor(sphereAnchor)
            
    //Camera
    let camera = PerspectiveCamera()
    let cameraAnchor = AnchorEntity(world: [0, 1, 1])
    cameraAnchor.addChild(camera)
    arView.scene.addAnchor(cameraAnchor)
    
    return arView
}


Solution 1:[1]

So I finally got it to work. I dont fully know why but it sounds like it has to do with an anti-pattern. With no changes made to the POST; I made my wrapping function Async and I moved the variable declaration with "await" before the Promise.

If anyone could put links or explain what is going on that would be great, i am quite new to the language.

async function makeImg(name, data) {
  // add await outside of promise
  let image = await Jimp.read('./imgs/casualTemplate.jpg');
  
  return new Promise(resolve => {
    
    Jimp.loadFont(Jimp.FONT_SANS_32_WHITE)
      .then(font => {
        image.print(font, 10, 10, `hello`);
        return image;
      }).then(image => {
        return image.writeAsync('./casualInvite.png');
      });

      resolve("casualInvite.png");
  });
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Loom