# Spotlight absolutePosition()

**URL:** <https://forum.babylonjs.com/t/spotlight-absoluteposition/47055>\
**Category:** Bugs\
**Tags:** spotlight\
**Created:** [January 8, 2024, 3:28pm UTC](https://forum.babylonjs.com/t/spotlight-absoluteposition/47055 "2024-01-08T15:28:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![RainerHeintzmann](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/rainerheintzmann/32/32692_2.png) [@RainerHeintzmann](https://forum.babylonjs.com/u/RainerHeintzmann)\
**Post date:** [January 8, 2024, 3:28pm UTC](https://forum.babylonjs.com/t/spotlight-absoluteposition/47055/1 "2024-01-08T15:28:53Z")

</div>

Playing with the spotlight, I noticed some odd behavior.  
When parenting the spotlight to another mesh, its getAbsolutePosition() does NOT update when the parent mesh is moved:

> **[Babylon.js Playground](https://playground.babylonjs.com/#20OAV9%2312835)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

This is very hard to understand and confusing to me. In the example workspace you can also see that another child `node`, attached to the spotlight does update correctly. Is this a bug? If not, the documentation should be more explicit on how to get the world-position of a spotlight. My feeling is, that the argument would be that “position” is only indicating the relative position from where the spotlight shines, but this is not in line with what `position` means everywhere else in conjunction with parenting etc.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [January 8, 2024, 4:59pm UTC](https://forum.babylonjs.com/t/spotlight-absoluteposition/47055/2 "2024-01-08T16:59:40Z")

</div>

Hello!  
I checked the SpotLight class to understand its behavior, and its inheritance chain is SpotLight → ShadowLight → Light → Node. So, it doesn’t inherit from TransformNode, whose `getAbsolutePosition` method computes the world matrix then gets the transformed absolute position: [Babylon.js/packages/dev/core/src/Meshes/transformNode.ts at c670e814b67be2f7be66ecafebe3119aa49278c7 · BabylonJS/Babylon.js · GitHub](https://github.com/BabylonJS/Babylon.js/blob/c670e814b67be2f7be66ecafebe3119aa49278c7/packages/dev/core/src/Meshes/transformNode.ts#L507). It instead inherits from ShadowLight’s `getAbsolutePosition`, which returns the untransformed position in case the transformed position hasn’t been calculated yet: [Babylon.js/packages/dev/core/src/Lights/shadowLight.ts at c670e814b67be2f7be66ecafebe3119aa49278c7 · BabylonJS/Babylon.js · GitHub](https://github.com/BabylonJS/Babylon.js/blob/c670e814b67be2f7be66ecafebe3119aa49278c7/packages/dev/core/src/Lights/shadowLight.ts#L262). If you calculate the transformed position with `computeTransformedInformation`, then the result of `getAbsolutePosition` is really the transformed one: [Spotlight Not Blocked By Mesh | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#20OAV9#12837). I’m not sure if `getAbsolutePosition` doesn’t call `computeTransformedInformation` beforehand for some purpose (which in case we should document this requirement), or if it is an oversight (in which case we should correct the method) - let me ping @sebavan to check 🙂

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [January 8, 2024, 10:39pm UTC](https://forum.babylonjs.com/t/spotlight-absoluteposition/47055/3 "2024-01-08T22:39:53Z")

</div>

It is by design to save perf so we do not do any extra calls but I agree it might be confusing.

I would be in favor of highlighting the behavior in the doc 🙂 @carolhmj would you mind adding it ?

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [January 9, 2024, 12:07pm UTC](https://forum.babylonjs.com/t/spotlight-absoluteposition/47055/4 "2024-01-09T12:07:34Z")

</div>

Complemented the docstring with this info: [Add clarification about transformed position in shadowLight. by carolhmj · Pull Request #14689 · BabylonJS/Babylon.js (github.com)](https://github.com/BabylonJS/Babylon.js/pull/14689)

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [January 9, 2024, 5:16pm UTC](https://forum.babylonjs.com/t/spotlight-absoluteposition/47055/5 "2024-01-09T17:16:05Z")

</div>

you are the best @carolhmj
