Skip to content

Commit fc4890e

Browse files
danribesclaude
andcommitted
fix: Ensure 3D hero background renders on dark theme
Add explicit setClearColor with alpha 0 and disable premultipliedAlpha to prevent transparent canvas from rendering as opaque black. Boost wireframe, fill, glow, and particle opacity for better visibility against the dark background. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1626c2c commit fc4890e

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

js/hero3d.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,16 @@
3939
// --- Renderer ---
4040
let renderer;
4141
try {
42-
renderer = new THREE.WebGLRenderer({ canvas: canvas, alpha: true, antialias: true });
42+
renderer = new THREE.WebGLRenderer({
43+
canvas: canvas,
44+
alpha: true,
45+
antialias: true,
46+
premultipliedAlpha: false
47+
});
4348
} catch (_) {
4449
return; // WebGL not available — hero looks fine with just CSS
4550
}
51+
renderer.setClearColor(0x000000, 0);
4652
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
4753
renderer.setSize(heroSection.offsetWidth, heroSection.offsetHeight);
4854

@@ -66,23 +72,23 @@
6672
color: color,
6773
wireframe: true,
6874
transparent: true,
69-
opacity: 0.55
75+
opacity: 0.75
7076
});
7177
group.add(new THREE.Mesh(geometry, wireMat));
7278

7379
// 2. Inner glow fill
7480
const fillMat = new THREE.MeshBasicMaterial({
7581
color: color,
7682
transparent: true,
77-
opacity: 0.07
83+
opacity: 0.12
7884
});
7985
group.add(new THREE.Mesh(geometry, fillMat));
8086

8187
// 3. Outer glow shell (BackSide, scaled up)
8288
const glowMat = new THREE.MeshBasicMaterial({
8389
color: color,
8490
transparent: true,
85-
opacity: 0.03,
91+
opacity: 0.06,
8692
side: THREE.BackSide
8793
});
8894
const glowMesh = new THREE.Mesh(geometry, glowMat);
@@ -128,10 +134,10 @@
128134
particleGeo.setAttribute('color', new THREE.BufferAttribute(colors, 3));
129135

130136
const particleMat = new THREE.PointsMaterial({
131-
size: 0.04,
137+
size: 0.06,
132138
vertexColors: true,
133139
transparent: true,
134-
opacity: 0.7,
140+
opacity: 0.85,
135141
blending: THREE.AdditiveBlending,
136142
depthWrite: false
137143
});

0 commit comments

Comments
 (0)