[solved] Decals disappear on moving transparent mesh

So here I am again with a new issue with DecalGeometry.
I need to make decals from meshes with a transparent material, and moving.

For some reason, the decals sometimes become transparent when made from a moving mesh with a transparent material.
Not systematically though, and not for rotation.

I changed the example to show the problem here : https://felixmariotto.github.io/decal_bug_transparent
Try creating decals before ticking the box to wave the model position : no problem when the material becomes transparent.
Then tick the box “shake_model” : decals that you add subsequently MAY disappear when the mesh from which it was created disappear.

I also show the issue in the following video :

I assume it’s related to the decal material’s parameters, as its creator indicated on the GitHub page of DecalGeometry that

The decal material can be any material, just make sure to have this attributes enabled:

var decalMaterial = new THREE.MeshNormalMaterial( {  
    transparent: true, 
	depthTest: true,   
	depthWrite: false,   
	polygonOffset: true,  
	polygonOffsetFactor: -4,   

Of course I use these parameters, though I don’t really know what they do but for ‘transparent’.

Does it work if you set the side property of the decal’s material to THREE.DoubleSide? Maybe it’s just a face culling issue…

Actually I just had to set a higher renderOrder on the decal meshes than on the support. :sweat_smile: :relieved:
( I updated the example above )

 var m = new THREE.Mesh( new THREE.DecalGeometry( mesh, position, orientation, size ), material ) ;

 m.renderOrder = mesh.renderOrder + 1 ;

 decals.push( m ) ;