From b08b6b7648b20b4798dccfd4adfdf71092e76e65 Mon Sep 17 00:00:00 2001 From: gator Date: Sun, 16 Aug 2026 13:03:22 +0000 Subject: [PATCH] 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. --- assets/viewer.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/assets/viewer.js b/assets/viewer.js index b090192..a1c2c5a 100644 --- a/assets/viewer.js +++ b/assets/viewer.js @@ -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());