Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load Animations? #1

Open
arkwl opened this issue Jan 30, 2018 · 6 comments
Open

Load Animations? #1

arkwl opened this issue Jan 30, 2018 · 6 comments

Comments

@arkwl
Copy link

arkwl commented Jan 30, 2018

Hello!

So ive tried to follow your tutorial here: https://blog.pusher.com/animating-3d-model-ar-arkit-mixamo/ and my code is identical to yours but im getting an error thrown at playAnimation(...) because the animations array is empty even though loadAnimations(...) is called. Any explanation? Im fairly new to Swift.

     loadAnimation(withKey: "dancing", sceneName: "IdleFixed", animationIdentifier: "samba_danceFixed-1")
    }
    
    func loadAnimation(withKey: String, sceneName:String, animationIdentifier:String) {
        let sceneURL = Bundle.main.url(forResource: sceneName, withExtension: "dae")
        let sceneSource = SCNSceneSource(url: sceneURL!, options: nil)
        
        if let animationObject = sceneSource?.entryWithIdentifier(animationIdentifier, withClass: CAAnimation.self) {
            // The animation will only play once
            animationObject.repeatCount = 1
            // To create smooth transitions between animations
            animationObject.fadeInDuration = CGFloat(1)
            animationObject.fadeOutDuration = CGFloat(0.5)
            
            // Store the animation for later use
            animations[withKey] = animationObject
        }
    }
@arkwl
Copy link
Author

arkwl commented Jan 30, 2018

It seems as though it's not returning True here:

if let animationObject = sceneSource?.entryWithIdentifier(animationIdentifier, withClass: CAAnimation.self) {

@eh3rrera
Copy link
Owner

Hi!

According to the line:

loadAnimation(withKey: "dancing", sceneName: "IdleFixed", animationIdentifier: "samba_danceFixed-1")

You're trying to load the animation samba_danceFixed-1 from the file IdleFixed.dae. Shouldn't be something like samba_danceFixed.dae?

You should have one DAE file for the idle position and another one for the dancing animation and you should load the dancing animation calling loadAnimation with the latter.

Otherwise, probably there's something wrong with the DAE file.

Check if your dancing animation file has only one animation node and that its identifier is samba_danceFixed-1:
screen shot 2018-01-29 at 23 35 48

@omarojo
Copy link

omarojo commented Aug 8, 2018

converting the .dae to .scn the animation is still there. But the method sceneSource?.entryWithIdentifier return nothing. even tho the node has the animation keys.

@eh3rrera
Copy link
Owner

eh3rrera commented Aug 9, 2018

Hi @omarojo.

Sorry, I never tried with a SCN file, and right now I cannot help you, my mac broke a few months ago and I have been disconnected from the iOS world since then.

But are you using the latest version of XCode? If so, maybe entryWithIdentifier is now deprecated or there's a new API for this.

Maybe someone else can see this issue and help.

@J-Arji
Copy link

J-Arji commented Mar 28, 2020

@eh3rrera

hi
when multi animation includes dae , how can play animation?

@eh3rrera
Copy link
Owner

Hi @J-Arji

I haven't programmed in ARKit for a while, but if I remember correctly, each animation has an identifier, so I guess you just have to get the animation you want by its identifier and then play it.

The code shown in these links might help you:
https://riptutorial.com/scenekit/example/23522/load-an-animation-from-a-collada-or-scn-file
https://stackoverflow.com/questions/29692388/scenekit-stop-continuously-looping-collada-animation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants