# Mesh disapears on vector.project

**URL:** <https://discourse.threejs.org/t/mesh-disapears-on-vector-project/6460>\
**Category:** Questions\
**Tags:** mesh, camera\
**Created:** [March 8, 2019, 3:21pm UTC](https://discourse.threejs.org/t/mesh-disapears-on-vector-project/6460 "2019-03-08T15:21:49Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ghostff](https://avatars.discourse-cdn.com/v4/letter/g/6a8cbe/32.png) [@Ghostff](https://discourse.threejs.org/u/Ghostff)\
**Post date:** [March 8, 2019, 3:21pm UTC](https://discourse.threejs.org/t/mesh-disapears-on-vector-project/6460/1 "2019-03-08T15:21:49Z")

</div>

Hi, I have a mesh and a text, and i want to move the mesh around with its text. The issue am facing is that each time i call the `toScreenPosition` function, it hides the mesh. (I think both of them move but i cant see mesh)

This is my sample  
[https://jsfiddle.net/8cmeLs1o/1/](https://jsfiddle.net/8cmeLs1o/1/)

commenting out `toScreenPosition` brings back the box mesh.

---

<div class="post-metadata">

**Author:** ![prisoner849](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/prisoner849/32/535_2.png) [@prisoner849](https://discourse.threejs.org/u/prisoner849)\
**Post date:** [March 8, 2019, 3:26pm UTC](https://discourse.threejs.org/t/mesh-disapears-on-vector-project/6460/2 "2019-03-08T15:26:29Z")

</div>

There is no `toScreenPosition()` function in the provided fiddle.

---

<div class="post-metadata">

**Author:** ![Ghostff](https://avatars.discourse-cdn.com/v4/letter/g/6a8cbe/32.png) [@Ghostff](https://discourse.threejs.org/u/Ghostff)\
**Post date:** [March 8, 2019, 3:27pm UTC](https://discourse.threejs.org/t/mesh-disapears-on-vector-project/6460/3 "2019-03-08T15:27:17Z")

</div>

Yes am sorry wrong link, i will make a new fiddle and update, wanted to delete but cant.

---

<div class="post-metadata">

**Author:** ![Ghostff](https://avatars.discourse-cdn.com/v4/letter/g/6a8cbe/32.png) [@Ghostff](https://discourse.threejs.org/u/Ghostff)\
**Post date:** [March 8, 2019, 3:40pm UTC](https://discourse.threejs.org/t/mesh-disapears-on-vector-project/6460/4 "2019-03-08T15:40:41Z")

</div>

Hi, i updated my fiddle link.

---

<div class="post-metadata">

**Author:** ![prisoner849](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/prisoner849/32/535_2.png) [@prisoner849](https://discourse.threejs.org/u/prisoner849)\
**Post date:** [March 8, 2019, 4:01pm UTC](https://discourse.threejs.org/t/mesh-disapears-on-vector-project/6460/5 "2019-03-08T16:01:21Z")

</div>

Did you try to log to console the result of `.project()`?

---

<div class="post-metadata">

**Author:** ![Ghostff](https://avatars.discourse-cdn.com/v4/letter/g/6a8cbe/32.png) [@Ghostff](https://discourse.threejs.org/u/Ghostff)\
**Post date:** [March 8, 2019, 4:08pm UTC](https://discourse.threejs.org/t/mesh-disapears-on-vector-project/6460/6 "2019-03-08T16:08:14Z")

</div>

for the first call in `init` i get `Object { x: NaN, y: -Infinity, z: -Infinity }`

---

<div class="post-metadata">

**Author:** ![Ghostff](https://avatars.discourse-cdn.com/v4/letter/g/6a8cbe/32.png) [@Ghostff](https://discourse.threejs.org/u/Ghostff)\
**Post date:** [March 12, 2019, 1:16pm UTC](https://discourse.threejs.org/t/mesh-disapears-on-vector-project/6460/7 "2019-03-12T13:16:43Z")

</div>

Hi, is there no solution to this.

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [March 12, 2019, 3:04pm UTC](https://discourse.threejs.org/t/mesh-disapears-on-vector-project/6460/8 "2019-03-12T15:04:08Z")

</div>

see

> [@Project world position to screen coordinate system](https://discourse.threejs.org/t/project-world-position-to-screen-coordinate-system/2477/2):
>
> You have to call camera.updateMatrixWorld(); before you use Vector3.project(). [https://jsfiddle.net/f2Lommf5/5772/](https://jsfiddle.net/f2Lommf5/5772/)

Adding `camera.updateMatrixWorld();` seems to solve the issue: [Edit fiddle - JSFiddle - Code Playground](https://jsfiddle.net/nutkbrgy/)

---

<div class="post-metadata">

**Author:** ![Ghostff](https://avatars.discourse-cdn.com/v4/letter/g/6a8cbe/32.png) [@Ghostff](https://discourse.threejs.org/u/Ghostff)\
**Post date:** [March 12, 2019, 3:09pm UTC](https://discourse.threejs.org/t/mesh-disapears-on-vector-project/6460/9 "2019-03-12T15:09:13Z")

</div>

No, i initial box is still hidden, what i mean if you comment out the line in `init()`.

```
// removing this shows mesh but wont set texts inital position.
toScreenPosition(mesh.position);
```

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [March 12, 2019, 3:15pm UTC](https://discourse.threejs.org/t/mesh-disapears-on-vector-project/6460/10 "2019-03-12T15:15:52Z")

</div>

The problem is right now that the project changes the position value of your cube. Try to clone the position vector before you pass it to `toScreenPosition()`. [https://jsfiddle.net/ak8f2dLb/](https://jsfiddle.net/ak8f2dLb/)
