Combine mesh material with line material in instnanced mesh


The cubes come from an instancedMesh:

  const geometry = new THREE.BoxBufferGeometry();
  const material = new THREE.MeshBasicMaterial();
  [...]
  const mesh = new THREE.InstancedMesh(geometry, material, instancesCount);

and the hard lines from an InstancedBufferGeometry:

  const geometry = new THREE.BoxBufferGeometry();
  const edges = new THREE.EdgesGeometry(geometry);
  const instGeometry = new THREE.InstancedBufferGeometry().copy(edges);
  const material = new THREE.LineBasicMaterial({color: 0x808080});
  [...]
  const lines = new THREE.LineSegments(instGeometry, material);

Is it possible to create the same result without creating two separate objects?
Do you know why the edges, where the red arrows are pointing at, are not vissible?

Hi!
Maybe try something like this, with modified shaders? How to update color values when using a shader? - #5 by prisoner849
Also related: Detecting objects which can camera see - #10 by prisoner849