4

I have a simple ARKit app (SceneKit). I create a SCNBox and then I'd like to add a web view on the front side of the cube.

func createBox(position: SCNVector3) {
  let box = SCNBox(width: 0.1, height: 0.1, length: 0.1, chamferRadius: 1)

  guard let url = URL(string: "https://www.google.com") else { return }
  let request = URLRequest(url: url)
  let webView = WKWebView(frame: CGRect(x: 0, y: 0, width: 500, height: 500), configuration: WKWebViewConfiguration())
  webView.load(request)

  let sides = [
    webView,              // Front
    UIColor.black,        // Right
    UIColor.black,        // Back
    UIColor.black,        // Left
    UIColor.black,        // Top
    UIColor.black         // Bottom
  ]

  let materials = sides.map { (side) -> SCNMaterial in
    let material = SCNMaterial()
    material.diffuse.contents = side
    material.locksAmbientWithDiffuse = true
    return material
  }

  box.materials = materials

  let boxNode = SCNNode(geometry: box)
  boxNode.position = position
  sceneView.scene.rootNode.addChildNode(boxNode)
}

It shows only white screen. It's not a blank page. I can scroll it and tap somewhere. And if I open a website with red background, it will be red and so on. It works, but I see only the background (and maybe an elements. For example on https://apple.com I see the background and the grey line on the top (navigation)). How can I solve it? Thanks.

nslllava
  • 499
  • 1
  • 9
  • 18

0 Answers0