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

feat: added Texture Options to spritesheet loader #11163

Merged
merged 7 commits into from
Dec 22, 2024
Merged

Conversation

sam007mac
Copy link
Contributor

Description of change

I've added the ability to set TextureOptions on sprites loaded via a spritesheet, as outlined in this Feature Request: #11148

Pre-Merge Checklist
  • Documentation is changed or added
  • Lint process passed (npm run lint)

I was having difficulty with the test suite but I tested my changes locally and it functioned as intended with normal and multipacked spritesheets.

Copy link

codesandbox-ci bot commented Dec 17, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 2c02812:

Sandbox Source
pixi.js-sandbox Configuration

Copy link
Member

@GoodBoyDigital GoodBoyDigital left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks so much for this @sam007mac ! tiny tweak requested!

const assets = await loader.load<Texture>([imagePath]);
let assets;

if (textureOptions)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we even need the if (textureOptions) check here as textureOptions can be null:

replacing the original line
assets = await loader.load<Texture>([imagePath]);

with
assets = await loader.load<Texture>([{ src: imagePath, data: textureOptions}]);

should work!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like that check is still needed, removing it caused the SVG spritesheet test to fail.
I could modify the SVG script to fix that issue but I don't know if that's in the scope of this PR, what are your thoughts?

Copy link
Member

@bigtimebuddy bigtimebuddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test here would be useful to make sure the options are actually set.

@sam007mac
Copy link
Contributor Author

I've added a test for checking the texture options.
I've also fixed the issue causing loadSVG to fail because of my change but I don't know if that should be under a separate PR or issue report, it's only partly related.

Copy link
Member

@bigtimebuddy bigtimebuddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix! Thank you for the test.

Copy link
Member

@GoodBoyDigital GoodBoyDigital left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @sam007mac 👍

@bigtimebuddy bigtimebuddy added the ✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t label Dec 18, 2024
@Zyie Zyie added this pull request to the merge queue Dec 22, 2024
Merged via the queue into pixijs:dev with commit 5571d49 Dec 22, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants