user preferences via API
This commit is contained in:
+15
-2
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user