[SOLVED] Destroy cloned droplets

As I create a lot of droplets in my project
https://launch.playcanvas.com/788001?debug=true

  • by the script:
ShapePicker.prototype.makeLotOfDroplets = function(clonedRec){
     //console.log("Le: "+this.e.length);

    for (var i = 0; i < 10;++i) {
this.iC  =this.eListCount*i;   
    this.e[i]=clonedRec.clone(); // Clone Entity
         var rErX= this.appRandom(4, 28)/2000; var rErY = this.appRandom(8, 44)/2000; 
        //var rErZ = this.appRandom(8, 44)/2000; //NB ikke vigtig da  runder draaber soeges
        var rErZpos = this.appRandom(8, 70)/2000;
        this.e[i].setLocalScale(0.002+rErX, 0.004+rErY, 0.004+rErY);
    clonedRec.parent.addChild(this.e[i]); // Add it as a sibling to the original
   
   this.e[i].setLocalScale(0.003+rErX, 0.004+rErY, 0.004+rErY);
                     var rEr2= this.appRandom(20+(i*15), 58+(i*15))/1000; var rEr2_XrotProc= this.appRandom(38, 99)/100;
                    // this.e[i].setRotation( this.cameraEntity.getRotation()); 
        var tmpXrot = this.cameraEntity.getRotation().x+rEr2_XrotProc; var tmpZrot = this.cameraEntity.getRotation().z+rEr2_XrotProc; ///NB! note to self Cam-rot er 90grader forskellig fra droplets!!
                    
        var getLocalScale= this.e[i].getLocalScale(); 
        
        var gennemgtaeng = (-0.003)+(0.001*this.gtFr); if( this.gtFrStart===true){this.gtFr++;}
        var posAlt = new pc.Vec3(this.hitPosition.x+gennemgtaeng, -0.73+this.hitPosition.y+rEr2,this.hitPosition.z+rErZpos+(-0.045));                                                                 
                     this.e[i].setPosition(posAlt);   
        
         if(i>0){
             //if(this.e[i].intersectsBoundingSphere){<
             
          this.getDelAndMove(i);
         }
       
       //  console.log("this.entEnLrgFct.length: "+this.entEnLrgFct.length);
        
         this.eListFindAll.push(this.e[i]);
     }
    
};

I thereafter try to delete by raycast-click on them seperately:

Raycast.prototype.doRayCast = function (screenPosition) {
    
     var from = this.entity.getPosition();
    // The pc.Vec3 to raycast to 
    var to = this.entity.camera.screenToWorld(screenPosition.x, screenPosition.y, this.entity.camera.farClip);
    
    // Raycast between the two points
    var result2 = this.app.systems.rigidbody.raycastFirst(from, to);
     if (result2) {
     var hitEntity = result2.entity;
        // Set the target position of the lerp script based on the name of the clicked box
        console.log("hitEntity.name "+ hitEntity.name);
         if(hitEntity.name === "HitMarker"){ 
             console.log("hgtrgrty.name "+ hitEntity.name); //Some other tries: hitEntity.translate(0, -4, -4); result2.entity.removeChild(hitEntity); result2.entity.destroy();   
              console.log("chil: " +this.entity.children[0].name);
             // Maybe I wish  to this.entity.children[0].destroy();
                                           }
     }
   
};

As one can tell I quite deperately try to acess them as children? But is there an ID-level of the cloned entities that can be erased droplet by droplet, or can I use the removeChild @Will-approach (Destroying entity isn't destroying parented entity)

Also tried a brute mousedown-approach:

var BoundingsSphere03 = pc.createScript('BoundingsSphere03');

BoundingsSphere03.attributes.add("radius", {type: "number", title: "Radius"});

// initialize code called once per entity
BoundingsSphere03.prototype.initialize = function() {
     this.BoundingsSphere03 = new pc.BoundingSphere(this.entity.getPosition(), this.radius);
    this.app.mouse.on(pc.EVENT_MOUSEDOWN, this.onMouseDown, this);
};

// update code called every frame
BoundingsSphere03.prototype.update = function(dt) {
    /*if(this.BoundingsSphere03.intersectsBoundingSphere){
        this.entity.collision.on('contact', this.onContact, this);        
    }*/
};

BoundingsSphere03.prototype.onMouseDown = function (event) {
   this.entity.destroy();
};

without luck as this destroys all droplets

… what to do otherwise? // on beforehand thanks

Found another way - the apporach became too heavy memory-wise anyway