# Light issues with custom camera

**URL:** <https://forum.babylonjs.com/t/light-issues-with-custom-camera/44160>\
**Category:** Questions\
**Created:** [September 15, 2023, 8:47am UTC](https://forum.babylonjs.com/t/light-issues-with-custom-camera/44160 "2023-09-15T08:47:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![7om](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/7om/32/11158_2.png) [@7om](https://forum.babylonjs.com/u/7om)\
**Post date:** [September 15, 2023, 8:47am UTC](https://forum.babylonjs.com/t/light-issues-with-custom-camera/44160/1 "2023-09-15T08:47:30Z")

</div>

I need a camera which is similar to an ArcRotateCamera, but with more “intuitive” rotations, so I customized a basic Camera class. I’m not yet done with the rotations, but what I already noticed is that the light behaves differently and I guess, my camera is missing some required attributes.

Here’s the [PG](https://playground.babylonjs.com/#3YLXE9#21).  
Update with working rotation: [PG](https://playground.babylonjs.com/#3YLXE9#24)

You can switch between my custom camera and an ArcRotateCamera with the boolean in the first line. As you can see, the two light sources are rendered incorrectly with my custom camera. [The final goal is to attach the two lights to the camera (as parent) but I commented that out for now.]

Any ideas what is missing are highly appreciated! Thanks in advance! 🙏

---

<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:** [September 15, 2023, 11:21am UTC](https://forum.babylonjs.com/t/light-issues-with-custom-camera/44160/2 "2023-09-15T11:21:47Z")

</div>

cc @PolygonalSun

---

<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:** [September 18, 2023, 3:35pm UTC](https://forum.babylonjs.com/t/light-issues-with-custom-camera/44160/3 "2023-09-18T15:35:16Z")

</div>

Assigned @PolygonalSun on September 18, 2023, 3:35pm UTC



---

<div class="post-metadata">

**Author:** ![PolygonalSun](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/polygonalsun/32/2704_2.png) [@PolygonalSun](https://forum.babylonjs.com/u/PolygonalSun)\
**Post date:** [September 18, 2023, 7:18pm UTC](https://forum.babylonjs.com/t/light-issues-with-custom-camera/44160/4 "2023-09-18T19:18:54Z")

</div>

I’m not quite sure that anything obvious stands out to me though I’m not too familiar with lighting. I’d imagine that there’s something that’s missing to update the lighting (callback or observable maybe?). @sebavan or @Evgeni_Popov, I don’t suppose you’d have any ideas, would you?

---

<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:** [September 18, 2023, 11:06pm UTC](https://forum.babylonjs.com/t/light-issues-with-custom-camera/44160/5 "2023-09-18T23:06:18Z")

</div>

@7om your code does not update globalPosition which is used by the babylon materials:

here is how the target camera is doing.

> <https://github.com/BabylonJS/Babylon.js/blob/master/packages/dev/core/src/Cameras/targetCamera.ts#L494>

---

<div class="post-metadata">

**Author:** ![7om](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/7om/32/11158_2.png) [@7om](https://forum.babylonjs.com/u/7om)\
**Post date:** [September 19, 2023, 8:40am UTC](https://forum.babylonjs.com/t/light-issues-with-custom-camera/44160/6 "2023-09-19T08:40:42Z")

</div>

@sebavan thanks a lot! That solved the issue. 🥳

I found it quite challenging to implement all the required stuff based on Camera to get a working customized camera. A template (or abstract base) class which points to all the required attributes and methods would have been very helpful (like the \_cache stuff or this \_globalPosition attribute). Or just a PG which is kept up to date. I know, so much one _could_ do and so little time…

---

<div class="post-metadata">

**Author:** ![PolygonalSun](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/polygonalsun/32/2704_2.png) [@PolygonalSun](https://forum.babylonjs.com/u/PolygonalSun)\
**Post date:** [September 19, 2023, 6:01pm UTC](https://forum.babylonjs.com/t/light-issues-with-custom-camera/44160/7 "2023-09-19T18:01:15Z")

</div>

Unassigned @PolygonalSun on September 19, 2023, 6:01pm UTC



---

<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:** [September 19, 2023, 8:35pm UTC](https://forum.babylonjs.com/t/light-issues-with-custom-camera/44160/8 "2023-09-19T20:35:57Z")

</div>

Agree this is a nice topic to document cc @PolygonalSun and @PatrickRyan
