In my application I used a cylinder with colorWrite: false to occlude parts of GLTF models and it worked fine until I started experimenting with different GLTF models. I bumped into one model that is “resistant” to occluding. When I use my occluder generation function:
getOccluder() {
const geometry = new THREE.CylinderGeometry( 0.035, 0.035, 0.1, 64 );
const material = new THREE.MeshBasicMaterial( { colorWrite: false, color: 0x00FFFF });
const occluder = new THREE.Mesh( geometry, material );
occluder.rotateY(Math.PI/2);
occluder.scale.set(0.7, 1, 1);
occluder.renderOrder = 0;
return occluder;
}
It simply doesn’t work, I mean the resulting cylinder is just transparent and doesn’t occlude any parts of the model, while working perfectly with other models. When I remove “colorWrite: false” and create occluder’s material like this:
const material = new THREE.MeshBasicMaterial( { color: 0x00FFFF });
It works as expected, but obviously the occluder is visible.
How can I fix it to ensure consistent behaviour?
Thank you in advance!