Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

feat: Attach container to bone #8

Merged
merged 9 commits into from
Jun 4, 2024
Merged

feat: Attach container to bone #8

merged 9 commits into from
Jun 4, 2024

Conversation

GoodBoyDigital
Copy link
Member

This PR allows for containers to be attached to Bones!

const spineBoy = Spine.from({
					skeleton:'spineboySkeletonBinary', 
					atlas:'spineboyAtlas',
					scale:0.75
				 });


const hat = Sprite.from('hat.png');

// attach:
spineBot.attachToBone(hat, 'hair1`);

// detach:
spineBot.detachFromBone(hat, 'hair1`);

One note is that the attached items are not depth sorted - and always on top. This is because the spine mesh is currently rendered in one go. Will look into sorting this in a follow up PR.

also added a little helper function that returns all available bone names spine.getBoneNames()

@GoodBoyDigital GoodBoyDigital requested a review from Zyie June 3, 2024 12:34
@Zyie Zyie changed the title Feature: Attach container to bone feat: Attach container to bone Jun 4, 2024
@Zyie Zyie changed the base branch from main to dev June 4, 2024 09:06
@Zyie Zyie merged commit 75d0f92 into dev Jun 4, 2024
2 checks passed
@Zyie Zyie deleted the feature/attachToBone branch June 4, 2024 09:06
@badlogic
Copy link

badlogic commented Jun 4, 2024

Hey folks, Mario from Esoteric Software here. Love your work on the v8 update of the official runtime. But maybe you should reconsider this PR?

You do not want to attach anything to a bone. A bone can be thought of as a container of one or more slots. Each slot is then either empty, or has a single attachment (image, mesh) active. At rendering time, we go through all the active slots with an attachment in them, and generate a mesh for them, which is added to the Spine object, which is a pixi container. The rendering order is defined by the zIndex on the respective mesh for the attachment of that slot.

It is much more versatile to attach pixi objects to slots instead of bones. That way you can control the rendering order, which still being able to apply the slot's parent bone's transform to the pixi object, just as it is done to the attachment meshes.

We have an open issue for that here with some more possible implementation details:
EsotericSoftware/spine-runtimes#2539

@GoodBoyDigital
Copy link
Member Author

this is great feedback @badlogic, thank you! - I'm currently working on a slightly meatier PR to handle depth sorting of attachments. I will adjust to accommodate your feedback!

@Zyie Zyie linked an issue Jun 5, 2024 that may be closed by this pull request
@Zyie
Copy link
Member

Zyie commented Jun 5, 2024

Hey @badlogic we have a new PR to attach to slots instead here: #10
If you get the chance to take a look that would be great

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use Skeleton.yDown = true; instead of negating y coordinates everywhere
3 participants