mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
fix skeletal animation (#5115)
* fix animation state re-init issue * create sockets when creating states
This commit is contained in:
committed by
Weiliang Wang
parent
cfddd96656
commit
afbce9bf4f
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user