Cluster definition
Any group of cubes of the same color, touching the planes of the face, not their angles.
The cluster would form a solid geometric shape.
To visualize the problem
Suppose each of these Legos has 1x1 units large.

In a simplified code example, consider a 2x2x2 grid of 2x2x2 cubes:
var mesh = [ // First layer ( x, y, z ) new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 0, 0, 1 ), new THREE.Vector3( 1, 0, 0 ), new THREE.Vector3( 1, 0, 1 ) //Second layer ( x, y, z ) new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 1, 1 ), new THREE.Vector3( 1, 1, 0 ), new THREE.Vector3( 1, 1, 1 ) ];

Each cube in the grid has a color:
//Indexes of mesh array sorted by color var colors = { red: [0, 1, 4, 6], green: [2, 3, 5, 7] }