-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Conversation
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:
|
There was a problem hiding this 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!
src/spritesheet/spritesheetAsset.ts
Outdated
const assets = await loader.load<Texture>([imagePath]); | ||
let assets; | ||
|
||
if (textureOptions) |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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?
There was a problem hiding this 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.
I've added a test for checking the texture options. |
There was a problem hiding this 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @sam007mac 👍
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
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.