what I want to do is the following, I create a custom shape voxel and I want to merge the different custom voxels into a single one. I try with:
let geom = new THREE.BufferGeometry();
for(let i = 0; i < scene.children.length; i++){
if(scene.children[i].name === "custom-voxel"){
geom.merge(scene.children[i].geometry);
}
}
But it doesn't work so I try with:
var geometries = [];
for(let i = 0; i < scene.children.length; i++){
if(scene.children[i].name === "custom-voxel"){
geometry.push(scene.children[i].geometry.clone());
}
}
geom = mergeBufferGeometries(geometries);
geom.computeBoundingBox();
var meshh = new THREE.Mesh(
geom,
new THREE.MeshBasicMaterial({ color: 0x0000ff })
);
But in this way it also doesn't work or better it create the all object in the same position, do you have an idea on how I can keep the distance between objects?
Thanks.