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

Animations regression with r154 #26470

Closed
lviggiani opened this issue Jul 21, 2023 · 2 comments · Fixed by #26476
Closed

Animations regression with r154 #26470

lviggiani opened this issue Jul 21, 2023 · 2 comments · Fixed by #26476

Comments

@lviggiani
Copy link

Description

After upgrading to r154, animations go wrong:

image

this with <= r153

image

Reproduction steps

  1. Upgrade to r154, no other changes

Code

playAnimations(reverse = false, ...animations:(string | THREE.AnimationClip | undefined)[]):Promise<void>{
        return new Promise((resolve, reject) => {

            animations = animations.map((animation) => typeof animation == "string" ?
                this.animations.find(item => item.name == animation) : animation)
    
            if (animations.find(animation => !animation)) return reject("Invalid animation");
    
            const clock = new THREE.Clock();
            const mixer = new THREE.AnimationMixer(this.scene);
            let isLoop = true;
            let toGo = animations.length;

            animations.forEach(animation => {
                const action = mixer.clipAction(animation as THREE.AnimationClip);
                action.loop = THREE.LoopOnce;
                action.clampWhenFinished = true;
                if (reverse){
                    action.timeScale = -1;
                    action.paused = false;
                    if(action.time === 0)
                        action.time = action.getClip().duration;
                }
                action.play();
            });
    
            mixer.addEventListener("finished", () => {
                toGo--;
                if (toGo) return;
                
                isLoop = false;
                resolve();
            });
            
            const loop = () => {
                mixer.update(clock.getDelta());
                this.requestRender();
                if (isLoop)
                    requestAnimationFrame(loop);
            }
            loop();
        });
    }

Live example

n.a.

Screenshots

No response

Version

r154

Device

Desktop

Browser

Chrome, Firefox, Edge

OS

Windows, MacOS, Linux

@Mugen87
Copy link
Collaborator

Mugen87 commented Jul 21, 2023

Looking at the release notes there were no animation related changes. Do you mind sharing the model so we can reproduce the issue?

@Mugen87
Copy link
Collaborator

Mugen87 commented Jul 22, 2023

I can reproduce the issue with the test asset from donmccurdy/three-gltf-viewer#344.

Reverting #26126 actually fixes the issue.

/ping @hybridherbst

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

Successfully merging a pull request may close this issue.

2 participants