Text is not rendered, issues creating floating labels in 3d space

Im trying to create simple floating text labels around the 3dspace,
I didn’t find the way to do them by themselves, so I am trying this:

// Create the 3D UI manager

var manager = new GUI.GUI3DManager(scene);

// Create a horizontal stack panel

var panel = new GUI.StackPanel3D();

panel.margin = 0.02;

manager.addControl(panel);

panel.position = new Vector3(0, 300, -50);

panel.scaling = new Vector3(100, 100, 100);

var button = new GUI.Button3D("orientation");

panel.addControl(button);

var text1 = new GUI.TextBlock();

text1.text = "Trying to create text label";

text1.color = "white";

text1.fontSize = 24333;

text1.fontFamily = "Arial";

button.content = text1;

and I can see the panel, the rectangular panel appears well,
and the text as well

but how can I make text labels appear without the panel, just by themselves?
and that I can position anywhere I want in the 3d space

thank you :slight_smile:

Have you tried the linkWithMesh property? See The Babylon GUI | Babylon.js Documentation

The mesh can in fact be a simple transformNode, you don’t have to pass a visible mesh to this method.

thank you,
look just put the code here

it says GUI not found, how can I include GUI library?

and in any case how can I make floating text label positioned in 3d space without panel or button?

will also check the linkmesh property you suggest :slight_smile:

this is not good because its 2d
All controls can be moved to track position of a mesh. To do this, just call control.linkWithMesh(mesh) . You can then offset the position with control.linkOffsetX and control.linkOffsetY .

I want to position in 3d space the label

The transformNode you pass to linkWithMesh holds a 3D position, so just set the transformNode position with your 3D coordinates.

look

but I dont see the text

yes now its there

just have to get rid of button and panel

You are mixing GUI 2D and GUI 3D. TextBlock is a control of GUI 2D, not GUI 3D. Look at the docs to see what pertains to 2D / 3D.

In your case, you need to create a full screen UI:

[UPDATE]
I stand corrected, you can use a 2D control as the content of a 3D button! But if you only want floating labels, the easiest way is to simply use the 2D GUI as shown in the PG above.
[/UPDATE]

yes thats a great example
thats exactly what i need

but again i have the same issue of before
var advancedTexture = GUI.AdvancedDynamicTexture.CreateFullscreenUI(“UI”);
that line keeps failing,
and I do have an scene created,
and I try to put parameters

“UI”, width, height, scene

but it fails with error

and i cannot put it in playground as i have two react separated files

Did you check the doc of CreateFullscreenUI as hinted in another thread?

It does not take name, width, height, scene as parameters.

1 Like

yes now it works!!!
thank you so much!
I had seen those parameters in another page, but in this link you sent the right ones were written, thank you,
it works

question, any suggestion if i wanted to have a thin line going from the text down, like you know when you put a marker in a model with text on top

oh next challenge,
this is still not what i need

I need to associate a text to a specific point in 3d , attached to the 3d model,

when i rotate now camera around model, text position doesnt match with model mmm

The doc site is really your friend :slight_smile:

(second PG of the paragraph has line + label)

1 Like

so I added the code of that example


and I can see the green rectangle with text, successful, just as in example,
but when i rotate camera the rectangle is not attached to the model,
even though i did a linktomesh with my model as parameter

i wonder if it has to do with type of camera,

I have used
scene.createDefaultCameraOrLight(true, true, true);

I think i see whats happening,
Im maybe rotating the object,
so the question is how can I rotate the object and maintain the linked texts rotating with it,

or alternatively,
how can i rotate main camera around a mesh, maintaining linked texts moving with it

the playground example is not rotating around object

very interesting, i see, i was replacing the main camera with that one,
but if i use this:

var camera = new FreeCamera(“camera1”, new Vector3(0, 0, -0), scene);
camera.setTarget(Vector3.Zero());
const canvas = scene.getEngine().getRenderingCanvas();
camera.attachControl(canvas, true);

the camera view appears,
but nothing happens when moving mouse,
no rotation around object

ok yes using
ArcRotateCamera
now it rotates around mesh, good,

but texts dont stay attached to mesh

Whatever the camera the label stays attached to the 3D position of the linked mesh.

You will need to either provide a repro or some screenshots to explain what you mean, I’m not sure I understand, the PG I have linked above does work, the text stays where it is supposed to be.

here you can see the problem:

change that if possible so that text is always attached to one of the corners of the mesh,
so that when you rotate camera, text is always attached to one specific corner of mesh

The easiest way to do that is to create a transform node and make it parent of the box so that it follows this mesh if moved: