reload scene now clears arrows + remove agent

This commit is contained in:
STEINNI
2025-11-24 19:39:05 +00:00
parent 9a7626f102
commit 76ff0ecb19
2 changed files with 15 additions and 3 deletions
+9 -3
View File
@@ -59,7 +59,7 @@ class KeyframeView extends WindozDomContent {
this.kfArena.startRendering() this.kfArena.startRendering()
this.outputs.btnAddAgent.disabled = true this.outputs.btnAddAgent.disabled = true
this.outputs.btnRemoveAgent.disabled = true this.outputs.btnRemoveAgent.disabled = true
this.outputs.btnSaveKF.disabled = true this.outputs.btnSaveKF.disabled = true
this.outputs.kfName.addEventListener('keyup', this.updateKfButtons.bind(this)) this.outputs.kfName.addEventListener('keyup', this.updateKfButtons.bind(this))
this.currentlySelectedAid = null this.currentlySelectedAid = null
@@ -160,12 +160,13 @@ class KeyframeView extends WindozDomContent {
if(this.currentlySelectedAid == aid){ // Deselect if(this.currentlySelectedAid == aid){ // Deselect
this.kfArena.clearHighlight3DObj(obj3D, this.kfArena.scene) this.kfArena.clearHighlight3DObj(obj3D, this.kfArena.scene)
this.currentlySelectedAid = null this.currentlySelectedAid = null
this.outputs.btnRemoveAgent.disabled = true
} else { // Select } else { // Select
if(this.currentlySelectedAid){ if(this.currentlySelectedAid){
this.kfArena.clearHighlight3DObj(this.kfArena.scene.getObjectByName(this.currentlySelectedAid), this.kfArena.scene) 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]) { if(this.kfArena.agents[aid]) {
this.kfArena.highlight3DObj(obj3D, this.kfArena.scene) this.kfArena.highlight3DObj(obj3D, this.kfArena.scene)
this.fillAgentProperties(aid, this.kfArena.agents[aid].props, this.kfArena.agents[aid].values) this.fillAgentProperties(aid, this.kfArena.agents[aid].props, this.kfArena.agents[aid].values)
@@ -185,6 +186,11 @@ class KeyframeView extends WindozDomContent {
this.updateKfButtons() this.updateKfButtons()
} }
onRemoveAgent(event){
if(!this.currentlySelectedAid) return
this.kfArena.removeAgent(this.currentlySelectedAid)
}
newAgent(aType, AgentValues){ newAgent(aType, AgentValues){
const aid = crypto.randomUUIDv7() const aid = crypto.randomUUIDv7()
this.kfArena.addAgent(aType, aid, this.currentAgentType.atp_props , AgentValues) this.kfArena.addAgent(aType, aid, this.currentAgentType.atp_props , AgentValues)
@@ -156,7 +156,13 @@ export class kfArena{
removeAgent(aid){ removeAgent(aid){
const obj3d = this.scene.getObjectByName(aid) const obj3d = this.scene.getObjectByName(aid)
this.clearHighlight3DObj(obj3d, this.scene)
this.scene.remove(obj3d) 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]) if(aid in this.agents) delete(this.agents[aid])
} }