better default agent props & speed & position numeric, not strings

This commit is contained in:
STEINNI
2026-06-21 12:08:25 +00:00
parent 54db203e86
commit 06a7868882
5 changed files with 106 additions and 9 deletions
+9 -1
View File
@@ -43,7 +43,15 @@ class AgentsModel extends WindozModel {
async getDefaultProps(id){
const aprops = await this.getProperties(id)
const defaults={ position: { x:0, y:0, z:0 }, speed: { x:0, y:0, z:0 }}
for(const p in aprops) defaults[p] = aprops[p].default
for(const p in aprops) {
const prop = aprops[p]
if(prop?.type === 'number') {
const n = Number(prop.default)
defaults[p] = Number.isFinite(n) ? n : 0
} else {
defaults[p] = prop.default
}
}
return(defaults)
}
}