Experience-Monks / three-bmfont-text

renders BMFont files in ThreeJS with word-wrapping
http://jam3.github.io/three-bmfont-text/test/
MIT License
785 stars 168 forks source link

Ability to change color and opacity in MSDF/SDF shader? #23

Open iangilman opened 6 years ago

iangilman commented 6 years ago

If i want to update the color or opacity of my text, it looks like what I need to do is generate a fresh material each time, like so:

mesh.material = new RawShaderMaterial(MsdfShader(materialConfig));

I'm wondering how efficient that is for, say, a fading animation. Would it be possible to somehow expose the necessary uniforms, assuming that would be more efficient?

iangilman commented 6 years ago

Oh I see... I have to modify the uniforms, like so:

mesh.material.uniforms.opacity.value = 0.5;

I'm still learning Three.js, so this wasn't obvious at first. Perhaps it's worth mentioning in https://github.com/Jam3/three-bmfont-text/blob/master/docs/sdf.md ?