tegumentar2
This commit is contained in:
1 parent
077e451902
commit
063bd629c2
4 files changed
+213
-84
No files matched your search
@@ -63,7 +63,12 @@ for (const [systemSlug, items] of bySystem) {
|
||||
.createMaterial(hex)
|
||||
.setBaseColorFactor(hexToRgb(hex))
|
||||
.setRoughnessFactor(0.6)
|
||||
.setMetallicFactor(0.05);
|
||||
.setMetallicFactor(0.05)
|
||||
// O bloco de pele usa caixas com a face da frente removida (ver
|
||||
// openFrontBox em geometry.mjs) pra dar pra ver o conteúdo por
|
||||
// dentro — sem dupla face, as paredes de trás/lados ficariam
|
||||
// invisíveis quando vistas "de dentro" da caixa aberta.
|
||||
.setDoubleSided(true);
|
||||
materialCache.set(hex, mat);
|
||||
return mat;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
// Minimal parametric mesh generators (box/sphere/cylinder), dependency-free.
|
||||
// Returns { positions: Float32Array, normals: Float32Array, indices: Uint32Array }.
|
||||
|
||||
export function box(w, h, d) {
|
||||
// skipNormals: normais (como "0,-1,0") das faces a NÃO gerar — usado pelo
|
||||
// bloco de pele em corte (openFrontBox abaixo) pra deixar a face da frente
|
||||
// aberta, como uma caixa de diorama, revelando o conteúdo interno em vez de
|
||||
// escondê-lo atrás de uma parede opaca.
|
||||
export function box(w, h, d, skipNormals = []) {
|
||||
const x = w / 2, y = h / 2, z = d / 2;
|
||||
const positions = [];
|
||||
const normals = [];
|
||||
@@ -17,7 +21,10 @@ export function box(w, h, d) {
|
||||
[[-1, 0, 0], [[-x, -y, -z], [-x, -y, z], [-x, y, z], [-x, y, -z]]],
|
||||
];
|
||||
|
||||
const skip = new Set(skipNormals.map((n) => n.join(",")));
|
||||
|
||||
for (const [n, corners] of faces) {
|
||||
if (skip.has(n.join(","))) continue;
|
||||
const base = positions.length / 3;
|
||||
for (const c of corners) {
|
||||
positions.push(...c);
|
||||
@@ -33,6 +40,14 @@ export function box(w, h, d) {
|
||||
};
|
||||
}
|
||||
|
||||
// Caixa "de diorama": todas as faces normais, exceto a de baixo em Y
|
||||
// (nosso eixo "frente/trás" no bloco de pele) — deixa a frente aberta pra
|
||||
// dar pra ver o conteúdo (folículos, glândulas, vasos) por dentro, em vez
|
||||
// de uma parede opaca escondendo tudo.
|
||||
export function openFrontBox(w, h, d) {
|
||||
return box(w, h, d, [[0, -1, 0]]);
|
||||
}
|
||||
|
||||
export function sphere(radius, widthSegments = 16, heightSegments = 12) {
|
||||
const positions = [];
|
||||
const normals = [];
|
||||
@@ -123,6 +138,7 @@ export function cylinder(radiusTop, radiusBottom, height, radialSegments = 12) {
|
||||
export function buildGeometry(shape) {
|
||||
switch (shape.type) {
|
||||
case "box": return box(shape.w, shape.h, shape.d);
|
||||
case "openFrontBox": return openFrontBox(shape.w, shape.h, shape.d);
|
||||
case "sphere": return sphere(shape.r);
|
||||
case "cylinder": return cylinder(shape.rt, shape.rb, shape.h);
|
||||
default: throw new Error(`Unknown shape type: ${shape.type}`);
|
||||
|
||||
Reference in new issue
Block a user