Why the boxes are not visible when the camera is in some position

try setting your internal meshes to a lower renderOrder than the external one…

  for (let i = 0; i < 5; i++) {
    const mesh2 = internalBox.clone();
    mesh2.renderOrder = -1;
    mesh2.position.set(0, 0, 8 * i);
    scene.add(mesh2);
  }

also see this