I am working with multiple JSON files in my three.js project and loading them using loader.load. The files are displayed when I click on the corresponding text content.
How can I unload or hide an object with a second click?
Below is the code I am currently using:
document.getElementById("dest").getElementsByTagName("span").onclick = function(element, key) {myFunction()};
function myFunction() {
document.getElementById("dest").getElementsByTagName("span").height = "100%";
var t = event.target.textContent;
var a = t.slice(1,t.length-1);
path = 'examples/brain_parts/' + groupNames[a] + '.json';
loader.load( path,
function ( geometry, materials, data ) {
var material = new THREE.MultiMaterial( materials );
var object = new THREE.Mesh( geometry, material );
object.scale.set(5,5,5);
object.position.set( 0, 0, 0 );
scene.add( object );
render();
})
}