# Vector3 unproject issue

**URL:** <https://discourse.threejs.org/t/vector3-unproject-issue/13867>\
**Category:** Questions\
**Tags:** math\
**Created:** [March 27, 2020, 6:10am UTC](https://discourse.threejs.org/t/vector3-unproject-issue/13867 "2020-03-27T06:10:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alejandro\_Insua](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/alejandro_insua/32/3958_2.png) [@Alejandro\_Insua](https://discourse.threejs.org/u/Alejandro_Insua)\
**Post date:** [March 27, 2020, 6:10am UTC](https://discourse.threejs.org/t/vector3-unproject-issue/13867/1 "2020-03-27T06:10:20Z")

</div>

Hi

I am havin a problem in order to convert screen coordinates into 3d world coordinates.

The goal is to project 3d screen coord into the near plane of my camera.  
In my code I am using this function:

```
function screenPositionToWorldPosition(pos) {
		var screenNormalizedPosition = new THREE.Vector3(pos.x / canvas_w * 2 - 1, -pos.y / canvas_h * 2 + 1, 0);
		var vector = new THREE.Vector3( screenNormalizedPosition.x, screenNormalizedPosition.y, -1 ).unproject( aCamera );
		console.log("world near plane coords: ", vector);
		return vector;
	}

```

In the version v113 this is not working, it doesn’t matter which 2d scrren coordinates I pass to the function the 3d coords are always the same.

In the previous version I used this function it was working v101.

Best regards

---

<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 27, 2020, 10:15am UTC](https://discourse.threejs.org/t/vector3-unproject-issue/13867/2 "2020-03-27T10:15:09Z")

</div>

> [@Alejandro\_Insua](#):
>
> In the previous version I used this function it was working v101.

Starting with `R103`, `Vector3.unproject()` does not recompute the inverse projection matrix anymore. This already happened automatically when calling `updateProjectionMatrix()`. Try to call this method (and `updateMatrixWorld()` in order to ensure all relevant matrices are up-to-date before using `Vector3.unproject()`.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Insua](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/alejandro_insua/32/3958_2.png) [@Alejandro\_Insua](https://discourse.threejs.org/u/Alejandro_Insua)\
**Post date:** [March 27, 2020, 10:41am UTC](https://discourse.threejs.org/t/vector3-unproject-issue/13867/3 "2020-03-27T10:41:39Z")

</div>

Hi Mikel.

It doesn’t work, here you can see:

```
aCamera.updateProjectionMatrix()
console.log(new THREE.Vector3(0, 0, 0.5).unproject(aCamera));
    Vector3 {x: 26749.836375147395, y: 50204.284069682326, z: 4162.34619140625}

aCamera.updateProjectionMatrix()
console.log(new THREE.Vector3(0, 0.5, 0.5).unproject(aCamera));
         Vector3 {x: 26749.836375147395, y: 50204.284069682326, z: 4162.351550390079}

```

Best regards

---

<div class="post-metadata">

**Author:** ![Alejandro\_Insua](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/alejandro_insua/32/3958_2.png) [@Alejandro\_Insua](https://discourse.threejs.org/u/Alejandro_Insua)\
**Post date:** [March 27, 2020, 11:28am UTC](https://discourse.threejs.org/t/vector3-unproject-issue/13867/4 "2020-03-27T11:28:22Z")

</div>

Hi Mikel.

I have done a small trace and it seems that the argument camera on unproject function on three.js is not properly taken.

Best regards

---

<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 27, 2020, 11:58am UTC](https://discourse.threejs.org/t/vector3-unproject-issue/13867/5 "2020-03-27T11:58:05Z")

</div>

Not sure what you mean by that. The implementation of `Vector3.unproject()` looks correct.

Can you please demonstrate with a small [editable live example](https://jsfiddle.net/hyok6tvj/) the wrong behavior?
