fogón

← Weapons3D assetfogon/sandbags

Bolsas de arena

by fogonCC05306 blocks
Bolsas de arenaDrag to turn it
// «Bolsas de arena» · propio
// A low curved wall of stacked burlap sandbags, three rows high, bags staggered like bricks, tan with darker seams.

// A low curved wall of sandbags, three rows high, each bag over the joint of the two below (like bricks). The wall
// follows an arc that bulges towards the front; the top row is one bag short at the left end.
const TONES = [
  { top: "#e2c996", base: "#cfb07a", shade: "#b39460", dark: "#8f7446" },
  { top: "#d9bd86", base: "#c4a46c", shade: "#a88956", dark: "#866b40" },
  { top: "#e8d2a4", base: "#d6ba88", shade: "#bb9e6c", dark: "#977c50" },
];
const SEAM = "#6f5530";
const R = 34, CX = 23.5, CY = 54; // the arc
const LEN = 11, ROW = 6, DEPTH = 4, HALF = 22; // a bag: 11 long, 6 high, 8 deep; the wall: 44 along the arc

for (let x = 0; x < 48; x++)
  for (let y = 0; y < 48; y++) {
    const dx = x - CX, dy = CY - y;
    const s = Math.atan2(dx, dy) * R, depth = Math.hypot(dx, dy) - R; // along the wall, and across it
    if (Math.abs(s) > HALF || Math.abs(depth) > DEPTH + 0.3) continue;
    for (let z = 0; z < 3 * ROW; z++) {
      const row = Math.floor(z / ROW), w = z % ROW;
      const q = s + HALF + (row % 2 ? LEN / 2 : 0);
      const n = Math.floor(q / LEN), u = q - n * LEN;
      if (row === 2 && n === 0) continue;
      // Each bag is a cushion: thinner at its ends and at its top and bottom, with the corners rounded off. That leaves
      // a groove between a bag and the next.
      const end = Math.min(u, LEN - u, s + HALF, HALF - s) < 1, lip = w === 0 || w === ROW - 1;
      if (end && lip) continue;
      if (Math.abs(depth) > DEPTH - (end ? 1 : 0) - (lip ? 1 : 0) + 0.3) continue;
      const T = TONES[(n * 2 + row) % 3];
      let c = w === ROW - 1 ? T.top : w === 0 ? T.dark : w === 1 ? T.shade : w === ROW - 2 && rand() < 0.5 ? T.top : T.base;
      if (end) c = w <= 1 ? T.dark : T.shade;
      else if (rand() < 0.07) c = T.shade; // the weave
      if (u >= 1.6 && u < 2.6 && w >= 1) c = SEAM; // the stitching near one end
      set(x, y, z, c);
    }
  }