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
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
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
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.
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 - https://playground.babylonjs.com/#MXCRPS#244