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

Allow passing BaseTexture options to Loader #7183

Merged
merged 5 commits into from Jan 25, 2021

Conversation

bigtimebuddy
Copy link
Member

@bigtimebuddy bigtimebuddy commented Jan 20, 2021

Fixes #7148

Now BaseTexture options can be passed to the metadata field.

loader.add('bunny', 'bunny.png', { metadata: {
  scaleMode: PIXI.SCALE_MODES.NEAREST,
  resolution: 1,
}});

loader.add('logo', 'logo.svg', { metadata: {
  resourceOptions: {
    scale: 0.25
  }
}});

🔥 Breaking Change

  • This changes the default load type for SVG images. Instead of loading as an <img> element, SVGs are loaded as text with resource-loader, and parsed with SVGResource.

🔬 Demos

https://jsfiddle.net/bigtimebuddy/gs6d81qk/ (png)
https://jsfiddle.net/bigtimebuddy/qwb6nduv/ (svg)

Follow-up Needed

  • Error handling for Textures & Loader is awful. We need to do a better job of handling internal errors with the fromLoader function. I suggest we return a Promise like fromUrl, and make sure the Loader does not swallow errors.

@codecov-io
Copy link

codecov-io commented Jan 20, 2021

Codecov Report

Merging #7183 (3fb192e) into dev (97db247) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##               dev     #7183   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           17        17           
  Lines          699       699           
=========================================
  Hits           699       699           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 97db247...3fb192e. Read the comment docs.

Copy link
Collaborator

@ivanpopelyshev ivanpopelyshev left a comment

Choose a reason for hiding this comment

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

It works!
Though it needs unit-tests for loader

+1 for error Handling problems

@bigtimebuddy
Copy link
Member Author

I have some ideas how to handle resource errors and bubble them up to the loader. Will work on that next. But yes on unit tests. Will add.

@bigtimebuddy
Copy link
Member Author

Okay I added unit-tests which uncovered an async error with SVGs. Basically, I needed to wait until the resource was completely finished loading before continuing with the Loader.

@ivanpopelyshev
Copy link
Collaborator

Good!

Copy link
Member

@ShukantPal ShukantPal left a comment

Choose a reason for hiding this comment

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

LGTM!

@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 Jan 24, 2021
@bigtimebuddy bigtimebuddy added this to the v6.0.0 milestone Jan 24, 2021
@saraOrkide
Copy link

How can I zoom in on svg sharply and control the gpu to slow it down?
Or how can I update the resolution or scale value each time I zoom in

@ivanpopelyshev
Copy link
Collaborator

Its possible, but so far people who did it didnt share :) If you give a demo that needs quality - someone can do that. From grounds up? sorry, no.

@ShukantPal
Copy link
Member

You could use @pixi-essentials/svg for sharp rendering of SVG files

@saraOrkide
Copy link

You could use @pixi-essentials/svg for sharp rendering of SVG files

When the number of svg paths is high and the use tag is used, it becomes very slow and does not support the pattern.

@saraOrkide
Copy link

Its possible, but so far people who did it didnt share :) If you give a demo that needs quality - someone can do that. From grounds up? sorry, no.

Well, there is no way I can better display svg with resolution and scaled when zooming

@ShukantPal
Copy link
Member

I think you can increase the width/height of the SVG, and then create a texture from it at that higher size

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.

Feature Request: Support Resource Options passed with Loader
5 participants