← NaturalezaObjeto 3Dfogon/algarrobo
Algarrobo
Arrastrá para girarlo// «Algarrobo» · gpt-6-sol (medium)
// A carob tree of the Argentine plains: a short twisted dark trunk splitting into wide crooked branches, a flat irregular crown of small olive-green leaves and hanging brown seed pods.
// A low, wind-shaped carob tree.
const bark = "#745035";
const barkLight = "#93633d";
const barkDark = "#513a2d";
const leafDark = "#597d34";
const leafMid = "#72993e";
const leafLight = "#91b44b";
const leafSun = "#b0ca62";
// Knotted trunk and broad roots, fixed to the ground.
ellipsoid(24, 24, 5, 4, 3, 6, bark);
ellipsoid(25, 24, 11, 3, 3, 5, bark);
line(24, 24, 3, 26, 23, 14, 3, bark);
line(23, 24, 2, 18, 22, 0, 2, bark);
line(25, 24, 2, 30, 22, 0, 2, bark);
line(24, 25, 2, 22, 30, 0, 2, bark);
line(26, 25, 2, 29, 29, 0, 1, bark);
line(23, 23, 3, 21, 22, 11, 1, barkLight);
line(26, 24, 5, 27, 23, 12, 1, barkLight);
line(25, 26, 2, 24, 26, 9, 0, barkDark);
line(22, 24, 4, 23, 23, 10, 0, barkDark);
line(27, 24, 7, 27, 24, 12, 0, barkDark);
// Everything above the trunk sways together.
part("crown", [25, 24, 14]);
const limbs = [
[[25,24,14],[20,23,19],[14,21,23],[8,20,25]],
[[25,24,14],[29,23,19],[35,20,23],[40,18,25]],
[[25,24,15],[22,28,20],[16,34,24],[11,37,26]],
[[26,24,15],[30,28,20],[36,33,24],[40,36,26]],
[[25,24,15],[24,18,20],[20,12,24],[17,9,26]],
[[26,24,15],[29,19,21],[34,13,25],[38,11,26]],
[[25,25,16],[24,29,22],[25,37,26]],
[[24,23,16],[24,17,22],[24,10,26]]
];
for (const points of limbs) {
for (let i = 0; i < points.length - 1; i++) {
const radius = i === 0 ? 2 : i === 1 ? 2 : 1;
line(...points[i], ...points[i + 1], radius, bark);
}
if (points.length > 2) {
line(...points[1], ...points[2], 0, barkLight);
}
}
line(20, 22, 19, 14, 20, 22, 0, barkDark);
line(30, 22, 19, 36, 19, 22, 0, barkDark);
line(22, 29, 21, 17, 34, 23, 0, barkDark);
// Broad, uneven canopy with a scalloped outline.
const bunches = [
[9,20,27,4,4,3], [13,17,28,5,4,3], [18,14,29,5,4,3],
[24,12,29,5,4,3], [31,13,29,5,4,3], [37,16,28,5,4,3],
[40,21,27,4,4,3], [38,27,28,5,4,3], [40,34,27,4,4,3],
[34,36,29,5,4,3], [27,38,28,5,4,3], [20,37,29,5,4,3],
[13,36,27,5,4,3], [9,31,27,4,4,3], [8,25,28,4,4,3],
[16,25,30,5,5,3], [23,21,31,5,5,3], [30,23,31,5,5,3],
[23,30,31,5,5,3], [31,31,30,5,5,3], [15,30,29,4,4,3],
[32,18,30,4,4,3], [20,17,31,4,4,3], [27,17,30,4,4,3]
];
for (const [x, y, z, rx, ry, rz] of bunches) {
ellipsoid(x, y, z, rx, ry, rz, leafDark);
ellipsoid(x, y, z + 1, rx - 1, ry - 1, rz - 1, leafMid);
ellipsoid(x - 1, y - 1, z + 2, Math.max(2, rx - 2), Math.max(2, ry - 2), 1, leafLight);
}
// Sunlit flecks and small patches of leaf variation.
forEach((x, y, z, color) => {
if (color !== leafDark && color !== leafMid && color !== leafLight) return;
if (!get(x, y, z + 1) && rand() < 0.37) {
set(x, y, z, rand() < 0.38 ? leafSun : leafLight);
} else if (rand() < 0.09) {
set(x, y, z, rand() < 0.5 ? leafMid : leafDark);
}
});
// Brown seed pods dangling beneath the leaves.
const pods = [
[11,19,24,4], [15,15,25,5], [20,12,26,4], [27,11,26,5],
[34,14,25,4], [39,19,24,5], [38,25,24,4], [35,31,25,5],
[29,35,25,4], [21,36,25,5], [14,34,24,4], [9,28,24,5],
[15,22,26,4], [20,18,27,5], [26,18,27,4], [31,20,27,5],
[18,30,26,4], [25,29,27,5], [32,29,26,4], [23,25,27,4]
];
for (const [x, y, z, length] of pods) {
line(x, y, z, x, y, z - 1, 0, barkDark);
line(x, y, z - 1, x + 1, y, z - length, 0, "#88552e");
set(x + 1, y, z - length, "#a76b35");
set(x + 1, y, z - length + 1, "#694329");
}
animate("crown", {type:"swing", axis:"y", speed:1.2, amplitude:0.08});import { draw } from "./assets/voxel";
import { algarrobo } from "./assets/algarrobo";
// En cada cuadro: parado sobre (x, y), el centro de su base.
draw(ctx, algarrobo, 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 algarrobo
# Con las herramientas de Fogón (conector)
add_assets({ slug: "<tu-juego>", ids: ["algarrobo"] })
# Queda en client/assets/algarrobo.ts
# https://fogon.page/object/algarrobo