2

SCNMaterialProperty's contents property on SCNMaterial is unable to render when assigned a AVPlayerLayer. Note this is only a issue on a physical device, works fine on the simulator (Xcode 6.0.1).

I am creating my SCNode as such:

SCNNode *videoBall = [SCNNode node];
videoBall.position = SCNVector3Make(-5, 5, -18);
videoBall.geometry = [SCNSphere sphereWithRadius:5];
videoBall.geometry.firstMaterial.locksAmbientWithDiffuse = YES;
videoBall.geometry.firstMaterial.diffuse.contents = [self videoLayer];
videoBall.geometry.firstMaterial.diffuse.contentsTransform = SCNMatrix4MakeScale(2, 1, 1);
videoBall.geometry.firstMaterial.diffuse.wrapS = SCNWrapModeMirror;
[[scene rootNode] addChildNode:videoBall];

I am creating the video layer as such:

- (AVPlayerLayer *)videoLayer {
  if (_videoLayer == nil) {
    AVPlayer *player = [AVPlayer playerWithURL:[NSURL URLWithString:@"http://devstreaming.apple.com/videos/wwdc/2014/609xxkxq1v95fju/609/609_sd_whats_new_in_scenekit.mov"]];
    _videoLayer = [AVPlayerLayer layer];
    [_videoLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
    _videoLayer.frame = CGRectMake(0, 0, 1000, 1000);
    _videoLayer.player = player;

    [player play];
  }
return _videoLayer;
}

So this works fine in the simulator. However on a iPhone 6 running iOS 8.0.2, I can hear the audio but the node is invisible.

Is this a bug or am I doing something wrong?

Cezar
  • 690
  • 1
  • 8
  • 17
  • 3
    If the goal is to map a movie on a 3D object you can try to use a SKVideoNode in a SKScene instead. – Toyos Oct 02 '14 at 07:44
  • 1
    I have the same problem except I'm trying to render the video on a plane, my code is written in Swift, and I'm running it on an iPAd (running 8.0.2 as well). So it's probably a bug :-(. – Guillaume Laurent Oct 02 '14 at 10:38
  • @Toyos , I need to render my layer onto a 3d scene. AFAIK I can't take a SKNode and push it onto a SCNScene, or otherwise manipulate the camera show that the the SKNode has depth – Cezar Oct 02 '14 at 15:31
  • 2
    you can set the `contents` of your `SCNMaterialProperty` to be an `SKScene` :) – mnuages Oct 09 '14 at 10:57
  • @Cezar, did you get to solve this? I'm facing the same issue – David Homes Oct 29 '15 at 12:54
  • @dhomes, Used SpriteKit and put the node inside a SKScene – Cezar Oct 30 '15 at 16:11
  • I'm dealing with same problem. In simulator just fine, but on physical device SCNScene contents not showing CAGradientLayer. Probably a bug cause this problem. – ytur Aug 25 '16 at 08:28
  • Did anyone filed a radar for this yet? – Ömer Karışman Sep 08 '17 at 19:46

0 Answers0