diff --git a/app/views/editors/KeyframeView.js b/app/views/editors/KeyframeView.js index 46758a1..cb15aa4 100644 --- a/app/views/editors/KeyframeView.js +++ b/app/views/editors/KeyframeView.js @@ -59,7 +59,7 @@ class KeyframeView extends WindozDomContent { this.kfArena.startRendering() this.outputs.btnAddAgent.disabled = true - this.outputs.btnRemoveAgent.disabled = true + this.outputs.btnRemoveAgent.disabled = true this.outputs.btnSaveKF.disabled = true this.outputs.kfName.addEventListener('keyup', this.updateKfButtons.bind(this)) this.currentlySelectedAid = null @@ -160,12 +160,13 @@ class KeyframeView extends WindozDomContent { if(this.currentlySelectedAid == aid){ // Deselect this.kfArena.clearHighlight3DObj(obj3D, this.kfArena.scene) this.currentlySelectedAid = null + this.outputs.btnRemoveAgent.disabled = true } else { // Select if(this.currentlySelectedAid){ this.kfArena.clearHighlight3DObj(this.kfArena.scene.getObjectByName(this.currentlySelectedAid), this.kfArena.scene) } - - this.currentlySelectedAid = aid + this.currentlySelectedAid = aid + this.outputs.btnRemoveAgent.disabled = false if(this.kfArena.agents[aid]) { this.kfArena.highlight3DObj(obj3D, this.kfArena.scene) this.fillAgentProperties(aid, this.kfArena.agents[aid].props, this.kfArena.agents[aid].values) @@ -185,6 +186,11 @@ class KeyframeView extends WindozDomContent { this.updateKfButtons() } + onRemoveAgent(event){ + if(!this.currentlySelectedAid) return + this.kfArena.removeAgent(this.currentlySelectedAid) + } + newAgent(aType, AgentValues){ const aid = crypto.randomUUIDv7() this.kfArena.addAgent(aType, aid, this.currentAgentType.atp_props , AgentValues) diff --git a/app/views/editors/modules/kfArena.module.js b/app/views/editors/modules/kfArena.module.js index fdd479c..2afae4e 100644 --- a/app/views/editors/modules/kfArena.module.js +++ b/app/views/editors/modules/kfArena.module.js @@ -156,7 +156,13 @@ export class kfArena{ removeAgent(aid){ const obj3d = this.scene.getObjectByName(aid) + this.clearHighlight3DObj(obj3d, this.scene) this.scene.remove(obj3d) + const arrow3d = this.scene.getObjectByName(`_speed_${aid}`) + if(arrow3d) { + this.clearHighlight3DObj(arrow3d, this.scene) + this.scene.remove(arrow3d) + } if(aid in this.agents) delete(this.agents[aid]) }