fogón

← CiudadObjeto 3Dfogon/pallet-stack

Pila de pallets

de fogonCC011942 bloques
Pila de palletsArrastrá para girarlo
// «Pila de pallets» · propio
// A stack of six wooden pallets, each with slats and gaps you can see through from the side, pale worn wood, the top one a little crooked.

// Six wooden pallets in a stack. Each is a block pallet (boards below, nine blocks, three bearers, slats on top), so you
// can see through it from the front and from the side. The top one sits crooked.
const WOODS = [
  { deck: ["#cdb07c", "#d9bf8e", "#e4cd9f"], board: "#bfa270", block: "#a88c5c", shade: "#8c7248" },
  { deck: ["#c2a570", "#cfb381", "#dbc192"], board: "#b39766", block: "#9c8152", shade: "#816840" },
  { deck: ["#d6be92", "#e1cca2", "#ebd9b3"], board: "#c8b085", block: "#b2996e", shade: "#967d55" },
];
const W = 36, D = 29, NAIL = "#6e5c44";

// What is at a point of a pallet W × D and 5 high.
function palletAt(lx, ly, lz, T) {
  if (lx < 0 || ly < 0 || lx >= W || ly >= D) return null;
  const inX = lx < 4 || lx >= W - 4 || (lx >= 16 && lx < 20);
  const inY = ly < 4 || ly >= D - 4 || (ly >= 12 && ly <= 16);
  if (lz === 0) return inY ? T.shade : null; // the boards underneath
  if (lz === 1 || lz === 2) return inX && inY ? (lz === 1 ? T.shade : T.block) : null; // the blocks
  if (lz === 3) return inX ? T.board : null; // the bearers
  if (ly % 5 === 4) return null; // the gap between two slats
  if (inX && ly % 5 === 1 && (lx === 1 || lx === W - 2 || lx === 17)) return NAIL;
  return rand() < 0.07 ? T.board : T.deck[Math.floor(ly / 5) % 3];
}

function pallet(cx, cy, z0, angle, T) {
  const ca = Math.cos(angle), sa = Math.sin(angle);
  for (let x = 0; x < 48; x++)
    for (let y = 0; y < 48; y++) {
      const dx = x - cx, dy = y - cy;
      const lx = Math.round(dx * ca + dy * sa + (W - 1) / 2), ly = Math.round(-dx * sa + dy * ca + (D - 1) / 2);
      for (let k = 0; k < 5; k++) {
        const c = palletAt(lx, ly, k, T);
        if (c) set(x, y, z0 + k, c);
      }
    }
}

const stack = [[0, 0, 0, 0], [1, -1, 0, 1], [-1, 0, 0, 0], [0, 1, 0, 2], [1, 0, 0, 1], [0, -1, 0.13, 0]];
stack.forEach(([dx, dy, angle, wood], i) => pallet(23.5 + dx, 24 + dy, i * 5, angle, WOODS[wood]));