expo-three icon indicating copy to clipboard operation
expo-three copied to clipboard

Canvas as a Texture

Open Secretmapper opened this issue 6 years ago • 8 comments

Displaying text in a plane with Three requires text placed on a canvas, then used a texture.

However, doing this in expo causes the error 'Invalid pixel data argument for gl.textImage2D()' I imagine because ExpoThree needs to wrap this texture data somehow.

Am I missing something, or is native magic needed for this?

Secretmapper avatar Jul 24 '18 11:07 Secretmapper

I think that the canvas is converted to base64 then sent to EXGL to be rendered. Unfortunately Base64 isn't supported in EXGL. I would recommend overriding this logic and writing the Base64 to a local URI first.

EvanBacon avatar Jul 31 '18 17:07 EvanBacon

@Secretmapper Have you successfully written text on canvas, then used that as a texture?

I am trying to do the same thing. I used react-native-canvas as the canvas and get the same error, Invalid pixel data argument for gl.textImage2D().

jacky-ttt avatar Dec 11 '18 12:12 jacky-ttt

Same Error here, map Canvas with CanvasTexture in material fails with Invalid pixel data argument for gl.textImage2D().

Will you plan to create some workflow for this issue?

xedoken avatar Mar 25 '19 09:03 xedoken

I'm running into this issue when trying to render text sprites through canvas. Some sort of workaround would be useful.

JuicyPasta avatar Jul 03 '19 06:07 JuicyPasta

Same error, trying to use react-native-canvas with Expo. Any workaround would be appreciated!

atablash avatar Aug 27 '19 14:08 atablash

Same here! Would be awesome in order to create a game HUD within expo.

joergjaeckel avatar Dec 10 '19 12:12 joergjaeckel

Same here! I would like to use some text rendered via react-native in a texture. And dunno how to do it, when i'm using ExpoTHREE.TextureLoader with a tmp file i got the error Could not download from ...

jniac avatar Dec 20 '19 13:12 jniac

Same problem here. Anybody find a work around for this?

alexcrist avatar Mar 19 '22 18:03 alexcrist