sistema tegumentar

This commit is contained in:
Rodrigo Bertoldo de Sousa Martins committed 2026-09-09 21:26:00 -03:00
1 parent 7bc99e8a6f
commit c422ccb05e
2 files changed
+222 -12

No files matched your search

+17 -5
View File
@@ -52,13 +52,25 @@ for (const [systemSlug, items] of bySystem) {
const scene = doc.createScene(systemSlug);
doc.getRoot().setDefaultScene(scene);
const material = doc
.createMaterial(systemSlug)
.setBaseColorFactor(hexToRgb(systemColors[systemSlug] ?? "#cccccc"))
.setRoughnessFactor(0.6)
.setMetallicFactor(0.05);
// Cada item pode pedir uma cor própria (opts.color) pra se distinguir dos
// demais (ex: glândula amarela, vaso vermelho/azul, pelo castanho) em vez
// de todo o sistema sair de uma cor só — cache por hex evita recriar
// material repetido.
const materialCache = new Map();
function materialFor(hex) {
if (materialCache.has(hex)) return materialCache.get(hex);
const mat = doc
.createMaterial(hex)
.setBaseColorFactor(hexToRgb(hex))
.setRoughnessFactor(0.6)
.setMetallicFactor(0.05);
materialCache.set(hex, mat);
return mat;
}
const defaultHex = systemColors[systemSlug] ?? "#cccccc";
for (const item of items) {
const material = materialFor(item.color ?? defaultHex);
const geo = buildGeometry(item.shape);
const posAccessor = doc
.createAccessor()