SceneKit material content is not animatable with an image.
| Originator: | eloy.de.enige | ||
| Number: | rdar://23283570 | Date Originated: | 27-Oct-2015 10:31 PM |
| Status: | Open | Resolved: | |
| Product: | Documentation | Product Version: | |
| Classification: | Other Bug | Reproducible: | Always |
Summary:
The SCNMaterialProperty.contents documentation simply states that the contents is animatable and lists UIImage/NSImage/CGImageRef as possible value types, however trying to do so does not work as expected.
Steps to Reproduce:
I’ve tried an implicit animation, in which case it immediately shows the ‘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];
An explicit animation, which 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 well as through a `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];
Expected Results:
A crossfade animation between the two images.
Actual Results:
It either shows just the first or the second texture.
Documentation:
https://developer.apple.com/library/prerelease/ios/documentation/SceneKit/Reference/SCNMaterialProperty_Class/index.html#//apple_ref/occ/instp/SCNMaterialProperty/contents
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!