How to replace a mesh in the scene by adding another mesh

Hi,
How to replace an existing mesh in the scene by adding another mesh with a button. Like the navigation tab in “Node material editor” in Babylonjs, where we can select different meshes with the help of an icon and replace the previous mesh.

https://nme.babylonjs.com

My project:
https://www.babylonjs-playground.com/#XD7UDJ#4

Thank you,
Devraj

you can use pseudo code like in your click handler:

var currentParent = currentMesh.parent;
currentMesh.dispose();
var newMesh = ...;
newMesh.parent = currentParent;

Thank you Sebavan!! Can you please show me in the project?

https://www.babylonjs-playground.com/#XD7UDJ#4

You were just missing the variable declaration:

https://www.babylonjs-playground.com/#XD7UDJ#9

1 Like

Thanks a lot!! :smiley: