mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 09:16:01 +08:00
Add basic ACE to plugin. C3 Color is used for rendering.
This commit is contained in:
parent
62e91b3ede
commit
7c053efdc5
@ -53,7 +53,7 @@ abstract class C3SkeletonRenderer<
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
draw (skeleton: Skeleton, opacity = 1) {
|
draw (skeleton: Skeleton, inColors: [number, number, number], opacity = 1) {
|
||||||
const { matrix, inv255 } = this;
|
const { matrix, inv255 } = this;
|
||||||
|
|
||||||
let command = this.render(skeleton);
|
let command = this.render(skeleton);
|
||||||
@ -81,9 +81,9 @@ abstract class C3SkeletonRenderer<
|
|||||||
const colorDst = i * 4;
|
const colorDst = i * 4;
|
||||||
const alpha = (color >>> 24 & 0xFF) * inv255 * opacity;
|
const alpha = (color >>> 24 & 0xFF) * inv255 * opacity;
|
||||||
const alphaInverse = inv255 * alpha;
|
const alphaInverse = inv255 * alpha;
|
||||||
c3colors[colorDst] = (color >>> 16 & 0xFF) * alphaInverse;
|
c3colors[colorDst] = inColors[0] * (color >>> 16 & 0xFF) * alphaInverse;
|
||||||
c3colors[colorDst + 1] = (color >>> 8 & 0xFF) * alphaInverse;
|
c3colors[colorDst + 1] = inColors[1] * (color >>> 8 & 0xFF) * alphaInverse;
|
||||||
c3colors[colorDst + 2] = (color & 0xFF) * alphaInverse;
|
c3colors[colorDst + 2] = inColors[2] * (color & 0xFF) * alphaInverse;
|
||||||
c3colors[colorDst + 3] = alpha;
|
c3colors[colorDst + 3] = alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -148,7 +148,8 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
|
|||||||
if (!skeleton) return;
|
if (!skeleton) return;
|
||||||
|
|
||||||
this.skeletonRenderer ||= new spine.C3RendererRuntime(renderer, this.matrix);
|
this.skeletonRenderer ||= new spine.C3RendererRuntime(renderer, this.matrix);
|
||||||
this.skeletonRenderer.draw(skeleton, this.opacity);
|
this.skeletonRenderer.draw(skeleton, this.colorRgb, this.opacity);
|
||||||
|
|
||||||
if (this.propDebugSkeleton) this.skeletonRenderer.drawDebug(skeleton, this.x, this.y, this.getBoundingQuad(false));
|
if (this.propDebugSkeleton) this.skeletonRenderer.drawDebug(skeleton, this.x, this.y, this.getBoundingQuad(false));
|
||||||
this.renderDragHandles();
|
this.renderDragHandles();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -206,7 +206,8 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
|
|||||||
|
|
||||||
this.update(0);
|
this.update(0);
|
||||||
this.skeletonRenderer ||= new spine.C3RendererEditor(iRenderer, this.matrix);
|
this.skeletonRenderer ||= new spine.C3RendererEditor(iRenderer, this.matrix);
|
||||||
this.skeletonRenderer.draw(skeleton, _inst.GetOpacity());
|
const color = _inst.GetColor();
|
||||||
|
this.skeletonRenderer.draw(skeleton, [color.getR(), color.getG(), color.getB()], color.getA() * _inst.GetOpacity());
|
||||||
const quad = _inst.GetQuad();
|
const quad = _inst.GetQuad();
|
||||||
if (_inst.GetPropertyValue(PLUGIN_CLASS.PROP_DEBUG_SKELETON) as boolean)
|
if (_inst.GetPropertyValue(PLUGIN_CLASS.PROP_DEBUG_SKELETON) as boolean)
|
||||||
this.skeletonRenderer.drawDebug(skeleton, rectX, rectY, quad);
|
this.skeletonRenderer.drawDebug(skeleton, rectX, rectY, quad);
|
||||||
|
|||||||
@ -41,20 +41,26 @@ const PLUGIN_CLASS = class SpineC3Plugin extends SDK.IPluginBase {
|
|||||||
|
|
||||||
SDK.Lang.PushContext(`plugins.${PLUGIN_ID.toLowerCase()}`);
|
SDK.Lang.PushContext(`plugins.${PLUGIN_ID.toLowerCase()}`);
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
this._info.SetName(globalThis.lang(".name"));
|
this._info.SetName(globalThis.lang(".name"));
|
||||||
// @ts-ignore
|
|
||||||
this._info.SetDescription(globalThis.lang(".description"));
|
this._info.SetDescription(globalThis.lang(".description"));
|
||||||
this._info.SetCategory(PLUGIN_CATEGORY);
|
this._info.SetCategory(PLUGIN_CATEGORY);
|
||||||
this._info.SetAuthor("Esoteric Software");
|
this._info.SetAuthor("Esoteric Software");
|
||||||
// @ts-ignore
|
|
||||||
this._info.SetHelpUrl(globalThis.lang(".help-url"));
|
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.SetIsResizable(true); // allow to be resized
|
||||||
this._info.SetIsRotatable(true); // allow to be rotated
|
this._info.SetIsRotatable(true); // allow to be rotated
|
||||||
this._info.SetHasImage(false);
|
this._info.SetHasImage(false);
|
||||||
this._info.SetSupportsEffects(true); // allow effects
|
this._info.SetSupportsEffects(true); // allow effects
|
||||||
this._info.SetMustPreDraw(true);
|
this._info.SetMustPreDraw(true);
|
||||||
|
|
||||||
|
this._info.AddCommonPositionACEs(); // Position: Set X/Y, Set position, etc.
|
||||||
|
this._info.AddCommonSizeACEs(); // Size: Set size, width, height
|
||||||
|
this._info.AddCommonAngleACEs(); // Angle: Set angle, rotate
|
||||||
|
this._info.AddCommonAppearanceACEs(); // Appearance: Set opacity, visible, color
|
||||||
|
this._info.AddCommonZOrderACEs(); // Z order: bring to front/back, move up/down
|
||||||
|
this._info.SetSupportsColor(true); // enable system colour/transparency
|
||||||
|
|
||||||
this._info.SetRuntimeModuleMainScript("c3runtime/main.js");
|
this._info.SetRuntimeModuleMainScript("c3runtime/main.js");
|
||||||
this._info.AddC3RuntimeScript("c3runtime/spine-construct3-lib.js");
|
this._info.AddC3RuntimeScript("c3runtime/spine-construct3-lib.js");
|
||||||
this._info.AddFileDependency({
|
this._info.AddFileDependency({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user