KF Editor => Reset KF button

This commit is contained in:
STEINNI
2026-06-05 08:33:06 +00:00
parent ea9b3d06cf
commit d301b78ea7
3 changed files with 219 additions and 14 deletions
+33 -13
View File
@@ -71,11 +71,20 @@ class KeyframeView extends WindozDomContent {
this.outputs.btnAddAgent.disabled = true
this.outputs.btnRemoveAgent.disabled = true
this.outputs.btnSaveKF.disabled = true
this.outputs.btnSaveKF.disabled = true
this.outputs.btnResetKF.disabled = true
this.outputs.kfName.addEventListener('keyup', this.updateKfButtons.bind(this))
this.currentlySelectedAid = null
}
deselectSceneAgent(){
if(!this.currentlySelectedAid) return
const obj3D = this.kfArena.scene.getObjectByName(this.currentlySelectedAid)
if(obj3D) this.kfArena.clearHighlight3DObj(obj3D, this.kfArena.scene)
this.currentlySelectedAid = null
this.outputs.btnRemoveAgent.disabled = true
}
async onChangeAgent(event){
if(this.outputs.agentsSelector.value) this.agentPreview.setAgent(this.outputs.agentsSelector.value)
if(!this.outputs.agentsSelector.value) return
@@ -85,36 +94,41 @@ class KeyframeView extends WindozDomContent {
} else {
this.currentAgentType = await this.models.agents.getProperties(this.outputs.agentsSelector.value)
this.fillAgentProperties('', this.currentAgentType)
// Deselect any on-scene selection
if(this.currentlySelectedAid){
this.kfArena.clearHighlight3DObj(this.kfArena.scene.getObjectByName(this.currentlySelectedAid), this.kfArena.scene)
}
this.currentlySelectedAid = null
this.deselectSceneAgent()
}
}
async onChangeKeyframe(event){
if(!this.outputs.keyframesSelector.value) return
let kfData = await this.models.keyframes.getKeyframe(this.outputs.keyframesSelector.value).then(data => data.payload)
await this.loadKeyframe(this.outputs.keyframesSelector.value)
}
async onResetKF(evt){
if(!this.currentKeyframe.kfId) return
await this.loadKeyframe(this.currentKeyframe.kfId)
}
async loadKeyframe(kfId){
let kfData = await this.models.keyframes.getKeyframe(kfId).then(data => data.payload)
this.currentKeyframe = {
kfId: kfData.info.ekf_uuid,
kfName: kfData.info.ekf_name,
prevKfId: kfData.info.ekf_prev_uuid,
}
this.outputs.kfName.value = kfData.info.ekf_name
this.deselectSceneAgent()
this.kfArena.reloadAgents(kfData.agents)
this.outputs.agentProperties.innerHTML = ''
this.outputs.btnAddAgent.disabled = true
this.updateKfButtons()
}
onclickAgent(obj3D){
const aid = obj3D.name
if(this.currentlySelectedAid == aid){ // Deselect
this.kfArena.clearHighlight3DObj(obj3D, this.kfArena.scene)
this.currentlySelectedAid = null
this.outputs.btnRemoveAgent.disabled = true
this.deselectSceneAgent()
} else { // Select
if(this.currentlySelectedAid){
this.kfArena.clearHighlight3DObj(this.kfArena.scene.getObjectByName(this.currentlySelectedAid), this.kfArena.scene)
}
this.deselectSceneAgent()
this.currentlySelectedAid = aid
this.outputs.btnRemoveAgent.disabled = false
if(this.kfArena.agents[aid]) {
@@ -139,6 +153,10 @@ class KeyframeView extends WindozDomContent {
onRemoveAgent(event){
if(!this.currentlySelectedAid) return
this.kfArena.removeAgent(this.currentlySelectedAid)
this.currentlySelectedAid = null
this.outputs.btnRemoveAgent.disabled = true
if(this.currentAgentType) this.fillAgentProperties('', this.currentAgentType)
this.updateKfButtons()
}
async newAgent(aType, AgentValues){
@@ -151,6 +169,7 @@ class KeyframeView extends WindozDomContent {
updateKfButtons(){
if((Object.keys(this.kfArena.agents).length > 0) && (this.outputs.kfName.value.length > 5)) { this.outputs.btnSaveKF.disabled = false }
else { this.outputs.btnSaveKF.disabled = true }
this.outputs.btnResetKF.disabled = !this.currentKeyframe.kfId
}
onPropsChanged(evt, comp){
@@ -230,6 +249,7 @@ class KeyframeView extends WindozDomContent {
await this.models.keyframes.save(this.currentKeyframe.kfId, this.kfArena.agents)
this.outputs.btnSaveKF.disabled = true
this.updateKfButtons()
ui.growl.append('Keyframe saved!','success',3000)
setTimeout(() => { this.outputs.btnSaveKF.disabled = false}, 3000)
}