Merge branch '4.2' into 4.3-beta

# Conflicts:
#	spine-unity/Assets/Spine/package.json
This commit is contained in:
Nathan Sweet 2025-04-30 17:29:49 -04:00
commit 020cd51b96
23 changed files with 451 additions and 120 deletions

View File

@ -26,7 +26,7 @@ runs:
python -m pip install scons==4.7.0
scons --version
- name: Setup dotnet 6
- name: Setup dotnet 8
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
dotnet-version: '8.0.x'

View File

@ -251,7 +251,7 @@ Ref<Animation> SpineAnimationTrack::create_animation(spine::Animation *animation
Ref<Animation> animation_ref;
INSTANTIATE(animation_ref);
String name;
name.parse_utf8(animation.getName().buffer());
name.parse_utf8(animation->getName().buffer());
animation_ref->set_name(name + (loop ? "" : "_looped"));
#if VERSION_MAJOR > 3
// animation_ref->set_loop(!loop);

View File

@ -62,10 +62,9 @@ class GodotSpineTextureLoader : public spine::TextureLoader {
Array *textures;
Array *normal_maps;
String normal_map_prefix;
bool is_importing;
public:
GodotSpineTextureLoader(Array *_textures, Array *_normal_maps, const String &normal_map_prefix, bool is_importing) : textures(_textures), normal_maps(_normal_maps), normal_map_prefix(normal_map_prefix), is_importing(is_importing) {
GodotSpineTextureLoader(Array *_textures, Array *_normal_maps, const String &normal_map_prefix, bool is_importing) : textures(_textures), normal_maps(_normal_maps), normal_map_prefix(normal_map_prefix) {
}
static bool fix_path(String &path) {

View File

@ -434,6 +434,9 @@ void SpineSprite::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_screen_material", "material"), &SpineSprite::set_screen_material);
ClassDB::bind_method(D_METHOD("get_screen_material"), &SpineSprite::get_screen_material);
ClassDB::bind_method(D_METHOD("get_time_scale"), &SpineSprite::get_time_scale);
ClassDB::bind_method(D_METHOD("set_time_scale", "v"), &SpineSprite::set_time_scale);
ClassDB::bind_method(D_METHOD("set_debug_root", "v"), &SpineSprite::set_debug_root);
ClassDB::bind_method(D_METHOD("get_debug_root"), &SpineSprite::get_debug_root);
ClassDB::bind_method(D_METHOD("set_debug_root_color", "v"), &SpineSprite::set_debug_root_color);
@ -509,7 +512,7 @@ void SpineSprite::_bind_methods() {
// Filled in in _get_property_list()
}
SpineSprite::SpineSprite() : update_mode(SpineConstant::UpdateMode_Process), preview_skin("Default"), preview_animation("-- Empty --"), preview_frame(false), preview_time(0), skeleton_clipper(nullptr), modified_bones(false) {
SpineSprite::SpineSprite() : update_mode(SpineConstant::UpdateMode_Process), time_scale(1.0), preview_skin("Default"), preview_animation("-- Empty --"), preview_frame(false), preview_time(0), skeleton_clipper(nullptr), modified_bones(false) {
skeleton_clipper = new spine::SkeletonClipping();
auto statics = SpineSpriteStatics::instance();
@ -817,12 +820,12 @@ void SpineSprite::update_skeleton(float delta) {
return;
emit_signal(SNAME("before_animation_state_update"), this);
animation_state->update(delta);
animation_state->update(delta * time_scale);
if (!is_visible_in_tree()) return;
emit_signal(SNAME("before_animation_state_apply"), this);
animation_state->apply(skeleton);
emit_signal(SNAME("before_world_transforms_change"), this);
skeleton->update(delta);
skeleton->update(delta * time_scale);
skeleton->update_world_transform(SpineConstant::Physics_Update);
modified_bones = false;
emit_signal(SNAME("world_transforms_changed"), this);
@ -1401,6 +1404,14 @@ void SpineSprite::set_screen_material(Ref<Material> material) {
screen_material = material;
}
void SpineSprite::set_time_scale(float time_scale) {
this->time_scale = time_scale;
}
float SpineSprite::get_time_scale() {
return time_scale;
}
#ifndef SPINE_GODOT_EXTENSION
// FIXME
#ifdef TOOLS_ENABLED

View File

@ -141,6 +141,7 @@ protected:
Ref<SpineSkeleton> skeleton;
Ref<SpineAnimationState> animation_state;
SpineConstant::UpdateMode update_mode;
float time_scale;
String preview_skin;
String preview_animation;
@ -230,6 +231,10 @@ public:
void set_screen_material(Ref<Material> material);
void set_time_scale(float time_scale);
float get_time_scale();
bool get_debug_root() { return debug_root; }
void set_debug_root(bool root) { debug_root = root; }

View File

@ -43,6 +43,7 @@
<li><a href="/spine-pixi-v8/example/physics3.html">Physics III</a> - (<a href="/spine-pixi-v7/example/physics3.html">v7</a>)</li>
<li><a href="/spine-pixi-v8/example/physics4.html">Physics IV</a> - (<a href="/spine-pixi-v7/example/physics4.html">v7</a>)</li>
<li><a href="/spine-pixi-v8/example/slot-objects.html">Slot Objects</a> - (<a href="/spine-pixi-v7/example/slot-objects.html">v7</a>)</li>
<li><a href="/spine-pixi-v8/example/slot-objects-scale-rotation.html">Slot Objects (Rotation, scale test)</a> - (<a href="/spine-pixi-v7/example/slot-objects-scale-rotation.html">v7</a>)</li>
<li><a href="/spine-pixi-v8/example/bounds.html">Bounds</a> - (<a href="/spine-pixi-v7/example/bounds.html">v7</a>)</li>
<li><a href="/spine-pixi-v8/example/bunnymark.html?count=500&renderer=webgpu">Bunny Mark</a> - (<a href="/spine-pixi-v7/example/bunnymark.html?count=500">v7</a>)</li>
</ul>

View File

@ -1,12 +1,12 @@
{
"name": "@esotericsoftware/spine-ts",
"version": "4.2.79",
"version": "4.2.80",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@esotericsoftware/spine-ts",
"version": "4.2.79",
"version": "4.2.80",
"license": "LicenseRef-LICENSE",
"workspaces": [
"spine-core",
@ -3244,18 +3244,18 @@
},
"spine-canvas": {
"name": "@esotericsoftware/spine-canvas",
"version": "4.2.79",
"version": "4.2.80",
"license": "LicenseRef-LICENSE",
"dependencies": {
"@esotericsoftware/spine-core": "4.2.79"
"@esotericsoftware/spine-core": "4.2.80"
}
},
"spine-canvaskit": {
"name": "@esotericsoftware/spine-canvaskit",
"version": "4.2.79",
"version": "4.2.80",
"license": "LicenseRef-LICENSE",
"dependencies": {
"@esotericsoftware/spine-core": "4.2.79",
"@esotericsoftware/spine-core": "4.2.80",
"canvaskit-wasm": "0.39.1"
},
"devDependencies": {
@ -3265,17 +3265,17 @@
},
"spine-core": {
"name": "@esotericsoftware/spine-core",
"version": "4.2.79",
"version": "4.2.80",
"license": "LicenseRef-LICENSE"
},
"spine-phaser-v3": {
"name": "@esotericsoftware/spine-phaser-v3",
"version": "4.2.79",
"version": "4.2.80",
"license": "LicenseRef-LICENSE",
"dependencies": {
"@esotericsoftware/spine-canvas": "4.2.79",
"@esotericsoftware/spine-core": "4.2.79",
"@esotericsoftware/spine-webgl": "4.2.79"
"@esotericsoftware/spine-canvas": "4.2.80",
"@esotericsoftware/spine-core": "4.2.80",
"@esotericsoftware/spine-webgl": "4.2.80"
},
"devDependencies": {
"phaser": "^3.60.0"
@ -3299,12 +3299,12 @@
},
"spine-phaser-v4": {
"name": "@esotericsoftware/spine-phaser-v4",
"version": "4.2.79",
"version": "4.2.80",
"license": "LicenseRef-LICENSE",
"dependencies": {
"@esotericsoftware/spine-canvas": "4.2.79",
"@esotericsoftware/spine-core": "4.2.79",
"@esotericsoftware/spine-webgl": "4.2.79"
"@esotericsoftware/spine-canvas": "4.2.80",
"@esotericsoftware/spine-core": "4.2.80",
"@esotericsoftware/spine-webgl": "4.2.80"
},
"devDependencies": {
"phaser": "^4.0.0-rc.1"
@ -3315,10 +3315,10 @@
},
"spine-pixi-v7": {
"name": "@esotericsoftware/spine-pixi-v7",
"version": "4.2.79",
"version": "4.2.80",
"license": "LicenseRef-LICENSE",
"dependencies": {
"@esotericsoftware/spine-core": "4.2.79"
"@esotericsoftware/spine-core": "4.2.80"
},
"peerDependencies": {
"@pixi/assets": "^7.2.4",
@ -3332,10 +3332,10 @@
},
"spine-pixi-v8": {
"name": "@esotericsoftware/spine-pixi-v8",
"version": "4.2.79",
"version": "4.2.80",
"license": "LicenseRef-LICENSE",
"dependencies": {
"@esotericsoftware/spine-core": "4.2.79"
"@esotericsoftware/spine-core": "4.2.80"
},
"peerDependencies": {
"pixi.js": "^8.4.0"
@ -3343,18 +3343,18 @@
},
"spine-player": {
"name": "@esotericsoftware/spine-player",
"version": "4.2.79",
"version": "4.2.80",
"license": "LicenseRef-LICENSE",
"dependencies": {
"@esotericsoftware/spine-webgl": "4.2.79"
"@esotericsoftware/spine-webgl": "4.2.80"
}
},
"spine-threejs": {
"name": "@esotericsoftware/spine-threejs",
"version": "4.2.79",
"version": "4.2.80",
"license": "LicenseRef-LICENSE",
"dependencies": {
"@esotericsoftware/spine-core": "4.2.79"
"@esotericsoftware/spine-core": "4.2.80"
},
"devDependencies": {
"@types/three": "0.162.0"
@ -3365,10 +3365,10 @@
},
"spine-webgl": {
"name": "@esotericsoftware/spine-webgl",
"version": "4.2.79",
"version": "4.2.80",
"license": "LicenseRef-LICENSE",
"dependencies": {
"@esotericsoftware/spine-core": "4.2.79"
"@esotericsoftware/spine-core": "4.2.80"
}
}
}

View File

@ -1,6 +1,6 @@
{
"name": "@esotericsoftware/spine-ts",
"version": "4.2.79",
"version": "4.2.80",
"description": "The official Spine Runtimes for the web.",
"type": "module",
"files": [

View File

@ -1,6 +1,6 @@
{
"name": "@esotericsoftware/spine-canvas",
"version": "4.2.79",
"version": "4.2.80",
"description": "The official Spine Runtimes for the web.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@ -31,6 +31,6 @@
},
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
"dependencies": {
"@esotericsoftware/spine-core": "4.2.79"
"@esotericsoftware/spine-core": "4.2.80"
}
}

View File

@ -1,6 +1,6 @@
{
"name": "@esotericsoftware/spine-canvaskit",
"version": "4.2.79",
"version": "4.2.80",
"description": "The official Spine Runtimes for CanvasKit for NodeJS",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@ -31,7 +31,7 @@
},
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
"dependencies": {
"@esotericsoftware/spine-core": "4.2.79",
"@esotericsoftware/spine-core": "4.2.80",
"canvaskit-wasm": "0.39.1"
},
"devDependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "@esotericsoftware/spine-core",
"version": "4.2.79",
"version": "4.2.80",
"description": "The official Spine Runtimes for the web.",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View File

@ -1,6 +1,6 @@
{
"name": "@esotericsoftware/spine-phaser-v3",
"version": "4.2.79",
"version": "4.2.80",
"description": "The official Spine Runtimes for the Phaser v3.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@ -31,9 +31,9 @@
},
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
"dependencies": {
"@esotericsoftware/spine-canvas": "4.2.79",
"@esotericsoftware/spine-core": "4.2.79",
"@esotericsoftware/spine-webgl": "4.2.79"
"@esotericsoftware/spine-canvas": "4.2.80",
"@esotericsoftware/spine-core": "4.2.80",
"@esotericsoftware/spine-webgl": "4.2.80"
},
"devDependencies": {
"phaser": "^3.60.0"

View File

@ -1,6 +1,6 @@
{
"name": "@esotericsoftware/spine-phaser-v4",
"version": "4.2.79",
"version": "4.2.80",
"description": "The official Spine Runtimes for the Phaser v4.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@ -31,9 +31,9 @@
},
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
"dependencies": {
"@esotericsoftware/spine-canvas": "4.2.79",
"@esotericsoftware/spine-core": "4.2.79",
"@esotericsoftware/spine-webgl": "4.2.79"
"@esotericsoftware/spine-canvas": "4.2.80",
"@esotericsoftware/spine-core": "4.2.80",
"@esotericsoftware/spine-webgl": "4.2.80"
},
"devDependencies": {
"phaser": "^4.0.0-rc.1"

View File

@ -0,0 +1,130 @@
<html>
<head>
<meta charset="UTF-8" />
<title>spine-pixi</title>
<script src="https://cdn.jsdelivr.net/npm/pixi.js@7.4.2/dist/pixi.min.js"></script>
<script src="../dist/iife/spine-pixi-v7.js"></script>
<script src="https://cdn.jsdelivr.net/npm/tweakpane@3.1.9/dist/tweakpane.min.js"></script>
<link rel="stylesheet" href="../../index.css">
<script src="https://cdn.jsdelivr.net/npm/lil-gui@0.20.0/dist/lil-gui.umd.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/lil-gui@0.20.0/dist/lil-gui.min.css" rel="stylesheet">
</head>
<body>
<script>
(async function () {
await Promise.resolve();
var app = new PIXI.Application({
width: window.innerWidth,
height: window.innerHeight,
resolution: window.devicePixelRatio || 1,
autoDensity: true,
resizeTo: window,
backgroundColor: 0x2c3e50,
hello: true,
});
document.body.appendChild(app.view);
// adding skeleton to cache
PIXI.Assets.cache.set("jsonSkel", jsonSkel);
// adding texture atlas to cache and loading the respective texture page
const textureAtlas = new spine.TextureAtlas(txtAtlas);
const texturePng = await PIXI.Assets.load(slotPng);
textureAtlas.pages[0].setTexture(spine.SpineTexture.from(texturePng.baseTexture));
PIXI.Assets.cache.set("spineboyAtlas", textureAtlas);
// creating spine game object
const spineGO = spine.Spine.from({skeleton: "jsonSkel", atlas: "spineboyAtlas" });
spineGO.position.set(300, 300);
app.stage.addChild(spineGO);
// creating slot object
const container = new PIXI.Container();
const sprite = await PIXI.Sprite.from(texturePng);
sprite.anchor.x = 0.5;
sprite.anchor.y = 0.5;
sprite.tint = 0x00ff00
container.addChild(sprite);
spineGO.addSlotObject("replaceMe", container);
// adding controls
const parentBone = spineGO.skeleton.findBone("pivot");
const parent2Bone = spineGO.skeleton.findBone("pivot2");
const bone = spineGO.skeleton.findBone("replaceMe");
const myObject = {
parentScaleX: 1, parentScaleY: 1, parentRotation: 0,
parent2ScaleX: 1, parent2ScaleY: 1, parent2Rotation: 0,
scaleX: 1, scaleY: 1, rotation: 0,
};
const gui = new lil.GUI({});
gui.add(myObject, 'parentScaleX').min(-3).max(3).step(0.1).name('parentScaleX').onChange(value => parentBone.scaleX = value);
gui.add(myObject, 'parentScaleY').min(-3).max(3).step(0.1).name('parentScaleY').onChange(value => parentBone.scaleY = value);
gui.add(myObject, 'parentRotation').min(-180).max(180).step(1).name('parentRotation').onChange(value => parentBone.rotation = value);
gui.add(myObject, 'parent2ScaleX').min(-3).max(3).step(0.1).name('parent2ScaleX').onChange(value => parent2Bone.scaleX = value);
gui.add(myObject, 'parent2ScaleY').min(-3).max(3).step(0.1).name('parent2ScaleY').onChange(value => parent2Bone.scaleY = value);
gui.add(myObject, 'parent2Rotation').min(-180).max(180).step(1).name('parent2Rotation').onChange(value => parent2Bone.rotation = value);
gui.add(myObject, 'scaleX').min(-3).max(3).step(0.1).name('scaleX').onChange(value => bone.scaleX = value);
gui.add(myObject, 'scaleY').min(-3).max(3).step(0.1).name('scaleY').onChange(value => bone.scaleY = value);
gui.add(myObject, 'rotation').min(-180).max(180).step(1).name('rotation').onChange(value => bone.rotation = value);
// add instructions
const basicText = new PIXI.Text(
"This example shows that slot objects follow scale and rotation from ancestors too, but if a rotation on a bone occurs scale won't work anymore on ancestors.",
{ fontSize: 20, fill: "white", wordWrap: true, wordWrapWidth: 300 }
);
basicText.position.set(10, 10);
basicText.anchor.set(0, 0);
app.stage.addChild(basicText);
})();
const jsonSkel = {
"bones": [
{ "name": "root" },
{ "name": "pivot", "parent": "root",
"scaleX": 1,
"scaleY": 1,
"rotation": 0,
"x": 20,
"y": -20
},
{
"name": "pivot2", "parent": "pivot",
"scaleX": 1,
"scaleY": 1,
"rotation": 0,
"x": 20,
"y": -20
},
{
"name": "replaceMe", "parent": "pivot2",
"scaleX": 1,
"scaleY": 1,
"rotation": 0,
"x": 20,
"y": -20
}
],
"slots": [{ "name": "replaceMe", "bone": "replaceMe", "attachment": "image" }],
"skins": [{ "name": "default", "attachments": { "replaceMe": { "image": { "width": 100, "height": 100 } } }}],
"animations": { "animation": {} }
}
const txtAtlas =
`skeleton.png
size:100,100
filter:Linear,Linear
image
bounds:0,0,100,100`;
const slotPng = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAABaZJREFUeJzt2ssrfFEcAPDxfuSR8khSysIzC/kDRB4RssAGJUVZEBuU+FqwURSKJSnKhqyklIVSVhbIhkReCXm/+fW9NdPcuZp753fn3vM9d4769us35p75nu9nzuOey/b7+wsi6ISNdQIiBAjpECDEQoAQC+5BbDabI1jn4vMgzhhWQeEW5C8MK6BwCeIOg3cUAUIsuAPRgsEzClcgnmDwisINiFrRrYLCBYjWYlsBhWsQve+lGORB/qfAPKOQBtFTWF5RyILoXQ94X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vdwGLm5udIJiAAxGQQX7ZaWFsXRE75eV1cHz8/P3gHBfXN3dzf09fU5YnBwEObm5qTDSD3PTKwGYq+T6x08LupDQ0Oaj6BkIJmZmW7nRXvgmUxJSYnqTY4vgfT29sLDwwOUlZUp2gwPD4elpSVNX2AHCB6MFRUVaQLBCAkJ0fwhVgPZ39+HsLAwGQj+4O9w5sjIyFC0i08PDw8PtYNgYWdnZyE0NFQTCD6yXFtb80kQPEJPSUlxXIOjZWFhwVFHPNHF6d65XUTDZ+1qjzNszv95fX2F8fFxaerCfTTi4EjAD7QHvoba+PDq/v7e9GJQAMHpfWxsDBISEqQvZk1NjfQHDc7vmZ+fV+zE8IxL7eTD5voCCuOuAD8AhxgOT5wz7YHHBniSiafDLIpBAQQDa4T3GRsbG3B1daWYKbDwzc3NjqeHiIMbIs1PDHkqBi854HEJ/pSWlko7MLWnhQLEhBxwROCfAWm9nxMgjHMQIMRyECDEchAgxHIQIMRyIA1CIQQIsRAgxMJnQaii+DQIRRTm9WCdgAgBQjoECLEQIMRCgBALAUIsBAixECDEQoAQi3/zZahFP7nPdgAAAABJRU5ErkJggg==";
</script>
</body>
</html>

View File

@ -1,6 +1,6 @@
{
"name": "@esotericsoftware/spine-pixi-v7",
"version": "4.2.79",
"version": "4.2.80",
"description": "The official Spine Runtimes for the web PixiJS v7.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@ -31,7 +31,7 @@
},
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
"dependencies": {
"@esotericsoftware/spine-core": "4.2.79"
"@esotericsoftware/spine-core": "4.2.80"
},
"peerDependencies": {
"@pixi/core": "^7.2.4",

View File

@ -34,7 +34,6 @@ import {
AtlasAttachmentLoader,
ClippingAttachment,
Color,
MathUtils,
MeshAttachment,
Physics,
RegionAttachment,
@ -52,7 +51,7 @@ import { SlotMesh } from "./SlotMesh.js";
import { DarkSlotMesh } from "./DarkSlotMesh.js";
import type { ISpineDebugRenderer, SpineDebugRenderer } from "./SpineDebugRenderer.js";
import { Assets } from "@pixi/assets";
import { IPointData, Point, Rectangle } from "@pixi/core";
import { IPointData, Point } from "@pixi/core";
import { Ticker } from "@pixi/core";
import type { IDestroyOptions, DisplayObject } from "@pixi/display";
import { Bounds, Container } from "@pixi/display";
@ -593,8 +592,24 @@ export class Spine extends Container {
if (slotObject.visible) {
slotObject.position.set(slot.bone.worldX, slot.bone.worldY);
slotObject.scale.set(slot.bone.getWorldScaleX(), slot.bone.getWorldScaleY());
slotObject.rotation = slot.bone.getWorldRotationX() * MathUtils.degRad;
slotObject.angle = slot.bone.getWorldRotationX();
let bone: Bone | null = slot.bone;
let cumulativeScaleX = 1;
let cumulativeScaleY = 1;
while (bone) {
cumulativeScaleX *= bone.scaleX;
cumulativeScaleY *= bone.scaleY;
bone = bone.parent;
};
if (cumulativeScaleX < 0) slotObject.angle -= 180;
slotObject.scale.set(
slot.bone.getWorldScaleX() * Math.sign(cumulativeScaleX),
slot.bone.getWorldScaleY() * Math.sign(cumulativeScaleY),
);
slotObject.zIndex = zIndex + 1;
slotObject.alpha = this.skeleton.color.a * slot.color.a;
}

View File

@ -0,0 +1,126 @@
<html>
<head>
<meta charset="UTF-8" />
<title>spine-pixi</title>
<script src="https://cdn.jsdelivr.net/npm/pixi.js@8/dist/pixi.min.js"></script>
<script src="../dist/iife/spine-pixi-v8.js"></script>
<script src="https://cdn.jsdelivr.net/npm/tweakpane@3.1.9/dist/tweakpane.min.js"></script>
<link rel="stylesheet" href="../../index.css">
<script src="https://cdn.jsdelivr.net/npm/lil-gui@0.20.0/dist/lil-gui.umd.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/lil-gui@0.20.0/dist/lil-gui.min.css" rel="stylesheet">
</head>
<body>
<script>
(async function () {
var app = new PIXI.Application();
await app.init({
width: window.innerWidth,
height: window.innerHeight,
resolution: window.devicePixelRatio || 1,
autoDensity: true,
resizeTo: window,
backgroundColor: 0x2c3e50,
hello: true,
})
document.body.appendChild(app.view);
// adding skeleton to cache
PIXI.Assets.cache.set("jsonSkel", jsonSkel);
// adding texture atlas to cache and loading the respective texture page
const textureAtlas = new spine.TextureAtlas(txtAtlas);
const texturePng = await PIXI.Assets.load(slotPng);
textureAtlas.pages[0].setTexture(spine.SpineTexture.from(texturePng.source));
PIXI.Assets.cache.set("spineboyAtlas", textureAtlas);
// creating spine game object
const spineGO = spine.Spine.from({skeleton: "jsonSkel", atlas: "spineboyAtlas" });
spineGO.position.set(300, 300);
app.stage.addChild(spineGO);
// creating slot object
const container = new PIXI.Container();
const sprite = await PIXI.Sprite.from(texturePng);
sprite.anchor.x = 0.5;
sprite.anchor.y = 0.5;
sprite.tint = 0x00ff00
container.addChild(sprite);
spineGO.addSlotObject("replaceMe", container);
// adding controls
const parentBone = spineGO.skeleton.findBone("pivot");
const parent2Bone = spineGO.skeleton.findBone("pivot2");
const bone = spineGO.skeleton.findBone("replaceMe");
const myObject = {
parentScaleX: 1, parentScaleY: 1, parentRotation: 0,
parent2ScaleX: 1, parent2ScaleY: 1, parent2Rotation: 0,
scaleX: 1, scaleY: 1, rotation: 0,
};
const gui = new lil.GUI({});
gui.add(myObject, 'parentScaleX').min(-3).max(3).step(0.1).name('parentScaleX').onChange(value => parentBone.scaleX = value);
gui.add(myObject, 'parentScaleY').min(-3).max(3).step(0.1).name('parentScaleY').onChange(value => parentBone.scaleY = value);
gui.add(myObject, 'parentRotation').min(-180).max(180).step(1).name('parentRotation').onChange(value => parentBone.rotation = value);
gui.add(myObject, 'parent2ScaleX').min(-3).max(3).step(0.1).name('parent2ScaleX').onChange(value => parent2Bone.scaleX = value);
gui.add(myObject, 'parent2ScaleY').min(-3).max(3).step(0.1).name('parent2ScaleY').onChange(value => parent2Bone.scaleY = value);
gui.add(myObject, 'parent2Rotation').min(-180).max(180).step(1).name('parent2Rotation').onChange(value => parent2Bone.rotation = value);
gui.add(myObject, 'scaleX').min(-3).max(3).step(0.1).name('scaleX').onChange(value => bone.scaleX = value);
gui.add(myObject, 'scaleY').min(-3).max(3).step(0.1).name('scaleY').onChange(value => bone.scaleY = value);
gui.add(myObject, 'rotation').min(-180).max(180).step(1).name('rotation').onChange(value => bone.rotation = value);
// add instructions
const basicText = new PIXI.Text({
text: "This example shows that slot objects follow scale and rotation from ancestors too, but if a rotation on a bone occurs scale won't work anymore on ancestors.",
style: { fontSize: 20, fill: "white", wordWrap: true, wordWrapWidth: 300 }
});
basicText.position.set(10, 10);
basicText.anchor.set(0, 0);
app.stage.addChild(basicText);
})();
const jsonSkel = {
"bones": [
{ "name": "root" },
{ "name": "pivot", "parent": "root",
"scaleX": 1,
"scaleY": 1,
"rotation": 0,
"x": 20,
"y": -20
},
{
"name": "pivot2", "parent": "pivot",
"scaleX": 1,
"scaleY": 1,
"rotation": 0,
"x": 20,
"y": -20
},
{
"name": "replaceMe", "parent": "pivot2",
"scaleX": 1,
"scaleY": 1,
"rotation": 0,
"x": 20,
"y": -20
}
],
"slots": [{ "name": "replaceMe", "bone": "replaceMe", "attachment": "image" }],
"skins": [{ "name": "default", "attachments": { "replaceMe": { "image": { "width": 100, "height": 100 } } }}],
"animations": { "animation": {} }
}
const txtAtlas =
`skeleton.png
size:100,100
filter:Linear,Linear
image
bounds:0,0,100,100`;
const slotPng = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAABaZJREFUeJzt2ssrfFEcAPDxfuSR8khSysIzC/kDRB4RssAGJUVZEBuU+FqwURSKJSnKhqyklIVSVhbIhkReCXm/+fW9NdPcuZp753fn3vM9d4769us35p75nu9nzuOey/b7+wsi6ISNdQIiBAjpECDEQoAQC+5BbDabI1jn4vMgzhhWQeEW5C8MK6BwCeIOg3cUAUIsuAPRgsEzClcgnmDwisINiFrRrYLCBYjWYlsBhWsQve+lGORB/qfAPKOQBtFTWF5RyILoXQ94XU9IgnirmDyicAXCui2fBDGigDyhkAIxsnC8oJABMXq+52U9IQFiVrF4QGEO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YnBwEObm5qTDSD3PTKwGYq+T6x08LupDQ0Oaj6BkIJmZmW7nRXvgmUxJSYnqTY4vgfT29sLDwwOUlZUp2gwPD4elpSVNX2AHCB6MFRUVaQLBCAkJ0fwhVgPZ39+HsLAwGQj+4O9w5sjIyFC0i08PDw8PtYNgYWdnZyE0NFQTCD6yXFtb80kQPEJPSUlxXIOjZWFhwVFHPNHF6d65XUTDZ+1qjzNszv95fX2F8fFxaerCfTTi4EjAD7QHvoba+PDq/v7e9GJQAMHpfWxsDBISEqQvZk1NjfQHDc7vmZ+fV+zE8IxL7eTD5voCCuOuAD8AhxgOT5wz7YHHBniSiafDLIpBAQQDa4T3GRsbG3B1daWYKbDwzc3NjqeHiIMbIs1PDHkqBi854HEJ/pSWlko7MLWnhQLEhBxwROCfAWm9nxMgjHMQIMRyECDEchAgxHIQIMRyIA1CIQQIsRAgxMJnQaii+DQIRRTm9WCdgAgBQjoECLEQIMRCgBALAUIsBAixECDEQoAQi3/zZahFP7nPdgAAAABJRU5ErkJggg=="
</script>
</body>
</html>

View File

@ -1,6 +1,6 @@
{
"name": "@esotericsoftware/spine-pixi-v8",
"version": "4.2.79",
"version": "4.2.80",
"description": "The official Spine Runtimes for PixiJS v8.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@ -31,7 +31,7 @@
},
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
"dependencies": {
"@esotericsoftware/spine-core": "4.2.79"
"@esotericsoftware/spine-core": "4.2.80"
},
"peerDependencies": {
"pixi.js": "^8.4.0"

View File

@ -33,7 +33,6 @@ import {
Cache,
Container,
ContainerOptions,
DEG_TO_RAD,
DestroyOptions,
fastCopy,
Graphics,
@ -785,14 +784,25 @@ export class Spine extends ViewContainer {
container.visible = this.skeleton.drawOrder.includes(slot) && followAttachmentValue;
if (container.visible) {
const bone = slot.bone;
let bone: Bone | null = slot.bone;
container.position.set(bone.worldX, bone.worldY);
container.angle = bone.getWorldRotationX();
container.scale.x = bone.getWorldScaleX();
container.scale.y = bone.getWorldScaleY();
let cumulativeScaleX = 1;
let cumulativeScaleY = 1;
while (bone) {
cumulativeScaleX *= bone.scaleX;
cumulativeScaleY *= bone.scaleY;
bone = bone.parent;
};
container.rotation = bone.getWorldRotationX() * DEG_TO_RAD;
if (cumulativeScaleX < 0) container.angle -= 180;
container.scale.set(
slot.bone.getWorldScaleX() * Math.sign(cumulativeScaleX),
slot.bone.getWorldScaleY() * Math.sign(cumulativeScaleY),
);
container.alpha = this.skeleton.color.a * slot.color.a;
}

View File

@ -1,6 +1,6 @@
{
"name": "@esotericsoftware/spine-player",
"version": "4.2.79",
"version": "4.2.80",
"description": "The official Spine Runtimes for the web.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@ -31,6 +31,6 @@
},
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
"dependencies": {
"@esotericsoftware/spine-webgl": "4.2.79"
"@esotericsoftware/spine-webgl": "4.2.80"
}
}

View File

@ -1,6 +1,6 @@
{
"name": "@esotericsoftware/spine-threejs",
"version": "4.2.79",
"version": "4.2.80",
"description": "The official Spine Runtimes for the web.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@ -31,7 +31,7 @@
},
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
"dependencies": {
"@esotericsoftware/spine-core": "4.2.79"
"@esotericsoftware/spine-core": "4.2.80"
},
"devDependencies": {
"@types/three": "0.162.0"

View File

@ -1,6 +1,6 @@
{
"name": "@esotericsoftware/spine-webgl",
"version": "4.2.79",
"version": "4.2.80",
"description": "The official Spine Runtimes for the web.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@ -31,6 +31,6 @@
},
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
"dependencies": {
"@esotericsoftware/spine-core": "4.2.79"
"@esotericsoftware/spine-core": "4.2.80"
}
}

View File

@ -310,7 +310,6 @@ namespace Spine.Unity.Editor {
UnityEditor.EditorUtility.DisplayDialog("No parent SkeletonUtilityBone found!", "Please select the first physically moving chain node, having a parent GameObject with a SkeletonUtilityBone component attached.", "OK");
return;
}
float mass = 10;
const float rotationLimit = 20.0f;
@ -334,40 +333,55 @@ namespace Spine.Unity.Editor {
//followRotationComponent.reference = skeletonUtility.boneRoot;
// Follower Kinematic Rigidbody
GameObject followerKinematicObject = new GameObject(kinematicParentUtilityBone.name + " Follower");
followerKinematicObject.transform.parent = normalChainParentObject.transform;
Rigidbody2D followerRigidbody = followerKinematicObject.AddComponent<Rigidbody2D>();
GameObject rootFollowerKinematic = new GameObject(kinematicParentUtilityBone.name + " Follower");
rootFollowerKinematic.transform.parent = normalChainParentObject.transform;
Rigidbody2D followerRigidbody = rootFollowerKinematic.AddComponent<Rigidbody2D>();
followerRigidbody.mass = mass;
followerRigidbody.isKinematic = true;
followerKinematicObject.AddComponent<FollowLocationRigidbody2D>().reference = kinematicParentUtilityBone.transform;
followerKinematicObject.transform.position = kinematicParentUtilityBone.transform.position;
followerKinematicObject.transform.rotation = kinematicParentUtilityBone.transform.rotation;
rootFollowerKinematic.AddComponent<FollowLocationRigidbody2D>().reference = kinematicParentUtilityBone.transform;
rootFollowerKinematic.transform.position = kinematicParentUtilityBone.transform.position;
rootFollowerKinematic.transform.rotation = kinematicParentUtilityBone.transform.rotation;
// Child Bones
SkeletonUtilityBone[] utilityBones = utilityBone.GetComponentsInChildren<SkeletonUtilityBone>();
Transform childBoneParentReference = followerKinematicObject.transform;
for (int i = 0; i < utilityBones.Length; ++i) {
SkeletonUtilityBone childBone = utilityBones[i];
mass *= 0.75f;
childBone.parentReference = (i == 0) ? kinematicParentUtilityBone.transform : childBoneParentReference;
childBone.transform.SetParent(normalChainParentObject.transform, true); // we need a flat hierarchy of all Joint objects in Unity.
AttachRigidbodyAndCollider2D(childBone);
childBone.mode = SkeletonUtilityBone.Mode.Override;
childBone.scale = childBone.position = childBone.zPosition = false;
HingeJoint2D joint = childBone.gameObject.AddComponent<HingeJoint2D>();
joint.connectedBody = childBoneParentReference.GetComponent<Rigidbody2D>();
joint.useLimits = true;
ApplyJoint2DAngleLimits(joint, rotationLimit, childBoneParentReference, childBone.transform);
childBone.GetComponent<Rigidbody2D>().mass = mass;
childBoneParentReference = childBone.transform;
}
CreateHingeChain2D(utilityBone, mass, rotationLimit, normalChainParentObject.transform,
rootFollowerKinematic.transform, kinematicParentUtilityBone.transform);
Duplicate2DHierarchyForFlippedChains(normalChainParentObject, commonParentActivateOnFlip, skeletonUtility.transform, rotationLimit);
UnityEditor.Selection.activeGameObject = commonParentObject;
}
void CreateHingeChain2D (SkeletonUtilityBone bone, float mass, float rotationLimit, Transform groupObject,
Transform jointParent, Transform utilityParent) {
mass *= 0.75f;
bone.parentReference = utilityParent;
bone.transform.SetParent(groupObject, true); // we need a flat hierarchy of all Joint objects in Unity.
AttachRigidbodyAndCollider2D(bone);
bone.mode = SkeletonUtilityBone.Mode.Override;
bone.scale = bone.position = bone.zPosition = false;
HingeJoint2D joint = bone.gameObject.AddComponent<HingeJoint2D>();
joint.connectedBody = jointParent.GetComponent<Rigidbody2D>();
joint.useLimits = true;
ApplyJoint2DAngleLimits(joint, rotationLimit, jointParent, bone.transform);
bone.GetComponent<Rigidbody2D>().mass = mass;
Transform parent = bone.transform;
List<SkeletonUtilityBone> children = new List<SkeletonUtilityBone>();
int utilityChildCount = 0;
for (int i = 0; i < parent.childCount; ++i) {
var childUtilityBone = parent.GetChild(i).GetComponent<SkeletonUtilityBone>();
if (childUtilityBone != null)
children.Add(childUtilityBone);
}
mass /= Mathf.Max(1.0f, utilityChildCount);
for (int i = 0; i < children.Count; ++i) {
SkeletonUtilityBone childBone = children[i];
if (childBone == null) continue;
CreateHingeChain2D(childBone, mass, rotationLimit, groupObject, parent, parent);
}
}
void ApplyJoint2DAngleLimits (HingeJoint2D joint, float rotationLimit, Transform parentBone, Transform bone) {
#if HINGE_JOINT_NEW_BEHAVIOUR
float referenceAngle = (parentBone.eulerAngles.z - bone.eulerAngles.z + 360f) % 360f;
@ -452,6 +466,8 @@ namespace Spine.Unity.Editor {
UnityEditor.EditorUtility.DisplayDialog("No parent SkeletonUtilityBone found!", "Please select the first physically moving chain node, having a parent GameObject with a SkeletonUtilityBone component attached.", "OK");
return;
}
float mass = 10;
const float rotationLimit = 20.0f;
SetSkeletonUtilityToFlipByRotation();
@ -465,39 +481,57 @@ namespace Spine.Unity.Editor {
followRotationComponent.reference = skeletonUtility.boneRoot;
// Follower Kinematic Rigidbody
GameObject followerKinematicObject = new GameObject(kinematicParentUtilityBone.name + " Follower");
followerKinematicObject.transform.parent = chainParentObject.transform;
Rigidbody followerRigidbody = followerKinematicObject.AddComponent<Rigidbody>();
followerRigidbody.mass = 10;
GameObject rootFollowerKinematic = new GameObject(kinematicParentUtilityBone.name + " Follower");
rootFollowerKinematic.transform.parent = chainParentObject.transform;
Rigidbody followerRigidbody = rootFollowerKinematic.AddComponent<Rigidbody>();
followerRigidbody.mass = mass;
followerRigidbody.isKinematic = true;
followerKinematicObject.AddComponent<FollowLocationRigidbody>().reference = kinematicParentUtilityBone.transform;
followerKinematicObject.transform.position = kinematicParentUtilityBone.transform.position;
followerKinematicObject.transform.rotation = kinematicParentUtilityBone.transform.rotation;
rootFollowerKinematic.AddComponent<FollowLocationRigidbody>().reference = kinematicParentUtilityBone.transform;
rootFollowerKinematic.transform.position = kinematicParentUtilityBone.transform.position;
rootFollowerKinematic.transform.rotation = kinematicParentUtilityBone.transform.rotation;
// Child Bones
SkeletonUtilityBone[] utilityBones = utilityBone.GetComponentsInChildren<SkeletonUtilityBone>();
Transform childBoneParentReference = followerKinematicObject.transform;
foreach (SkeletonUtilityBone childBone in utilityBones) {
childBone.parentReference = childBoneParentReference;
childBone.transform.SetParent(chainParentObject.transform, true); // we need a flat hierarchy of all Joint objects in Unity.
AttachRigidbodyAndCollider(childBone);
childBone.mode = SkeletonUtilityBone.Mode.Override;
CreateHingeChain(utilityBone, mass, rotationLimit, chainParentObject.transform, rootFollowerKinematic.transform);
HingeJoint joint = childBone.gameObject.AddComponent<HingeJoint>();
joint.axis = Vector3.forward;
joint.connectedBody = childBoneParentReference.GetComponent<Rigidbody>();
joint.useLimits = true;
joint.limits = new JointLimits {
min = -20,
max = 20
};
childBone.GetComponent<Rigidbody>().mass = childBoneParentReference.transform.GetComponent<Rigidbody>().mass * 0.75f;
childBoneParentReference = childBone.transform;
}
UnityEditor.Selection.activeGameObject = chainParentObject;
}
void CreateHingeChain (SkeletonUtilityBone bone, float mass, float rotationLimit, Transform groupObject,
Transform jointParent) {
mass *= 0.75f;
bone.parentReference = jointParent;
bone.transform.SetParent(groupObject.transform, true); // we need a flat hierarchy of all Joint objects in Unity.
AttachRigidbodyAndCollider(bone);
bone.mode = SkeletonUtilityBone.Mode.Override;
HingeJoint joint = bone.gameObject.AddComponent<HingeJoint>();
joint.axis = Vector3.forward;
joint.connectedBody = jointParent.GetComponent<Rigidbody>();
joint.useLimits = true;
joint.limits = new JointLimits {
min = -rotationLimit,
max = rotationLimit
};
bone.GetComponent<Rigidbody>().mass = mass;
Transform parent = bone.transform;
List<SkeletonUtilityBone> children = new List<SkeletonUtilityBone>();
int utilityChildCount = 0;
for (int i = 0; i < parent.childCount; ++i) {
var childUtilityBone = parent.GetChild(i).GetComponent<SkeletonUtilityBone>();
if (childUtilityBone != null)
children.Add(childUtilityBone);
}
mass /= Mathf.Max(1.0f, utilityChildCount);
for (int i = 0; i < children.Count; ++i) {
SkeletonUtilityBone childBone = children[i];
if (childBone == null) continue;
CreateHingeChain(childBone, mass, rotationLimit, groupObject, parent);
}
}
void SetSkeletonUtilityToFlipByRotation () {
if (!skeletonUtility.flipBy180DegreeRotation) {
skeletonUtility.flipBy180DegreeRotation = true;