# Size scale attach to the camera

**URL:** <https://forum.babylonjs.com/t/size-scale-attach-to-the-camera/1322>\
**Category:** Questions\
**Created:** [February 12, 2019, 12:34pm UTC](https://forum.babylonjs.com/t/size-scale-attach-to-the-camera/1322 "2019-02-12T12:34:55Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![ninecurrentscript](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@ninecurrentscript](https://forum.babylonjs.com/u/ninecurrentscript)\
**Post date:** [February 12, 2019, 12:34pm UTC](https://forum.babylonjs.com/t/size-scale-attach-to-the-camera/1322/1 "2019-02-12T12:34:55Z")

</div>

Hello everyone,

I would like a size scale in my playground. I tried with the GUI but he does not use the same unit of the mesh. (One on pixel or pourcentage the other random unit). I’m also trying to attach one mesh (which serves to unit) to the camera to follow this movement but if i move the positioning of the camera or I zoom with them my “unit” don’t expand.

For exemple in this picture I want the black line as the same size what ever if I zoom or move camera

 ![56](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/1X/caa6d706f14ad1a7e26a3ce9578bc0670c29ea54.png)

If you have a solution or idea to do it, it would be perfect!

I set up a playground if you want test in my project : [Babylon.js Playground](https://playground.babylonjs.com/#7EPIGY)

Sorry for my bad english, if you don’t understand something don’t hesitate to ask me.

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![Wingnut](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wingnut/32/53_2.png) [@Wingnut](https://forum.babylonjs.com/u/Wingnut)\
**Post date:** [February 12, 2019, 2:06pm UTC](https://forum.babylonjs.com/t/size-scale-attach-to-the-camera/1322/2 "2019-02-12T14:06:01Z")

</div>

Hiya N! Your box is lookin’ great! I “had-to” make a “thin-panel” version… so I could see it without the z-fighting problem.

[https://playground.babylonjs.com/#7EPIGY#1](https://playground.babylonjs.com/#7EPIGY#1)

Ok, let’s clarify/reword a bit.

1. You want to put a black line/mesh/whatever… on the surface of the box?
2. The black thing must NOT get bigger/smaller when camera zooms in/out.
3. The black thing must display in the same orientation/position… for any box size/scale.

That sounds VERY CLOSE to edgesRenderer.

[https://playground.babylonjs.com/#7EPIGY#2](https://playground.babylonjs.com/#7EPIGY#2) (lines 336-342)

Maybe I am off-topic. 🙂 The black lines get “proportionally” (proportionately?) -bigger/smaller with camera zoom, and the black lines can never be clickable. But, maybe this is what you seek.

Note: The ‘_of_’ in line 337 likely does not work in standard Internet Explorer. Use a more-standard for-loop syntax… for “non-Edge” IE versions.

---

<div class="post-metadata">

**Author:** ![ninecurrentscript](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@ninecurrentscript](https://forum.babylonjs.com/u/ninecurrentscript)\
**Post date:** [February 12, 2019, 2:42pm UTC](https://forum.babylonjs.com/t/size-scale-attach-to-the-camera/1322/3 "2019-02-12T14:42:25Z")

</div>

Ok 😅, I’m probably not well explained.

I would like the same thing as this on “google maps”:  
 ![48](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/1X/01e1de7eb502d94ed18a9c5f9f456ebb4ae1230f.png)  
(On bottom right)

I don’t want to put a black line on the surface of the box it’s juste for explain 😂

---

<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:** [February 12, 2019, 3:53pm UTC](https://forum.babylonjs.com/t/size-scale-attach-to-the-camera/1322/4 "2019-02-12T15:53:44Z")

</div>

I think multilines from GUI could solve that:  
[https://doc.babylonjs.com/how\_to/gui#multiline](https://doc.babylonjs.com/how_to/gui#multiline)

---

<div class="post-metadata">

**Author:** ![ninecurrentscript](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@ninecurrentscript](https://forum.babylonjs.com/u/ninecurrentscript)\
**Post date:** [February 12, 2019, 4:01pm UTC](https://forum.babylonjs.com/t/size-scale-attach-to-the-camera/1322/5 "2019-02-12T16:01:35Z")

</div>

The problem with this is the size of multilines is on px or % but mesh is not on px or %  
It is necessary that I find the calculate for corresponding px or % on size of mesh ? 🤔

---

<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:** [February 12, 2019, 4:06pm UTC](https://forum.babylonjs.com/t/size-scale-attach-to-the-camera/1322/6 "2019-02-12T16:06:06Z")

</div>

You can give a mesh and the system will do the math for you. So just attach dummy meshes between two points and create a line between the two dummies

---

<div class="post-metadata">

**Author:** ![ninecurrentscript](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@ninecurrentscript](https://forum.babylonjs.com/u/ninecurrentscript)\
**Post date:** [February 13, 2019, 9:09am UTC](https://forum.babylonjs.com/t/size-scale-attach-to-the-camera/1322/7 "2019-02-13T09:09:16Z")

</div>

I think I use this technique because, with multilines lines, it is not possible to attach it to the camera.  
[https://playground.babylonjs.com/#7EPIGY#6](https://playground.babylonjs.com/#7EPIGY#6)

Thanks to the person who did his, but why the line is deform ?  
 ![28](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/1X/5242ae7f321f6451283b2a1bb5ea62c500568fcd.png)

The problem with this solution is if we change the size of the window the measurements are no longer true 😥

I think it’s impossible or it’s too difficult for my level in JS and BABYLON

---

<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:** [February 13, 2019, 7:32pm UTC](https://forum.babylonjs.com/t/size-scale-attach-to-the-camera/1322/8 "2019-02-13T19:32:35Z")

</div>

Never say never 🙂  
Let’s go back to whiteboard for a second: you have 3d coordinates right?

Here is an example that will draw lines between two 3d coordinates no matter what the window size is:  
[https://www.babylonjs-playground.com/#XCPP9Y#890](https://www.babylonjs-playground.com/#XCPP9Y#890)

---

<div class="post-metadata">

**Author:** ![ninecurrentscript](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@ninecurrentscript](https://forum.babylonjs.com/u/ninecurrentscript)\
**Post date:** [February 14, 2019, 9:06am UTC](https://forum.babylonjs.com/t/size-scale-attach-to-the-camera/1322/9 "2019-02-14T09:06:29Z")

</div>

Yes then I would like that if we move the camera it remains in the field of vision at the same place. This I succeeded with 2 scene but now the length of line don’t move and I would like the line move when i zoom.  
[https://www.babylonjs-playground.com/#XCPP9Y#892](https://www.babylonjs-playground.com/#XCPP9Y#892)

---

<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:** [February 14, 2019, 2:56pm UTC](https://forum.babylonjs.com/t/size-scale-attach-to-the-camera/1322/10 "2019-02-14T14:56:41Z")

</div>

sorry this is confusing 🙂 How do you want the line to move when zooming?

You have control over the 2 Vector3 that bind the line so you can do whatever you want with these 2 coordinates.

---

<div class="post-metadata">

**Author:** ![ninecurrentscript](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@ninecurrentscript](https://forum.babylonjs.com/u/ninecurrentscript)\
**Post date:** [February 15, 2019, 9:04am UTC](https://forum.babylonjs.com/t/size-scale-attach-to-the-camera/1322/11 "2019-02-15T09:04:32Z")

</div>

Sorry is very difficult to explain because english is not my natal language and same in french is difficult to explain 😅

I would like the line is the same size (length) of the object (Here the sphere) in the middle of playground.  
[https://www.babylonjs-playground.com/#XCPP9Y#895](https://www.babylonjs-playground.com/#XCPP9Y#895)

I think you speak French so if you need details I can explain in French it would be clearer 🇫🇷

---

<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:** [February 15, 2019, 2:42pm UTC](https://forum.babylonjs.com/t/size-scale-attach-to-the-camera/1322/12 "2019-02-15T14:42:12Z")

</div>

Please use french! (Sorry guys, but user needs first 😃 )

Donc en gros tu veux que ton trait fasse quoi?

---

<div class="post-metadata">

**Author:** ![ninecurrentscript](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@ninecurrentscript](https://forum.babylonjs.com/u/ninecurrentscript)\
**Post date:** [February 15, 2019, 3:05pm UTC](https://forum.babylonjs.com/t/size-scale-attach-to-the-camera/1322/13 "2019-02-15T15:05:07Z")

</div>

Merci beaucoup.

Donc en gros j’aimerais que la longueur de mon trait fasse toujours la même taille que mon objet mais juste visuellement.

Quand on zoom la taille de la sphère de bouge pas mais visuellement elle est plus grande. Je voudrais donc que la longueur du trait représente visuellement cette taille.

Je veux exactement comme sur ce site (en bas à gauche) [Plan Maison 3D Gratuit - Créez votre Plan 3D simplement | Kozikaza](https://www.kozikaza.com/kazaplan/new)

J’espère que ça sera plus plaire comme ça. 😆

---

<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:** [February 15, 2019, 3:30pm UTC](https://forum.babylonjs.com/t/size-scale-attach-to-the-camera/1322/14 "2019-02-15T15:30:49Z")

</div>

Alors du coup il suffit d’attacher deux meshes a la grosse sphere, de les placer correctement et ca devrait marcher:  
[https://www.babylonjs-playground.com/#XCPP9Y#896](https://www.babylonjs-playground.com/#XCPP9Y#896)

---

<div class="post-metadata">

**Author:** ![ninecurrentscript](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@ninecurrentscript](https://forum.babylonjs.com/u/ninecurrentscript)\
**Post date:** [February 15, 2019, 4:01pm UTC](https://forum.babylonjs.com/t/size-scale-attach-to-the-camera/1322/15 "2019-02-15T16:01:13Z")

</div>

Très bien mais du coup pour que la ligne soit par exemple toujours en bas à droite du playground et qu’il sont attacher à la grosse sphère, il faut que place les 2 mesh en fonction de la caméra c’est bien sa ?

---

<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:** [February 15, 2019, 5:14pm UTC](https://forum.babylonjs.com/t/size-scale-attach-to-the-camera/1322/16 "2019-02-15T17:14:19Z")

</div>

ha je crois que je commence a comprendre. Tu veux une echelle en fait?  
[https://www.babylonjs-playground.com/#XCPP9Y#897](https://www.babylonjs-playground.com/#XCPP9Y#897)

---

<div class="post-metadata">

**Author:** ![ninecurrentscript](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@ninecurrentscript](https://forum.babylonjs.com/u/ninecurrentscript)\
**Post date:** [February 18, 2019, 8:26am UTC](https://forum.babylonjs.com/t/size-scale-attach-to-the-camera/1322/17 "2019-02-18T08:26:56Z")

</div>

Oui c’est exactement ça !

Je te remercie énormément !

Here is a part of solution for my playground : [https://playground.babylonjs.com/#7EPIGY#10](https://playground.babylonjs.com/#7EPIGY#10)
