Hello!
This is my first forum post . I have just started my journey with babylon, js , so don’t be mad if my question is trivial, but I guess I Searched everywhere .
So, I have a task:
I need a text displayed in 3D , attached to some object like cube - done
This text must always be directed to camera - i used .billboardMode = BABYLON.Mesh.BILLBOARDMODE_ALL; and it works
and here is the hard part. Text has a lot of formating - bold, italic or both .
it looks like this :
Była sobieżabka mała Rere kum-kum rere kum-kum
Która mamy nie słuchała Rere kum-kum BĘĆ!
I am Polish and the text is also in Polish, but i guess the meaning is not that important .
I used an Array, divided the text, styled everything separately ,
then i used for(let i=o …)
it worked but the text overlaps ,it is illegible
I will be honored if someone try to help me
Hi, my suggestion would be to keep a running total of the width of each text block, and then when that width exceeds the max width allowed for one line, push the text block to the next line. You can turn resizeToFit on for the text blocks to have them calculate the width and height based on the dimensions of the text.
You will need to wait one frame after the text blocks are created for the dimensions to be calculated. Once the dimensions are there (you can check the text block’s widthInPixels and heightInPixels to retrieve them), you can calculate the layout using the method I described.
HI! Thank you for your answer. I really do appreciate this .
I understand what you mean , but to be honest I do not know where I can check after waiting one frame . Should I check console or inspector ?
Thank you for explaining ! Sorry for not answering for a while. I will definetely try your suggestion
I managed to do my task using dynamic texture and then drawText method, but I also spend some time aligning the text to look good.
@carolhmj@DarraghBurke@RaananW
Is this 'StructuredTextBlock’ PR still pending? (rethoric question, I know it is Anyways, I believe once it’s live, it would most certainly deserve to be showcased and mentioned.
Yeah, since the original author seems busy, it looks like we’ll have to take over it. If I’m not mistaken Raanan will be OOF the next two weeks, but I’ll discuss finishing the work with him once he’s back.