← NaturalezaObjeto 3Dfogon/arbusto-con-bayas
Arbusto con bayas
Arrastrá para girarlo// «Arbusto con bayas» · gpt-6-sol (medium)
// A rounded dark green bush with clusters of small shiny blue and red berries scattered over it.
// Rounded, sunlit bush
ellipsoid(24, 24, 15, 17, 16, 14, "#28743b");
ellipsoid(24, 24, 8, 15, 14, 8, "#235f35");
const lobes = [
[13, 19, 17, 8, 8, 8], [34, 18, 17, 8, 8, 8],
[13, 29, 16, 8, 8, 8], [35, 29, 16, 8, 8, 8],
[23, 12, 17, 9, 7, 8], [24, 36, 16, 9, 7, 8],
[18, 22, 23, 8, 8, 7], [30, 24, 23, 8, 8, 7],
[24, 29, 25, 8, 7, 6]
];
for (const l of lobes) ellipsoid(...l, "#28743b");
// Four foliage shades, with brighter leaves catching light on top.
forEach((x, y, z, color) => {
const n = rand();
let shade;
if (z < 8) shade = n < 0.73 ? "#205b32" : "#28743b";
else if (z < 18) shade = n < 0.2 ? "#205b32" : n < 0.77 ? "#28743b" : "#318a43";
else shade = n < 0.13 ? "#28743b" : n < 0.68 ? "#318a43" : "#45a451";
set(x, y, z, shade);
});
// Find a leaf on the outside of the bush along a direction.
function surface(dx, dy, dz) {
let last = null;
for (let t = 0; t < 30; t += 0.35) {
const x = Math.round(24 + dx * t);
const y = Math.round(24 + dy * t);
const z = Math.round(16 + dz * t);
if (get(x, y, z)) last = [x, y, z];
else if (last && t > 6) return last;
}
return last;
}
const colors = [
{ dark: "#185397", fruit: "#267fda", shine: "#a9e5ff" },
{ dark: "#a82d42", fruit: "#e34753", shine: "#ffb9aa" }
];
// Small bunches, concentrated on the visible front and the sunny crown.
for (let bunch = 0; bunch < 30; bunch++) {
const angle = rand() < 0.72
? Math.PI + (rand() - 0.5) * Math.PI * 1.55
: rand() * Math.PI * 2;
const latitude = 0.02 + rand() * 0.92;
const berryColor = colors[rand() < 0.52 ? 0 : 1];
const count = 2 + Math.floor(rand() * 2);
for (let j = 0; j < count; j++) {
const a = angle + (rand() - 0.5) * 0.27;
const h = latitude + (rand() - 0.5) * 0.21;
const horizontal = Math.sqrt(Math.max(0, 1 - h * h));
const dx = Math.cos(a) * horizontal;
const dy = Math.sin(a) * horizontal;
const dz = h;
const leaf = surface(dx, dy, dz);
if (!leaf) continue;
const bx = Math.round(leaf[0] + dx);
const by = Math.round(leaf[1] + dy);
const bz = Math.round(leaf[2] + dz);
if (bz < 8 || bz > 34) continue;
sphere(bx, by, bz, 1.2, berryColor.dark);
set(bx, by, bz, berryColor.fruit);
set(bx, by - 1, bz + 1, berryColor.shine);
}
}import { draw } from "./assets/voxel";
import { arbustoConBayas } from "./assets/arbusto-con-bayas";
// En cada cuadro: parado sobre (x, y), el centro de su base.
draw(ctx, arbustoConBayas, 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 arbusto-con-bayas
# Con las herramientas de Fogón (conector)
add_assets({ slug: "<tu-juego>", ids: ["arbusto-con-bayas"] })
# Queda en client/assets/arbusto-con-bayas.ts
# https://fogon.page/object/arbusto-con-bayas