Skip to content

Instantly share code, notes, and snippets.

@rajajawahar
Created March 6, 2019 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajajawahar/097ec01279472841ae6e1effd9f107b2 to your computer and use it in GitHub Desktop.
Save rajajawahar/097ec01279472841ae6e1effd9f107b2 to your computer and use it in GitHub Desktop.
func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? {
let node = SCNNode()
if let imageAnchor = anchor as? ARImageAnchor {
let videoNode = SKVideoNode(fileNamed: "eam.mp4")
videoNode.play()
let videoScene = SKScene(size: CGSize(width: 480, height: 360))
videoNode.position = CGPoint(x: videoScene.size.width / 2, y: videoScene.size.height / 2)
videoNode.yScale = -1.0
videoScene.addChild(videoNode)
let plane = SCNPlane(width: imageAnchor.referenceImage.physicalSize.width, height: imageAnchor.referenceImage.physicalSize.height)
plane.firstMaterial?.diffuse.contents = videoScene
let planeNode = SCNNode(geometry: plane)
planeNode.eulerAngles.x = -.pi / 2
node.addChildNode(planeNode)
}
return node
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment