Add set-track-alpha and set-track-mix-blend.

This commit is contained in:
Davide Tantillo 2025-11-06 12:00:38 +01:00
parent 8ed7554f14
commit c47b829019
5 changed files with 150 additions and 1 deletions

View File

@ -261,6 +261,37 @@
}
]
},
{
"id": "set-track-alpha",
"scriptName": "SetTrackAlpha",
"highlight": false,
"params": [
{
"id": "alpha",
"type": "number"
},
{
"id": "track-index",
"type": "number"
}
]
},
{
"id": "set-track-mix-blend",
"scriptName": "SetTrackMixBlend",
"highlight": false,
"params": [
{
"id": "mix-blend",
"type": "combo",
"items": ["setup", "first", "replace", "add"]
},
{
"id": "track-index",
"type": "number"
}
]
},
{
"id": "set-slot-color",
"scriptName": "SetSlotColor",

View File

@ -73,6 +73,14 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Acts =
this.setSkeletonColor(color);
},
SetTrackAlpha (this: SDKInstanceClass, alpha: number, trackIndex: number) {
this.setTrackAlpha(alpha, trackIndex);
},
SetTrackMixBlend (this: SDKInstanceClass, mixBlend: 0 | 1 | 2 | 3, trackIndex: number) {
this.setTrackMixBlend(mixBlend, trackIndex);
},
SetSlotColor (this: SDKInstanceClass, slotName: string, color: string) {
this.setSlotColor(slotName, color);
},

View File

@ -1,4 +1,4 @@
import type { AnimationState, AnimationStateListener, AssetLoader, Event, Skeleton, SkeletonRendererCore, Skin, TextureAtlas, } from "@esotericsoftware/spine-construct3-lib";
import { type AnimationState, type AnimationStateListener, type AssetLoader, type Event, MathUtils, type Skeleton, type SkeletonRendererCore, type Skin, type TextureAtlas, } from "@esotericsoftware/spine-construct3-lib";
const C3 = globalThis.C3;
const spine = globalThis.spine;
@ -281,6 +281,44 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
skeleton.color.setFromString(color);
}
public setTrackAlpha (alpha: number, trackIndex: number) {
const { state } = this;
if (!state) {
console.warn('[Spine] setAlpha: no state');
return;
}
const track = state.tracks[trackIndex];
if (!track) {
console.warn(`[Spine] setAlpha: track ${trackIndex} not found`);
return;
}
track.alpha = MathUtils.clamp(0, 1, alpha);
}
public setTrackMixBlend (mixBlend: 0 | 1 | 2 | 3, trackIndex: number) {
const { state } = this;
if (!state) {
console.warn('[Spine] setMixBlend: no state');
return;
}
const track = state.tracks[trackIndex];
if (!track) {
console.warn(`[Spine] setMixBlend: track ${trackIndex} not found`);
return;
}
switch (mixBlend) {
case 0: track.mixBlend = spine.MixBlend.setup; break;
case 1: track.mixBlend = spine.MixBlend.first; break;
case 2: track.mixBlend = spine.MixBlend.replace; break;
case 3: track.mixBlend = spine.MixBlend.add; break;
default: console.warn('[Spine] Invalid mix blend mode:', mixBlend);
}
}
public setSlotColor (slotName: string, color: string) {
const { skeleton } = this;
if (!skeleton) {

View File

@ -343,6 +343,42 @@
}
}
},
"set-track-alpha": {
"list-name": "Set track alpha",
"display-text": "Set alpha {0} on track {1}",
"description": "Set the alpha/opacity of an animation track. Used for blending animations on different tracks.",
"params": {
"alpha": {
"name": "Alpha",
"desc": "Alpha value (0.0 to 1.0, where 0 is transparent and 1 is opaque)"
},
"track-index": {
"name": "Track index",
"desc": "Track index to set alpha for"
}
}
},
"set-track-mix-blend": {
"list-name": "Set track mix blend",
"display-text": "Set mix blend {0} on track {1}",
"description": "Set the mix blend mode for an animation track. Controls how animations are layered and combined.",
"params": {
"mix-blend": {
"name": "Mix blend",
"desc": "Mix blend mode",
"items": {
"setup": "Setup (transition to/from setup pose)",
"first": "First (for first animations applied)",
"replace": "Replace (for layered animations)",
"add": "Add (additive blending for layered animations)"
}
},
"track-index": {
"name": "Track index",
"desc": "Track index to set mix blend for"
}
}
},
"set-slot-color": {
"list-name": "Set slot color",
"display-text": "Set slot {0} color to {1}",

View File

@ -344,6 +344,42 @@
}
}
},
"set-track-alpha": {
"list-name": "设置轨道透明度",
"display-text": "在轨道{1}上设置透明度为{0}",
"description": "设置动画轨道的透明度/不透明度。用于混合不同轨道上的动画。",
"params": {
"alpha": {
"name": "透明度",
"desc": "透明度值0.0 到 1.0,其中 0 为完全透明1 为完全不透明)"
},
"track-index": {
"name": "轨道索引",
"desc": "要设置透明度的轨道索引"
}
}
},
"set-track-mix-blend": {
"list-name": "设置轨道混合模式",
"display-text": "在轨道{1}上设置混合模式为{0}",
"description": "设置动画轨道的混合模式。控制动画如何分层和组合。",
"params": {
"mix-blend": {
"name": "混合模式",
"desc": "混合模式",
"items": {
"setup": "设置(过渡到/从设置姿势)",
"first": "首次(用于首次应用的动画)",
"replace": "替换(用于分层动画)",
"add": "叠加(用于分层动画的叠加混合)"
}
},
"track-index": {
"name": "轨道索引",
"desc": "要设置混合模式的轨道索引"
}
}
},
"set-slot-color": {
"list-name": "设置插槽颜色",
"display-text": "设置插槽{0}的颜色为{1}",