# PointLightHelper position problem

**URL:** <https://discourse.threejs.org/t/pointlighthelper-position-problem/47760>\
**Category:** Questions\
**Tags:** geometry\
**Created:** [February 7, 2023, 11:29am UTC](https://discourse.threejs.org/t/pointlighthelper-position-problem/47760 "2023-02-07T11:29:53Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Smithangshu\_Ghosh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/smithangshu_ghosh/32/10803_2.png) [@Smithangshu\_Ghosh](https://discourse.threejs.org/u/Smithangshu_Ghosh)\
**Post date:** [February 7, 2023, 11:29am UTC](https://discourse.threejs.org/t/pointlighthelper-position-problem/47760/1 "2023-02-07T11:29:53Z")

</div>

If we add PointLight to a Group(or anything other than scene) along with the PointLightHelper. Then PointLightHelper does not move along with the PointLight.

I checked the documentation of PointLightHelper, it says following-  
.matrix : Object  
Reference to the pointLight’s matrixWorld

I think, this is causing the problem. Because, if the we translate the PointLight parent Group by 10 unit along with the X axis. So PointLight matrixWorld would have 10 unit value in the first row of the last column but PointLightHelper would have the same also but in it’s matrix, and that means it has 10 unit displacement along with X axis relative to it’s parent Group. So the parent group is already has 10 unit displacement along with X axis relative to scene center. But PointLightHelper now has 10+10=20 unit displacement along with X axis relative to scene center which is not correct.

Please suggest a workaround.

---

<div class="post-metadata">

**Author:** ![PavelBoytchev](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/pavelboytchev/32/38639_2.png) [@PavelBoytchev](https://discourse.threejs.org/u/PavelBoytchev)\
**Post date:** [February 7, 2023, 5:58pm UTC](https://discourse.threejs.org/t/pointlighthelper-position-problem/47760/2 "2023-02-07T17:58:30Z")

</div>

Just curious: Would it work if the `PointLight` is in a `Group`, but the `PointLightHelper` is outside?

---

<div class="post-metadata">

**Author:** ![Smithangshu\_Ghosh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/smithangshu_ghosh/32/10803_2.png) [@Smithangshu\_Ghosh](https://discourse.threejs.org/u/Smithangshu_Ghosh)\
**Post date:** [February 7, 2023, 6:02pm UTC](https://discourse.threejs.org/t/pointlighthelper-position-problem/47760/3 "2023-02-07T18:02:19Z")

</div>

If PointLightHelper is directly in scene but PointLight is inside a group it works. Because matrix and matrixWorld is same at that point for the PointLightHelper.

---

<div class="post-metadata">

**Author:** ![PavelBoytchev](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/pavelboytchev/32/38639_2.png) [@PavelBoytchev](https://discourse.threejs.org/u/PavelBoytchev)\
**Post date:** [February 7, 2023, 6:09pm UTC](https://discourse.threejs.org/t/pointlighthelper-position-problem/47760/4 "2023-02-07T18:09:46Z")

</div>

> [@Smithangshu\_Ghosh](#):
>
> Please suggest a workaround.

So, is this a workaround or not?

---

<div class="post-metadata">

**Author:** ![Smithangshu\_Ghosh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/smithangshu_ghosh/32/10803_2.png) [@Smithangshu\_Ghosh](https://discourse.threejs.org/u/Smithangshu_Ghosh)\
**Post date:** [February 7, 2023, 6:17pm UTC](https://discourse.threejs.org/t/pointlighthelper-position-problem/47760/5 "2023-02-07T18:17:43Z")

</div>

No sorry mate, I am already doing this. But I want to keep PointLight and PointLightHelper inside same parent. So, a solution that enables me to do that would be the workaround.

---

<div class="post-metadata">

**Author:** ![PavelBoytchev](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/pavelboytchev/32/38639_2.png) [@PavelBoytchev](https://discourse.threejs.org/u/PavelBoytchev)\
**Post date:** [February 7, 2023, 6:58pm UTC](https://discourse.threejs.org/t/pointlighthelper-position-problem/47760/6 "2023-02-07T18:58:53Z")

</div>

Does this work:

```javascript
var light = new THREE.PointLight( 'royalblue', 1 ),
    helper = new THREE.PointLightHelper( light.clone() ); // ← the magic is here

var lightGroup = new THREE.Group( );
    lightGroup.add( light, helper );

```

---

<div class="post-metadata">

**Author:** ![Smithangshu\_Ghosh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/smithangshu_ghosh/32/10803_2.png) [@Smithangshu\_Ghosh](https://discourse.threejs.org/u/Smithangshu_Ghosh)\
**Post date:** [February 7, 2023, 7:38pm UTC](https://discourse.threejs.org/t/pointlighthelper-position-problem/47760/7 "2023-02-07T19:38:41Z")

</div>

It only works when both are in a same Group, but it doesn’t work when both are directly inside the scene. Actually, what I want is to keep them inside same parent it could be a Group (or even in a Group that is situated deep inside multiple level of Groups) or the Scene.

---

<div class="post-metadata">

**Author:** ![PavelBoytchev](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/pavelboytchev/32/38639_2.png) [@PavelBoytchev](https://discourse.threejs.org/u/PavelBoytchev)\
**Post date:** [February 7, 2023, 7:42pm UTC](https://discourse.threejs.org/t/pointlighthelper-position-problem/47760/8 "2023-02-07T19:42:36Z")

</div>

You have a solution when the light and the helper are inside the same group. You have a solution when they are inside a scene. You can just combine both solutions. If the light is a child of the scene, add a helper for the light; otherwise, add a helper for the clone of the light.

---

<div class="post-metadata">

**Author:** ![Smithangshu\_Ghosh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/smithangshu_ghosh/32/10803_2.png) [@Smithangshu\_Ghosh](https://discourse.threejs.org/u/Smithangshu_Ghosh)\
**Post date:** [February 8, 2023, 7:35am UTC](https://discourse.threejs.org/t/pointlighthelper-position-problem/47760/9 "2023-02-08T07:35:54Z")

</div>

Hi mate, sorry for late reply. Actually, I am creating an 3D scene editor, it does not have anything fixed. We cannot have different solution for different cases. We need a unique solution, because just imagine in a scene element tree, if user drags PointLight to a Group from the Scene or to the Scene to from a Group. We cannot change between different solutions, for both PointLight and PointLightHelper. It will be very hard to manage, because it’s not only PointLight rather it could have huge list of things to manage. There is nothing to be hardcoded everything is dynamic. So, we need a solution which works regardless of which structure we are putting the PointLight in.

---

<div class="post-metadata">

**Author:** ![Smithangshu\_Ghosh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/smithangshu_ghosh/32/10803_2.png) [@Smithangshu\_Ghosh](https://discourse.threejs.org/u/Smithangshu_Ghosh)\
**Post date:** [February 8, 2023, 8:02am UTC](https://discourse.threejs.org/t/pointlighthelper-position-problem/47760/10 "2023-02-08T08:02:29Z")

</div>

I don’t know what the vision is behind to develop PointLightHelper in such a way, so that it only works correctly when it’s directly under the Scene. If does not have any specific vision or reason behind doing this, then it’s better to fix the code inside PointLightHelper rather than beating around the bush.

---

<div class="post-metadata">

**Author:** ![PavelBoytchev](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/pavelboytchev/32/38639_2.png) [@PavelBoytchev](https://discourse.threejs.org/u/PavelBoytchev)\
**Post date:** [February 8, 2023, 8:51am UTC](https://discourse.threejs.org/t/pointlighthelper-position-problem/47760/11 "2023-02-08T08:51:05Z")

</div>

Then, just make your own class `MyPointLightHelper` that installs a helper as a child of the light and without the automatic update of position. In this way when a helper is created, it does not need to be added to the scene or to the hosting group.

Click on the image to try it (red light/helper are in the scene, blue light/helper is in a group):

[![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/3/a/3a1119dcb61d3dc3074b738673a95491dc79ad5b.png)](https://codepen.io/boytchev/full/gOjJxgW)

Edit: replaced the link with a link to CodePen.

---

<div class="post-metadata">

**Author:** ![Smithangshu\_Ghosh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/smithangshu_ghosh/32/10803_2.png) [@Smithangshu\_Ghosh](https://discourse.threejs.org/u/Smithangshu_Ghosh)\
**Post date:** [February 8, 2023, 9:16am UTC](https://discourse.threejs.org/t/pointlighthelper-position-problem/47760/12 "2023-02-08T09:16:00Z")

</div>

I really appreciate your dedication to solve the problem. Also, I think the idea you are proposing would work for my case. Thanks a lot buddy.
