fogón

← Nature3D assetfogon/arbol-otonal

Árbol de otoño

by fogonCC013973 blocks
Árbol de otoñoDrag to turn it
// «Árbol de otoño» · gpt-6-sol (medium)
// A round deciduous tree in autumn colors: a brown trunk and a lumpy crown made of overlapping spheres in orange, red and golden yellow, with a few fallen orange leaves scattered on the ground around the base.

const bark = ["#794323", "#93512a", "#aa6232", "#bd7540"];
const groove = "#67391f";

// Stout trunk and spreading roots.
cylinder(24, 24, 0, 4, 7, bark[1]);
cylinder(24, 24, 6, 3.5, 11, bark[2]);
cylinder(24, 24, 16, 2.8, 9, bark[1]);

for (const [x, y] of [[19, 22], [29, 22], [21, 29], [28, 28]]) {
  line(24, 24, 3, x, y, 0, 1.5, bark[1]);
  set(x, y, 0, bark[0]);
}

// Vertical bark grooves, broken into short, natural-looking strokes.
for (const [x, y, start, end] of [
  [23, 20, 2, 12], [26, 21, 7, 19], [21, 23, 3, 15],
  [25, 27, 4, 13], [23, 27, 12, 21]
]) {
  for (let z = start; z <= end; z++) {
    if (rand() > 0.23) set(x, y, z, groove);
  }
}

// The branches and every leaf cluster sway together from the trunk top.
part("crown", [24, 24, 24]);
for (const [x, y, z] of [
  [16, 22, 29], [32, 21, 30], [20, 32, 30], [29, 31, 29]
]) {
  line(24, 24, 23, x, y, z, 1.5, bark[0]);
}

const leafPalettes = {
  orange: ["#a9461f", "#d65c24", "#f2792b", "#ff9838"],
  red:    ["#922f27", "#bd3b2d", "#e44d32", "#f3693d"],
  gold:   ["#ad7621", "#d99a28", "#f5bc38", "#ffd454"]
};

function leafClump(cx, cy, cz, rx, ry, rz, kind) {
  const shades = leafPalettes[kind];
  for (let x = Math.floor(cx - rx); x <= Math.ceil(cx + rx); x++)
  for (let y = Math.floor(cy - ry); y <= Math.ceil(cy + ry); y++)
  for (let z = Math.floor(cz - rz); z <= Math.ceil(cz + rz); z++) {
    const dx = (x - cx) / rx, dy = (y - cy) / ry, dz = (z - cz) / rz;
    const edge = 1 + 0.055 * Math.sin(x * 1.7 + z) * Math.cos(y * 1.4);
    if (dx * dx + dy * dy + dz * dz > edge) continue;

    let shade = dz > 0.34 ? 3 : dz > -0.18 ? 2 : dz > -0.58 ? 1 : 0;
    if (x < cx && y < cy && rand() < 0.28) shade++;
    if (rand() < 0.11) shade += rand() < 0.5 ? -1 : 1;
    set(x, y, z, shades[Math.max(0, Math.min(3, shade))]);
  }
}

// A full central canopy, surrounded by overlapping, differently colored lobes.
leafClump(24, 24, 32, 10, 10, 9, "orange");
for (const c of [
  [15, 19, 30, 8, 8, 8, "gold"],
  [32, 18, 31, 8, 8, 8, "red"],
  [15, 29, 30, 8, 8, 7, "red"],
  [32, 30, 30, 8, 8, 8, "orange"],
  [23, 14, 33, 9, 7, 8, "orange"],
  [23, 34, 33, 9, 7, 8, "gold"],
  [11, 24, 32, 5, 6, 6, "orange"],
  [37, 24, 32, 5, 6, 6, "gold"],
  [20, 23, 39, 7, 7, 5, "gold"],
  [28, 25, 39, 7, 7, 5, "red"],
  [25, 19, 25, 7, 6, 5, "red"]
]) leafClump(...c);

animate("crown", { type: "swing", axis: "y", speed: 1.2, amplitude: 0.08 });

part("body");

// Small fallen leaves rest on the ground, separate from the swaying crown.
const fallen = ["#e86c27", "#f58b2e", "#f4b638", "#cf4930"];
for (let i = 0; i < 48; i++) {
  const angle = rand() * Math.PI * 2;
  const distance = 6 + rand() * 15;
  const x = Math.round(24 + Math.cos(angle) * distance);
  const y = Math.round(24 + Math.sin(angle) * distance);
  const color = fallen[Math.floor(rand() * fallen.length)];
  set(x, y, 0, color);
  if (rand() < 0.32) set(x + (rand() < 0.5 ? -1 : 1), y, 0, color);
}