# Adding Mesh on mouse click

**URL:** <https://discourse.threejs.org/t/adding-mesh-on-mouse-click/22922>\
**Category:** Questions\
**Tags:** raycaster\
**Created:** [January 28, 2021, 3:18pm UTC](https://discourse.threejs.org/t/adding-mesh-on-mouse-click/22922 "2021-01-28T15:18:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![w99910](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/w99910/32/14080_2.png) [@w99910](https://discourse.threejs.org/u/w99910)\
**Post date:** [January 28, 2021, 3:18pm UTC](https://discourse.threejs.org/t/adding-mesh-on-mouse-click/22922/1 "2021-01-28T15:18:05Z")

</div>

I wanna add simple mesh like box where is created at the position of mouse pointer.  
Please enlighten me. Thanks you.  
[https://codepen.io/w99910/pen/BaQBGym?editors=1011](https://codepen.io/w99910/pen/BaQBGym?editors=1011)

---

<div class="post-metadata">

**Author:** ![w99910](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/w99910/32/14080_2.png) [@w99910](https://discourse.threejs.org/u/w99910)\
**Post date:** [January 29, 2021, 10:37am UTC](https://discourse.threejs.org/t/adding-mesh-on-mouse-click/22922/2 "2021-01-29T10:37:23Z")

</div>

Any help ? Please 😅

---

<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:** [January 29, 2021, 1:17pm UTC](https://discourse.threejs.org/t/adding-mesh-on-mouse-click/22922/3 "2021-01-29T13:17:20Z")

</div>

Try it like so: [https://jsfiddle.net/sfpu9Lw2/](https://jsfiddle.net/sfpu9Lw2/)

The idea is to setup a raycaster with the mouse and camera like in the `three.js` demos. Instead of performing an intersection test, you use its ray and move a defined distance along it. This is done by using the `at()` method.

---

<div class="post-metadata">

**Author:** ![w99910](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/w99910/32/14080_2.png) [@w99910](https://discourse.threejs.org/u/w99910)\
**Post date:** [January 29, 2021, 2:34pm UTC](https://discourse.threejs.org/t/adding-mesh-on-mouse-click/22922/4 "2021-01-29T14:34:33Z")

</div>

Thank you so much. I have been struggling for two days.
