diff --git a/spine-ts/spine-construct3/spine-construct3-lib/src/C3Matrix.ts b/spine-ts/spine-construct3/spine-construct3-lib/src/C3Matrix.ts index a03ca518b..e1b898ed0 100644 --- a/spine-ts/spine-construct3/spine-construct3-lib/src/C3Matrix.ts +++ b/spine-ts/spine-construct3/spine-construct3-lib/src/C3Matrix.ts @@ -37,21 +37,24 @@ export class C3Matrix { public d = 0; public tx = 0; public ty = 0; + public tz = 0; public prevX = Infinity; public prevY = Infinity; + public prevZ = Infinity; public prevAngle = Infinity; public prevScaleX = Infinity; public prevScaleY = Infinity; private tempPoint = new Vector2(); - public update (x: number, y: number, angle: number, scaleX = 1, scaleY = 1) { - if (this.prevX === x && this.prevY === y && + public update (x: number, y: number, z: number, angle: number, scaleX = 1, scaleY = 1) { + if (this.prevX === x && this.prevY === y && this.prevZ === z && this.prevAngle === angle && this.prevScaleX === scaleX && this.prevScaleY === scaleY) return false; this.prevX = x; this.prevY = y; + this.prevZ = z; this.prevAngle = angle; this.prevScaleX = scaleX; this.prevScaleY = scaleY; @@ -63,6 +66,7 @@ export class C3Matrix { this.d = scaleY * cos; this.tx = x; this.ty = y; + this.tz = z; return true; } diff --git a/spine-ts/spine-construct3/spine-construct3-lib/src/C3SkeletonRenderer.ts b/spine-ts/spine-construct3/spine-construct3-lib/src/C3SkeletonRenderer.ts index 4653db076..80a747811 100644 --- a/spine-ts/spine-construct3/spine-construct3-lib/src/C3SkeletonRenderer.ts +++ b/spine-ts/spine-construct3/spine-construct3-lib/src/C3SkeletonRenderer.ts @@ -49,6 +49,7 @@ abstract class C3SkeletonRenderer< private prevX = Infinity; private prevY = Infinity; + private prevZ = Infinity; private prevAngle = Infinity; private prevRed = -1; private prevGreen = -1; @@ -64,11 +65,12 @@ abstract class C3SkeletonRenderer< draw (skeleton: Skeleton, inColors: [number, number, number], opacity = 1, requestRedraw = true) { const { matrix, inv255 } = this; - const { a, b, c, d, tx, ty, prevX, prevY, prevAngle } = matrix; + const { a, b, c, d, tx, ty, prevX, prevY, prevZ, prevAngle } = matrix; - const requestRedrawForMatrix = this.prevX !== prevX || this.prevY !== prevY || this.prevAngle !== prevAngle; + const requestRedrawForMatrix = this.prevX !== prevX || this.prevY !== prevY || this.prevZ !== prevZ || this.prevAngle !== prevAngle; this.prevX = prevX; this.prevY = prevY; + this.prevZ = prevZ; this.prevAngle = prevAngle; const requestRedrawForColor = this.prevRed !== inColors[0] || this.prevGreen !== inColors[1] || this.prevBlue !== inColors[2] || this.prevAlpha !== opacity; @@ -95,6 +97,7 @@ abstract class C3SkeletonRenderer< const y = positions[index + 1]; positions[index] = a * x + c * y + tx; positions[index + 1] = b * x + d * y + ty; + positions[index + 2] = prevZ; const color = colors[i]; const colorDst = i * 4; diff --git a/spine-ts/spine-construct3/src/c3runtime/instance.ts b/spine-ts/spine-construct3/src/c3runtime/instance.ts index 4677cf6ac..4c3ab785d 100644 --- a/spine-ts/spine-construct3/src/c3runtime/instance.ts +++ b/spine-ts/spine-construct3/src/c3runtime/instance.ts @@ -163,6 +163,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase { this.matrix.update( this.x + this.propOffsetX, this.y + this.propOffsetY, + this.totalZElevation, this.angle + this.propOffsetAngle, this.width / this.spineBounds.width * this.propScaleX * (this.isFlippedX ? -1 : 1), this.height / this.spineBounds.height * this.propScaleY); diff --git a/spine-ts/spine-construct3/src/instance.ts b/spine-ts/spine-construct3/src/instance.ts index a76a5428a..f71c8a54b 100644 --- a/spine-ts/spine-construct3/src/instance.ts +++ b/spine-ts/spine-construct3/src/instance.ts @@ -572,6 +572,7 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase { this.matrix.update( this._inst.GetX() + this.propOffsetX, this._inst.GetY() + this.propOffsetY, + this._inst.GetTotalZElevation(), this._inst.GetAngle() + this.propOffsetAngle, actualScaleX, actualScaleY); diff --git a/spine-ts/spine-construct3/src/plugin.ts b/spine-ts/spine-construct3/src/plugin.ts index 6f6326a4e..9035b55f4 100644 --- a/spine-ts/spine-construct3/src/plugin.ts +++ b/spine-ts/spine-construct3/src/plugin.ts @@ -78,14 +78,15 @@ const PLUGIN_CLASS = class SpineC3Plugin extends SDK.IPluginBase { this._info.SetCategory(PLUGIN_CATEGORY); this._info.SetAuthor("Esoteric Software"); this._info.SetHelpUrl(globalThis.lang(".help-url")); - this._info.SetPluginType("world"); // mark as world plugin, which can draw + this._info.SetPluginType("world"); // mark as world plugin, which can draw - this._info.SetIsResizable(true); // allow to be resized - this._info.SetIsRotatable(true); // allow to be rotated + this._info.SetIsResizable(true); // allow to be resized + this._info.SetIsRotatable(true); // allow to be rotated this._info.SetHasImage(false); - this._info.SetSupportsEffects(true); // allow effects + this._info.SetSupportsEffects(true); // allow effects this._info.SetMustPreDraw(true); this._info.SetSupportsColor(true); // enable system colour/transparency + this._info.SetSupportsZElevation(true); // enable z elevation this._info.AddCommonPositionACEs(); // Position: Set X/Y, Set position, etc. this._info.AddCommonSizeACEs(); // Size: Set size, width, height