← CiudadObjeto 3Dfogon/dumpster
Volquete
Arrastrá para girarlo// «Volquete» · propio
// A dark green steel dumpster with slanted sides, reinforcing ribs, side pockets for the truck's forks and two black plastic lids, one half open.
// A green steel dumpster: slanted ends, ribs, a pocket on each end for the truck's forks, and two plastic lids hinged at
// the back. The right lid is shut; the left one is half open and the rubbish shows.
const GREEN = { base: "#2f6b45", light: "#3d8257", dark: "#24543a", rim: "#4a9465", inside: "#1c4630", rust: "#7a5a30" };
const LID = "#25272b", LID_RIDGE = "#3d4046", LID_UNDER = "#1a1b1e";
const BOTTOM = 2;
// The body is wider at the top than at the bottom, and higher at the back than at the front.
const lean = (z) => Math.round(3 * (1 - Math.min(1, (z - BOTTOM) / 18)));
const x0 = (z) => 7 + lean(z), x1 = (z) => 40 - lean(z);
const y0 = (z) => 13 + Math.round(lean(z) / 2), Y1 = 34;
const rim = (y) => 20 + Math.round(((y - 13) * 5) / 21);
// The rubbish first (the walls go over whatever sticks out).
ellipsoid(15, 20, 11, 6, 5, 5, "#2a2c30");
ellipsoid(19, 28, 12, 6, 5, 5, "#34373c");
ellipsoid(13, 29, 11, 5, 5, 4, "#232528");
ellipsoid(20, 20, 13, 4, 4, 4, "#3f4248");
ellipsoid(14, 25, 14, 3, 3, 3, "#d9dcd6");
box(17, 23, 14, 22, 27, 16, "#c49a62");
box(17, 23, 16, 22, 27, 16, "#d6ae76");
box(19, 23, 16, 20, 27, 16, "#e3c898");
box(10, 15, 4, 37, 33, 8, "#2a2c30");
for (let z = BOTTOM; z <= 25; z++)
for (let y = y0(z); y <= Y1; y++) {
if (z > rim(y)) continue;
for (let x = x0(z); x <= x1(z); x++) {
const d = Math.min(x - x0(z), x1(z) - x, y - y0(z), Y1 - y, z - BOTTOM);
if (d > 1) continue; // hollow
let c = d === 1 ? GREEN.inside : rand() < 0.1 ? GREEN.light : rand() < 0.12 ? GREEN.dark : GREEN.base;
if (d === 0 && z <= BOTTOM + 2 && rand() < 0.4) c = GREEN.dark;
if (d === 0 && rand() < 0.012) c = GREEN.rust;
if (z >= rim(y) - 1) c = d === 1 ? GREEN.base : GREEN.rim; // the rim
set(x, y, z, c);
}
}
// Ribs on the front and on the ends.
for (let z = BOTTOM + 1; z <= 18; z++) {
for (const x of [13, 20, 27, 34]) { set(x, y0(z) - 1, z, GREEN.light); set(x + 1, y0(z) - 1, z, GREEN.base); }
for (const y of [17, 31]) { set(x0(z) - 1, y, z, GREEN.light); set(x1(z) + 1, y, z, GREEN.base); }
}
for (let x = 9; x <= 38; x++) set(x, y0(19) - 1, 19, GREEN.rim);
// The fork pockets: a square tube along each end, open at the front and at the back.
for (const side of [-1, 1]) {
const wall = side < 0 ? x0(12) : x1(12);
for (let y = 14; y <= 33; y++)
for (let z = 10; z <= 14; z++)
for (let k = 1; k <= 4; k++) {
const hollow = k < 4 && z > 10 && z < 14;
set(wall + side * k, y, z, hollow ? null : z === 14 ? GREEN.rim : k === 4 ? GREEN.base : GREEN.dark);
}
}
// Wheels.
for (const x of [11, 35]) for (const y of [15, 30]) box(x, y, 0, x + 1, y + 2, 1, "#1f2023");
// The hinge bar along the back, the shut lid (right) and the half-open one (left).
box(6, 35, 25, 41, 35, 26, "#6f747a");
for (let x = 24; x <= 41; x++)
for (let y = 12; y <= 34; y++) {
const z = rim(Math.max(13, y)) + 1;
set(x, y, z, x % 4 === 1 ? LID_RIDGE : LID);
if (y === 12) set(x, y, z - 1, LID);
}
const tilt = (40 * Math.PI) / 180;
for (let x = 6; x <= 23; x++)
for (let s = 0; s <= 23; s += 0.5) {
const y = Math.round(34.5 - s * Math.cos(tilt)), z = Math.round(26.5 + s * Math.sin(tilt));
set(x, y, z, x % 4 === 1 ? LID_RIDGE : LID);
set(x, y, z - 1, LID_UNDER);
}import { draw } from "./assets/voxel";
import { dumpster } from "./assets/dumpster";
// En cada cuadro: parado sobre (x, y), el centro de su base.
draw(ctx, dumpster, 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 dumpster
# Con las herramientas de Fogón (conector)
add_assets({ slug: "<tu-juego>", ids: ["dumpster"] })
# Queda en client/assets/dumpster.ts
# https://fogon.gg/object/dumpster