# Babylonjs hotspots/annotations

**URL:** <https://forum.babylonjs.com/t/babylonjs-hotspots-annotations/13341>\
**Category:** Questions\
**Created:** [August 12, 2020, 6:28pm UTC](https://forum.babylonjs.com/t/babylonjs-hotspots-annotations/13341 "2020-08-12T18:28:44Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![nogalo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nogalo/32/120_2.png) [@nogalo](https://forum.babylonjs.com/u/nogalo)\
**Post date:** [August 12, 2020, 6:28pm UTC](https://forum.babylonjs.com/t/babylonjs-hotspots-annotations/13341/1 "2020-08-12T18:28:44Z")

</div>

Hi guys. How can I create something like this with Babylon?

[https://modelviewer.dev/examples/annotations.html](https://modelviewer.dev/examples/annotations.html)

I know there is a way to connect GUI with the mesh in Babylon. But I am not sure how it works when user places the hotspot on the model. How can I detect that position on the model and add hotspot there which will then properly be linked to that position in 3D space.

This is type of annotations I am looking for (it should be fairly simply to create this using GUI)

![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [August 12, 2020, 7:29pm UTC](https://forum.babylonjs.com/t/babylonjs-hotspots-annotations/13341/2 "2020-08-12T19:29:30Z")

</div>

Hey, you can simply create dummy meshes (set with visible = false), attach that mesh to the parent mesh and call it a day 😃

---

<div class="post-metadata">

**Author:** ![nogalo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nogalo/32/120_2.png) [@nogalo](https://forum.babylonjs.com/u/nogalo)\
**Post date:** [August 12, 2020, 7:48pm UTC](https://forum.babylonjs.com/t/babylonjs-hotspots-annotations/13341/3 "2020-08-12T19:48:35Z")

</div>

Oh, that’s interesting. So I could create dummy mesh and on user click I could place that mesh on the position where is clicked on the model (so something like using picking rays to determine where it is clicked in 3D space). And with that dummy mesh I create GUI element which is parented to it, that way it will look properly in the scene, and I can even detect when the mesh is occluded, so I can make GUI element less/or no visible in the scene.

Could this work like that?

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [August 12, 2020, 8:26pm UTC](https://forum.babylonjs.com/t/babylonjs-hotspots-annotations/13341/4 "2020-08-12T20:26:08Z")

</div>

yep!

---

<div class="post-metadata">

**Author:** ![nogalo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nogalo/32/120_2.png) [@nogalo](https://forum.babylonjs.com/u/nogalo)\
**Post date:** [August 12, 2020, 8:37pm UTC](https://forum.babylonjs.com/t/babylonjs-hotspots-annotations/13341/5 "2020-08-12T20:37:34Z")

</div>

Yea. I feel like this solved my problem, even though I didn’t implemented it yet. Thank you for the great thinking. As always, life is easier with you guys. I am constantly grateful that I chose to work with Babylon instead of any other engine, you guys are amazing. 🙂

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [August 12, 2020, 8:45pm UTC](https://forum.babylonjs.com/t/babylonjs-hotspots-annotations/13341/6 "2020-08-12T20:45:41Z")

</div>

Please spread the word 😉

---

<div class="post-metadata">

**Author:** ![jayakannan](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@jayakannan](https://forum.babylonjs.com/u/jayakannan)\
**Post date:** [July 5, 2021, 11:35am UTC](https://forum.babylonjs.com/t/babylonjs-hotspots-annotations/13341/7 "2021-07-05T11:35:16Z")

</div>

any playground example for this.

---

<div class="post-metadata">

**Author:** ![Hamid\_Nawaz](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/hamid_nawaz/32/16255_2.png) [@Hamid\_Nawaz](https://forum.babylonjs.com/u/Hamid_Nawaz)\
**Post date:** [July 5, 2021, 1:48pm UTC](https://forum.babylonjs.com/t/babylonjs-hotspots-annotations/13341/8 "2021-07-05T13:48:28Z")

</div>

Hey, this is a quick playground I made.  
[https://playground.babylonjs.com/#EES9W5#4](https://playground.babylonjs.com/#EES9W5#4)

Instead of creating a sphere you can create gui.

---

<div class="post-metadata">

**Author:** ![jayakannan](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@jayakannan](https://forum.babylonjs.com/u/jayakannan)\
**Post date:** [July 6, 2021, 6:14am UTC](https://forum.babylonjs.com/t/babylonjs-hotspots-annotations/13341/9 "2021-07-06T06:14:54Z")

</div>

Okay, But can we use normal html and css customized hotspot on this. and you used the following lines in the sample playground.

```auto
scene.onDispose = function(){
        scene.onPrePointerObservable.removeCallback(onPointerDown);
    };

```

What is the purpose of it?

---

<div class="post-metadata">

**Author:** ![Hamid\_Nawaz](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/hamid_nawaz/32/16255_2.png) [@Hamid\_Nawaz](https://forum.babylonjs.com/u/Hamid_Nawaz)\
**Post date:** [July 6, 2021, 6:37am UTC](https://forum.babylonjs.com/t/babylonjs-hotspots-annotations/13341/10 "2021-07-06T06:37:11Z")

</div>

I am sorry I don’t know what you mean by this.

> [@jayakannan](#):
>
> can we use normal html and css customized hotspot on this

Also It is good practice to remove an observable when it is not being used. Because we added a POINTERDOWN observable on scene(line 49) we want to remove it when the scene is removed which is what is happening in this code. The onDispose is called when the scene is being disposed.

---

<div class="post-metadata">

**Author:** ![jayakannan](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@jayakannan](https://forum.babylonjs.com/u/jayakannan)\
**Post date:** [July 6, 2021, 6:43am UTC](https://forum.babylonjs.com/t/babylonjs-hotspots-annotations/13341/11 "2021-07-06T06:43:14Z")

</div>

Thanks for your kind reply. Actually my need is , create some hotspots in webgl scene. But the hotspots should be created with the html and css, like a rounded image for hotspot and while clicking it some effects needs to be happened using css. is it possible ?

////  
please have a look into the below link. In this some hotspot has been made with html and css .  
https://codepen.io/vsueiro/embed/preview/KvpLEj?default-tabs=css%2Cresult&height=300&host=https%3A%2F%2Fcodepen.io&slug-hash=KvpLEj  
I need this kind of hotspots in webgl scene. Is it possible

---

<div class="post-metadata">

**Author:** ![Hamid\_Nawaz](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/hamid_nawaz/32/16255_2.png) [@Hamid\_Nawaz](https://forum.babylonjs.com/u/Hamid_Nawaz)\
**Post date:** [July 6, 2021, 7:19am UTC](https://forum.babylonjs.com/t/babylonjs-hotspots-annotations/13341/12 "2021-07-06T07:19:13Z")

</div>

I think you should use [Babylon GUI](https://doc.babylonjs.com/divingDeeper/gui/gui) for the hotspots and change css on button click like you normally would. You might have to change your logic to open the popups.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [July 6, 2021, 7:56am UTC](https://forum.babylonjs.com/t/babylonjs-hotspots-annotations/13341/13 "2021-07-06T07:56:48Z")

</div>

If you definitely need html you would need to rely on the unproject functions from the maths lib to find your css position in the canvas so you could manually mix and match them

---

<div class="post-metadata">

**Author:** ![jayakannan](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@jayakannan](https://forum.babylonjs.com/u/jayakannan)\
**Post date:** [July 6, 2021, 9:02am UTC](https://forum.babylonjs.com/t/babylonjs-hotspots-annotations/13341/14 "2021-07-06T09:02:20Z")

</div>

@sebavan Thanks for your reply. Any other way except html available in babylonjs to get a hotspot like this? Actually I tried Sprites. but when I use it and the performance is very low. So only I am searching some other way.;

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [July 6, 2021, 9:07am UTC](https://forum.babylonjs.com/t/babylonjs-hotspots-annotations/13341/15 "2021-07-06T09:07:07Z")

</div>

Sprites should be fast not sure why they would be slow Could ypu share a repro ?
