Crash with EquiRectangularCubeTexture instantiation with worker

Hi Everyone !

I am using BJS with a web worker for performance reasons.
When I try to create a new EquiRectangularCubeTexture, a crash occurs.

It happens because, to extract the texture buffer, the function _loadImage of the EquiRectangularCubeTexture create a new canvas in the document, which is not accessible in the worker scope.
const canvas = document.createElement("canvas");

Is there a possible workaround for this ? Maybe using the readPixels method ?

Thanks a lot !

Yeah this will not work for sure. Let me think about how to help you here

ok so unfortunately I cannot find a simple way to get the data from the image without using a canvas to read (and decode) the source image :frowning:

Wait! I may have an idea!

Here we are: Allow EquiRectangularCuteTexture to work in a Worker environment by deltakosh · Pull Request #15886 · BabylonJS/Babylon.js

3 Likes

Thanks a lot for the quick answer and PR ! :raised_hands:

1 Like