@@ -52,7 +52,8 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
5252 propBoundsProvider: SpineBoundsProviderType = "setup";
5353 propEnableCollision = false;
5454
55- isFlippedX = false;
55+ isMirrored = false;
56+ isFlipped = false;
5657 collisionSpriteInstance?: IWorldInstance;
5758 collisionSpriteClassName = "";
5859 isPlaying = true;
@@ -166,7 +167,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
166167 this.y + this.propOffsetY,
167168 this.totalZ,
168169 this.angle + this.propOffsetAngle,
169- this.width / this.spineBounds.width * this.propScaleX * (this.isFlippedX ? -1 : 1) ,
170+ this.width / this.spineBounds.width * this.propScaleX,
170171 this.height / this.spineBounds.height * this.propScaleY);
171172
172173 this.updateCollisionSprite();
@@ -848,6 +849,14 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
848849 this.boneFollowers.delete(boneName);
849850 }
850851
852+ private mirrorFollower (instance: IWorldInstance) {
853+ instance.setSize(-instance.width, instance.height);
854+ }
855+
856+ private flipFollower (instance: IWorldInstance) {
857+ instance.setSize(instance.width, -instance.height);
858+ }
859+
851860 private updateBoneFollowers (matrix: C3Matrix) {
852861 if (this.boneFollowers.size === 0) return;
853862
@@ -872,8 +881,8 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
872881 const rotatedOffsetX = follower.offsetX * cos - follower.offsetY * sin;
873882 const rotatedOffsetY = follower.offsetX * sin + follower.offsetY * cos;
874883
875- instance.x = x + rotatedOffsetX;
876- instance.y = y + rotatedOffsetY;
884+ instance.x = x + rotatedOffsetX * (this.isMirrored ? -1 : 1) ;
885+ instance.y = y + rotatedOffsetY * (this.isFlipped ? -1 : 1) ;
877886 instance.angleDegrees = boneRotation + follower.offsetAngle;
878887 }
879888 }
@@ -1101,8 +1110,34 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
11011110 * Skeleton
11021111 */
11031112
1104- public flipX (isFlippedX: boolean) {
1105- this.isFlippedX = isFlippedX;
1113+ public mirror (isMirrored: boolean) {
1114+ if (isMirrored !== this.isMirrored) {
1115+ this.isMirrored = isMirrored;
1116+ this.width = -this.width
1117+
1118+ for (const [, followers] of this.boneFollowers) {
1119+ for (const follower of followers) {
1120+ const instance = this.runtime.getInstanceByUid(follower.uid) as IWorldInstance;
1121+ if (instance) this.mirrorFollower(instance);
1122+ }
1123+ }
1124+
1125+ }
1126+ }
1127+
1128+ public flip (isFlipped: boolean) {
1129+ if (isFlipped !== this.isFlipped) {
1130+ this.isFlipped = isFlipped;
1131+ this.height = -this.height;
1132+
1133+ for (const [, followers] of this.boneFollowers) {
1134+ for (const follower of followers) {
1135+ const instance = this.runtime.getInstanceByUid(follower.uid) as IWorldInstance;
1136+ if (instance) this.flipFollower(instance);
1137+ }
1138+ }
1139+
1140+ }
11061141 }
11071142
11081143 public setPhysicsMode (mode: 0 | 1 | 2 | 3) {
0 commit comments