AnimationMixer.existingAction() 是 THREE.js 中的一个方法,它可以返回已经存在于 AnimationMixer 中的 AnimationAction 对象。
existingAction(clip, optionalRoot)
clip:(必须)要搜索的 AnimationClip 对象。optionalRoot:(可选) Object3D 对象,用于限制搜索范围。如果找到 AnimationAction 对象,则返回该对象。否则,返回 null。
const mixer = new THREE.AnimationMixer(model);
const animationAction = mixer.clipAction(clip);
// 一段时间后...
const existingAction = mixer.existingAction(clip);
if (existingAction) {
  existingAction.play();
}
existingAction() 方法必须在 mixer.clipAction() 方法之后调用,否则将无法找到 AnimationAction。AnimationAction,则返回第一个找到的对象。AnimationMixer 中没有找到匹配的 AnimationAction,则返回 null。optionalRoot 参数,则会在 AnimationMixer 管理的所有 Object3D 对象中搜索匹配的 AnimationAction。提供 optionalRoot 参数将限制搜索的范围。