Mesh looks transparent - in some cases is possible to see the mesh behind

Please take a look at this playground.

It will generate trees with the given official babylons js tree resource.

Even camera collisions are activated,

mesh looks transparent:

if you move behind a tree,

often you can see trought this tree.

More trees more glitches.

I tought the leafs was not rendered as solid, but this still valid also for the trunk.

any suggestion? thanks

Does this work for you?

You can tweak to lower camera.minZ value if you can see through some leafs.

1 Like

you can easily see a tree behind another tree

Sorry I got you wrong, thought you had issues with transparent leafs and collision.
But collision is not related to seeing through the trees.
There seems to be an opacityTexture on the tree, if you set to null it works:

sorry, as i’m a newbie, probably i was using incorrect terminology.
Your suggestion fix the issue.
thanks a lot.

sorry, another help if you can. using Typescript,

theMesh.material.opacityTexture = null;


Property ‘opacityTexture’ does not exist on type ‘Material’.

Same problem i have with createInstance method, solved with

const theMesh:Mesh = meshes[0] as Mesh

so i tried

const theMeshMaterial:Material = theMesh.material as Material
theMeshMaterial.opacityTexture = null

but still obtaining


followed using StandardMaterial instead of Material

yup you need to cast into the correct material type so as StandardMaterial in your case :slight_smile: