[SOLVED] diffuseMap.getSource() returning a Uint8Array

Hi guys!

I am trying to get the texture from a render to change its size, but i am stuck in getting the texture point.

According to the documentation, the getSource() function returns a HTMLImageElement, but i am getting a Uint8Array.

Code sample:

var ChangeTextureSize = pc.createScript('changeTextureSize');

// initialize code called once per entity
ChangeTextureSize.prototype.initialize = function () {

    const renders = this.entity.findComponents('render');

    renders.forEach(function (render) {

        const meshInstances = render.meshInstances;

        meshInstances.forEach(async function (meshInstance) {

            const diffuseMap = meshInstance.material.diffuseMap;
            const img = diffuseMap.getSource();





Error image:

Any clues in what is happening?

is it perhaps compressed texture?
or related to this? Add option to use Image instead of ImageBitmap when loading textures · Issue #4759 · playcanvas/engine · GitHub

1 Like

The compression was the problem!

Thank you!

1 Like