Fix the socket target in Spine is not functioning correctly (#16572)

This commit is contained in:
bofeng-song
2023-12-07 17:36:06 +08:00
committed by GitHub
parent 6eadc13af6
commit d25d3b1fa5
3 changed files with 9 additions and 2 deletions
+5 -2
View File
@@ -48,8 +48,7 @@ export class AttachUtil {
init (skeletonComp: Skeleton): void {
this._isInitialized = false;
if (!skeletonComp || skeletonComp.socketNodes?.size === 0) return;
const isCached = skeletonComp.isAnimationCached();
this._skeletonBones = isCached && skeletonComp._curFrame ? skeletonComp._curFrame.boneInfos : skeletonComp._skeleton.bones;
this._skeletonBones = skeletonComp._skeleton.bones;
if (!this._skeletonBones || this._skeletonBones.length < 1) return;
this._socketNodes = skeletonComp.socketNodes;
if (!this._socketNodes || this._socketNodes.size <= 0) return;
@@ -57,6 +56,10 @@ export class AttachUtil {
this._syncAttachedNode();
}
updateSkeletonBones (bones: FrameBoneInfo[]): void {
this._skeletonBones = bones;
}
reset (): void {
this._isInitialized = false;
this._skeletonBones = null;
+3
View File
@@ -1051,6 +1051,9 @@ export class Skeleton extends UIRenderer {
frameCache.updateToFrame(frameIdx);
}
this._curFrame = frames[frameIdx];
if (this._curFrame !== undefined) {
this.attachUtil.updateSkeletonBones(this._curFrame.boneInfos);
}
if (frameCache.isCompleted && frameIdx >= frames.length) {
this._playCount++;
if (this._playTimes > 0 && this._playCount >= this._playTimes) {
@@ -844,6 +844,7 @@ const cacheManager = require('./jsb-cache-manager');
assembler.updateRenderData = function (comp) {
comp._render();
comp.syncAttachedNode();
};
// eslint-disable-next-line no-unused-vars