Optimized ground cannot be added to water reflection

If I add the ground (CreateGroundFromHeightMap()) that has been optimized with ground.optimize() then added to the reflection of the water (addToRenderList(ground)), it creates this problem : Error property ‘0’ of undefined. I get a black screen

In this PG and uncomment line 77 :


@Dad72 I wasn’t seeing any console error when running your PG?

But that ground has 20 submeshes so I do get a different result with:

ground.getChildMeshes(true).forEach(m => waterMaterial.addToRenderList(m));

See: https://www.babylonjs-playground.com/#1DFTDT#15

Is this result what you intended?

1 Like

Yes, that seems to solve the problem. I did not think about this solution. Thank you

I don’t quite understand, the ground has no child meshes: sub meshes of a mesh are not children of this mesh (they are “part” of it).

So ground.getChildMeshes() returns an empty array…

I think it’s due to the use of ground.optimize (20)

In any case, that solved the problem with that :
ground.getChildMeshes(true).forEach((m) => waterMaterial.addToRenderList(m));

In fact you are right, that did not solve it, but just that does not add the world to the reflection of water.
@Deltakosh So the bug is still there


Piniging @julien-moreau who is the Watermaterial author

Setting checkReadyOnEveryCall to true also correct this one (as for The fog does not disappear completely with FOGMODE_NONE on the MixMaterial):


1 Like

Yes, that solves the problem, Thanks @Evgeni_Popov.
For the fog, it work in part, but I have a problem with the shadows afterwards.

You rox !!