Merging and copying group of meshes

Is it possible to merge Meshes like spheres and lines? In my project I do those spheres on double click on bigger mesh. When there’s two spheres they are being connected with line. I would like to make some kind of list of Objects of this speheres and lines. 2 spheres and 1 line would be 1 element. I was thinking about merging it and copying but I got this error
Line 16 : 166588 - Cannot merge vertex data that do not have the same set of attributes

A line does not have the same structure as other meshes use a thin tube instead and use multimultimaterials

1 Like

Thanks, that’s working really great. I am wondering now If I could add to it elements of GUI. E.q. in the middle of link will be displaying rectangle with description about the length between spheres. Is this possible to think about this already merged meshes + gui as a 1 element?

Something like this

You will need to do a bit of work on correctly positioning the GUI automatically.

1 Like

Yes, something like this, great :slight_smile:. Actually I am doing it like:

And I want those 3 spheres + line + description (link, rectangle, text) to be a single element.

So it’s just about setting the parent of advancedTexture, great :slight_smile:
I was using AdvancedDynamicTexture like this
const advancedTexture = GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI");

Could I do something like creating 3 spheres push them to something like tmpSpheresArray then ascribe it to new array like spheresArray and clear tmpSpheresArray? But I want spheres to stay in spheresArray but they have been removing anyways

to sum up:

//it's just a pseudo code
let sphere1, sphere2, sphere3;

let spheresArray=tmpSpheresArray;


and now I expect those spheres to not be removed. I want them to be in spheresArray

I know about Object Cloner - Babylon.js Documentation objectcloner, but I need it for GUI elements too


//it's just a pseudo code
let measurementArray: any[]  = []
let sphere1;
let description; (gui element)
let line; (gui element)
tmpMeasurement.push(line );


tmpMeasurement.disposeall() //Thete is no such a method I know, just for pseudocode

so I don’t want those element to disapear after removing tmpMeasurement. Just keep them in measurementArray


I figure this out that I just need to delete those elements which I want. Not use disposeall()
something like

let elementsToDelete=measurementArray.slice(1,1);
elementsToDelete.forEach(mesh => mesh.dispose())