Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprite component #247

Closed
4 tasks done
JaimeTorrealba opened this issue Oct 9, 2023 · 5 comments · Fixed by #331
Closed
4 tasks done

Sprite component #247

JaimeTorrealba opened this issue Oct 9, 2023 · 5 comments · Fixed by #331
Assignees
Labels
good first issue Good for newcomers p2-nice-to-have Not breaking anything but nice to have (priority)

Comments

@JaimeTorrealba
Copy link
Member

Description

As a developer using Tresjs I would like to create sprite animations by cycling through a sequence of frames from a sprite sheet image or JSON data, so I could add sprites images to my 3D spaces.

Suggested solution

Inspired by: https://github.com/pmndrs/drei#sprite-animator

Alternative

Feel free to suggest other alternatives

Additional context

No response

Validations

@andretchen0
Copy link
Contributor

Not sure if it'd be useful here, but this is the nicest way that I've come across to declare sprite animations in code:

https://github.com/deepnight/deepnightLibs/blob/144e494fc405766a570fad5bd20c27c806e6282d/src/dn/heaps/slib/SpriteLib.hx#L544

If you name your images "idle0.png", "idle1.png", "idle2.png", "walk0.png", "walk1.png". Then, when you declare your e.g., idle animation, you can specify order and delay:

defineAnim( "idle", "0-2, 0(2), 1" );

So the animation above would show images 0-2 for 1 frame each, then frame 0 for 2 frames, then frame 1.

@alvarosabu alvarosabu added the good first issue Good for newcomers label Oct 22, 2023
@andretchen0 andretchen0 self-assigned this Dec 18, 2023
@andretchen0
Copy link
Contributor

andretchen0 commented Dec 18, 2023

@JaimeTorrealba @alvarosabu

I'll take this. (I see it's marked "Good First Issue", but I'd really like to see if I can improve on the DX of the Drei version.)

Questions

The Drei version accepts a JSON texture atlas / packed sprites.

  • Do you have a preference for a particular piece of software for creating those files?
  • Or is there a particular atlas spec we should use?

Otherwise, some options:

  • LibGDX TexturePacker – This is a free standalone GUI. Maybe users would have a tough time getting it to work – I believe users will have to install a JRE if they don't have one.
  • Roll our own – An inefficient but ok-for-our-purposes command line texture packer isn't very hard to write, assuming we add an image processing dependency – I've had good luck with Sharp. But I don't want to make Cientos responsible for continued support unless that's the way you guys want to go.
  • Don't offer/suggest a tool – Let users figure it out on their own. And type out a sprite atlas by hand if that's what they want.

@damienmontastier
Copy link
Collaborator

Hey @andretchen0 ✌ ! I don't know if you know TexturePacker, I've used it a few times and it's always been quick and easy to use.

@andretchen0
Copy link
Contributor

Hey @andretchen0 ✌ ! I don't know if you know TexturePacker, I've used it a few times and it's always been quick and easy to use.

@damienmontastier

Thanks for the recommendation!

I have checked out TexturePacker in the past and it's a great tool. Maybe one of the others can chime in to the contrary if I'm wrong, but I think for Tres/Cientos, we'd want to have a free – but ideally FOSS – tool that people could use.

@JaimeTorrealba JaimeTorrealba added the p2-nice-to-have Not breaking anything but nice to have (priority) label Apr 5, 2024
@andretchen0 andretchen0 linked a pull request Apr 7, 2024 that will close this issue
@andretchen0 andretchen0 moved this to In Progress in Team Board Apr 8, 2024
@andretchen0 andretchen0 moved this from In Progress to Done in Team Board Apr 13, 2024
@andretchen0
Copy link
Contributor

Closing: completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants