Skip to content

Animations regression with r154 #26470

@lviggiani

Description

@lviggiani

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions