|
@@ -36,10 +36,11 @@ export default class XAnimationController {
|
|
|
return resolve(null);
|
|
|
|
|
|
this._prerocess(animationName, isLoop),
|
|
|
- this._avatar.avatarManager.loadAnimation(this._avatar.avatarType, animationName).then(animation => {
|
|
|
- if (!animation) return reject(new AvatarAnimationError("animation group does not exist"));
|
|
|
+ this._avatar.avatarManager.loadAnimation(this._avatar.avatarType, animationName).then(animationGroup => {
|
|
|
+ if (!animationGroup) return reject(new AvatarAnimationError("animation group does not exist"));
|
|
|
|
|
|
- const skeleton = this._mappingSkeleton(animation);
|
|
|
+ // 实际上skeleton还是AnimationGroup类型
|
|
|
+ const skeleton = this._mappingSkeleton(animationGroup);
|
|
|
if (!skeleton) return reject(new AvatarAnimationError("mapping animation failed"))
|
|
|
|
|
|
if (skeleton && this._isAnimationValid(skeleton))
|
|
@@ -185,23 +186,23 @@ export default class XAnimationController {
|
|
|
getAnimation(e, i) {
|
|
|
return avatarLoader.animations.get(getAnimationKey(i, e))
|
|
|
}
|
|
|
- _mappingSkeleton(animation) {
|
|
|
- if (animation) {
|
|
|
- const skeleton = animation.clone(animation.name, o=>{
|
|
|
- const name = o.name.split(" ").length > 2 ? o.name.split(" ")[2] : o.name;
|
|
|
+ _mappingSkeleton(animationGroup) {
|
|
|
+ if (animationGroup) {
|
|
|
+ const animationGroupClone = animationGroup.clone(animationGroup.name, boneOld => {
|
|
|
+ const name = boneOld.name.split(" ").length > 2 ? boneOld.name.split(" ")[2] : boneOld.name;
|
|
|
if (this._boneMap.size === (this._avatar.skeleton && this._avatar.skeleton.bones.length)) return this._boneMap.get(name);
|
|
|
{
|
|
|
- let bone = this._avatar.skeleton && this._avatar.skeleton.bones.find(bone => bone.name === o.name || bone.name === o.name.split(" ")[2])
|
|
|
- const b = bone && bone.getTransformNode();
|
|
|
- return b && (
|
|
|
- b.name = name,
|
|
|
- this._boneMap.set(name, b)
|
|
|
- ),
|
|
|
- b
|
|
|
+ let bone0 = this._avatar.skeleton && this._avatar.skeleton.bones.find(bone => bone.name === boneOld.name || bone.name === boneOld.name.split(" ")[2])
|
|
|
+ const bone = bone0 && bone0.getTransformNode();
|
|
|
+ bone && (
|
|
|
+ bone.name = name,
|
|
|
+ this._boneMap.set(name, bone)
|
|
|
+ )
|
|
|
+ return bone
|
|
|
}
|
|
|
});
|
|
|
- return skeleton._parentContainer = animation._parentContainer,
|
|
|
- skeleton
|
|
|
+ animationGroupClone._parentContainer = animationGroup._parentContainer
|
|
|
+ return animationGroupClone
|
|
|
} else
|
|
|
return
|
|
|
}
|
|
@@ -257,10 +258,12 @@ export default class XAnimationController {
|
|
|
}
|
|
|
_playAnimation(e=0) {
|
|
|
return e == 0 && this.iBodyAnim && this.iBodyAnim.animGroup ? (
|
|
|
+ // 身体动画
|
|
|
this.onPlayObservable.notifyObservers(this._scene),
|
|
|
this.iBodyAnim.animGroup.start(this.loop, this.iBodyAnim.playSpeed, this.iBodyAnim.startFrame, this.iBodyAnim.endFrame, !1),
|
|
|
!0
|
|
|
) : e == 1 && this.iFaceAnim && this.iFaceAnim.animGroup ? (
|
|
|
+ // 脸部动画
|
|
|
this.iFaceAnim.animGroup.start(this.loop, this.iFaceAnim.playSpeed, this.iFaceAnim.startFrame, this.iFaceAnim.endFrame, !1),
|
|
|
!0
|
|
|
) : !1
|