Skip to content

Commit 2d269de

Browse files
committed
Fixes to instances and expressions.
1 parent 469bec1 commit 2d269de

File tree

3 files changed

+10
-19
lines changed

3 files changed

+10
-19
lines changed

spine-ts/spine-construct3/src/c3runtime/expressions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Exps =
106106
if (field === "balance") return this.triggeredEventData?.balance ?? 0;
107107
if (field === "volume") return this.triggeredEventData?.volume ?? 0;
108108
if (field === "audiopath") return this.triggeredEventData?.data.audioPath ?? "";
109-
if (field === "event") return this.triggeredEventData?.data.name ?? 0;
110-
if (field === "animation") return this.triggeredEventData?.animation ?? 0;
109+
if (field === "event") return this.triggeredEventData?.data.name ?? "";
110+
if (field === "animation") return this.triggeredEventData?.animation ?? "";
111111
if (field === "track") return this.triggeredEventData?.track ?? -1;
112112
return "";
113113
},

spine-ts/spine-construct3/src/c3runtime/instance.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
661661
return;
662662
}
663663

664-
track.alpha = spine.MathUtils.clamp(0, 1, alpha);
664+
track.alpha = spine.MathUtils.clamp(alpha, 0, 1);
665665
}
666666

667667

@@ -910,6 +910,8 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
910910
private updateBoneFollowers (matrix: C3Matrix) {
911911
if (this.boneFollowers.size === 0) return;
912912

913+
const staleFollowers: { uid: number, boneName: string }[] = [];
914+
913915
for (const [boneName, followers] of this.boneFollowers) {
914916
const bone = this.skeleton?.findBone(boneName);
915917
if (!bone) continue;
@@ -933,7 +935,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
933935
for (const follower of followers) {
934936
const instance = this.runtime.getInstanceByUid(follower.uid) as IWorldInstance;
935937
if (!instance) {
936-
this.detachInstanceFromBoneByUid(follower.uid, boneName);
938+
staleFollowers.push({ uid: follower.uid, boneName });
937939
continue;
938940
}
939941

@@ -957,6 +959,8 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
957959
);
958960
}
959961
}
962+
963+
for (const { uid, boneName } of staleFollowers) this.detachInstanceFromBoneByUid(uid, boneName);
960964
}
961965

962966
private updateBonesOverride () {
@@ -1184,7 +1188,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
11841188
public mirror (isMirrored: boolean) {
11851189
if (isMirrored !== this.isMirrored) {
11861190
this.isMirrored = isMirrored;
1187-
this.width = -this.width
1191+
this.width = -this.width;
11881192

11891193
for (const [, followers] of this.boneFollowers) {
11901194
for (const follower of followers) {

spine-ts/spine-construct3/src/instance.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
269269

270270
if (errorsString) {
271271
const webglText = this.getErrorTextC3(iRenderer, this.layoutView);
272-
webglText.SetSize(_inst.GetWidth(), _inst.GetHeight(), this.debugZoomFactor(iDrawParams));
272+
webglText.SetSize(_inst.GetWidth(), _inst.GetHeight(), iDrawParams.GetLayoutView().GetZoomFactor());
273273
webglText.SetText(errorsString);
274274

275275
const texture = webglText.GetTexture();
@@ -283,19 +283,6 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
283283
}
284284
}
285285

286-
private debugZoomFactor (iDrawParams: SDK.Gfx.IDrawParams) {
287-
const layoutView = iDrawParams.GetLayoutView();
288-
let count = 1000;
289-
let zoom = -1;
290-
while (zoom === -1 && count-- > 0) {
291-
try {
292-
zoom = layoutView.GetZoomFactor();
293-
} catch (error) {
294-
console.log("error ZOOM: ", error);
295-
}
296-
}
297-
return zoom === -1 ? 1 : zoom;
298-
}
299286

300287
private setAnimation () {
301288
const propValue = this._inst.GetPropertyValue(PLUGIN_CLASS.PROP_ANIMATION) as string;

0 commit comments

Comments
 (0)