reupload clip after model destroyed (#5716)

This commit is contained in:
Yun Hsiao Wu
2019-11-08 17:38:57 +08:00
committed by pandamicro
parent 4b200fdb80
commit 1ae2069a7a
2 changed files with 12 additions and 6 deletions
@@ -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);
}
}
}
+2 -3
View File
@@ -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);