mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-22 17:56:43 +08:00
Add support for z elevation.
This commit is contained in:
parent
8aba39f7d5
commit
bc6f750a39
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user