← BásicoObjeto 3Dfogon/cofre-del-tesoro-v3
Cofre del tesoro
Arrastrá para girarlo// «Cofre del tesoro» · gpt-6-sol (medium)
// Treasure chest («Cofre del tesoro»). One of several variations of this object: follow the reference picture closely.
// Open treasure chest: dark walnut, copper trim, and a heap of gold.
const wood = "#693922";
const dark = "#3c2119";
const edge = "#99542d";
const copper = "#b87942";
const bright = "#dfaa60";
const gold = ["#c68c25", "#e1ae38", "#f5d45b", "#ffe881"];
function fleck(x0, y0, z0, x1, y1, z1, n, colors) {
for (let i = 0; i < n; i++) {
const x = x0 + Math.floor(rand() * (x1 - x0 + 1));
const y = y0 + Math.floor(rand() * (y1 - y0 + 1));
const z = z0 + Math.floor(rand() * (z1 - z0 + 1));
set(x, y, z, colors[Math.floor(rand() * colors.length)]);
}
}
// Short blocky feet and solid bottom.
for (const x of [7, 38]) for (const y of [11, 33])
box(x, y, 0, x + 3, y + 3, 2, dark);
box(5, 9, 2, 43, 37, 5, "#512b1c");
box(6, 10, 3, 42, 36, 4, edge);
// Thick walls around a genuinely open, dark interior.
box(5, 9, 5, 43, 12, 17, wood);
box(5, 34, 5, 43, 37, 17, wood);
box(5, 13, 5, 8, 33, 17, wood);
box(40, 13, 5, 43, 33, 17, wood);
box(9, 13, 5, 39, 33, 9, "#332018");
// Recessed panels on the broad front.
for (const [a, b] of [[9, 21], [26, 39]]) {
box(a, 8, 5, b, 8, 14, "#44251c");
box(a + 2, 7, 7, b - 2, 7, 13, "#663922");
box(a + 3, 6, 9, b - 3, 6, 10, "#764329");
box(a, 7, 5, b, 7, 5, edge);
box(a, 7, 14, b, 7, 14, edge);
}
// Matching inset panel on the visible left end.
box(4, 15, 5, 4, 32, 14, "#42241b");
box(3, 18, 7, 3, 29, 12, "#643820");
box(3, 16, 5, 3, 31, 5, edge);
// Heavy upper and lower rims.
box(4, 8, 3, 44, 9, 5, dark);
box(4, 8, 5, 44, 8, 6, copper);
box(4, 8, 16, 44, 10, 18, edge);
box(5, 8, 18, 43, 9, 18, bright);
box(4, 10, 16, 8, 37, 18, edge);
box(5, 12, 18, 7, 36, 18, copper);
box(40, 10, 16, 44, 37, 18, edge);
box(6, 35, 17, 42, 38, 18, copper);
box(5, 9, 4, 43, 10, 4, bright);
box(5, 10, 3, 8, 36, 4, edge);
box(40, 10, 3, 43, 36, 4, edge);
// Copper corner protectors and vertical reinforcing strips.
for (const x of [6, 22, 41]) {
box(x, 7, 5, x + 2, 7, 17, copper);
box(x, 6, 7, x, 6, 15, bright);
for (const z of [7, 14]) set(x + 1, 6, z, "#f1bd6b");
}
for (const y of [11, 33]) {
box(3, y, 5, 3, y + 2, 17, copper);
box(2, y, 8, 2, y, 15, bright);
set(2, y + 1, 7, "#f1bd6b");
set(2, y + 1, 15, "#f1bd6b");
}
for (const x of [7, 23, 42]) {
set(x, 6, 5, "#5b3020");
set(x, 6, 16, "#f3bf69");
}
// Glittering, uneven pile of chunky coins inside the opening.
box(10, 14, 9, 38, 32, 11, "#8e5b18");
for (let i = 0; i < 240; i++) {
const x = 10 + Math.floor(rand() * 29);
const y = 14 + Math.floor(rand() * 19);
const rise = 1.8 * (1 - Math.abs(x - 24) / 20);
const z = 10 + Math.floor(rand() * 3 + rise);
const c = gold[Math.floor(rand() * gold.length)];
box(x, y, z, x + (rand() < .3 ? 1 : 0), y, z, c);
}
for (const [x, y, z] of [[15, 19, 15], [21, 26, 15], [30, 20, 15], [35, 28, 16]]) {
box(x, y, z, x + 3, y + 1, z + 1, "#b88020");
box(x, y, z + 2, x + 3, y, z + 2, "#ffe46a");
set(x + 2, y, z + 1, "#fff09c");
}
fleck(11, 15, 12, 37, 31, 16, 32, ["#f5d65d", "#ffe989", "#ae791a"]);
// The raised lid is a broad, thick plank sloping upward toward the back.
for (let y = 12; y <= 37; y++) {
const top = 24 + Math.floor((y - 12) * 0.4);
box(5, y, top - 4, 43, y, top - 1, "#4a271c");
box(5, y, top, 43, y, top, "#79402a");
box(7, y, top + 1, 41, y, top + 1, "#87482d");
// Layered wooden lip, darker underneath.
box(5, y, top - 4, 7, y, top, "#713a25");
box(41, y, top - 4, 43, y, top, "#713a25");
if (y >= 16 && y <= 19) box(8, y, top + 2, 40, y, top + 2, "#a05b37");
if (y >= 26 && y <= 28) box(8, y, top + 2, 40, y, top + 2, "#51291e");
if (y >= 32 && y <= 34) box(8, y, top + 2, 40, y, top + 2, "#a05b37");
// Two wide metal straps running over the lid.
for (const x of [11, 35]) {
box(x, y, top + 2, x + 3, y, top + 2, "#a96536");
box(x + 1, y, top + 3, x + 2, y, top + 3,
y % 7 === 0 ? "#f0bd6c" : "#d2934e");
}
}
// Dark underside and stepped front lip of the raised lid.
for (let y = 12; y <= 15; y++) {
const z = 24 + Math.floor((y - 12) * 0.4);
box(5, y, z - 5, 43, y, z - 3, "#382119");
box(5, y, z - 2, 43, y, z - 2, edge);
}
box(5, 11, 21, 43, 12, 24, "#75402a");
box(6, 10, 23, 42, 11, 24, copper);
box(8, 10, 25, 40, 10, 25, "#e2a35a");
// Exposed ends of the lid show layered boards and warm metal studs.
for (const x of [4, 44]) {
for (let y = 14; y <= 36; y += 5) {
const z = 24 + Math.floor((y - 12) * 0.4);
set(x, y, z - 2, "#a76538");
set(x, y + 1, z - 1, "#d59752");
}
}
for (const x of [12, 36]) {
for (const y of [13, 35]) {
const z = 24 + Math.floor((y - 12) * 0.4);
set(x, y, z + 4, "#ffe09a");
}
}
// Brass lock plate and a deep black keyhole on the front.
box(23, 5, 10, 28, 6, 16, "#a96832");
box(24, 4, 11, 27, 4, 15, "#d49a4b");
box(25, 3, 12, 26, 3, 14, "#382720");
set(25, 2, 14, "#241b18");
set(26, 2, 14, "#241b18");
set(25, 2, 13, "#241b18");
set(25, 4, 16, "#ffca70");
set(27, 4, 15, "#f4bc65");import { draw } from "./assets/voxel";
import { cofreDelTesoroV3 } from "./assets/cofre-del-tesoro-v3";
// En cada cuadro: parado sobre (x, y), el centro de su base.
draw(ctx, cofreDelTesoroV3, 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 cofre-del-tesoro-v3
# Con las herramientas de Fogón (conector)
add_assets({ slug: "<tu-juego>", ids: ["cofre-del-tesoro-v3"] })
# Queda en client/assets/cofre-del-tesoro-v3.ts
# https://fogon.page/object/cofre-del-tesoro-v3