Volumetric Light Scattering Post Process never creates default mesh in 5.0.0-alpha.37

Hi there!
This is a TypeScript only related problem.

mesh will be never null, it can be a Mesh instance or undefined as seen on the second screenshot.

Obviously, you can’t call the constructor with a null mesh parameter.


Getting the scene should be also changed to:
scene = scene ?? camera.getScene()

camera can not be null nor undefined according to d.ts. If one provides the scene parameter, it should take precedence.

Any thoughts?! :slight_smile:

Thank you!


Hey @roland , pinging @Evgeni_Popov to see if he can help

Maybe the function signature has evolved while the code remained…

Technically you are right, but changing it would be a breaking change as the code can still be called directly through javascript and so null values can be passed.

I don’t know if we should fix that or not. Thoughts @RaananW and @Deltakosh?

Hey, what about this?

scene = ((camera === null || camera === undefined) ? scene : camera.getScene());


_this.mesh = ((mesh !== null && mesh !== undefined) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene));


Why not

this.mesh = mesh ??  VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene)));


scene =  scene ?? camera.getScene());
1 Like

If we don’t want a breaking change, the scene one should be:

scene = camera?.getScene() ?? scene


seems like camera is never null, but I agree that .js users are still able to pass null. Sure, this seems like a clean solution

Sure, it can be done in multiple ways, but at the end it gets transpiled to something similar to my code. And this way it is much more cleaner for everyone, that it accepts both null and undefined in javascript. :sunglasses:

sure, but we are still in typescript and still need to keep back compat

I get it. But I don’t see any problems, if we just change those two lines. We don’t break the d.ts, we don’t break backwards compatibility for js, for ts neither. Or am I missing something?

I might be missing something :slight_smile:

ts will anyhow generate this code in js, as this is the way it transpiles to js. So Why do we need the extra characters in our source (ts) code?

Guys, I just reported the error, it is really up to you, how would you like to fix it. I don’t feel privileged to argue.

I quickly solved the problem by sending a mesh into the constructor


I think we totally agree on everything :slight_smile:

it’s just the typescript syntax we are stuck on. Thanks for reporting the bug, it will be available in the next nightly - mesh can be undefined (and not only null) by RaananW · Pull Request #10841 · BabylonJS/Babylon.js (github.com)

1 Like

To be honest I am a fan of the latest stuff… :alien: so let’s ??

1 Like