Autodesk Forge Viewer – Add a field/box that allows text to be displayed in the viewer window itself

Viewed 49

Good morning, I need to be able to show in a corner of the Forge viewer the value of the zoom applied to the model I am viewing (for example "25%").

I wanted to know if it is possible to show this information by adding a text field/box or something similar in the viewer window itself (just as it has a toolbar with buttons, so add fields that show text).

I have tried to add it to the scene through a text mesh that I place in a certain position, but when zooming in on the model the size of the text increases or decreases (logical since it is a mesh, although it could be rescaled) and also when moving the model the mesh also moves with it (and here I do see a problem because I don't want to be constantly checking/reloading the scene just to get this text to appear where I want it to).

This solution therefore does not work for me and this is not what I want to do, so I need to know how I can display information (which would change value) in a fixed position in the viewer window. I think there must be a way to do it but I can't find how.

Thank you very much in advance, let me know if you have any questions and I'll try to explain myself better!

1 Answers

It's quite straightforward. Just to add an HTML DIV element. Here is an example:

var div = document.createElement('div');
div.style.zIndex = 2;
div.style.height = '10px';
div.style.position = 'absolute';
div.style.width = '100px';
div.style.top = 0;
div.style.backgroundColor = 'red';

viewer.container.appendChild(div);

Here is the result (see the red block at the left-top corner): enter image description here

Related