SceneKit播放序列帧动画

解决方案

通过改变模型的diffuse属性,设置为imageview,然后播放图片就可以了

child.geometry.firstMaterial.diffuse.contents = m_iamgeView;

关键性代码

//创建好imageView
    NSMutableArray *imagesArr = [[NSMutableArray alloc]init];
    NSString * bundlePath = [[NSBundle mainBundle] pathForResource:@"art" ofType:@"scnassets"];
    
    for (int i = 0; i<29; i++) {
        
        NSString *imgPath = [bundlePath stringByAppendingPathComponent:[NSString stringWithFormat:@"tiff/Fire 08_%d.png",i]];
        
        UIImage *i = [UIImage imageWithContentsOfFile:imgPath];

        [imagesArr addObject:i];
        
    }
    
    UIImageView * m_iamgeView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 200, 200)];
    m_iamgeView.animationImages = imagesArr;
    m_iamgeView.animationDuration = 1;
    m_iamgeView.animationRepeatCount = -1;
    [m_iamgeView startAnimating];

    SCNScene * idleScene = [SCNScene sceneNamed:@"art.scnassets/tif/boom.DAE"]; //获取.dae文件都是用SCNScene来接收
    
    SCNNode * node = [[SCNNode alloc]init];
    
    for (SCNNode * child in idleScene.rootNode.childNodes) {
        
        [node addChildNode:child];
             
        if ([child.name isEqual: @"Plane001"]) {
            child.geometry.firstMaterial.diffuse.contents = m_iamgeView;
        }
        
    }

    node.position = SCNVector3Make(0, 5, -300);
    node.scale    = SCNVector3Make(0.5, 0.5, 0.5);
    
    [self.jpARSCNView.scene.rootNode addChildNode:node];
    

效果图:


Untitled.gif

你可能感兴趣的:(SceneKit播放序列帧动画)