Error when trying light.excludedMeshes.push(obj)

Good morning!

I have another one of those “works in a playground” but not in a project thing going on. So I’ve been trying to work with multiple lights. I have 7 and want some spheres I’m generating to be ignored by all but 1 light.

I saw this playground and played with it, finding it to my liking.

But when trying it on a local project I got this error:

Uncaught TypeError: a[s]._resyncLighSource is not a function
at Array.e.push (babylon.js:7019)

Thrown at my code in this area:

let dls = Discrepancies.filter(function (disc) {  
        // returns sphere mesh from an array of objects
        return disc.sphere;
dls.forEach(function (disc) {
    light.excludedMeshes.push(disc);        // <== Errors out here

Any thoughts of why this might be?

I wonder, is _resyncLighSource supposed to be _resyncLightSource?

Not to say that the way which you are trying should not work, but another way is layermasks. It would be really easy if you also were ok with light7 only is for the spheres.

It would still work even if the light for the sphere needed to work for but much trickier, using excludeWithLayerMask for all the other lights, like you are currently doing.

sphereN.layerMask = 0x10000000;
light.includeOnlyWithLayerMask =  0x10000000;
1 Like

very cool! thanks a ton, JC!

Are you sure to be on the latest version? Also you can share a repro somewhere while referencing babylon.max.js so we can debug :slight_smile:

The last time I upgraded was fairly recent. I want to say I’m on 3.3. So maybe not the latest but for sure more recent than that playground in the original post. I will try to reproduce it somewhere.

Yes please that is the best option to get help