Whenever I input a number for the second, third, etc. time in the textbox, I want to remove old objects and add new ones. Basically, I need to delete existing objects from the scene and then introduce new objects based on the new input. I have tried various solutions found on the web but none have worked for me. Can someone provide a working example or edit my fiddle?
Find my working fiddle here: Here
Below is the sample code snippet:
for (var i = 0; i < document.getElementById('txtN').value; i++) {
var scale = 10;
var conegeo = new THREE.Mesh(getGeometry(meshMaterial), new THREE.MeshFaceMaterial(meshMaterial));
subset.push(conegeo);
conegeo.doubleSided = true;
conegeo.overdraw = true;
conegeo.position.set(i*(0.5-Math.random())*scale, (0.5-Math.random()*scale, (0.5-Math.random())*scale);
conegeo.updateMatrix();
conegeo.matrixAutoUpdate = false;
scene.add(conegeo);
}
Any assistance would be greatly appreciated.