← City3D assetfogon/cable-reel
Bobina de cable
Drag to turn it// «Bobina de cable» · propio
// A big wooden cable reel standing on its edge: two round plank flanges with bolts and a drum between them wound with thick black cable.
// A big wooden cable reel standing on its edge (its axle runs front to back): two plank flanges with bolts and, between
// them, the drum wound with black cable. Wedges keep it from rolling; the end of the cable hangs loose.
const WOOD = { plank: ["#c39a5e", "#b78d52", "#cfa86c"], groove: "#8d6a3a", rim: "#95713f", edge: "#7d5d33", dirt: "#a07c48", wedge: "#7a5a34", wedgeTop: "#93703f" };
const STEEL = "#7d8288", STEEL_DARK = "#4d5157", BOLT = "#2f2c29";
const CABLE = ["#1b1c1f", "#2d2f34", "#3d4046"];
const CX = 23.5, CZ = 20, R = 20.4;
function flange(yFrom, yTo, outside) {
for (let x = 3; x <= 44; x++)
for (let z = 0; z <= 40; z++) {
const r = Math.hypot(x - CX, z - CZ);
if (r > R) continue;
for (let y = yFrom; y <= yTo; y++) {
if (r < 2.2) continue; // the hole for the axle
let c = (x - 3) % 6 === 2 ? WOOD.groove : WOOD.plank[Math.floor((x - 3 + 3) / 6) % 3];
if (c !== WOOD.groove && rand() < 0.07) c = WOOD.dirt;
if (z < 5 && rand() < 0.5) c = WOOD.dirt;
if (r > R - 1.4) c = WOOD.rim;
if (y !== outside) c = r > R - 1.4 ? WOOD.edge : c;
if (r < 5.2) c = r < 3.4 ? STEEL_DARK : STEEL; // the plate around the hole
set(x, y, z, c);
}
}
// Eight bolts around, four on the plate.
for (let n = 0; n < 8; n++) {
const a = (n / 8) * 2 * Math.PI + 0.39;
set(Math.round(CX + 14.5 * Math.cos(a)), outside, Math.round(CZ + 14.5 * Math.sin(a)), BOLT);
}
for (const [dx, dz] of [[-4, 0], [4, 0], [0, -4], [0, 4]]) set(Math.round(CX + dx), outside, Math.round(CZ + dz), BOLT);
}
// The cable on the drum: a hollow roll, one turn per block, lighter where the light falls.
for (let y = 13; y <= 34; y++)
for (let x = 6; x <= 41; x++)
for (let z = 3; z <= 37; z++) {
const r = Math.hypot(x - CX, z - CZ);
if (r > 14.3 || r < 12) continue;
const turn = y % 2;
set(x, y, z, z - CZ > 9 ? CABLE[turn + 1] : CABLE[turn]);
}
flange(10, 12, 10);
flange(35, 37, 37);
// The wedges under each flange.
for (const [yFrom, yTo] of [[9, 13], [34, 38]])
for (let x = 8; x <= 39; x++) {
const d = Math.abs(x - CX);
if (d < 8 || d > 15) continue;
const under = Math.floor(CZ - Math.sqrt(R * R - d * d));
const h = Math.min(under, 4);
for (let z = 0; z < h; z++) for (let y = yFrom; y <= yTo; y++) if (!get(x, y, z)) set(x, y, z, z === h - 1 ? WOOD.wedgeTop : WOOD.wedge);
}
// The loose end: off the roll on the left, down to the floor and out to the front, bare copper at the tip.
for (let z = 0; z <= 21; z++) box(8, 22, z, 9, 23, z, z % 2 ? CABLE[0] : CABLE[1]);
for (let y = 4; y <= 23; y++) box(8, y, 0, 9, y, 1, y % 2 ? CABLE[0] : CABLE[1]);
box(8, 2, 0, 9, 3, 1, "#c9783a");import { draw } from "./assets/voxel";
import { cableReel } from "./assets/cable-reel";
// Every frame: standing on (x, y), the centre of its base.
draw(ctx, cableReel, x, y, { size: 64, angle: 0, t: performance.now() / 1000 });
// size: its longest side, in px
// angle: turn on the floor, in radians
// t: seconds; if it moves, that animates it# In a terminal, in the game's folder
fogon assets add cable-reel
# With Fogón's tools (connector)
add_assets({ slug: "<your-game>", ids: ["cable-reel"] })
# It lands in client/assets/cable-reel.ts
# https://fogon.gg/object/cable-reel