Cannot Create Texture in PlayCanvas 1.52.6

I’m working on a playcanvas project that worked fine before the latest update (PlayCanvas 1.52.6) .

Now it seems that creating a texture like this:

var texture = new pc.Texture(1, {

    width: 8,

    height: 8,

    format: pc.PIXELFORMAT_R8_G8_B8

});

will result in an error like this:

TypeError: graphicsDevice.createTextureImpl is not a function
    at new Texture (playcanvas.dbg.js?version=1.52.6:7447:31)

Would anyone know what has changed between the versions to cause this error?
Is there a work around that anyone would know about?

Thanks for your time

the constructor of the Texture accepts graphicsDevice as a first parameter - you need to pass that instead of 1.

see here Texture | PlayCanvas API Reference

Thank you! This did the trick!

var texture = new pc.Texture(this.app.graphicsDevice, {

    width: 8,

    height: 8,

    format: pc.PIXELFORMAT_R8_G8_B8

});

Out of Curiosity, would you be willing to explain why it worked in the previous version ?

Thanks again!

@devinhell the API always required to provide a device as a first argument. If you didn’t see an error in previous version, then there must be other issues in your code that prevented showing it.

in the previous version, the graphicsDevice wasn’t used in the constructor and only later … so it was likely creating some errors later. In the new version, it’s used right away.

4 Likes