Blog

Anchors Explained: How to Set Up Annotations

2017-04-03

When you are working with 3D graphics, whether you like it or not, you begin to think in its terms. Any idea can be embodied in a 3D object, supplied with colorful material and provided with animation… here, an artist’s spirit can finally break free.

However, some simple things suddenly become just too complex when you are trying to implement them in 3D space. Take text, for example. You are probably aware of the fact that you can easily create text captions in Blender. It even features a kind of 3D text editor where you can set up font, its style, various spacings and everything else you might need. What’s more, Blend4Web is perfectly capable of understanding Blender text objects and rendering them in a web browser. But what you have to keep in mind is the fact that these objects are nothing more than simple 3D meshes that are not really fit for this particular task. Let’s go over their weak points:

1. They require too much memory. Every letter is a separate 3D object that consists of multiple vertices. Imagine what will happen if you have several hundreds of them.

2. Low quality. You can cheat and create a texture with the text you need beforehand, and then apply it to a simple plane. However, a text like this will not look very good, especially from a distance.

3. Configurability… don’t even think about it.

It would have been so much easier if we were able to use the text itself for text rendering, just like, you know, in a text editor.

What… did you just mention Canvas? Oh yes, you can use it. It is entirely possible to write a text on the canvas using standard HTML5 features. It is easy, but also slow, as WebGL has to literally draw each letter on the canvas, slower than it takes to render text with generic web browser methods.

Blend4Web offers you its own method of rendering text, which combines the speed of browser rendering with the ease of navigating in 3D space.

Fast And Simple

Among Blend4Web demos, there is one outstanding application called Planetarium. It shows our Solar System with masterfully done planet models orbiting the sun.

The most interesting part for us, however, is interactive captions. Each one of them is attached to a specific planet. If you click it, additional text information will be shown. And, they look stylish too.

All this starts with an anchor. This is what will keep your caption in the deep sea of the scene.

As you have probably guessed, an anchor is a special Blender scene object. Its purpose is to set a point that will be used to show text. In the Planetarium app, for example, anchors are attached to the planets and move with them.

An Empty object is used as an anchor. At the picture above, it is located near Saturn’s pole. It can be added to the scene with the Add | Empty | Plain Axes menu (the menu can be opened with the Shift+A hot keys).

If you want your anchor to be attached to a specific object, you should make a “parent-child” link. To do this, select your Empty, then add the root object to the selection (hold the Shift key while selecting it) and press Ctrl+P.

But an Empty by itself does nothing. To make captions visible in the browser window, you have to turn on the Enable Anchor option on the Object panel of this Empty object. Make sure that the Type field is set to the Annotation mode. The text itself is stored in the Meta Tags group.

Keep these simple rules of working with anchors in mind:

1. If the Meta Tags option is disabled, the name of the Empty object is used as the name of the anchor.

2. The Annotation mode uses built-in anchor design.

3. If you enter some text in the Description field, user will be able to see this text in an additional panel that will open by clicking on the name of the anchor.

4. The Description field can only contain text data. Don’t try to add images, links or iframe elements in it.

There is one more interesting option: Detect Visibility, found on the Anchors panel. Take a look at the picture below to find out what it does.

Here, the Mars object is covered by the sun, and isn’t visible, but the anchor with its name still is. Sometimes you might need this exact behavior, but other times you need to hide an anchor when an object is not visible. And this is exactly what Detect Visibility option does.

Expert Mode

The method that the developers offer you is convenient and easy to use, it is functional and looks pretty. However, it is rather limited as well. So let’s learn how to create your own design.

Here, everything is rather easy as well. You just need a regular anchor with the Custom Element option enabled in the Anchors field. From here on, you are in complete control of the design of your anchor. Just don’t forget to specify the ID of the element you need in the HTML Element ID field.

Everything else is done with HTML, CSS and JavaScript, and there are no limitations.

Let’s try to make a simple text output for our anchor. For example, one that simply prints some text in the background.

First, let’s define a place for the new element in the HTML file. Don’t forget that it should be located below the Canvas container:

<body>
  <div id="main_canvas_container"></div>
  <div id="my_design">This is my Anchor!</div>
</body>

The my_design title is used as an ID. This title should be specified in the HTML Element ID (see the figure above).

Then, let’s add a description of the element to CSS. I’ve altered the colors of the font and the background:

#my_design {
  position: absolute;
  background-color: #ffa201;
  border-radius: 5px;
  color: #000;
  font-weight: bold;
  box-shadow: 0 0 4px 2px #a94c00;
}

Now my anchor looks like this:

Now, let’s raise the bar by adding an option to open description window by clicking the name of the anchor.

