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

Bug: loadTextures ignores provided format #10378

Closed
elsassph opened this issue Mar 26, 2024 · 4 comments · Fixed by pixijs/pixijs.com#103
Closed

Bug: loadTextures ignores provided format #10378

elsassph opened this issue Mar 26, 2024 · 4 comments · Fixed by pixijs/pixijs.com#103
Labels
📢 Accepting PRs Would welcome a PR from the community. 🤩 Good First PR Indicating to new contributors a PR is simple/easy. Things like documentation or type fixes. 👍 Not A Bug Verified issue and is working as intended.

Comments

@elsassph
Copy link
Contributor

Current Behavior

Our images are hosted without a recognizable file extension.

Assets API seem to indicate that the format can be optionally provided through UnresolvedAsset.

Unfortunately, loadTextures ignores this information and only looks up the extension from the URL.

Expected Behavior

loadTextures should use the provided format.

Steps to Reproduce

const texture = await Assets.load({
  src: imageUrlWithoutRecognizableExtension,
  format: "png"
});

Environment

Possible Solution

One workaround that seems to work is to specify the loadParser as:

const texture = await Assets.load({
  src: imageUrlWithoutRecognizableExtension,
  loadParser: "loadTextures"
});

It would be great to add this information in the documentation BTW, because it's really arcane.

Additional Information

No response

@bigtimebuddy
Copy link
Member

loadParser is indeed the correct solution to this problem. Welcome PR if someone wants to add more explicit mention in the docs or to the guides.

@bigtimebuddy bigtimebuddy added 👍 Not A Bug Verified issue and is working as intended. 📢 Accepting PRs Would welcome a PR from the community. 🤩 Good First PR Indicating to new contributors a PR is simple/easy. Things like documentation or type fixes. labels Mar 26, 2024
@elsassph
Copy link
Contributor Author

What is the role of the format option then?

@bigtimebuddy
Copy link
Member

Good question @elsassph. The format is similar to resolution in that they are used by the Assets' Resolver figure out which asset to load based on the developer's preferences. For example, maybe on a mobile device you want to prefer resolution of 1 and a format of webp. These attributes allow you to explicitly define that instead of inferring from the filename (however resolution/format can be inferred from src, e.g., image@2x.png would be 2 resolution and png format). It's helpful if you are shipping cross-platform assets like compressed textures, or image formats like avif that might not have universal support to be able to define fallbacks.

@elsassph
Copy link
Contributor Author

Thanks, I'll let you guys document that ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📢 Accepting PRs Would welcome a PR from the community. 🤩 Good First PR Indicating to new contributors a PR is simple/easy. Things like documentation or type fixes. 👍 Not A Bug Verified issue and is working as intended.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants