How to add SKVideoNode to ARKit-SceneKit in iOS 11?

Viewed 738

Is there a way to add SKVideoNode to ARKit scene(Scenekit)? I tried adding SKVideoNode as SCNPlane geometry diffuse contents but it is not working,

    let videoNode = SKVideoNode(fileNamed: "0.mov")
    videoNode.size = CGSize(width: 200, height: 100)
    videoNode.alpha = 0.8
    videoNode.play()
    self.videoNode = videoNode

    let plane = SCNPlane(width: 0.05, height: 0.05)
    let newMaterial = SCNMaterial()
    newMaterial.isDoubleSided = true
    newMaterial.diffuse.contents = self.videoNode
    plane.materials = [newMaterial]
    let node = SCNNode(geometry: plane)

    parent.addChildNode(node)
2 Answers

SKNode is not one of the supported types for SceneKit material property contents. Neither are any of its subclasses.

If you want to get SpriteKit content mapped onto a SceneKit material, the way to do it is to set an SKScene as the material property contents. That scene can then contain any number or type of SpriteKit nodes.

Related