agentIDs and raycasting like mad!

This commit is contained in:
STEINNI
2025-10-22 19:45:32 +00:00
parent 006bed2ad5
commit 8276a77172
6 changed files with 97 additions and 30 deletions
+26 -6
View File
@@ -42,6 +42,7 @@ class KeyframeView extends WindozDomContent {
this.agentPreview.animation = true
this.kfArena = new app.LoadedModules.kfArena(this.outputs.kfArenaCanvas, this.agentSprites)
this.kfArena.onclickAgent = this.onclickAgent.bind(this)
this.kfArena.startRendering()
this.outputs.btnAddAgent.disabled = true
@@ -53,20 +54,37 @@ class KeyframeView extends WindozDomContent {
if(this.outputs.agentsSelector.value) this.agentPreview.setAgent(this.outputs.agentsSelector.value)
if(!this.outputs.agentsSelector.value) return
const agent = await this.models.agents.getProperties(this.outputs.agentsSelector.value)
this.fillAgentProperties(agent.atp_props)
this.fillAgentProperties('', agent.atp_props)
}
onclickAgent(aid){
console.log('Agent clicked:', aid)
this.updateKfButtons()
}
onAddAgent(event){
//TODO prevent collisions !
const aid = crypto.randomUUIDv7()
this.output('agentId', `ID: ${aid}`)
this.kfArena.addAgent(this.outputs.agentsSelector.value, aid, {
x: document.querySelector('[name="position.x"]').value,
y: document.querySelector('[name="position.y"]').value,
z: document.querySelector('[name="position.z"]').value,
position: {
x: document.querySelector('[name="position.x"]').value,
y: document.querySelector('[name="position.y"]').value,
z: document.querySelector('[name="position.z"]').value,
}
})
this.updateKfButtons()
}
fillAgentProperties(agentProps){
this.outputs.agentProperties.innerHTML=''
updateKfButtons(){
if(this.kfArena.agents.length > 0) this.outputs.btnSaveKF.disabled = false
}
fillAgentProperties(aid, agentProps){
this.outputs.agentProperties.innerHTML = `
<div data-output="agentId">ID: ${aid}</div>
`
this.outputs.agentProperties.append(...this.fieldsFromJSON(agentProps, 'Internal properties'))
this.outputs.agentProperties.append(...this.fieldsFromJSON({
"position.x": {
@@ -103,8 +121,10 @@ class KeyframeView extends WindozDomContent {
},
}, 'Speed vector'))
this.outputs.btnAddAgent.disabled = false
this.setupRefs()
}
}
app.registerClass('KeyframeView', KeyframeView)