viewer: treat a fully transparent material as bad data, not a choice

Two EasyEDA-converted connectors (WJ128V-5.0-3P, HR911105A) shipped with every
material at transparency 1.0. The WRL downloads, parses and renders perfectly --
as nothing: blank tile, a valid PNG of empty space, no error anywhere. The models
are fixed; this stops the next bad vendor material vanishing the same silent way.
This commit is contained in:
gator 2026-08-16 13:03:22 +00:00
parent 0a1208e496
commit b08b6b7648

View file

@ -29,7 +29,12 @@ function prepare(model) {
model.traverse((m) => {
if (m.isMesh && m.material) { m.castShadow = true;
const mats = Array.isArray(m.material) ? m.material : [m.material];
mats.forEach((mat) => { mat.envMapIntensity = 0.7; if ('metalness' in mat) mat.metalness = Math.min(mat.metalness ?? 0.2, 0.35); if ('roughness' in mat) mat.roughness = Math.max(mat.roughness ?? 0.6, 0.45); mat.needsUpdate = true; });
mats.forEach((mat) => { mat.envMapIntensity = 0.7; if ('metalness' in mat) mat.metalness = Math.min(mat.metalness ?? 0.2, 0.35); if ('roughness' in mat) mat.roughness = Math.max(mat.roughness ?? 0.6, 0.45);
// A vendor material with transparency 1.0 loads, parses and renders perfectly --
// as nothing. The part looks broken with no error anywhere. Two EasyEDA-converted
// connectors shipped like that. Treat fully invisible as a bad value, not a choice.
if (mat.opacity <= 0.01) { mat.opacity = 1; mat.transparent = false; }
mat.needsUpdate = true; });
}
});
return new THREE.Box3().setFromObject(model).getSize(new THREE.Vector3());