Utilizing three.js
, I am combining multiple cubes to form various block shapes using the THREE.GeometryUtils.merge
function. My goal is to achieve transparency for these block shapes; however, this currently results in a visible display of multiple individual cubes stuck together.
How can I create transparent merged cubes without rendering the inner edges? (Is there a way to eliminate the internal faces?)
Below is my code snippet for merging the cubes:
geometry = new THREE.CubeGeometry(STEP_SIZE, STEP_SIZE, STEP_SIZE);
for (i = 0; i < shape.length; i++) {
tmpGeometry = new THREE.Mesh(new THREE.CubeGeometry(STEP_SIZE, STEP_SIZE, STEP_SIZE));
tmpGeometry.position.x = STEP_SIZE * shape[i].x;
tmpGeometry.position.y = STEP_SIZE * shape[i].y;
THREE.GeometryUtils.merge(geometry, tmpGeometry);
}
block = new THREE.Mesh(geometry, new THREE.MeshBasicMaterial({ color: 0x0000ff, opacity: 0.5, transparent: true }));