Jump to content

Load images individually


royibernthal
 Share

Recommended Posts

I'm creating a scrollable list of images, I need to be able to individually load and unload each image according to whether it's currently within the viewport or not.

PIXI loader is not good for this case because I need to wait for it to finish loading every time before I can load more images, which results in an async operation.

 

What comes to my mind is to create my own images loader:

1) Load individual images by creating img element and setting src

2) Once an image is loaded - create from it base texture

3) From base texture - create texture

 

Would that be the best way to achieve what I need or would it be reinventing the wheel?

Link to comment
Share on other sites

Good to see it's already been done :) I'll probably use Texture.fromImage().

In order to destroy a specific texture and its base texture, other than calling texture.destroy(true), would I also need to do:

delete PIXI.utils.TextureCache[key];
delete PIXI.utils.BaseTextureCache[key];

In other words, how do I make sure I completely free all memory related to a specific image?

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...