← NaturalezaObjeto 3Dfogon/margaritas
Margaritas
Arrastrá para girarlo// «Margaritas» · gpt-6-sol (medium)
// A cluster of daisies: white petals with yellow centers on thin green stems at slightly different heights.
const greenDark = "#338a39";
const green = "#43ad43";
const greenLight = "#69c957";
function leaf(x, y, z, dx, dz, length, width) {
const mag = Math.hypot(dx, dz);
const ux = dx / mag, uz = dz / mag;
const vx = -uz, vz = ux;
const cx = x + ux * length * 0.52;
const cz = z + uz * length * 0.52;
for (let X = Math.floor(cx - length - width); X <= Math.ceil(cx + length + width); X++)
for (let Y = y - 2; Y <= y + 2; Y++)
for (let Z = Math.floor(cz - length - width); Z <= Math.ceil(cz + length + width); Z++) {
const a = (X - cx) * ux + (Z - cz) * uz;
const b = (X - cx) * vx + (Z - cz) * vz;
const v = (a / (length * 0.55)) ** 2 + (b / width) ** 2 + ((Y - y) / 1.5) ** 2;
if (v <= 1) set(X, Y, Z, Z > cz ? greenLight : green);
}
line(x, y - 1, z, x + ux * length * 0.85, y - 1, z + uz * length * 0.85, 0, "#88db68");
}
// A soft, irregular cluster of foliage rooted on the floor.
ellipsoid(24, 25, 1, 15, 10, 3, greenDark);
for (const [x, y, r] of [
[12, 23, 5], [17, 31, 5], [25, 29, 6],
[34, 29, 5], [37, 21, 5], [21, 17, 5], [30, 17, 5]
]) {
ellipsoid(x, y, 2, r, r * 0.7, 3, green);
ellipsoid(x - 1, y - 1, 4, r * 0.68, r * 0.46, 2, greenLight);
}
// Stems bend gently toward their individual blossoms.
const flowers = [
{ x: 19, y: 30, z: 17, root: [19, 28] },
{ x: 31, y: 30, z: 18, root: [29, 28] },
{ x: 11, y: 19, z: 27, root: [18, 24] },
{ x: 37, y: 20, z: 28, root: [31, 24] },
{ x: 24, y: 16, z: 35, root: [24, 25] }
];
for (const f of flowers) {
const [rx, ry] = f.root;
const mx = (rx + f.x) / 2, my = (ry + f.y) / 2;
line(rx, ry, 3, mx, my, f.z * 0.53, 1, greenDark);
line(mx, my, f.z * 0.53, f.x, f.y + 2, f.z, 1, green);
line(mx, my - 1, f.z * 0.53, f.x, f.y + 1, f.z - 2, 0, greenLight);
const h = f.z * 0.48;
leaf(mx, my, h, -1, 0.35, 7, 2.1);
leaf(mx, my + 1, h - 3, 1, 0.3, 6, 1.9);
}
function daisy(f) {
const { x, y, z } = f;
ellipsoid(x, y + 2, z, 4.5, 2, 4.5, greenDark);
// Eight distinct, rounded petals lie in a plane facing the viewer.
for (let p = 0; p < 8; p++) {
const angle = p * Math.PI / 4;
const ux = Math.cos(angle), uz = Math.sin(angle);
const tx = -uz, tz = ux;
for (let X = x - 11; X <= x + 11; X++)
for (let Z = z - 11; Z <= z + 11; Z++)
for (let Y = y - 2; Y <= y + 2; Y++) {
const dx = X - x, dz = Z - z;
const radial = dx * ux + dz * uz - 6.2;
const across = dx * tx + dz * tz;
const depth = Y - y;
if ((radial / 4.25) ** 2 +
(across / 2.25) ** 2 +
(depth / 1.85) ** 2 <= 1) {
const shade = Y > y || Z < z - 3
? "#dce7e8"
: rand() < 0.13 ? "#f0f0e5" : "#fffdf2";
set(X, Y, Z, shade);
}
}
}
// A raised golden button sits clearly in front of the petals.
ellipsoid(x, y - 1, z, 3.7, 2, 3.7, "#dc9828");
ellipsoid(x, y - 2, z, 3.05, 1.9, 3.05, "#ffcb35");
for (const [dx, dz] of [[-1, 1], [1, 1], [0, -1], [-2, 0], [2, 0]]) {
set(x + dx, y - 4, z + dz, "#ffe46a");
}
}
for (const f of flowers) daisy(f);import { draw } from "./assets/voxel";
import { margaritas } from "./assets/margaritas";
// En cada cuadro: parado sobre (x, y), el centro de su base.
draw(ctx, margaritas, 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 margaritas
# Con las herramientas de Fogón (conector)
add_assets({ slug: "<tu-juego>", ids: ["margaritas"] })
# Queda en client/assets/margaritas.ts
# https://fogon.page/object/margaritas