After a long study, I found that I do not have an additional parameter for the 'merge' method from the Geometry object, the last parameter is the index of the material that the grid from the array of materials should have, for example: 0 → the first material in the array of materials, etc.
So my last piece of code looks like this:
pine_geometry.merge(pine_1.geometry, pine_1.matrix, 0); var pine_texture_2 = THREE.ImageUtils.loadTexture('./res/textures/5.jpg'); var pine_geometry_2 = new THREE.CylinderGeometry(0, 70, 250, 8); var pine_material_2 = new THREE.MeshBasicMaterial({ map : pine_texture_2 }); var pine_2 = new THREE.Mesh(pine_geometry_2); pine_2.position.x = x; pine_2.position.y = y + 175; pine_2.position.z = z; pine_2.updateMatrix(); pine_geometry.merge(pine_2.geometry, pine_2.matrix, 1);
(Pay attention to the latest numbers that I add for each merge).
However, I want to clarify that this practice only works when we deal with different geometries of the same type, in this case we combine two CylinderGeometry , but if we want to combine, for example, a cylinder with a box and add MeshFaceMaterial, it will not be recognized properly, and the console will throw us “Cannot read map / property attributes from undefined”, however, we can still combine both geometries, but not provide several materials (this is a terrible mistake I made).
Hope this helps anyone.
source share