Is there a way to dynamically change a mesh in a group triggered by a button click?
I am loading an external .obj file:
loader.load( obj, function ( object ) {
createScene( object, mod.tipo, pid, cor.replace("#","0x") );
});
and adding it to a group
function createScene( geometry, name, id, cor ) {
geometry.traverse( function ( child ) {
if ( child instanceof THREE.Mesh ) {
var material = new THREE.MeshPhongMaterial( {
specular: 0xffffff,
shininess: 10,
side: THREE.DoubleSide,
map: THREE.ImageUtils.loadTexture('/3d/js/texturas/white.jpg'),
shading: THREE.SmoothShading
} );
material.color.setHex(cor);
child.material = material;
group.add( child );
}
Then this group is added to the scene: scene.add( group )
To hide the mesh, I set its visibility to false. However, I want to completely remove it from both the scene and the group.
I have already tried using scene.remove('name')
or scene.remove(mesh)
, but they did not work. Does anyone know how to achieve this?