Pull addAnimation from #2949.

This commit is contained in:
Davide Tantillo 2025-11-03 12:42:05 +01:00
parent 19396f435c
commit 281d36e634
8 changed files with 105 additions and 33 deletions

View File

@ -61,9 +61,11 @@ export class AssetLoader {
const blob = projectFile.GetBlob();
const content = await blob.text();
const path = projectFile.GetPath();
const basePath = path.substring(0, path.lastIndexOf("/") + 1);
const textureAtlas = new TextureAtlas(content);
await Promise.all(textureAtlas.pages.map(async page => {
const texture = await this.loadSpineTextureEditor(page.name, page.pma, instance);
const texture = await this.loadSpineTextureEditor(basePath + page.name, page.pma, instance);
if (texture) {
const spineTexture = new C3TextureEditor(texture, renderer, page);
page.setTexture(spineTexture);
@ -112,9 +114,10 @@ export class AssetLoader {
const content = await instance.assets.fetchText(fullPath);
if (!content) return null;
const basePath = path.substring(0, path.lastIndexOf("/") + 1);
const textureAtlas = new TextureAtlas(content);
await Promise.all(textureAtlas.pages.map(async page => {
const texture = await this.loadSpineTextureRuntime(page.name, page.pma, instance);
const texture = await this.loadSpineTextureRuntime(basePath + page.name, page.pma, instance);
if (texture) {
const spineTexture = new C3Texture(texture, renderer, page);
page.setTexture(spineTexture);

View File

@ -31,11 +31,6 @@
}
],
"actions": [
{
"id": "do-alert",
"scriptName": "Alert",
"highlight": true
},
{
"id": "set-skin",
"scriptName": "SetSkin",
@ -50,7 +45,7 @@
{
"id": "set-animation",
"scriptName": "SetAnimation",
"highlight": false,
"highlight": true,
"params": [
{
"id": "track",
@ -65,6 +60,29 @@
"type": "boolean"
}
]
},
{
"id": "add-animation",
"scriptName": "AddAnimation",
"highlight": true,
"params": [
{
"id": "track",
"type": "number"
},
{
"id": "animation",
"type": "string"
},
{
"id": "loop",
"type": "boolean"
},
{
"id": "delay",
"type": "number"
}
]
}
],
"expressions": [

View File

@ -15,6 +15,10 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Acts =
SetAnimation (this: SDKInstanceClass, track: number, animation: string, loop = false) {
this.setAnimation(track, animation, loop);
},
AddAnimation (this: SDKInstanceClass, track: number, animation: string, loop = false, delay = 0) {
this.addAnimation(track, animation, loop, delay);
}
};

View File

@ -144,6 +144,32 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
}
}
public addAnimation (track: number, animation: string, loop = false, delay = 0) {
const trackEntry = this.state?.addAnimation(track, animation, loop, delay);
if (!trackEntry) return;
trackEntry.listener = {
start: () => {
this.triggetAnimationEvent("start", track, animation);
},
dispose: () => {
this.triggetAnimationEvent("dispose", track, animation);
},
event: (_, event) => {
this.triggetAnimationEvent("event", track, animation, event);
},
interrupt: () => {
this.triggetAnimationEvent("interrupt", track, animation);
},
end: () => {
this.triggetAnimationEvent("end", track, animation);
},
complete: () => {
this.triggetAnimationEvent("complete", track, animation);
},
}
}
public setSkin (skins: string[]) {
this.propSkin = skins;
this._setSkin();

View File

@ -61,7 +61,6 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
OnCreate () {
this._inst.SetPropertyValue(PLUGIN_CLASS.PROP_BOUNDS_PROVIDER_MOVE, false);
this._inst.GetPropertyValue(PLUGIN_CLASS.PROP_SKELETON) as number;
}
OnPlacedInLayout () {

View File

@ -135,6 +135,29 @@
"desc": "loop"
}
}
},
"add-animation": {
"list-name": "Add animation",
"display-text": "Add animation {1} on track {0} with loop {2} and delay {3}",
"description": "Add animation",
"params": {
"track": {
"name": "track",
"desc": "track"
},
"animation": {
"name": "animations name",
"desc": "animations name"
},
"loop": {
"name": "loop",
"desc": "loop"
},
"delay": {
"name": "delay",
"desc": "delay"
}
}
}
},
"expressions": {

View File

@ -117,29 +117,6 @@
}
}
},
"add-animation": {
"list-name": "添加动画",
"display-text": "在轨道{0}上添加动画{1},循环{2},延迟{3}",
"description": "添加动画",
"params": {
"track": {
"name": "轨道",
"desc": "轨道"
},
"animation": {
"name": "动画名称",
"desc": "动画名称"
},
"loop": {
"name": "循环",
"desc": "循环"
},
"delay": {
"name": "延迟",
"desc": "延迟"
}
}
},
"set-animation": {
"list-name": "设置动画",
"display-text": "在轨道{0}上设置动画{1},循环{2}",
@ -160,6 +137,29 @@
}
}
},
"add-animation": {
"list-name": "添加动画",
"display-text": "在轨道{0}上添加动画{1},循环{2},延迟{3}",
"description": "添加动画",
"params": {
"track": {
"name": "轨道",
"desc": "轨道"
},
"animation": {
"name": "动画名称",
"desc": "动画名称"
},
"loop": {
"name": "循环",
"desc": "循环"
},
"delay": {
"name": "延迟",
"desc": "延迟"
}
}
},
"expressions": {
"double": {
"description": "将数字翻倍。",

File diff suppressed because one or more lines are too long