Skip to content

Instantly share code, notes, and snippets.

@azamsharp
Created February 19, 2018 15:18
Show Gist options
  • Save azamsharp/121ad1d62dd3b59aed1c0afef636eb7d to your computer and use it in GitHub Desktop.
Save azamsharp/121ad1d62dd3b59aed1c0afef636eb7d to your computer and use it in GitHub Desktop.
@objc func tapped(recognizer :UIGestureRecognizer) {
guard let currentFrame = self.sceneView.session.currentFrame else {
return
}
let videoNode = SKVideoNode(fileNamed: "big_buck_bunny.mp4")
videoNode.play()
let skScene = SKScene(size: CGSize(width: 640, height: 480))
skScene.addChild(videoNode)
videoNode.position = CGPoint(x: skScene.size.width/2, y: skScene.size.height/2)
videoNode.size = skScene.size
let tvPlane = SCNPlane(width: 1.0, height: 0.75)
tvPlane.firstMaterial?.diffuse.contents = skScene
tvPlane.firstMaterial?.isDoubleSided = true
let tvPlaneNode = SCNNode(geometry: tvPlane)
var translation = matrix_identity_float4x4
translation.columns.3.z = -1.0
tvPlaneNode.simdTransform = matrix_multiply(currentFrame.camera.transform, translation)
tvPlaneNode.eulerAngles = SCNVector3(Double.pi,0,0)
self.sceneView.scene.rootNode.addChildNode(tvPlaneNode)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment