Jump to content

Loading Remote Images


tkmonie
 Share

Recommended Posts

Hello there,

Im having an issue loading in resources from another domain. Its strange because it seem that using Sprite.from('https://website.com/image.png') works just fine, but using the pixi loader doesn't seem to work. 

Here's a codepen of an example: https://codepen.io/tkmoney/pen/mdmLjgX

 

What is interesting is that I can see in the chrome network tools the image request is successful but in the loader callback function the resource for the image doesnt have a texture object. I also tried a different image that is hosted on codepen.io and that DID seem to work. So something strange with coors maybe? Any help would be great. Thanks!

Link to comment
Share on other sites

pixi_app.loader.add("bg", img_src, { crossOrigin: "*" , loadType: 2});

because loader has no way of knowing whether to create Image or XHR for your resource because it doenst have "png" not "jpg" extension.

I dont remember where LOAD_TYPE enum is inside PIXI namespac,e probably something like "PIXI.Loader.LOAD_TYPE", its somewhere in docs, so i just put "2" there.

How could you find this? Easy. read the sources of https://github.com/englercj/resource-loader/blob/8c27956c2ee68e5190e489d87a3e641df035116b/src/Resource.js#L132

why external lib and not-master branch? its a history, in 6.1.0 it will be embedded. 

You also could find it in non-minified pixi , maybe just by debugging.

Link to comment
Share on other sites

On 7/31/2021 at 4:27 AM, ivan.popelyshev said:

pixi_app.loader.add("bg", img_src, { crossOrigin: "*" , loadType: 2});

because loader has no way of knowing whether to create Image or XHR for your resource because it doenst have "png" not "jpg" extension.

I dont remember where LOAD_TYPE enum is inside PIXI namespac,e probably something like "PIXI.Loader.LOAD_TYPE", its somewhere in docs, so i just put "2" there.

How could you find this? Easy. read the sources of https://github.com/englercj/resource-loader/blob/8c27956c2ee68e5190e489d87a3e641df035116b/src/Resource.js#L132

why external lib and not-master branch? its a history, in 6.1.0 it will be embedded. 

You also could find it in non-minified pixi , maybe just by debugging.

Thanks so much!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...