mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 09:48:44 +00:00
Character Animation Engine: Add character/animation removal logic
This commit is contained in:
1 parent
9e1e71c233
commit
ca0b199558
1 file changed
+28
@@ -191,6 +191,11 @@ export class CharacterAnimationEngine {
|
||||
})
|
||||
}
|
||||
|
||||
stopCharacter(character: THREE.Object3D) {
|
||||
const mixer = this.characterMixers.get(character);
|
||||
mixer?.stopAllAction();
|
||||
}
|
||||
|
||||
stop() {
|
||||
this.characterMixers.forEach((mixer) => {
|
||||
mixer.stopAllAction();
|
||||
@@ -236,4 +241,27 @@ export class CharacterAnimationEngine {
|
||||
});
|
||||
}
|
||||
|
||||
removeCharacter(character: THREE.Object3D) {
|
||||
console.debug("Removing character from animation engine", character);
|
||||
this.characterAnimations.delete(character);
|
||||
this.characterMixers.delete(character);
|
||||
}
|
||||
|
||||
removeAnimation(character: THREE.Object3D, clip: ClipUI) {
|
||||
console.debug("Removing animation from character", character, clip);
|
||||
const clips = this.characterAnimations.get(character)!;
|
||||
|
||||
const clipIndex = clips.findIndex((c) => c.clip_uuid === clip.clip_uuid);
|
||||
if (clipIndex < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove the clip from character's tracked clips
|
||||
clips.splice(clipIndex, 1);
|
||||
|
||||
// Stop all character animations to cleanly reset
|
||||
this.stopCharacter(character);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user