mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Merge branch '4.2' into 4.3-beta
# Conflicts: # spine-unity/Assets/Spine/package.json
This commit is contained in:
commit
020cd51b96
@ -26,7 +26,7 @@ runs:
|
|||||||
python -m pip install scons==4.7.0
|
python -m pip install scons==4.7.0
|
||||||
scons --version
|
scons --version
|
||||||
|
|
||||||
- name: Setup dotnet 6
|
- name: Setup dotnet 8
|
||||||
uses: actions/setup-dotnet@v3
|
uses: actions/setup-dotnet@v3
|
||||||
with:
|
with:
|
||||||
dotnet-version: '6.0.x'
|
dotnet-version: '8.0.x'
|
||||||
@ -251,7 +251,7 @@ Ref<Animation> SpineAnimationTrack::create_animation(spine::Animation *animation
|
|||||||
Ref<Animation> animation_ref;
|
Ref<Animation> animation_ref;
|
||||||
INSTANTIATE(animation_ref);
|
INSTANTIATE(animation_ref);
|
||||||
String name;
|
String name;
|
||||||
name.parse_utf8(animation.getName().buffer());
|
name.parse_utf8(animation->getName().buffer());
|
||||||
animation_ref->set_name(name + (loop ? "" : "_looped"));
|
animation_ref->set_name(name + (loop ? "" : "_looped"));
|
||||||
#if VERSION_MAJOR > 3
|
#if VERSION_MAJOR > 3
|
||||||
// animation_ref->set_loop(!loop);
|
// animation_ref->set_loop(!loop);
|
||||||
|
|||||||
@ -62,10 +62,9 @@ class GodotSpineTextureLoader : public spine::TextureLoader {
|
|||||||
Array *textures;
|
Array *textures;
|
||||||
Array *normal_maps;
|
Array *normal_maps;
|
||||||
String normal_map_prefix;
|
String normal_map_prefix;
|
||||||
bool is_importing;
|
|
||||||
|
|
||||||
public:
|
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) {
|
static bool fix_path(String &path) {
|
||||||
|
|||||||
@ -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("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_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("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("get_debug_root"), &SpineSprite::get_debug_root);
|
||||||
ClassDB::bind_method(D_METHOD("set_debug_root_color", "v"), &SpineSprite::set_debug_root_color);
|
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()
|
// 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();
|
skeleton_clipper = new spine::SkeletonClipping();
|
||||||
auto statics = SpineSpriteStatics::instance();
|
auto statics = SpineSpriteStatics::instance();
|
||||||
|
|
||||||
@ -817,12 +820,12 @@ void SpineSprite::update_skeleton(float delta) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
emit_signal(SNAME("before_animation_state_update"), this);
|
emit_signal(SNAME("before_animation_state_update"), this);
|
||||||
animation_state->update(delta);
|
animation_state->update(delta * time_scale);
|
||||||
if (!is_visible_in_tree()) return;
|
if (!is_visible_in_tree()) return;
|
||||||
emit_signal(SNAME("before_animation_state_apply"), this);
|
emit_signal(SNAME("before_animation_state_apply"), this);
|
||||||
animation_state->apply(skeleton);
|
animation_state->apply(skeleton);
|
||||||
emit_signal(SNAME("before_world_transforms_change"), this);
|
emit_signal(SNAME("before_world_transforms_change"), this);
|
||||||
skeleton->update(delta);
|
skeleton->update(delta * time_scale);
|
||||||
skeleton->update_world_transform(SpineConstant::Physics_Update);
|
skeleton->update_world_transform(SpineConstant::Physics_Update);
|
||||||
modified_bones = false;
|
modified_bones = false;
|
||||||
emit_signal(SNAME("world_transforms_changed"), this);
|
emit_signal(SNAME("world_transforms_changed"), this);
|
||||||
@ -1401,6 +1404,14 @@ void SpineSprite::set_screen_material(Ref<Material> material) {
|
|||||||
screen_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
|
#ifndef SPINE_GODOT_EXTENSION
|
||||||
// FIXME
|
// FIXME
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
|
|||||||
@ -141,6 +141,7 @@ protected:
|
|||||||
Ref<SpineSkeleton> skeleton;
|
Ref<SpineSkeleton> skeleton;
|
||||||
Ref<SpineAnimationState> animation_state;
|
Ref<SpineAnimationState> animation_state;
|
||||||
SpineConstant::UpdateMode update_mode;
|
SpineConstant::UpdateMode update_mode;
|
||||||
|
float time_scale;
|
||||||
|
|
||||||
String preview_skin;
|
String preview_skin;
|
||||||
String preview_animation;
|
String preview_animation;
|
||||||
@ -230,6 +231,10 @@ public:
|
|||||||
|
|
||||||
void set_screen_material(Ref<Material> material);
|
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; }
|
bool get_debug_root() { return debug_root; }
|
||||||
|
|
||||||
void set_debug_root(bool root) { debug_root = root; }
|
void set_debug_root(bool root) { debug_root = root; }
|
||||||
|
|||||||
@ -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/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/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.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/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>
|
<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>
|
</ul>
|
||||||
|
|||||||
50
spine-ts/package-lock.json
generated
50
spine-ts/package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@esotericsoftware/spine-ts",
|
"name": "@esotericsoftware/spine-ts",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@esotericsoftware/spine-ts",
|
"name": "@esotericsoftware/spine-ts",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"license": "LicenseRef-LICENSE",
|
"license": "LicenseRef-LICENSE",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"spine-core",
|
"spine-core",
|
||||||
@ -3244,18 +3244,18 @@
|
|||||||
},
|
},
|
||||||
"spine-canvas": {
|
"spine-canvas": {
|
||||||
"name": "@esotericsoftware/spine-canvas",
|
"name": "@esotericsoftware/spine-canvas",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"license": "LicenseRef-LICENSE",
|
"license": "LicenseRef-LICENSE",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-core": "4.2.79"
|
"@esotericsoftware/spine-core": "4.2.80"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"spine-canvaskit": {
|
"spine-canvaskit": {
|
||||||
"name": "@esotericsoftware/spine-canvaskit",
|
"name": "@esotericsoftware/spine-canvaskit",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"license": "LicenseRef-LICENSE",
|
"license": "LicenseRef-LICENSE",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-core": "4.2.79",
|
"@esotericsoftware/spine-core": "4.2.80",
|
||||||
"canvaskit-wasm": "0.39.1"
|
"canvaskit-wasm": "0.39.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -3265,17 +3265,17 @@
|
|||||||
},
|
},
|
||||||
"spine-core": {
|
"spine-core": {
|
||||||
"name": "@esotericsoftware/spine-core",
|
"name": "@esotericsoftware/spine-core",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"license": "LicenseRef-LICENSE"
|
"license": "LicenseRef-LICENSE"
|
||||||
},
|
},
|
||||||
"spine-phaser-v3": {
|
"spine-phaser-v3": {
|
||||||
"name": "@esotericsoftware/spine-phaser-v3",
|
"name": "@esotericsoftware/spine-phaser-v3",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"license": "LicenseRef-LICENSE",
|
"license": "LicenseRef-LICENSE",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-canvas": "4.2.79",
|
"@esotericsoftware/spine-canvas": "4.2.80",
|
||||||
"@esotericsoftware/spine-core": "4.2.79",
|
"@esotericsoftware/spine-core": "4.2.80",
|
||||||
"@esotericsoftware/spine-webgl": "4.2.79"
|
"@esotericsoftware/spine-webgl": "4.2.80"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"phaser": "^3.60.0"
|
"phaser": "^3.60.0"
|
||||||
@ -3299,12 +3299,12 @@
|
|||||||
},
|
},
|
||||||
"spine-phaser-v4": {
|
"spine-phaser-v4": {
|
||||||
"name": "@esotericsoftware/spine-phaser-v4",
|
"name": "@esotericsoftware/spine-phaser-v4",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"license": "LicenseRef-LICENSE",
|
"license": "LicenseRef-LICENSE",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-canvas": "4.2.79",
|
"@esotericsoftware/spine-canvas": "4.2.80",
|
||||||
"@esotericsoftware/spine-core": "4.2.79",
|
"@esotericsoftware/spine-core": "4.2.80",
|
||||||
"@esotericsoftware/spine-webgl": "4.2.79"
|
"@esotericsoftware/spine-webgl": "4.2.80"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"phaser": "^4.0.0-rc.1"
|
"phaser": "^4.0.0-rc.1"
|
||||||
@ -3315,10 +3315,10 @@
|
|||||||
},
|
},
|
||||||
"spine-pixi-v7": {
|
"spine-pixi-v7": {
|
||||||
"name": "@esotericsoftware/spine-pixi-v7",
|
"name": "@esotericsoftware/spine-pixi-v7",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"license": "LicenseRef-LICENSE",
|
"license": "LicenseRef-LICENSE",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-core": "4.2.79"
|
"@esotericsoftware/spine-core": "4.2.80"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@pixi/assets": "^7.2.4",
|
"@pixi/assets": "^7.2.4",
|
||||||
@ -3332,10 +3332,10 @@
|
|||||||
},
|
},
|
||||||
"spine-pixi-v8": {
|
"spine-pixi-v8": {
|
||||||
"name": "@esotericsoftware/spine-pixi-v8",
|
"name": "@esotericsoftware/spine-pixi-v8",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"license": "LicenseRef-LICENSE",
|
"license": "LicenseRef-LICENSE",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-core": "4.2.79"
|
"@esotericsoftware/spine-core": "4.2.80"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"pixi.js": "^8.4.0"
|
"pixi.js": "^8.4.0"
|
||||||
@ -3343,18 +3343,18 @@
|
|||||||
},
|
},
|
||||||
"spine-player": {
|
"spine-player": {
|
||||||
"name": "@esotericsoftware/spine-player",
|
"name": "@esotericsoftware/spine-player",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"license": "LicenseRef-LICENSE",
|
"license": "LicenseRef-LICENSE",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-webgl": "4.2.79"
|
"@esotericsoftware/spine-webgl": "4.2.80"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"spine-threejs": {
|
"spine-threejs": {
|
||||||
"name": "@esotericsoftware/spine-threejs",
|
"name": "@esotericsoftware/spine-threejs",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"license": "LicenseRef-LICENSE",
|
"license": "LicenseRef-LICENSE",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-core": "4.2.79"
|
"@esotericsoftware/spine-core": "4.2.80"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/three": "0.162.0"
|
"@types/three": "0.162.0"
|
||||||
@ -3365,10 +3365,10 @@
|
|||||||
},
|
},
|
||||||
"spine-webgl": {
|
"spine-webgl": {
|
||||||
"name": "@esotericsoftware/spine-webgl",
|
"name": "@esotericsoftware/spine-webgl",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"license": "LicenseRef-LICENSE",
|
"license": "LicenseRef-LICENSE",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-core": "4.2.79"
|
"@esotericsoftware/spine-core": "4.2.80"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esotericsoftware/spine-ts",
|
"name": "@esotericsoftware/spine-ts",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"description": "The official Spine Runtimes for the web.",
|
"description": "The official Spine Runtimes for the web.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"files": [
|
"files": [
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esotericsoftware/spine-canvas",
|
"name": "@esotericsoftware/spine-canvas",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"description": "The official Spine Runtimes for the web.",
|
"description": "The official Spine Runtimes for the web.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
@ -31,6 +31,6 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
|
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-core": "4.2.79"
|
"@esotericsoftware/spine-core": "4.2.80"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esotericsoftware/spine-canvaskit",
|
"name": "@esotericsoftware/spine-canvaskit",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"description": "The official Spine Runtimes for CanvasKit for NodeJS",
|
"description": "The official Spine Runtimes for CanvasKit for NodeJS",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
@ -31,7 +31,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
|
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-core": "4.2.79",
|
"@esotericsoftware/spine-core": "4.2.80",
|
||||||
"canvaskit-wasm": "0.39.1"
|
"canvaskit-wasm": "0.39.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esotericsoftware/spine-core",
|
"name": "@esotericsoftware/spine-core",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"description": "The official Spine Runtimes for the web.",
|
"description": "The official Spine Runtimes for the web.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esotericsoftware/spine-phaser-v3",
|
"name": "@esotericsoftware/spine-phaser-v3",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"description": "The official Spine Runtimes for the Phaser v3.",
|
"description": "The official Spine Runtimes for the Phaser v3.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
@ -31,9 +31,9 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
|
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-canvas": "4.2.79",
|
"@esotericsoftware/spine-canvas": "4.2.80",
|
||||||
"@esotericsoftware/spine-core": "4.2.79",
|
"@esotericsoftware/spine-core": "4.2.80",
|
||||||
"@esotericsoftware/spine-webgl": "4.2.79"
|
"@esotericsoftware/spine-webgl": "4.2.80"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"phaser": "^3.60.0"
|
"phaser": "^3.60.0"
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esotericsoftware/spine-phaser-v4",
|
"name": "@esotericsoftware/spine-phaser-v4",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"description": "The official Spine Runtimes for the Phaser v4.",
|
"description": "The official Spine Runtimes for the Phaser v4.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
@ -31,9 +31,9 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
|
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-canvas": "4.2.79",
|
"@esotericsoftware/spine-canvas": "4.2.80",
|
||||||
"@esotericsoftware/spine-core": "4.2.79",
|
"@esotericsoftware/spine-core": "4.2.80",
|
||||||
"@esotericsoftware/spine-webgl": "4.2.79"
|
"@esotericsoftware/spine-webgl": "4.2.80"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"phaser": "^4.0.0-rc.1"
|
"phaser": "^4.0.0-rc.1"
|
||||||
|
|||||||
130
spine-ts/spine-pixi-v7/example/slot-objects-scale-rotation.html
Normal file
130
spine-ts/spine-pixi-v7/example/slot-objects-scale-rotation.html
Normal 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/qfAPKOQBtFTWF5RyILoXQ94XU9IgnirmDyicAXCui2fBDGigDyhkAIxsnC8oJABMXq+52U9IQFiVrF4QGEOYnaRqKOQBbHaZ3IBwrIwVFGYgVAoCIUcSIBQmcep5MEUhFoRyOVDpQAsOk8xJ1NBKHWcam6mgVDpMPUcTQGhNk9TztNwEAqd5ClfQ0FYd47HvJmAsC445dwNA+EZg2UfDAHhdaqi0A+vg1gFg1V/vApiNQwW/TIFhHVBeeqb10CsjGFmH70C4gsYZvVVN4hV1w1W/dUF4i45T4J1kSn1hQQISxhqffhvEG93xCogevvh0yBG9IEZiBEdsgKI7pzMLoK7YvhiDgKEWA4ChFgOAoRYDgKEWA4CxOAcfn5+4Pv7W4CYncPLywtcXl7C4+MjfH5+wsHBAUxOTkJHRwf09PTA4uKi9HtPcRQgHx8f8Pb2JklTLQbrHM7Pz6Grqwuys7OhuLgYqqurISoqCvz8/Bzt+Pv7Q1JSEkxMTEh4HoMgwN7eHrS3t0N9fT0sLy/D+/s7uWKwzgHrNDo6CgEBAX9e7xqBgYHQ0NAANzc3noHg0KusrJRksaHExETY2toiVQwKOXx9fUFFRYUmDHvgyKmqqoLb21vtIKenpxAbGytrZGBggFQxKOSAIAUFBW5HxF+jB+vZ2dkpXa8J5OLiAqKjo2WN1NbW6toxWBEEp6zGxkbFdZGRkdDU1ATb29uwsrICqampivfExcXB2dmZNpC7uzvpAucG8JugJuprIBgjIyOKb//MzIy027K/5+joCNLT0xWjR20ZcIA8PT1BcnKyrIG8vDxp10WpGBRyWF1dday19piamlK8b3h4WLbzwqlsfX1dGwhudV2HWVZWlmE7LZ5BdnZ2ICgoSDZC+vv7pdkEpzT89+TkBHJycmRt4zWbm5vaQHAkpKWlyRrAISdGiDLw9iA4OFh2HU7vbW1t0NraKu3C4uPjZaMDIyYmBo6Pj7WDuM55AuTv2N3dVYCoBeLgoq9WT1UQMWVpGyFqGPn5+dIdvmpOaiBihOgbIbiQl5eXw/X1tbacBIgxIHhfUlhYCNPT05qPTQSIgSARERHSTaKnh7QCxEsgrvdwGLm5udIJiAAxGQQX7ZaWFsXRE75eV1cHz8/P3gHBfXN3dzf09fU5YnBwEObm5qTDSD3PTKwGYq+T6x08LupDQ0Oaj6BkIJmZmW7nRXvgmUxJSYnqTY4vgfT29sLDwwOUlZUp2gwPD4elpSVNX2AHCB6MFRUVaQLBCAkJ0fwhVgPZ39+HsLAwGQj+4O9w5sjIyFC0i08PDw8PtYNgYWdnZyE0NFQTCD6yXFtb80kQPEJPSUlxXIOjZWFhwVFHPNHF6d65XUTDZ+1qjzNszv95fX2F8fFxaerCfTTi4EjAD7QHvoba+PDq/v7e9GJQAMHpfWxsDBISEqQvZk1NjfQHDc7vmZ+fV+zE8IxL7eTD5voCCuOuAD8AhxgOT5wz7YHHBniSiafDLIpBAQQDa4T3GRsbG3B1daWYKbDwzc3NjqeHiIMbIs1PDHkqBi854HEJ/pSWlko7MLWnhQLEhBxwROCfAWm9nxMgjHMQIMRyECDEchAgxHIQIMRyIA1CIQQIsRAgxMJnQaii+DQIRRTm9WCdgAgBQjoECLEQIMRCgBALAUIsBAixECDEQoAQi3/zZahFP7nPdgAAAABJRU5ErkJggg==";
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esotericsoftware/spine-pixi-v7",
|
"name": "@esotericsoftware/spine-pixi-v7",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"description": "The official Spine Runtimes for the web PixiJS v7.",
|
"description": "The official Spine Runtimes for the web PixiJS v7.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
@ -31,7 +31,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
|
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-core": "4.2.79"
|
"@esotericsoftware/spine-core": "4.2.80"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@pixi/core": "^7.2.4",
|
"@pixi/core": "^7.2.4",
|
||||||
|
|||||||
@ -34,7 +34,6 @@ import {
|
|||||||
AtlasAttachmentLoader,
|
AtlasAttachmentLoader,
|
||||||
ClippingAttachment,
|
ClippingAttachment,
|
||||||
Color,
|
Color,
|
||||||
MathUtils,
|
|
||||||
MeshAttachment,
|
MeshAttachment,
|
||||||
Physics,
|
Physics,
|
||||||
RegionAttachment,
|
RegionAttachment,
|
||||||
@ -52,7 +51,7 @@ import { SlotMesh } from "./SlotMesh.js";
|
|||||||
import { DarkSlotMesh } from "./DarkSlotMesh.js";
|
import { DarkSlotMesh } from "./DarkSlotMesh.js";
|
||||||
import type { ISpineDebugRenderer, SpineDebugRenderer } from "./SpineDebugRenderer.js";
|
import type { ISpineDebugRenderer, SpineDebugRenderer } from "./SpineDebugRenderer.js";
|
||||||
import { Assets } from "@pixi/assets";
|
import { Assets } from "@pixi/assets";
|
||||||
import { IPointData, Point, Rectangle } from "@pixi/core";
|
import { IPointData, Point } from "@pixi/core";
|
||||||
import { Ticker } from "@pixi/core";
|
import { Ticker } from "@pixi/core";
|
||||||
import type { IDestroyOptions, DisplayObject } from "@pixi/display";
|
import type { IDestroyOptions, DisplayObject } from "@pixi/display";
|
||||||
import { Bounds, Container } from "@pixi/display";
|
import { Bounds, Container } from "@pixi/display";
|
||||||
@ -593,8 +592,24 @@ export class Spine extends Container {
|
|||||||
|
|
||||||
if (slotObject.visible) {
|
if (slotObject.visible) {
|
||||||
slotObject.position.set(slot.bone.worldX, slot.bone.worldY);
|
slotObject.position.set(slot.bone.worldX, slot.bone.worldY);
|
||||||
slotObject.scale.set(slot.bone.getWorldScaleX(), slot.bone.getWorldScaleY());
|
slotObject.angle = slot.bone.getWorldRotationX();
|
||||||
slotObject.rotation = slot.bone.getWorldRotationX() * MathUtils.degRad;
|
|
||||||
|
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.zIndex = zIndex + 1;
|
||||||
slotObject.alpha = this.skeleton.color.a * slot.color.a;
|
slotObject.alpha = this.skeleton.color.a * slot.color.a;
|
||||||
}
|
}
|
||||||
|
|||||||
126
spine-ts/spine-pixi-v8/example/slot-objects-scale-rotation.html
Normal file
126
spine-ts/spine-pixi-v8/example/slot-objects-scale-rotation.html
Normal 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,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"
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esotericsoftware/spine-pixi-v8",
|
"name": "@esotericsoftware/spine-pixi-v8",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"description": "The official Spine Runtimes for PixiJS v8.",
|
"description": "The official Spine Runtimes for PixiJS v8.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
@ -31,7 +31,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
|
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-core": "4.2.79"
|
"@esotericsoftware/spine-core": "4.2.80"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"pixi.js": "^8.4.0"
|
"pixi.js": "^8.4.0"
|
||||||
|
|||||||
@ -33,7 +33,6 @@ import {
|
|||||||
Cache,
|
Cache,
|
||||||
Container,
|
Container,
|
||||||
ContainerOptions,
|
ContainerOptions,
|
||||||
DEG_TO_RAD,
|
|
||||||
DestroyOptions,
|
DestroyOptions,
|
||||||
fastCopy,
|
fastCopy,
|
||||||
Graphics,
|
Graphics,
|
||||||
@ -785,14 +784,25 @@ export class Spine extends ViewContainer {
|
|||||||
container.visible = this.skeleton.drawOrder.includes(slot) && followAttachmentValue;
|
container.visible = this.skeleton.drawOrder.includes(slot) && followAttachmentValue;
|
||||||
|
|
||||||
if (container.visible) {
|
if (container.visible) {
|
||||||
const bone = slot.bone;
|
let bone: Bone | null = slot.bone;
|
||||||
|
|
||||||
container.position.set(bone.worldX, bone.worldY);
|
container.position.set(bone.worldX, bone.worldY);
|
||||||
|
container.angle = bone.getWorldRotationX();
|
||||||
|
|
||||||
container.scale.x = bone.getWorldScaleX();
|
let cumulativeScaleX = 1;
|
||||||
container.scale.y = bone.getWorldScaleY();
|
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;
|
container.alpha = this.skeleton.color.a * slot.color.a;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esotericsoftware/spine-player",
|
"name": "@esotericsoftware/spine-player",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"description": "The official Spine Runtimes for the web.",
|
"description": "The official Spine Runtimes for the web.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
@ -31,6 +31,6 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
|
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-webgl": "4.2.79"
|
"@esotericsoftware/spine-webgl": "4.2.80"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esotericsoftware/spine-threejs",
|
"name": "@esotericsoftware/spine-threejs",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"description": "The official Spine Runtimes for the web.",
|
"description": "The official Spine Runtimes for the web.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
@ -31,7 +31,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
|
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-core": "4.2.79"
|
"@esotericsoftware/spine-core": "4.2.80"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/three": "0.162.0"
|
"@types/three": "0.162.0"
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esotericsoftware/spine-webgl",
|
"name": "@esotericsoftware/spine-webgl",
|
||||||
"version": "4.2.79",
|
"version": "4.2.80",
|
||||||
"description": "The official Spine Runtimes for the web.",
|
"description": "The official Spine Runtimes for the web.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
@ -31,6 +31,6 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
|
"homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-core": "4.2.79"
|
"@esotericsoftware/spine-core": "4.2.80"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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");
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float mass = 10;
|
float mass = 10;
|
||||||
const float rotationLimit = 20.0f;
|
const float rotationLimit = 20.0f;
|
||||||
|
|
||||||
@ -334,40 +333,55 @@ namespace Spine.Unity.Editor {
|
|||||||
//followRotationComponent.reference = skeletonUtility.boneRoot;
|
//followRotationComponent.reference = skeletonUtility.boneRoot;
|
||||||
|
|
||||||
// Follower Kinematic Rigidbody
|
// Follower Kinematic Rigidbody
|
||||||
GameObject followerKinematicObject = new GameObject(kinematicParentUtilityBone.name + " Follower");
|
GameObject rootFollowerKinematic = new GameObject(kinematicParentUtilityBone.name + " Follower");
|
||||||
followerKinematicObject.transform.parent = normalChainParentObject.transform;
|
rootFollowerKinematic.transform.parent = normalChainParentObject.transform;
|
||||||
Rigidbody2D followerRigidbody = followerKinematicObject.AddComponent<Rigidbody2D>();
|
Rigidbody2D followerRigidbody = rootFollowerKinematic.AddComponent<Rigidbody2D>();
|
||||||
followerRigidbody.mass = mass;
|
followerRigidbody.mass = mass;
|
||||||
followerRigidbody.isKinematic = true;
|
followerRigidbody.isKinematic = true;
|
||||||
followerKinematicObject.AddComponent<FollowLocationRigidbody2D>().reference = kinematicParentUtilityBone.transform;
|
rootFollowerKinematic.AddComponent<FollowLocationRigidbody2D>().reference = kinematicParentUtilityBone.transform;
|
||||||
followerKinematicObject.transform.position = kinematicParentUtilityBone.transform.position;
|
rootFollowerKinematic.transform.position = kinematicParentUtilityBone.transform.position;
|
||||||
followerKinematicObject.transform.rotation = kinematicParentUtilityBone.transform.rotation;
|
rootFollowerKinematic.transform.rotation = kinematicParentUtilityBone.transform.rotation;
|
||||||
|
|
||||||
// Child Bones
|
CreateHingeChain2D(utilityBone, mass, rotationLimit, normalChainParentObject.transform,
|
||||||
SkeletonUtilityBone[] utilityBones = utilityBone.GetComponentsInChildren<SkeletonUtilityBone>();
|
rootFollowerKinematic.transform, kinematicParentUtilityBone.transform);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
Duplicate2DHierarchyForFlippedChains(normalChainParentObject, commonParentActivateOnFlip, skeletonUtility.transform, rotationLimit);
|
Duplicate2DHierarchyForFlippedChains(normalChainParentObject, commonParentActivateOnFlip, skeletonUtility.transform, rotationLimit);
|
||||||
UnityEditor.Selection.activeGameObject = commonParentObject;
|
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) {
|
void ApplyJoint2DAngleLimits (HingeJoint2D joint, float rotationLimit, Transform parentBone, Transform bone) {
|
||||||
#if HINGE_JOINT_NEW_BEHAVIOUR
|
#if HINGE_JOINT_NEW_BEHAVIOUR
|
||||||
float referenceAngle = (parentBone.eulerAngles.z - bone.eulerAngles.z + 360f) % 360f;
|
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");
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
float mass = 10;
|
||||||
|
const float rotationLimit = 20.0f;
|
||||||
|
|
||||||
SetSkeletonUtilityToFlipByRotation();
|
SetSkeletonUtilityToFlipByRotation();
|
||||||
|
|
||||||
@ -465,39 +481,57 @@ namespace Spine.Unity.Editor {
|
|||||||
followRotationComponent.reference = skeletonUtility.boneRoot;
|
followRotationComponent.reference = skeletonUtility.boneRoot;
|
||||||
|
|
||||||
// Follower Kinematic Rigidbody
|
// Follower Kinematic Rigidbody
|
||||||
GameObject followerKinematicObject = new GameObject(kinematicParentUtilityBone.name + " Follower");
|
GameObject rootFollowerKinematic = new GameObject(kinematicParentUtilityBone.name + " Follower");
|
||||||
followerKinematicObject.transform.parent = chainParentObject.transform;
|
rootFollowerKinematic.transform.parent = chainParentObject.transform;
|
||||||
Rigidbody followerRigidbody = followerKinematicObject.AddComponent<Rigidbody>();
|
Rigidbody followerRigidbody = rootFollowerKinematic.AddComponent<Rigidbody>();
|
||||||
followerRigidbody.mass = 10;
|
followerRigidbody.mass = mass;
|
||||||
followerRigidbody.isKinematic = true;
|
followerRigidbody.isKinematic = true;
|
||||||
followerKinematicObject.AddComponent<FollowLocationRigidbody>().reference = kinematicParentUtilityBone.transform;
|
rootFollowerKinematic.AddComponent<FollowLocationRigidbody>().reference = kinematicParentUtilityBone.transform;
|
||||||
followerKinematicObject.transform.position = kinematicParentUtilityBone.transform.position;
|
rootFollowerKinematic.transform.position = kinematicParentUtilityBone.transform.position;
|
||||||
followerKinematicObject.transform.rotation = kinematicParentUtilityBone.transform.rotation;
|
rootFollowerKinematic.transform.rotation = kinematicParentUtilityBone.transform.rotation;
|
||||||
|
|
||||||
// Child Bones
|
CreateHingeChain(utilityBone, mass, rotationLimit, chainParentObject.transform, rootFollowerKinematic.transform);
|
||||||
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;
|
|
||||||
|
|
||||||
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;
|
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 () {
|
void SetSkeletonUtilityToFlipByRotation () {
|
||||||
if (!skeletonUtility.flipBy180DegreeRotation) {
|
if (!skeletonUtility.flipBy180DegreeRotation) {
|
||||||
skeletonUtility.flipBy180DegreeRotation = true;
|
skeletonUtility.flipBy180DegreeRotation = true;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user