The documentation for SCNMaterialProperty.contents claims to be an animated property, and I can do crossfades between two colors. However, Im failed to cross between the two images.
So, I'm starting to wonder if this is possible at all, or do I need to create a custom shader for this?
Ive tried implicit animation, in which case it immediately displays "after image:
node.geometry.firstMaterial.diffuse.contents = [UIImage imageNamed:@"before"]; [SCNTransaction begin]; [SCNTransaction setAnimationDuration:5]; node.geometry.firstMaterial.diffuse.contents = [UIImage imageNamed:@"after"]; [SCNTransaction commit];
Explicit animation that does nothing:
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"contents"]; animation.fromValue = (__bridge id)[UIImage imageNamed:@"before"].CGImage; animation.toValue = (__bridge id)[UIImage imageNamed:@"after"].CGImage; animation.duration = 5; [node.geometry.firstMaterial.diffuse addAnimation:animation forKey:nil];
As with CALayer , which does nothing:
CALayer *textureLayer = [CALayer layer]; textureLayer.frame = CGRectMake(0, 0, 793, 1006); textureLayer.contents = (__bridge id)[UIImage imageNamed:@"before"].CGImage; node.geometry.firstMaterial.diffuse.contents = textureLayer; CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"contents"]; animation.fromValue = (__bridge id)[UIImage imageNamed:@"before"].CGImage; animation.toValue = (__bridge id)[UIImage imageNamed:@"after"].CGImage; animation.duration = 5; [textureLayer addAnimation:animation forKey:nil];
core-animation opengl-es scenekit
alloy
source share