mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
reupload clip after model destroyed (#5716)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user