better default agent props & speed & position numeric, not strings
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user