I'm trying to set the SceneViews
background to a .mov
video. I can get the video to play if I pass it to a VideoPlayer
but not if I set it as a material on my Sphere & use it in my SceneView
. Ideally I would like the video to play behind the sphere but I would settle for applying it as a material. I have looked at this solution but it hasn't worked, I just see white.
Any help getting a video in my Scene is much appreciated!!
View:
GeometryReader { _ in
SceneView(scene: testScene, options: [.allowsCameraControl])
}
Scene Creation:
private var testScene: SCNScene? {
var earthScene = SCNScene()
let material = SCNMaterial()
let path = Bundle.main.url(forResource: "test_video",
withExtension: "mov")!
let player = AVPlayer(url: path)
player.play()
material.diffuse.contents = player
let earthNode = SCNNode()
earthNode.geometry = SCNSphere(radius: CGFloat(150))
earthScene.rootNode.addChildNode(earthNode)
earthNode.geometry?.materials = [material]
earthScene.rootNode.addChildNode(earthNode)
return flowerScene
}