← NaturalezaObjeto 3Dfogon/tronco-caido
Tronco caído
Arrastrá para girarlo// «Tronco caído» · gpt-6-sol (medium)
// A fallen log lying horizontally along x: a thick brown bark cylinder with visible light tan rings at the cut ends, a bit of moss on top and a small mushroom growing on its side.
// A chunky fallen log, with its cut ends facing along the x axis.
const bark = ["#75401f", "#884a24", "#9a572b", "#ad6933"];
const tan = ["#f6d391", "#ecc079", "#dba963", "#bd8447"];
for (let x = 4; x <= 43; x++) {
const end = Math.min(x - 4, 43 - x);
const r = end < 2 ? 8.35 : end < 4 ? 8.75 : 9.15;
for (let y = 14; y <= 34; y++) {
for (let z = 0; z <= 19; z++) {
const dy = y - 24, dz = z - 9;
if (dy * dy + dz * dz > r * r) continue;
const angle = Math.atan2(dz, dy);
const groove = Math.abs(Math.sin(angle * 10 + x * 0.075 + Math.sin(x * 0.28) * 0.3));
let shade = z >= 14 ? 2 : z <= 5 ? 0 : 1;
if (groove < 0.17) shade = Math.max(0, shade - 1);
else if (z >= 15 && rand() < 0.22) shade = 3;
else if (rand() < 0.065) shade = Math.max(0, shade - 1);
set(x, y, z, bark[shade]);
}
}
}
// Flat, pale cut faces with concentric growth rings.
for (const x of [3, 44]) {
for (let y = 16; y <= 32; y++) {
for (let z = 1; z <= 17; z++) {
const d = Math.hypot(y - 24, z - 9);
if (d > 7.65) continue;
let color = tan[0];
if (d > 7.12) color = "#a56534";
else if (d > 6.55 || (d > 4.65 && d < 5.18) ||
(d > 2.65 && d < 3.12) || (d > 1.15 && d < 1.48))
color = tan[2];
else if (d > 5.2 || d < 0.9) color = tan[1];
if (rand() < 0.035 && d < 6.5) color = tan[3];
set(x, y, z, color);
}
}
}
// A few dark knots and bark scars on the viewer-facing side.
ellipsoid(17, 15, 9, 2.2, 0.7, 1.5, "#67371e");
ellipsoid(17, 14, 9, 0.9, 0.5, 0.7, "#a86432");
line(8, 16, 6, 13, 15, 6, 0, "#67391e");
line(21, 15, 12, 27, 15, 12, 0, "#704020");
// Irregular, fresh moss cushions on the sunlit upper bark.
const patches = [
[10, 21, 5.0, 3.0],
[19, 27, 5.8, 3.4],
[29, 21, 6.8, 3.2],
[38, 27, 3.5, 2.8]
];
for (let x = 6; x <= 41; x++) {
for (let y = 17; y <= 31; y++) {
let inside = false;
for (const [cx, cy, rx, ry] of patches) {
const wobble = 0.12 * Math.sin(x * 1.7 + y * 2.2);
if (((x - cx) / rx) ** 2 + ((y - cy) / ry) ** 2 < 1 + wobble) inside = true;
}
if (!inside || rand() < 0.09) continue;
for (let z = 19; z >= 13; z--) {
if (get(x, y, z)) {
set(x, y, z, rand() < 0.25 ? "#367d32" : "#50a83d");
if (rand() < 0.48) set(x, y, z + 1, rand() < 0.55 ? "#75c84b" : "#62b840");
break;
}
}
}
}
// A little red-and-cream mushroom growing out of the front side.
box(33, 12, 11, 34, 14, 15, "#f3dfb5");
box(33, 11, 13, 34, 12, 15, "#fff0ca");
ellipsoid(33.5, 12.5, 15, 2.0, 1.7, 0.7, "#e5c699");
ellipsoid(33.5, 12.5, 17, 4.5, 3.1, 2.2, "#e34b38");
ellipsoid(33.5, 12.4, 18, 3.3, 2.2, 1.1, "#f26145");
set(31, 11, 18, "#fff4d8");
set(35, 10, 17, "#fff4d8");
set(36, 13, 19, "#fff4d8");
set(33, 14, 19, "#fff4d8");import { draw } from "./assets/voxel";
import { troncoCaido } from "./assets/tronco-caido";
// En cada cuadro: parado sobre (x, y), el centro de su base.
draw(ctx, troncoCaido, x, y, { size: 64, angle: 0, t: performance.now() / 1000 });
// size: lo que mide en px su lado más largo
// angle: giro sobre el piso, en radianes
// t: segundos; si se mueve, se anima solo con eso# En una terminal, en la carpeta del juego
fogon assets add tronco-caido
# Con las herramientas de Fogón (conector)
add_assets({ slug: "<tu-juego>", ids: ["tronco-caido"] })
# Queda en client/assets/tronco-caido.ts
# https://fogon.page/object/tronco-caido