[SOLVED] Resize downloaded texture

hi,
I’m downloading a lot of textures at runtime , the issue im facing that some times different resolution of textures won’t fit on my static texture element (in playcnavas) , So I need a way to resize the texture itself before applying to an element.

My code to download texture:

var Array;
  var Asset=SOME URL;
            this.app.assets.loadFromUrl(Asset, "texture", function (err, asset) {
              Array[1]=asset;//asset is received which I put in an array 
            });

to assgin this downloaded texture I use:
this.image.element.texture=Array[1].resource;

I want to resize downloaded texture to 196 x 196? Can you please help me out ?

Just to check, do you actually want to resize the texture asset or the rendered size on the screen?

I want to resize the texture asset itself

It be really slow to do at runtime. If you need different sizes of textures, I would create the most common sizes and down load the one you need at runtime.

The engine does this if you load a texture that is bigger than the largest supported dimension of the WebGL implementation:

If you’re only doing that operation once on load, I don’t think it would be particularly slow.

2 Likes

Thanks @will @yaustar for the guidance, much appreciated