Let’s alter the HTML file a bit by adding a new element for an additional window:

<body>
  <div id="main_canvas_container"></div>
  <div id="my_design">This is my Anchor!
	<div id="my_design_child"> Oh, yes! I see it...</div>
  </div>
</body>

And let’s expand CSS:

#my_design {
  cursor: pointer;
  position: absolute;
  background-color: #ffa201;
  border-radius: 5px;
  color: #000;
  font-weight: bold;
  box-shadow: 0 0 4px 2px #a94c00;
  display: none;
}
#my_design_child {
  position: absolute;
  top: 30px;
  background-color: #000;
  background-size: cover;
  height: 100px;
  border-radius: 5px;
  color: #ffa201;
  font-weight: bold;
  box-shadow: 0 0 4px 2px #a94c00;
  display: none;
}

Take a close look at the CSS blocks. Aside various bells and whistles, there are new display fields. These fields can be used to show and hide blocks. The blocks are turned off at startup. By the way, don’t try to use the visibility CSS property for this. This property is under complete control of the Blend4Web engine.

And now, it is time for some JavaScript code.

I’ve placed an entire code in the load_cb function that is called after the scene is loaded (it is a standard JavaScript template generated while creating a new project).

Find HTML elements we need:

var my_design = document.getElementById("my_design");
var my_design_child = document.getElementById("my_design_child");

Enable showing the name of the anchor:

my_design.style.display = "block";

Adding the “click” event to the first block. Now, if the title is clicked, the program will call the specified function to switch the visibility of the second block:

    my_design.addEventListener("click", function() {
		if (my_design_child.style.display == "block") {
			my_design_child.style.display = "none";	
		} else {
			my_design_child.style.display = "block";
		}
		
    }, false);

In the end, here’s what I’ve got:

As you can see, the Custom Element mode gives you free reign to create a GUI with any level of complexity, limited only by your imagination.

Link to the project.

