Is there a way to initialize a (TypeScript) light to use includedOnlyMeshes without any meshes?

Hi everyone!

Fast question; is there a way to initialize a light with an empty includedOnlyMeshes array, so the light only affects the Meshes I want to add to the array?

Currently I do this:
light.includedOnlyMeshes = [null]

The code above does work, but if you put the TypeScript setting to strict, you get the following error:
Type 'null' is not assignable to type 'AbstractMesh'

Understandable, but is there a way to go around this issue? I’ve been wondering about this for a while now, and I think code wise Babylon only checks if there is anything in the includedOnlyMeshes to go into the “only process these Meshes” -mode.

I am afraid to change the default behavior mostly related to back compat on this one.

you could either create an empty AbstractMesh and use this in the array :slight_smile: or us null as unknown as AbstractMesh in typescript ?


Yeah, I was going for the AbstractMesh, but casting to null as unknown as AbstractMesh seems to be fine solution for now :smiley: Thanks for clarifying!

Maybe in the future there could be a boolean flag for the reallyUseIncludedOnlyMeshes or something :grin:

ahah, I love the name for this one !!! :slight_smile:

1 Like