roomyrooms

Hey! This is a hyper-specific request/question so I totally understand if it's a little much.

Basically, I'd like to be able to pull image data from a slot/attachment somehow. A data URL would be preferable, but whatever's good (obv.)! To do this I've been researching miles of docs on the rendering process and so on, but I've been experiencing a lot of trouble figuring out what it actually parses from to get the image data. I understand it has to peel sections of the atlases away for each slot/attachment, but is there no in-between where I'd be able to snipe the passing data?

I'm using Pixi JS right now. I'd love to be able to grab the image data on-command at runtime, but even caching it as it's loaded in my own way and calling on that per-attachment path would be awesome. Do you guys have any advice as to how to accomplish this?

For context, I'm just trying to pull the head sprites (possibly hair/etc.) so I can put them in an html src tag in the player's profile.

---

Just as a brief update on my "method":

I can successfully get it to output a data URI with the correct size for the slot (15x15 for the head), but it's blank, presumably because the sprite has a size set that's accurate to the slot's size, but doesn't get any actual image data until later. FWIW, I'm doing this on a visible spine object w/ the window open.
roomyrooms
  • Сообщения: 4

Nate

It sounds like you want to render an image containing only some attachments? If it's one attachment, you can just use the atlas region (unless it is a mesh that cuts away part of the image). Otherwise you'd need a way to only render the attachments you care about, then a way to render those to an image file. That is something a server could do. I'm not sure how a client would capture the pixel data for rendering and send it to the server, but that might be possible too.

It may be easier to render the skeleton on the player's profile, cropped so only the head is visible. This is more heavy weight than an image, but has the benefit that it can be animated.
Аватара пользователя
Nate

Nate
  • Сообщения: 10750

roomyrooms

Your comment about the atlas region pointed me in the right direction- I was trying too hard to take an existing sprite and pull data from it.

My new method for doing this in case anyone comes along in the future:
1. Grab a given slot's attachment
2. Create a new SpineSprite using the attachment's region's texture
3. Use Pixi's renderer.extract.base64 func to turn said sprite into a data URI
4. Dispose of SpineSprite (or whatever you want to do with it after)
4. Apply said data URI to desired image container

I think this is probably the best method I'm going to find? Like you said, rendering a whole skeleton is going to be very heavy relatively (esp. when I don't necessarily need animations), and the next best thing I can think of would involve a lot of post processing crap, so. I'm pretty sure this is a decent enough solution! Thanks for the help Nate, I appreciate the reply (I was seriously lost for a bit there) :)
roomyrooms
  • Сообщения: 4


Вернуться в Runtimes