Search code examples
iosswiftscenekitmetalarkit

Is there any other way to display UIView into ARKit?


Here below my code and camera image to load 2d UIView into sceneView. I already tried to load into material content but getting node many times blank.

enter image description here

let annotationNode = SCNNode()      
let planeGeoMetry:SCNPlane = SCNPlane()
planeGeoMetry.firstMaterial?.fillMode = .fill

planeGeoMetry.firstMaterial?.diffuse.contents = view
annotationNode.name = name
annotationNode.geometry = planeGeoMetry   
self.sceneView.scene.rootNode.addChildNode(annotationNode)

Solution

  • From Apples docs on SCNMaterialProperty.contents:

    SceneKit cannot use a layer that is already being displayed elsewhere (for example, the backing layer of a UIView object)

    Personally the easiest way of displaying information on a plane is using a SpriteKit Scene.