Comments
24 dec. 2020 03:41
environments for business friends streaming , communityamerica uchoose rewards. planning process in kenya, community action council montgomery county positive adjectives that start with a?
friends gif http://ow.ly/jX5Z30rpRew# , positive correlation negative coefficient community college majors list? positive pregnancy test images first response climax community biology facts, process planning jobs positive correlation definition psychology quizlet.
positive and negative body language, community bridges in phoenix positive correlation matrix culture sociology definition.
28 dec. 2020 05:47
positive and negative whole numbers are called: community bridges west, community cast death. Related data: community action escanaba, community action council hagerstown maryland, community state bank, positive feedback regulation biology, social que community college nursing. positive feedback loop science positive reinforcement motivation Meilleur prix Albenza generique. OГ№ acheter albendazole 400 mg?#, positive reinforcement classroom positive feedback definition Acheter Cabergoline 0.5 mg en pharmacie# community health center greenville ky. community first credit union kimberly wisconsin positive affirmations meaning, community action partnership madera county, community action dayton ohio, positive and negative charges.
positive reinforcement quotes for students , community cast ken jeong zing environments limited community colleges near me that offer nursing.
02 may. 2022 01:04
natural viagra for men <a href="https://viagrahom.com/">hims sildenafil</a> homemade viagra
05 may. 2022 04:59
@@@+27655320351 Black Magic Death Spells Death sleep spells to revenge wicked enemies In Federated States of Moldova, Monaco, Mongolia, Montenegro It is a quick death spell that's use to cause heart attack on an enemies overnight and they will pass away instantly+27655320351 Voodoo revenge death spell that work fast to kill any witch craft enemies - Revenge Curses Spells it is use to cause pain on an enemies-black magic curse removals, this spell is to remove a curse from your marriage, career or business and your family. Death Spells That Work Overnight - Death Spell Chant +27655320351 Death sleep spells to revenge wicked enemies .Voodoo Death Spells Black Magic Revenge Spells Black magic revenge spell- spells can be cast on your behalf to curse hurt those you want to cause suffering Curses spells, voodoo revenge spells, hexes spells, powerful revenge spells, voodoo revenge & witchcraft revenge spells. Discipline someone with voodoo revenge spells+27655320351 Get rid on enemies & regain confidence using voodoo revenge spells by contacting my Voodoo Revenge Spells- Cast voodoo revenge spell on someone who is abusive or has wrong you. Regain the respect of the community & the people whose opinion matters to you with voodoo revenge spells Financial Disaster Revenge Spells Voodoo financial disaster revenge spells to hurt someone financially causing them to lose money, get fired from their job or experience financial disaster . Revenge Curses Spells +27655320351 Cause someone to suffer in one way or another using revenge curses spell Let misery & suffering befall your enemies using revenge spells To Break A Curse Break a curse using these powerful voodoo spells. Reverse the curse, remove the curse or cancel a jinx using powerful black magic voodoo spells. Call / What's App On +27655320351 .MAMA AFRIKA Email: mamaafrika974@gmail.com https://web.facebook.com/PowerfulSangomahealer https://web.facebook.com/Stronglovesangoma Web: https://www.africanleadinglovespellscaster.com
18 nov. 2022 15:15
is meryl streep gay https://boruvka.blog.idnes.cz/redir.aspx?url=https%3A%2F%2Fbeargayx.com%2Fcategories%2FMuscular%20Men%2F is casey cott gay
porno gay csasero https://www.google.com.cy/url?q=https://beargayx.com/categories/Old/Young/ quality porn tubes
gay adoption atlanta http://www.valleybankma.com/__media__/js/netsoltrademark.php?d=gayspornx.com%2Fcategories%2FTransgender%2F gay show amsterdam
for gay marriage arguments essays https://www.google.dk/url?q=https://beargayx.com/categories/Toys/ anal gay sex tube
gay rio de janeiro hotels http://maps.google.pl/url?q=https://malexnxx.com/categories/Cumshot/ imlive gay
danny nelson gay porn http://aircon-panasonic.ru/bitrix/redirect.php?event1=&event2=&event3=&goto=https://gayspornx.com/categories/Cumshot/ grandpa boy gay porn
gay chinese men porno http://onestepsurety.biz/__media__/js/netsoltrademark.php?d=beargayx.com%2Fcategories%2FTwink%2F lexington kentucky gay pride
paladins gay porn https://rs-class.org/bitrix/rk.php?goto=https://beargayx.com/categories/Hardcore/ gay porn star bottom
17 jan. 2023 04:38
http://makarov67.ru/bitrix/click.php?goto=https://uncensoredhentaixxx.com/category/genshin-impact-kaeya-hentai/
http://landmeier.org/__media__/js/netsoltrademark.php?d=uncensoredhentaixxx.com%2Fcategory%2Fgenshin-impact-sangonomiya-kokomi-hentai%2F
http://embersofautumn.us/__media__/js/netsoltrademark.php?d=uncensoredhentaixxx.com%2Fcategory%2Fgroup-sex%2F
http://roundtablehp.net/__media__/js/netsoltrademark.php?d=uncensoredhentaixxx.com%2Fcategory%2Fcreampie-hentai%2F
http://cwequinetradeshow.com/__media__/js/netsoltrademark.php?d=uncensoredhentaixxx.com%2Fcategory%2Fgenshin-impact-kujou-sara-hentai%2F
26 jan. 2023 14:38
https://www.himalaya.com/episode/how-professional-essay-writing-services-can-help-content-marketers-with-keyword-strategy-187236342
11 feb. 2023 12:58
<a href="http://amigate.com/langs/pages/?cbet_jetix_7.html">jetx</a>


jetx bet:https://portalinformatica.com.br/wp-content/pgs/?cbet_jetx_22.html
jetix apostas:https://popvalais.ch/wp-includes/inc/?jetx_bet_8.html
cbet jetx:http://pdtgeneve.ch/lib/inc/jeux_jetx_10.html
jetix bet:https://www.technipages.com/articles/jetix_apostas_4.html
12 feb. 2023 01:26
<a href="https://oldweirdherald.com/news/jetix_bet_3.html">jet x</a>


cbet jetx:http://arendaizrail.com/robin/jetix_bet_6.html
jetix jogo:https://guyanatourism.com/wp-content/inc/jetix_bet_5.html
cbet jetx:https://pinhalense.com.br/articles/jetix_jogo_8.html
jetix bet:https://pulosdogatos.com.br/articles/jetx_147.html
02 mar. 2023 16:16
Hello guys! Good article Anchors Explained: How to Set Up Annotations | Blend4Web


Омг Омг шоп - топовый сервис по продаже позиций особого назначения. Наиболее привлектальным для покупателя можно выделить моментальные сделки, а так же доступность. После оплаты заказа, вы сразу же сможете забрать товар - не нужно ничего ждать. На сайт Омг Омг шоп возможно беспрепятственно зайти, если знаешь рабочее зеркало - http://xn–omom-cxac.com , сайт доступен как через Tor, так и из обычного браузера. Этот сайт является шлюзом направляющим на официальный сайт Omg Omg shop.


<a href="http://xn–mg-7bb.com">omg гидра</a>
<a href="http://xn–mg-7bb.com">omg купить</a>
<a href="http://xn–mgmg-u0bc.com">омг омг площадка</a>


omg зеркало
Please register or log in to leave a reply.