Skip to content

Instantly share code, notes, and snippets.

@simform-solutions
Created June 25, 2018 12:21

Revisions

  1. simform-solutions created this gist Jun 25, 2018.
    14 changes: 14 additions & 0 deletions AVImageDetection.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? {
    let node = SCNNode()
    if let imageAnchor = anchor as? ARImageAnchor {
    let plane = SCNPlane(width: imageAnchor.referenceImage.physicalSize.width, height: imageAnchor.referenceImage.physicalSize.height)
    plane.firstMaterial?.diffuse.contents = UIColor(white: 1, alpha: 0.8)
    let material = SCNMaterial()
    material.diffuse.contents = viewObj
    plane.materials = [material]
    let planeNode = SCNNode(geometry: plane)
    planeNode.eulerAngles.x = -.pi / 2
    node.addChildNode(planeNode)
    }
    return node
    }