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());