Jump to content

Long text labels on objects in BabylonJs


dbs2000
 Share

Recommended Posts

I started looking at this thread (http://www.html5gamedevs.com/topic/7238-label-on-top-of-an-objects/) but could not find what I wanted. I have followed this example also (http://playground.babylonjs.com/#O4OXG#4). But the problem is that the text is on a plane that is a square. In most places the labels are going to be long for me, like several words & I may also have the requirement of clicking the label to take some action. I can have a big plane & make it tranparent, as in this example, but the click (through actionManager.registerAction) would be on the plane which is now much bigger than the text. 
 
I tried using Ground instead of plane & making it a rectangular but the text gets squished if it is a rectangle
 
An ideal situation for me would be to have a piece of text independent of plane, where by the text itself is an object or otherwise have a rectangular plane or ground or mesh (of the size of the label) where the text does not get squished. Is any of these possible? Or is there any object labeling facility available directly in babylon that I am missing. 
 
Also let me take the opportunity to ask one more related question. Will it be possible to put line breaks/newline in the texts.
 
Thanks
Link to comment
Share on other sites

Hi Temechon,

Thanks for your reply. I tried what you suggested but without success. Here, is the code that I wrote.

 
var gSys = new bGUI.GUISystem(scene, 600, 600);
var txt = new bGUI.GUIText("txt1", 200, 100, { text: 'My test text', font: 'bold 25px Segoe UI' }, gSys);
txt.guiPosition.x = 10;
txt.guiPosition.y = 15;
txt.guiPosition.z = 5;
 
It came as a static piece of text on the top left corner of the canvas, half cut & it would not rotate or zoom with the mouse. Do I need to do something different?
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...