diff --git a/cocos/core/3d/framework/skinning-model-component.ts b/cocos/core/3d/framework/skinning-model-component.ts index 6f03f0ffdc..c413c359cf 100644 --- a/cocos/core/3d/framework/skinning-model-component.ts +++ b/cocos/core/3d/framework/skinning-model-component.ts @@ -53,9 +53,11 @@ export class SkinningModelComponent extends ModelComponent { @property(Node) protected _skinningRoot: INode | null = null; + protected _clip: AnimationClip | null = null; + /** - * @en The bone nodes - * @zh 骨骼节点。 + * @en The skeleton resource + * @zh 骨骼资源。 */ @property({ type: Skeleton }) get skeleton () { @@ -85,6 +87,7 @@ export class SkinningModelComponent extends ModelComponent { } public uploadAnimation (clip: AnimationClip | null) { + this._clip = clip; if (this._model) { (this._model as SkinningModel).uploadAnimation(clip); } } @@ -104,6 +107,10 @@ export class SkinningModelComponent extends ModelComponent { } private _update () { - if (this._model) { (this._model as SkinningModel).bindSkeleton(this._skeleton, this._skinningRoot); } + if (this._model) { + const model = (this._model as SkinningModel); + model.bindSkeleton(this._skeleton, this._skinningRoot); + model.uploadAnimation(this._clip); + } } } diff --git a/cocos/core/renderer/models/skinning-model.ts b/cocos/core/renderer/models/skinning-model.ts index 2aaafcddae..d8d1573591 100644 --- a/cocos/core/renderer/models/skinning-model.ts +++ b/cocos/core/renderer/models/skinning-model.ts @@ -137,14 +137,13 @@ export class SkinningModel extends Model { stride: UBOSkinningTexture.SIZE, }); } - this.uploadAnimation(this.uploadedAnim); } public uploadAnimation (anim: AnimationClip | null) { if (!this._skeleton) { return; } this.uploadedAnim = anim; - const texture = this.uploadedAnim ? - this._scene.texturePool.getJointsTextureWithAnimation(this._skeleton, this.uploadedAnim) : + const texture = anim ? + this._scene.texturePool.getJointsTextureWithAnimation(this._skeleton, anim) : this._scene.texturePool.getDefaultJointsTexture(this._skeleton); JointsAnimationInfo.switchClip(this._transform.uuid, anim); this._applyJointsTexture(texture);