Hello,
In my scene, I am trying to create a plane, of which the surface displays animated contents. I tried doing so by creating a Core Animation Layer and then setting that layer as the content of the SCNPlane, as the code below shows.
var images = [CGImage]()
let count = CGImageSourceGetCount(source!)
for i in 0..<count {
if let image = CGImageSourceCreateImageAtIndex(source!, i, nil) {
images.append(image)
}
}
let layer = CALayer()
layer.contents = images
let animation = CAKeyframeAnimation(keyPath: "contents")
animation.values = images
animation.repeatCount = .greatestFiniteMagnitude
animation.duration = 2
layer.add(animation, forKey: "key frame animation")
let imagePlane = SCNPlane(width: self.sceneView.bounds.width / 3000, height: self.sceneView.bounds.height / 3000)
imagePlane.firstMaterial?.diffuse.contents = layer
imagePlane.firstMaterial?.lightingModel = .constant
let wrapperNode = SCNNode(geometry: imagePlane)
However, the plane does not show up in my scene. I do not know what went wrong. Any advice would be greatly appreciated!
Thanks!