BABYLON.WaterMaterial scene parameter required?

I experimented with different materials and found that WaterMaterial doesn’t work without the scene parameter.
All other materials work.

If you remove the scene parameter in line 32, then an error occurs


API doesn’t tell us that scene parameter is optional - WaterMaterial | Babylon.js Documentation

1 Like

This is because of a bug in WaterMaterial’s constructor, where the parameter scene is used when this.getScene() should be used instead.

EDIT: and here’s the PR :slight_smile:

1 Like

The Material base class has this line in its constructor thou which makes passing the scene effectively optional even thou it’s not an optional parameter. Probably the parameter’s description should mention this so it’s more clear thou. :slight_smile:

this._scene = scene || EngineStore.LastCreatedScene;

I think it should be mentioned in API description. Currently it is not clear.
It is really nice when you may use the same materials in different scenes -

1 Like