fogón

← Piezas de nivel 2Objeto 3Dfogon/nivel-plataforma-que-cae

Plataforma que se cae

de fogonCC09460 bloques
Plataforma que se caeArrastrá para girarlo
// «Plataforma que se cae» · gpt-6-sol (medium)
// A crumbling platform: a 40x40 slab (x 4..43, y 4..43) 6 thick floating with its top at z 26, made of cracked sandy-brown stone with dark crack lines across the top, small chunks missing at the edges and a few loose pebbles falling below it.

// Floating, crumbling sandstone slab: x 4..43, y 4..43, z 21..26.
part("losa", [24, 24, 23]);

const top = ["#e8bd78", "#e5b873", "#efc887"];
const side = ["#c79558", "#d2a466", "#d9ad6d"];
const lower = ["#a97846", "#b6844c"];

for (let x = 4; x <= 43; x++) {
  for (let y = 4; y <= 43; y++) {
    for (let z = 21; z <= 26; z++) {
      let color;
      if (z === 26) color = top[rand() < 0.09 ? 2 : rand() < 0.22 ? 1 : 0];
      else if (z === 21) color = lower[rand() < 0.28 ? 1 : 0];
      else color = side[rand() < 0.08 ? 2 : rand() < 0.23 ? 0 : 1];
      set(x, y, z, color);
    }
  }
}

// Chipped-out bites, kept within the platform's square footprint.
function chip(cx, cy, rx, ry, depth) {
  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++) {
      const d = Math.abs(x - cx) / rx + Math.abs(y - cy) / ry;
      if (d < 1.22 && rand() > 0.12) {
        for (let z = 27 - depth; z <= 26; z++) set(x, y, z, null);
      }
    }
  }
}
chip(11, 4, 3, 2, 3);
chip(33, 4, 2, 3, 2);
chip(43, 13, 3, 2, 4);
chip(43, 34, 2, 3, 2);
chip(5, 29, 2, 3, 3);
chip(27, 43, 3, 2, 2);
chip(4, 5, 2, 2, 2);

// Angular, branching fissures across the upper surface.
function crack(points, color = "#765034") {
  for (let i = 1; i < points.length; i++) {
    const [ax, ay] = points[i - 1], [bx, by] = points[i];
    const steps = Math.max(Math.abs(bx - ax), Math.abs(by - ay));
    for (let j = 0; j <= steps; j++) {
      const x = Math.round(ax + (bx - ax) * j / steps);
      const y = Math.round(ay + (by - ay) * j / steps);
      if (get(x, y, 26)) set(x, y, 26, color);
    }
  }
}
crack([[11,5],[12,8],[15,10],[15,14],[19,16],[20,20],[24,22],[24,27],[28,29],[30,34],[34,36],[36,41]]);
crack([[20,20],[18,23],[14,24],[12,28],[8,29],[5,31]]);
crack([[33,6],[32,10],[29,12],[28,17],[25,19],[24,22]]);
crack([[43,14],[39,15],[37,18],[33,19],[30,22],[29,26],[28,29]]);
crack([[29,29],[25,32],[24,36],[21,39],[20,43]]);
crack([[7,16],[11,17],[13,20],[14,24]], "#986b46");
crack([[35,36],[39,37],[42,39]], "#986b46");

// Narrow strata and short fractures on the exposed vertical faces.
for (let x = 5; x <= 42; x++) {
  if (x % 9 < 6 && get(x, 4, 23)) set(x, 4, 23, "#b3824e");
  if (x % 13 < 4 && get(x, 4, 25)) set(x, 4, 25, "#e1b577");
}
for (let y = 5; y <= 42; y++) {
  if (y % 10 < 6 && get(43, y, 23)) set(43, y, 23, "#a97948");
}
for (const x of [15, 30, 38]) {
  for (let z = 23; z <= 25; z++) {
    if (get(x, 4, z)) set(x, 4, z, "#8e603c");
  }
}

animate("losa", { type: "swing", axis: "y", amplitude: 0.05, speed: 12 });

// Falling fragments and a few pieces that have reached the floor.
part("body");
const pebbles = [
  [10, 7, 17, 2], [14, 9, 12, 1],
  [39, 14, 16, 2], [42, 18, 10, 1],
  [7, 30, 14, 2], [27, 40, 18, 2],
  [31, 39, 11, 1], [35, 7, 13, 1],
  [12, 11, 0, 2], [38, 17, 0, 1], [29, 37, 0, 2]
];
for (const [x, y, z, size] of pebbles) {
  box(x, y, z, x + size - 1, y + size - 1, z + size - 1, "#b6844c");
  set(x, y, z + size - 1, "#e5b873");
}