fix skeletal animation (#5115)

* fix animation state re-init issue

* create sockets when creating states
This commit is contained in:
Yun Hsiao Wu
2019-08-07 17:38:12 +08:00
committed by Weiliang Wang
parent cfddd96656
commit afbce9bf4f
3 changed files with 17 additions and 10 deletions
+10 -10
View File
@@ -451,6 +451,16 @@ export class AnimationComponent extends Component implements IEventTarget {
return new AnimationState(clip, name);
}
protected _doCreateState (clip: AnimationClip, name: string) {
const state = this._createState(clip, name);
state._setEventTarget(this);
if (this.node) {
state.initialize(this.node);
}
this._nameToState[state.name] = state;
return state;
}
private _getStateByNameOrDefaultClip (name?: string) {
if (!name) {
if (!this._defaultClip) {
@@ -477,16 +487,6 @@ export class AnimationComponent extends Component implements IEventTarget {
}
}
}
private _doCreateState (clip: AnimationClip, name: string) {
const state = this._createState(clip, name);
state._setEventTarget(this);
if (this.node) {
state.initialize(this.node);
}
this._nameToState[state.name] = state;
return state;
}
}
// for restore on and off
+1
View File
@@ -345,6 +345,7 @@ export class AnimationState extends Playable {
}
public initialize (root: INode) {
if (this._curveLoaded) { return; }
this._curveLoaded = true;
this._samplerSharedGroups.length = 0;
this._targetNode = root;
@@ -141,6 +141,12 @@ export class SkeletalAnimationComponent extends AnimationComponent {
protected _createState (clip: AnimationClip, name?: string) {
return new SkeletalAnimationState(clip, name);
}
protected _doCreateState (clip: AnimationClip, name: string) {
const state = super._doCreateState(clip, name) as SkeletalAnimationState;
state.rebuildSocketCurves(this._sockets);
return state;
}
}
cc.SkeletalAnimationComponent = SkeletalAnimationComponent;