user preferences via API

This commit is contained in:
STEINNI
2025-10-07 19:57:58 +00:00
parent d5940e2f08
commit db3d10539a
7 changed files with 79 additions and 65 deletions
+15 -2
View File
@@ -213,12 +213,25 @@ export class Threetobus{
return(renderEngine)
}
agentFromJSON(id, desc){
let obj
if(desc.type === 'Mesh') {
const geom = new THREE[desc.geometry.type](...(desc.geometry.args || []))
const mat = new THREE[desc.material.type]( desc.material.color ? { color: desc.material.color } : {} )
const matType = desc.material.type
const matProps = { ...desc.material }
for (const key in matProps) {
if (key === 'type') continue
if (typeof matProps[key] === 'string' && THREE[matProps[key]] !== undefined) {
matProps[key] = THREE[matProps[key]]
}
}
// convert color strings like "0xffffaa" to numbers
if (typeof matProps.color === 'string' && matProps.color.startsWith('0x')) {
matProps.color = parseInt(matProps.color)
}
const mat = new THREE[matType](matProps)
obj = new THREE.Mesh(geom, mat)
} else if(desc.type === 'Group') {
obj = new THREE.Group()