I'm trying to add canvas with text on existing mesh that already has a texture. But no matter what, I always getting black background instead of transparent.
my current canvas init.
function canvasTexture() {
const canvas = document.createElement('canvas');
canvas.width = 1276;
canvas.height = 295;
const ctx = canvas.getContext('2d');
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.font = '48px serif';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillStyle = 'red';
ctx.fillText('Hello world', 300, 150);
const canvasTxt = new THREE.CanvasTexture(canvas);
canvasTxt.needsUpdate = true;
return canvasTxt;
}
And my result always black background with red text. I can change color of that backgorund(by setting ctx.fillRect and fillStyle, but it does not recognise alpha channel on fillStyle = "rgba(0,0,0,0,)).
Maybe someone has any ideas?
I'm using Three js fiber and alpha is true there on renderer.