Transparent instancedMesh only shows three sides

Hey! I’m using an instancedMesh to display lots of successive boxes with no space between them. I’m using a custom shaderMaterial to make their edges black and to control the transparency. When I set all the boxes except one to alpha=0, the one that’s supposed to stay visible has only three sides visible, instead of six.

The fragment shader I’m using is:

    varying vec3 vPos;
    uniform vec3 size;
    uniform float thickness;
    uniform float smoothness;
    uniform vec3 color;
    varying float vAlpha;
    void main() {

      float a = smoothstep(thickness, thickness + smoothness, length(abs(vPos.xy) - size.xy));
      a *= smoothstep(thickness, thickness + smoothness, length(abs(vPos.yz) - size.yz));
      a *= smoothstep(thickness, thickness + smoothness, length(abs(vPos.xz) - size.xz));

      vec4 c = mix(vec4(vec3(0), 1.0), vec4(color, vAlpha), a);

      gl_FragColor = c;

The vertex shader is:

    varying vec3 vPos;
    attribute float alpha;
    varying float vAlpha;
    void main()	{
      vAlpha = alpha;
      vPos = position;
      gl_Position = projectionMatrix * modelViewMatrix * instanceMatrix * vec4(position,1.0);

It’s my first time using a shader, so I’m not sure what’s exactly wrong.

Thank you!