← Basics3D assetfogon/cofre-del-tesoro-v5
Cofre del tesoro
Drag to turn it// «Cofre del tesoro» · gpt-6-sol (medium)
// Treasure chest («Cofre del tesoro»). One of several variations of this object: follow the reference picture closely.
const woodDark = "#552a18";
const woodShadow = "#713518";
const wood = "#98471f";
const woodLight = "#b9602d";
const woodHighlight = "#ca7440";
const ironDark = "#586969";
const iron = "#aebbb8";
const ironLight = "#e0e7df";
const ironShadow = "#82928f";
function arch(y) {
return 20 + Math.min(9, Math.floor(Math.min(y - 10, 36 - y) * 0.86));
}
// Solid chest body and slightly projecting base.
box(6, 11, 0, 42, 35, 2, woodDark);
box(5, 10, 2, 43, 36, 18, woodDark);
box(7, 11, 4, 41, 35, 17, wood);
// Broad wooden panels, with fine horizontal grain.
for (let z = 4; z <= 16; z++) {
for (let x = 8; x <= 40; x++) {
let c = z % 5 === 0 ? woodShadow : wood;
if (rand() < 0.12) c = woodLight;
set(x, 9, z, c);
}
for (let y = 12; y <= 34; y++) {
set(4, y, z, rand() < 0.13 ? woodLight : wood);
}
}
for (const z of [5, 8, 12, 15]) {
for (let x = 10; x <= 39; x++) {
if (rand() > 0.13) set(x, 8, z, z === 5 ? woodShadow : woodLight);
}
}
// Recessed panels on the front and on the visible left end.
box(11, 8, 5, 38, 8, 15, woodShadow);
box(12, 7, 6, 37, 7, 14, wood);
for (let z = 7; z <= 13; z += 3) {
for (let x = 13; x <= 36; x++) {
if (rand() > 0.10) set(x, 6, z, z === 7 ? woodShadow : woodLight);
}
}
box(3, 15, 5, 3, 32, 15, woodShadow);
box(2, 16, 6, 2, 31, 14, wood);
for (const z of [7, 11, 13]) {
box(1, 17, z, 1, 30, z, z === 7 ? woodShadow : woodLight);
}
// Thick arched, barrel-like lid.
for (let x = 6; x <= 42; x++) {
for (let y = 10; y <= 36; y++) {
const top = arch(y);
for (let z = 19; z <= top; z++) {
let c = woodShadow;
if (z === top) {
c = y < 17 || y > 29 ? wood : woodLight;
if (y % 4 === 0) c = woodShadow;
if (rand() < 0.12) c = woodHighlight;
} else if (z >= top - 2) {
c = wood;
}
set(x, y, z, c);
}
}
}
// Long, raised planks running across the crown.
for (const y of [13, 17, 21, 26, 30, 34]) {
for (let x = 8; x <= 40; x++) {
if (rand() > 0.045) set(x, y, arch(y) + 1, y === 13 || y === 34 ? woodShadow : woodHighlight);
}
}
for (const y of [15, 19, 24, 28, 32]) {
for (let x = 8; x <= 40; x++) {
if (rand() > 0.08) set(x, y, arch(y) + 1, woodShadow);
}
}
// Arched end caps, edged with dark wood.
for (const x of [5, 43]) {
for (let y = 10; y <= 36; y++) {
const top = arch(y);
for (let z = 19; z <= top; z++) {
set(x, y, z, z === top || y === 10 || y === 36 ? woodDark : wood);
}
}
}
// Pale iron base rails and lid seam.
box(5, 8, 2, 43, 9, 3, ironShadow);
box(7, 7, 3, 41, 7, 3, ironLight);
box(4, 10, 2, 5, 36, 3, iron);
box(43, 10, 2, 44, 36, 3, ironShadow);
box(5, 8, 17, 43, 9, 19, iron);
box(6, 7, 19, 42, 7, 19, ironLight);
box(4, 10, 17, 5, 36, 19, ironLight);
box(43, 10, 17, 44, 36, 19, ironShadow);
box(5, 10, 18, 43, 10, 18, ironDark);
// Chunky metal corner reinforcements and front upright.
for (const x of [5, 16, 42]) {
box(x, 7, 3, x + 1, 8, 17, ironDark);
box(x, 6, 5, x, 7, 16, iron);
box(x + 1, 7, 4, x + 1, 7, 17, ironLight);
for (const z of [5, 13]) set(x, 6, z, ironLight);
}
for (const y of [11, 35]) {
box(3, y, 3, 5, y + 1, 18, ironShadow);
box(2, y, 5, 3, y, 17, ironLight);
box(3, y, 18, 5, y + 1, 19, ironLight);
}
// Two wide straps follow the curve over the lid and down its front lip.
for (const sx of [10, 37]) {
for (let y = 10; y <= 36; y++) {
const h = arch(y);
for (let dx = 0; dx <= 2; dx++) {
set(sx + dx, y, h + 1, dx === 0 ? ironLight : dx === 2 ? ironShadow : iron);
}
if (y <= 14 || y >= 33) {
for (let z = 19; z <= h; z++) {
set(sx, y, z, ironLight);
set(sx + 1, y, z, iron);
set(sx + 2, y, z, ironShadow);
}
}
}
box(sx, 8, 18, sx + 2, 9, 20, iron);
box(sx, 7, 18, sx, 8, 20, ironLight);
}
// Raised clasp hanging from the center of the lid.
box(25, 6, 17, 29, 8, 21, ironDark);
box(26, 5, 18, 28, 6, 22, iron);
box(26, 4, 19, 26, 5, 22, ironLight);
box(25, 4, 12, 30, 6, 16, ironDark);
box(26, 3, 13, 29, 4, 16, iron);
box(26, 2, 14, 28, 3, 16, ironLight);
box(27, 2, 11, 28, 3, 13, ironShadow);
set(28, 1, 14, ironDark);
// Sturdy U-shaped carrying handle on the visible end.
box(0, 20, 8, 1, 28, 13, ironDark);
box(0, 21, 9, 0, 27, 12, woodDark);
box(-0, 19, 9, 1, 20, 13, iron);
box(0, 28, 9, 1, 29, 13, iron);
box(0, 21, 7, 1, 27, 8, iron);
box(0, 20, 12, 1, 21, 14, ironLight);
box(0, 27, 12, 1, 28, 14, ironLight);
set(0, 23, 7, ironLight);import { draw } from "./assets/voxel";
import { cofreDelTesoroV5 } from "./assets/cofre-del-tesoro-v5";
// Every frame: standing on (x, y), the centre of its base.
draw(ctx, cofreDelTesoroV5, 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 cofre-del-tesoro-v5
# With Fogón's tools (connector)
add_assets({ slug: "<your-game>", ids: ["cofre-del-tesoro-v5"] })
# It lands in client/assets/cofre-del-tesoro-v5.ts
# https://fogon.page/object/cofre-del-tesoro-v5