Files
Fishing/tools/bbshop/guild2.js
T

630 lines
49 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Гильдия рыбаков v2: крупнее (≈40×30×30), оба этажа проходимые. Низ каменный (зал 30×20, высота 12),
// верх фахверковый с выносом (архив и зал рангов), Г-образная лестница (подъём 0.8, проступь 1.0, ширина 3).
// Лицо в −Z, центр X/Z в нуле, низ на Y=0. node tools/bbshop/guild2.js <scratch> [renderPrefix]
const path = require('path');
const { Model, fish, barrel, crate, lantern } = require('./lib');
const m = new Model('lobby_guild_hall_v2');
const C = (k, rgb) => m.color(k, rgb);
C('stone', [150, 146, 140]); C('stoneLight', [178, 174, 166]); C('stoneDark', [112, 108, 104]); C('stoneDeep', [86, 82, 80]);
C('plaster', [232, 222, 198]); C('plasterShade', [214, 202, 176]); C('timber', [74, 48, 32]); C('timber2', [92, 60, 38]);
C('wood', [150, 98, 58]); C('wood2', [128, 82, 48]); C('woodLight', [184, 136, 88]); C('floor', [124, 86, 54]); C('floor2', [108, 74, 46]);
C('roof', [64, 70, 84]); C('roof2', [54, 58, 72]); C('roof3', [76, 82, 96]); C('iron', [56, 56, 62]); C('brass', [204, 158, 66]); C('gold', [228, 184, 74]);
C('glow', [255, 206, 120]); C('glowBlue', [130, 170, 220]); C('glowRed', [224, 128, 96]); C('glowGreen', [150, 196, 124]);
C('fire', [255, 140, 50]); C('fireCore', [255, 220, 120]); C('blue', [44, 82, 150]); C('blueDark', [30, 56, 108]); C('cream', [238, 226, 196]);
C('shutter', [66, 92, 118]); C('signFace', [44, 30, 26]); C('rug', [140, 46, 42]); C('rugBorder', [214, 168, 80]); C('rug2', [52, 84, 120]); C('leaf', [76, 140, 62]); C('leaf2', [56, 110, 48]);
C('red', [204, 64, 60]); C('yellow', [242, 202, 76]); C('purple', [172, 108, 210]); C('white', [244, 240, 230]); C('rope', [196, 168, 116]); C('book1', [130, 40, 40]); C('book2', [40, 90, 70]);
C('fishSilver', [168, 184, 196]); C('fishBelly', [228, 232, 222]); C('fishFin', [118, 138, 150]); C('fishEye', [24, 24, 30]); C('fishGold', [206, 142, 62]); C('fishGoldFin', [170, 96, 44]); C('candle', [240, 232, 210]);
C('rankF', [140, 140, 140]); C('rankE', [96, 150, 84]); C('rankD', [70, 140, 150]); C('rankC', [72, 102, 178]); C('rankB', [132, 92, 168]); C('rankA', [186, 72, 62]); C('rankS', [230, 182, 64]);
C('mapWater', [92, 150, 186]); C('mapDeep', [64, 112, 160]); C('mapLand', [118, 160, 92]); C('mapSand', [222, 204, 150]); C('parchment', [226, 210, 170]);
const box = (...a) => m.box(...a);
const G = name => m.group(name);
// ---------- размеры
const GX = 16, GZ = 11, T = 1.0, F0 = 1.0, F1 = 13.0; // низ: наружные ±16 × ±11, пол 1, потолок 13 (зал 30×20, высота 12)
const U0 = 13.8, UX = 16.8, UZ = 11.8, UT = 0.6, U1 = 22.4; // верх: пол 13.8, стены ±16.8 × ±11.8 толщиной 0.6, до 22.4
const RIDGE = 30.4, SLOPE = (RIDGE - U1) / UZ, ANG = Math.atan(SLOPE) * 180 / Math.PI;
const DOOR = 2.6, DOORH = 6.0; // проём: прямоугольник до 7.0 + полукруг r 2.6 (верх 9.6)
const IX = GX - T, IZ = GZ - T, UIX = UX - UT, UIZ = UZ - UT; // внутренние грани: низ ±15 × ±10, верх ±16.2 × ±11.2
// грани: n — ось нормали, s — направление «наружу от плоскости» (для внутренних — в комнату), p — плоскость, u — ось вдоль
const FACE = {
gf: { n: 2, s: -1, p: -GZ, u: 0 }, gb: { n: 2, s: 1, p: GZ, u: 0 }, gl: { n: 0, s: -1, p: -GX, u: 2 }, gr: { n: 0, s: 1, p: GX, u: 2 },
uf: { n: 2, s: -1, p: -UZ, u: 0 }, ub: { n: 2, s: 1, p: UZ, u: 0 }, ul: { n: 0, s: -1, p: -UX, u: 2 }, ur: { n: 0, s: 1, p: UX, u: 2 },
igf: { n: 2, s: 1, p: -IZ, u: 0 }, igb: { n: 2, s: -1, p: IZ, u: 0 }, igl: { n: 0, s: 1, p: -IX, u: 2 }, igr: { n: 0, s: -1, p: IX, u: 2 },
iuf: { n: 2, s: 1, p: -UIZ, u: 0 }, iub: { n: 2, s: -1, p: UIZ, u: 0 }, iul: { n: 0, s: 1, p: -UIX, u: 2 }, iur: { n: 0, s: -1, p: UIX, u: 2 },
};
const INNER = { gf: 'igf', gb: 'igb', gl: 'igl', gr: 'igr', uf: 'iuf', ub: 'iub', ul: 'iul', ur: 'iur' };
function fb(name, col, f, u0, u1, y0, y1, d0, d1, o = {}) {
const lo = [0, 0, 0], hi = [0, 0, 0];
lo[f.u] = Math.min(u0, u1); hi[f.u] = Math.max(u0, u1); lo[1] = Math.min(y0, y1); hi[1] = Math.max(y0, y1);
const a = f.p + f.s * d0, b = f.p + f.s * d1; lo[f.n] = Math.min(a, b); hi[f.n] = Math.max(a, b);
return box(name, col, lo, hi, o);
}
function brace(name, col, f, u0, y0, u1, y1, t, d0, d1) {
const cu = (u0 + u1) / 2, cy = (y0 + y1) / 2, len = Math.hypot(u1 - u0, y1 - y0);
const cn = f.p + f.s * (d0 + d1) / 2, hn = Math.abs(d1 - d0) / 2;
if (f.u === 0) { const ang = Math.atan2(y1 - y0, u1 - u0) * 180 / Math.PI; box(name, col, [cu - len / 2, cy - t / 2, cn - hn], [cu + len / 2, cy + t / 2, cn + hn], { rot: [0, 0, ang], pivot: [cu, cy, cn] }); }
else { const ang = Math.atan2(-(y1 - y0), u1 - u0) * 180 / Math.PI; box(name, col, [cn - hn, cy - t / 2, cu - len / 2], [cn + hn, cy + t / 2, cu + len / 2], { rot: [ang, 0, 0], pivot: [cn, cy, cu] }); }
}
// окно с витражным переплётом (цветные стёкла по углам), с обеих сторон стены
function glass(f, u0, u1, y0, y1, d) {
fb('Window_Glow', 'glow', f, u0, u1, y0, y1, d, d + 0.04, { group: 'WindowGlow' });
const w = u1 - u0, h = y1 - y0, cw = Math.min(0.32, w * 0.16), ch = Math.min(0.32, h * 0.12);
[[u0, y1 - ch, 'glowBlue'], [u1 - cw, y1 - ch, 'glowBlue'], [u0, y0, 'glowGreen'], [u1 - cw, y0, 'glowGreen']].forEach(([a, b, c]) => fb('Window_Stain', c, f, a, a + cw, b, b + ch, d + 0.04, d + 0.06, { group: 'WindowGlow' }));
fb('Window_StainMid', 'glowRed', f, (u0 + u1) / 2 - cw * 0.6, (u0 + u1) / 2 + cw * 0.6, y1 - h * 0.3, y1 - h * 0.3 + ch * 1.2, d + 0.04, d + 0.06, { group: 'WindowGlow' });
}
function frameSet(f, uc, yc, w, h, d, fr) {
const u0 = uc - w / 2, u1 = uc + w / 2, y0 = yc - h / 2, y1 = yc + h / 2;
fb('WinFrameT', fr, f, u0 - 0.15, u1 + 0.15, y1, y1 + 0.18, d, d + 0.16); fb('WinFrameB', fr, f, u0 - 0.15, u1 + 0.15, y0 - 0.18, y0, d, d + 0.16);
fb('WinFrameL', fr, f, u0 - 0.15, u0, y0, y1, d, d + 0.16); fb('WinFrameR', fr, f, u1, u1 + 0.15, y0, y1, d, d + 0.16);
fb('WinMullionV', fr, f, uc - 0.05, uc + 0.05, y0, y1, d, d + 0.1);
for (const q of [0.33, 0.66]) fb('WinMullionH', fr, f, u0, u1, y0 + h * q - 0.04, y0 + h * q + 0.04, d, d + 0.1);
for (const q of [0.25, 0.75]) fb('WinCame', 'iron', f, u0 + w * q - 0.02, u0 + w * q + 0.02, y0, y1, d, d + 0.08);
}
function windowAt(key, uc, yc, w, h, o = {}) {
const f = FACE[key], fi = FACE[INNER[key]], u0 = uc - w / 2, u1 = uc + w / 2, y0 = yc - h / 2, y1 = yc + h / 2, fr = o.frame || 'timber';
glass(f, u0, u1, y0, y1, 0); frameSet(f, uc, yc, w, h, 0, fr);
glass(fi, u0, u1, y0, y1, 0.08); frameSet(fi, uc, yc, w, h, 0.08, 'timber2');
fb('WinSillIn', 'wood', fi, u0 - 0.25, u1 + 0.25, y0 - 0.3, y0 - 0.12, 0.08, 0.45);
fb('WinSill', o.sill || 'stoneLight', f, u0 - 0.3, u1 + 0.3, y0 - 0.35, y0 - 0.15, 0, 0.32);
fb('WinLintel', o.lintel || 'stoneLight', f, u0 - 0.35, u1 + 0.35, y1 + 0.18, y1 + 0.5, 0, 0.18);
if (o.shutters) for (const sgn of [-1, 1]) {
const a = sgn < 0 ? u0 - 0.15 - w * 0.5 : u1 + 0.15, b = a + w * 0.5;
fb('Shutter', 'shutter', f, a, b, y0, y1, 0, 0.1);
for (const yy of [y0 + 0.3, y1 - 0.4]) fb('ShutterStrap', 'iron', f, a + 0.05, b - 0.05, yy, yy + 0.1, 0.1, 0.13);
}
if (o.flowers) {
const by = y0 - 0.35;
fb('FlowerBox', 'wood2', f, u0 - 0.15, u1 + 0.15, by - 0.45, by, 0.05, 0.6);
fb('FlowerBoxRim', 'timber', f, u0 - 0.2, u1 + 0.2, by - 0.05, by + 0.03, 0.02, 0.64);
const n = Math.max(3, Math.round(w / 0.45));
for (let i = 0; i < n; i++) {
const uu = u0 + (i + 0.5) * w / n;
fb('FlowerLeaves', i % 2 ? 'leaf' : 'leaf2', f, uu - 0.22, uu + 0.22, by, by + 0.3 + (i % 2) * 0.08, 0.15, 0.5);
fb('Flower', ['red', 'yellow', 'purple', 'white'][i % 4], f, uu - 0.1, uu + 0.1, by + 0.32 + (i % 3) * 0.06, by + 0.48 + (i % 3) * 0.06, 0.24, 0.42);
}
}
}
function anchor(nm, cx, cy, z, s, col, fishCols, dirZ = -1) {
const zt = [z - 0.05, z + 0.05];
box(nm + '_Shank', col, [cx - 0.07 * s, cy - 0.85 * s, zt[0]], [cx + 0.07 * s, cy + 0.75 * s, zt[1]]);
box(nm + '_Stock', col, [cx - 0.5 * s, cy + 0.52 * s, zt[0]], [cx + 0.5 * s, cy + 0.64 * s, zt[1]]);
box(nm + '_RingT', col, [cx - 0.17 * s, cy + 0.94 * s, zt[0]], [cx + 0.17 * s, cy + 1.02 * s, zt[1]]);
for (const sg of [-1, 1]) box(nm + '_RingS', col, [cx + sg * 0.17 * s - 0.04 * s, cy + 0.75 * s, zt[0]], [cx + sg * 0.17 * s + 0.04 * s, cy + 1.02 * s, zt[1]]);
for (const sg of [-1, 1]) {
const px = cx, py = cy - 0.8 * s;
box(nm + '_Arm', col, [px, py - 0.06 * s, zt[0]], [px + sg * 0.62 * s, py + 0.06 * s, zt[1]], { rot: [0, 0, sg * 38], pivot: [px, py, z] });
const ex = px + sg * 0.62 * s * Math.cos(38 * Math.PI / 180), ey = py + 0.62 * s * Math.sin(38 * Math.PI / 180);
box(nm + '_Fluke', col, [ex - 0.13 * s, ey - 0.13 * s, zt[0]], [ex + 0.13 * s, ey + 0.13 * s, zt[1]], { rot: [0, 0, 45], pivot: [ex, ey, z] });
}
box(nm + '_Crown', col, [cx - 0.12 * s, cy - 0.95 * s, zt[0]], [cx + 0.12 * s, cy - 0.78 * s, zt[1]]);
if (fishCols) fish(m, nm + 'Fish', [cx, cy - 0.05 * s, z + dirZ * 0.07], 1.5 * s, { a: 'x', w: 'y', t: 'z', dir: -1, ...fishCols });
}
// стена-панель изнутри: доски снизу, штукатурка с балками сверху (стойки пропускаются в проёмах)
function interiorWall(key, from, to, y0, y1, holes = []) {
const f = FACE[key], free = (a, b) => !holes.some(([h0, h1]) => b > h0 && a < h1);
for (let u = from; u < to - 0.01; u += 0.6) { const b = Math.min(to, u + 0.58); if (free(u, b)) fb('WainPlank', Math.round(u / 0.6) % 2 ? 'wood' : 'wood2', f, u, b, y0, y0 + 2.6, 0, Math.round(u / 0.6) % 2 ? 0.08 : 0.12); }
for (const [a, b] of splitSpans(from, to, holes)) { fb('WainCap', 'timber', f, a, b, y0 + 2.6, y0 + 2.85, 0, 0.22); fb('WainBase', 'timber', f, a, b, y0, y0 + 0.25, 0, 0.16); }
fb('Plaster', 'plaster', f, from, to, y0 + 2.85, y1, 0, 0.04);
for (const [a, b] of splitSpans(from, to, holes)) fb('WallBeam', 'timber', f, a, b, y1 - 0.45, y1, 0, 0.2);
for (let u = from + 0.2; u <= to; u += 3.6) { const uu = Math.min(u, to - 0.2); if (free(uu - 0.2, uu + 0.2)) fb('WallPost', 'timber', f, uu - 0.2, uu + 0.2, y0 + 2.85, y1 - 0.45, 0, 0.16); }
}
function splitSpans(a, b, holes) { let s = [[a, b]]; for (const [h0, h1] of holes) s = s.flatMap(([x, y]) => (h1 <= x || h0 >= y) ? [[x, y]] : [[x, Math.max(x, h0)], [Math.min(y, h1), y]].filter(([p, q]) => q - p > 0.05)); return s; }
// ================= Фундамент и пол =================
G('Foundation');
box('Slab', 'stoneDeep', [-GX - 0.4, 0, -GZ - 0.4], [GX + 0.4, 0.85, GZ + 0.4]);
{ let k = 0;
for (const key of ['gf', 'gb', 'gl', 'gr']) { const f = FACE[key], len = f.u === 0 ? GX + 0.4 : GZ + 0.4;
for (let u = -len; u < len - 0.01; k++) { const w = [1.6, 2.2, 1.3, 1.9, 2.5][k % 5], u1 = Math.min(len, u + w); fb('FoundStone', k % 2 ? 'stoneDark' : 'stone', f, u, u1 - 0.06, 0.05, 0.95, 0.38, 0.55); u = u1; } } }
for (let i = 0; i < 10; i++) { const z = -IZ + i * 2.0; box('FloorPlank_' + i, i % 2 ? 'floor2' : 'floor', [-IX, 0.85, z], [IX, F0, z + 1.98]); }
// ================= Каменный нижний этаж (полые стены) =================
G('StoneFloor');
box('Wall_Back', 'stone', [-GX, F0, IZ], [GX, F1, GZ]);
box('Wall_Left', 'stone', [-GX, F0, -GZ], [-IX, F1, GZ]);
box('Wall_Right', 'stone', [IX, F0, -GZ], [GX, F1, GZ]);
box('Wall_FrontL', 'stone', [-GX, F0, -GZ], [-DOOR, F1, -IZ]);
box('Wall_FrontR', 'stone', [DOOR, F0, -GZ], [GX, F1, -IZ]);
box('Wall_OverDoor', 'stone', [-DOOR, F0 + DOORH + DOOR, -GZ], [DOOR, F1, -IZ]);
for (let y = F0 + DOORH; y < F0 + DOORH + DOOR - 0.01; y += 0.25) {
const dy = Math.min(DOOR, y + 0.25 - (F0 + DOORH)), x = Math.sqrt(Math.max(0, DOOR * DOOR - dy * dy));
for (const s of [-1, 1]) box('Spandrel', 'stone', [s < 0 ? -DOOR : x, y, -GZ], [s < 0 ? -x : DOOR, y + 0.26, -IZ]);
}
for (const key of ['gf', 'gb', 'gl', 'gr']) {
const f = FACE[key], len = f.u === 0 ? GX : GZ;
for (const y of [2.8, 5.0, 7.2, 9.4, 11.6]) {
if (key === 'gf') { fb('Course', 'stoneDark', f, -len, -DOOR - 1.0, y, y + 0.1, 0, 0.03); fb('Course', 'stoneDark', f, DOOR + 1.0, len, y, y + 0.1, 0, 0.03); }
else fb('Course', 'stoneDark', f, -len, len, y, y + 0.1, 0, 0.03);
}
for (let i = 0; i < 10; i++) { const y0 = F0 + i * 1.2, wq = i % 2 ? 0.8 : 1.3; for (const e of [-1, 1]) fb('Quoin', 'stoneLight', f, e < 0 ? -len : len - wq, e < 0 ? -len + wq : len, y0 + 0.04, y0 + 1.16, 0, 0.08); }
}
for (let i = 0; i < 9; i++) {
const col = i === 4 ? 'stoneLight' : i % 2 ? 'stone' : 'stoneLight';
box('ArchStone_' + i, col, [DOOR, F0 + DOORH - 0.42, -GZ - 0.2], [DOOR + 0.95 + (i === 4 ? 0.35 : 0), F0 + DOORH + 0.42, -GZ + 0.05], { rot: [0, 0, (i + 0.5) * 20], pivot: [0, F0 + DOORH, -GZ] });
}
for (let i = 0; i < 5; i++) for (const s of [-1, 1]) {
const y0 = F0 + i * 1.2, w = i % 2 ? 0.6 : 0.95;
box('Jamb', i % 2 ? 'stone' : 'stoneLight', [s < 0 ? -DOOR - w : DOOR, y0 + 0.03, -GZ - 0.2], [s < 0 ? -DOOR : DOOR + w, y0 + 1.17, -GZ + 0.05]);
}
// окна нижнего этажа (витражи, свет с обеих сторон)
G('Windows');
const GWIN = { gf: [-13, -7.5, 7.5, 13], gb: [-1.5, 4.5, 10.5], gl: [-6.5, 3.5], gr: [-6.5, 8] };
for (const key in GWIN) for (const u of GWIN[key]) windowAt(key, u, 6.0, 2.4, 3.6, { shutters: key !== 'gf', flowers: true });
// ================= Двери (открыты внутрь, тонкие — без коллизии) =================
G('Door');
for (const s of [-1, 1]) {
const hx = s * DOOR, o = { rot: [0, s < 0 ? -75 : 75, 0], pivot: [hx, 0, -GZ + 0.3] };
const x0 = Math.min(hx, hx - s * DOOR), x1 = Math.max(hx, hx - s * DOOR);
for (let k = 0; k < 4; k++) { const a = x0 + k * DOOR / 4; box('DoorPlank', k % 2 ? 'wood2' : 'wood', [a + 0.01, F0, -GZ + 0.18], [a + DOOR / 4 - 0.01, F0 + DOORH + 1.2, -GZ + 0.42], o); }
for (const y of [F0 + 1.0, F0 + 3.2, F0 + 5.6]) box('DoorStrap', 'iron', [x0 + 0.05, y, -GZ + 0.14], [x1 - 0.05, y + 0.2, -GZ + 0.18], o);
box('DoorCarve', 'timber', [x0 + 0.5, F0 + 1.6, -GZ + 0.15], [x1 - 0.5, F0 + 2.8, -GZ + 0.18], o);
box('DoorRing', 'brass', [s < 0 ? x1 - 0.5 : x0 + 0.3, F0 + 3.0, -GZ + 0.1], [s < 0 ? x1 - 0.3 : x0 + 0.5, F0 + 3.4, -GZ + 0.15], o);
}
// ================= Крыльцо, вывеска над дверью, фонари =================
G('Porch');
box('Step1', 'stone', [-3.9, 0, -GZ - 2.5], [3.9, 0.35, -GZ - 0.3]);
box('Step2', 'stoneLight', [-3.6, 0.35, -GZ - 1.8], [3.6, 0.68, -GZ - 0.3]);
box('Landing', 'stone', [-3.3, 0.68, -GZ - 1.0], [3.3, F0, -IZ]);
for (const s of [-1, 1]) box('StepCheek', 'stoneDark', [s * 3.9 - (s < 0 ? 0 : 0.35), 0, -GZ - 2.5], [s * 3.9 + (s < 0 ? 0.35 : 0), 0.85, -GZ - 0.3]);
G('Sign');
box('Sign_Back', 'timber', [-5.4, 10.75, -GZ - 0.3], [5.4, 12.75, -GZ]);
box('Sign_Face', 'signFace', [-5.0, 10.95, -GZ - 0.42], [5.0, 12.55, -GZ - 0.3]);
for (const [a, b, c0, d0] of [[-5.4, 5.4, 12.55, 12.75], [-5.4, 5.4, 10.75, 10.95], [-5.4, -5.0, 10.95, 12.55], [5.0, 5.4, 10.95, 12.55]]) box('SignTrim', 'brass', [a, c0, -GZ - 0.46], [b, d0, -GZ - 0.3]);
G('Lantern_L'); lantern(m, 'L', -3.75, 7.0, -GZ - 0.35, -1, { iron: 'iron', glow: 'glow', brass: 'brass' });
G('Lantern_R'); lantern(m, 'R', 3.75, 7.0, -GZ - 0.35, 1, { iron: 'iron', glow: 'glow', brass: 'brass' });
// ================= Перекрытие (пол 2-го этажа) с проёмом лестницы =================
const SW = [-IX, -5, 6.8, IZ]; // проём лестницы: x −15..−5, z 6.8..10
G('UpperSlab');
box('Slab_A', 'floor', [-UX, F1, -UZ], [UX, U0, SW[2]]);
box('Slab_B', 'floor', [SW[1], F1, SW[2]], [UX, U0, UZ]);
box('Slab_C', 'floor', [-UX, F1, SW[3]], [SW[1], U0, UZ]);
box('Slab_D', 'floor', [-UX, F1, SW[2]], [SW[0], U0, SW[3]]);
for (let z = -UIZ; z < UIZ - 0.1; z += 1.6) {
const z0 = z + 0.02, z1 = Math.min(UIZ, z + 1.58), col = Math.round(z / 1.6) % 2 ? 'floor2' : 'wood2';
if (z1 > SW[2] && z0 < SW[3]) { // доска пересекает проём лестницы — режем
if (z0 < SW[2]) box('UpperFloorPlank', col, [-UIX, U0, z0], [UIX, U0 + 0.03, SW[2]]);
if (z1 > SW[3]) box('UpperFloorPlank', col, [-UIX, U0, SW[3]], [UIX, U0 + 0.03, z1]);
box('UpperFloorPlank', col, [SW[1], U0, Math.max(z0, SW[2])], [UIX, U0 + 0.03, Math.min(z1, SW[3])]);
} else box('UpperFloorPlank', col, [-UIX, U0, z0], [UIX, U0 + 0.03, z1]);
}
// внешний пояс перекрытия и консоли
G('Jetty');
for (const key of ['gf', 'gb', 'gl', 'gr']) {
const f = FACE[key], len = f.u === 0 ? UX + 0.1 : UZ + 0.1, out = f.n === 2 ? UZ - GZ : UX - GX;
fb('FloorBand', 'timber', f, -len, len, F1, U0, out, out + 0.1);
for (let u = -len + 0.8; u < len - 0.5; u += 1.5) fb('Joist', 'timber2', f, u - 0.22, u + 0.22, F1 - 0.45, F1, 0, out);
}
// ================= Второй этаж: полые фахверковые стены =================
G('UpperFloor');
const BD = 1.3, BDH = 3.6; // балконная дверь: x ±1.3, высота до 17.4
box('UWall_FrontL', 'plaster', [-UX, U0, -UZ], [-BD, U1, -UIZ]);
box('UWall_FrontR', 'plaster', [BD, U0, -UZ], [UX, U1, -UIZ]);
box('UWall_FrontTop', 'plaster', [-BD, U0 + BDH, -UZ], [BD, U1, -UIZ]);
box('UWall_Back', 'plaster', [-UX, U0, UIZ], [UX, U1, UZ]);
box('UWall_Left', 'plaster', [-UX, U0, -UZ], [-UIX, U1, UZ]);
box('UWall_Right', 'plaster', [UIX, U0, -UZ], [UX, U1, UZ]);
box('UCeiling', 'wood2', [-UX, U1 - 0.6, -UZ], [UX, U1, UZ]);
G('Timber');
const UWIN = { uf: [-13, -7.5, 7.5, 13], ub: [-12, -6, 0, 6, 12], ul: [-6, 2], ur: [-8.5, 6.5] };
const UW = 2.2, UH = 3.0, UYC = 18.3;
for (const key of ['uf', 'ub', 'ul', 'ur']) {
const f = FACE[key], len = f.u === 0 ? UX : UZ, wins = UWIN[key].map(c => [c - UW / 2 - 0.3, c + UW / 2 + 0.3]);
if (key === 'uf') wins.push([-BD - 0.3, BD + 0.3]);
fb('Sill', 'timber', f, -len, len, U0, U0 + 0.45, 0, 0.12);
fb('TopPlate', 'timber', f, -len, len, U1 - 0.5, U1, 0, 0.12);
const studs = []; for (let u = -len + 0.15; u <= len; u += 2.7) studs.push(Math.min(u, len - 0.15));
studs.push(len - 0.15);
const ok = studs.filter(u => !wins.some(([a, b]) => u + 0.18 > a && u - 0.18 < b));
for (const u of ok) fb('Stud', 'timber', f, u - 0.18, u + 0.18, U0 + 0.45, U1 - 0.5, 0, 0.12);
for (let i = 0; i < ok.length - 1; i++) {
const a = ok[i] + 0.18, b = ok[i + 1] - 0.18;
if (b - a < 0.5) continue;
const hasWin = wins.some(([p, q]) => q > a && p < b);
if (!hasWin) {
fb('Rail', 'timber', f, a, b, 17.9, 18.2, 0, 0.1);
brace('Brace', 'timber', f, a + 0.1, U0 + 0.45, b - 0.1, 17.9, 0.3, 0, 0.1);
brace('Brace', 'timber', f, a + 0.1, U1 - 0.5, b - 0.1, 18.2, 0.3, 0, 0.1);
} else {
fb('RailLow', 'timber', f, a, b, UYC - UH / 2 - 0.65, UYC - UH / 2 - 0.4, 0, 0.1);
}
}
for (const c of UWIN[key]) windowAt(key, c, UYC, UW, UH, { frame: 'timber', sill: 'timber2', lintel: 'timber', flowers: key === 'uf' || key === 'ul' });
}
// балконная дверь: проём открыт, створка распахнута внутрь (тонкая)
fb('BalconyDoorFrame', 'timber', FACE.uf, -BD - 0.25, BD + 0.25, U0 + BDH, U0 + BDH + 0.3, 0, 0.16);
for (const s of [-1, 1]) fb('BalconyDoorJamb', 'timber', FACE.uf, s * BD - 0.2, s * BD + 0.2, U0, U0 + BDH, 0, 0.16);
box('BalconyDoorLeaf', 'wood2', [-BD, U0, -UIZ - 0.12], [BD, U0 + BDH - 0.05, -UIZ + 0.12], { rot: [0, -80, 0], pivot: [-BD, 0, -UIZ] });
box('BalconyDoorLeafGlass', 'glow', [-BD + 0.4, U0 + 2.0, -UIZ - 0.14], [BD - 0.4, U0 + 3.2, -UIZ - 0.12], { rot: [0, -80, 0], pivot: [-BD, 0, -UIZ], group: 'WindowGlow' });
// ================= Балкон и герб =================
G('Balcony');
const BZ = -UZ - 2.4;
box('BalconyFloor', 'wood', [-5, U0 - 0.05, BZ], [5, U0 + 0.3, -UZ]);
box('BalconyEdge', 'timber', [-5.1, U0 - 0.3, BZ - 0.1], [5.1, U0, BZ + 0.15]);
for (const x of [-4.5, 4.5]) {
const a = [F1 - 2.2, -GZ], b = [U0 - 0.05, BZ + 0.3], cy = (a[0] + b[0]) / 2, cz = (a[1] + b[1]) / 2, len = Math.hypot(b[0] - a[0], b[1] - a[1]);
box('BalconyBracket', 'timber', [x - 0.18, cy - 0.18, cz - len / 2], [x + 0.18, cy + 0.18, cz + len / 2], { rot: [Math.atan2(-(b[0] - a[0]), b[1] - a[1]) * 180 / Math.PI, 0, 0], pivot: [x, cy, cz] });
}
box('BalconyKick', 'timber', [-5, U0 + 0.3, BZ], [5, U0 + 0.65, BZ + 0.3]);
for (const s of [-1, 1]) box('BalconyKickSide', 'timber', [s * 4.85 - 0.15, U0 + 0.3, BZ], [s * 4.85 + 0.15, U0 + 0.65, -UZ]);
for (let x = -4.7; x <= 4.71; x += 0.78) box('Baluster', 'woodLight', [x - 0.08, U0 + 0.65, BZ + 0.07], [x + 0.08, U0 + 1.55, BZ + 0.23]);
for (let z = BZ + 0.7; z < -UZ; z += 0.7) for (const s of [-1, 1]) box('BalusterSide', 'woodLight', [s * 4.85 - 0.08, U0 + 0.65, z - 0.08], [s * 4.85 + 0.08, U0 + 1.55, z + 0.08]);
box('RailFront', 'timber', [-5.05, U0 + 1.55, BZ - 0.02], [5.05, U0 + 1.85, BZ + 0.32]);
for (const s of [-1, 1]) box('RailSide', 'timber', [s * 4.85 - 0.16, U0 + 1.55, BZ], [s * 4.85 + 0.16, U0 + 1.85, -UZ]);
for (const s of [-1, 1]) box('RailPost', 'timber', [s * 4.85 - 0.2, U0 - 0.05, BZ - 0.04], [s * 4.85 + 0.2, U0 + 2.1, BZ + 0.36]);
G('Crest');
const CRZ = -UZ - 0.14;
box('CrestBoard', 'blue', [-1.5, 17.9, CRZ - 0.12], [1.5, 20.6, CRZ]);
box('CrestBoardTip', 'blue', [-1.0, 17.6, CRZ - 0.12], [1.0, 17.9, CRZ]);
box('CrestBoardTip2', 'blue', [-0.5, 17.35, CRZ - 0.12], [0.5, 17.6, CRZ]);
for (const [a, b, c0, d0] of [[-1.62, 1.62, 20.6, 20.78], [-1.62, -1.5, 17.75, 20.6], [1.5, 1.62, 17.75, 20.6]]) box('CrestTrim', 'gold', [a, c0, CRZ - 0.15], [b, d0, CRZ]);
anchor('CrestAnchor', 0, 19.15, CRZ - 0.22, 0.85, 'gold', { body: 'fishSilver', belly: 'fishBelly', fin: 'fishFin' });
// ================= Знамёна под выносом =================
G('Banners');
for (const s of [-1, 1]) {
const x = s * 10.25, z = -GZ - 0.5;
box('BannerRod', 'iron', [x - 0.9, F1 - 0.75, z - 0.05], [x + 0.9, F1 - 0.65, z + 0.05]);
for (const e of [-1, 1]) box('BannerRope', 'rope', [x + e * 0.8 - 0.02, F1 - 0.65, z - 0.02], [x + e * 0.8 + 0.02, F1, z + 0.02]);
box('BannerCloth', 'blue', [x - 0.75, 6.9, z - 0.03], [x + 0.75, F1 - 0.7, z + 0.03]);
box('BannerTailL', 'blue', [x - 0.75, 6.1, z - 0.03], [x - 0.08, 6.9, z + 0.03]);
box('BannerTailR', 'blue', [x + 0.08, 6.1, z - 0.03], [x + 0.75, 6.9, z + 0.03]);
for (const e of [-1, 1]) box('BannerBorder', 'cream', [x + e * 0.66 - 0.06, 6.1, z - 0.05], [x + e * 0.66 + 0.06, F1 - 0.7, z - 0.03]);
box('BannerBorderT', 'cream', [x - 0.75, F1 - 0.95, z - 0.05], [x + 0.75, F1 - 0.82, z - 0.03]);
anchor('BannerAnchor', x, 9.2, z - 0.09, 0.8, 'cream');
}
// ================= Крыша, фронтоны, слуховые окна, труба =================
G('Roof');
const LS = Math.hypot(UZ + 1.5, (UZ + 1.5) * SLOPE);
for (const s of [-1, 1]) {
const o = { rot: [s * ANG, 0, 0], pivot: [0, RIDGE, 0] };
box('RoofDeck', 'timber', [-UX - 1.4, RIDGE - 0.4, s < 0 ? -LS : 0], [UX + 1.4, RIDGE, s < 0 ? 0 : LS], o);
for (let k = 0; k < Math.ceil(LS / 0.95); k++) {
const a = k * 0.95, b = Math.min(LS, a + 1.0);
box('Shingles', ['roof', 'roof2', 'roof3'][k % 3], [-UX - 1.45, RIDGE + 0.02, s < 0 ? -b : a], [UX + 1.45, RIDGE + 0.22, s < 0 ? -a : b], o);
for (let x = -UX - 1.1 + (k % 2) * 0.95; x < UX + 1.1; x += 1.9) box('ShingleGap', 'roof2', [x, RIDGE + 0.22, s < 0 ? -b + 0.1 : a + 0.1], [x + 0.08, RIDGE + 0.25, s < 0 ? -a : b - 0.1], o);
}
for (const e of [-1, 1]) box('BargeBoard', 'timber', [e * (UX + 1.45) - 0.13, RIDGE - 0.6, s < 0 ? -LS : 0], [e * (UX + 1.45) + 0.13, RIDGE + 0.28, s < 0 ? 0 : LS], o);
box('Fascia', 'timber', [-UX - 1.45, RIDGE - 0.65, s < 0 ? -LS : LS - 0.16], [UX + 1.45, RIDGE + 0.22, s < 0 ? -LS + 0.16 : LS], o);
}
box('RidgeCap', 'roof2', [-UX - 1.5, RIDGE - 0.1, -0.38], [UX + 1.5, RIDGE + 0.5, 0.38]);
for (const e of [-1, 1]) box('RidgeFinial', 'timber', [e * (UX + 1.45) - 0.16, RIDGE + 0.2, -0.16], [e * (UX + 1.45) + 0.16, RIDGE + 1.1, 0.16]);
G('Gables');
for (const e of [-1, 1]) {
for (let y = U1; y < RIDGE - 0.2; y += 0.5) { const zw = (RIDGE - (y + 0.5)) / SLOPE; box('Gable', 'plaster', [e < 0 ? -UX : UX - 0.5, y, -zw], [e < 0 ? -UX + 0.5 : UX, y + 0.51, zw]); }
const f = e < 0 ? FACE.ul : FACE.ur;
fb('GableKing', 'timber', f, -0.2, 0.2, U1, RIDGE - 0.3, 0, 0.12);
const cy = 26.6, cw = (RIDGE - cy - 0.3) / SLOPE;
fb('GableCollar', 'timber', f, -cw, cw, cy, cy + 0.3, 0, 0.12);
brace('GableBrace', 'timber', f, -6.5, U1 + 0.1, -0.25, cy, 0.3, 0, 0.12);
brace('GableBrace', 'timber', f, 6.5, U1 + 0.1, 0.25, cy, 0.3, 0, 0.12);
for (const u of [-2.6, 2.6]) {
const ff = f; fb('Window_Glow', 'glow', ff, u - 0.6, u + 0.6, 23.5, 25.3, 0, 0.04, { group: 'WindowGlow' }); frameSet(ff, u, 24.4, 1.2, 1.8, 0, 'timber');
}
}
G('Dormers');
const DZ0 = -9.6, DZ1 = -3.0, DW = 2.0, DY1 = 25.6, DR = 27.6;
for (const dx of [-8, 8]) {
box('DormerWall', 'plaster', [dx - DW, U1 - 0.4, DZ0], [dx + DW, DY1, DZ1]);
for (let y = DY1; y < DR - 0.2; y += 0.4) { const xw = (DR - (y + 0.4)) / Math.tan(40 * Math.PI / 180); box('DormerGable', 'plaster', [dx - xw, y, DZ0], [dx + xw, y + 0.41, DZ1]); }
const DF = { n: 2, s: -1, p: DZ0, u: 0 };
fb('Window_Glow', 'glow', DF, dx - 0.75, dx + 0.75, 23.3, 25.1, 0, 0.04, { group: 'WindowGlow' }); frameSet(DF, dx, 24.2, 1.5, 1.8, 0, 'timber');
fb('DormerSill', 'timber2', DF, dx - 1.0, dx + 1.0, 22.9, 23.1, 0, 0.3);
for (const s of [-1, 1]) {
fb('DormerPost', 'timber', DF, dx + s * DW - 0.15, dx + s * DW + 0.15, U1 - 0.4, DY1, 0, 0.12);
const o = { rot: [0, 0, s * -40], pivot: [dx, DR, 0] };
box('DormerRoof', 'roof', [s < 0 ? dx - 3.3 : dx, DR - 0.3, DZ0 - 0.5], [s < 0 ? dx : dx + 3.3, DR, DZ1 + 0.5], o);
for (let k = 0; k < 4; k++) box('DormerShingle', ['roof2', 'roof3'][k % 2], [s < 0 ? dx - 0.85 * (k + 1) : dx + 0.85 * k, DR, DZ0 - 0.55], [s < 0 ? dx - 0.85 * k : dx + 0.85 * (k + 1), DR + 0.15, DZ1 + 0.5], o);
}
box('DormerRidge', 'roof2', [dx - 0.25, DR - 0.1, DZ0 - 0.55], [dx + 0.25, DR + 0.25, DZ1 + 0.5]);
}
G('Chimney');
const CZ0 = 1.5, CZ1 = 4.5;
box('ChimneyBase', 'stone', [GX, 0, CZ0], [UX + 2.0, F1, CZ1]);
box('ChimneyShaft', 'stone', [UX, F1, CZ0 + 0.4], [UX + 1.8, 32.2, CZ1 - 0.4]);
for (let y = 1.2; y < 32; y += 1.2) { const lo = y < F1; box('ChimneyCourse', Math.round(y / 1.2) % 2 ? 'stoneDark' : 'stoneLight', [lo ? GX - 0.02 : UX - 0.02, y, lo ? CZ0 - 0.02 : CZ0 + 0.38], [lo ? UX + 2.02 : UX + 1.82, y + 0.12, lo ? CZ1 + 0.02 : CZ1 - 0.38]); }
box('ChimneyCap', 'stoneDark', [UX - 0.2, 32.2, CZ0 + 0.2], [UX + 2.0, 32.6, CZ1 - 0.2]);
box('ChimneyTop', 'stoneDeep', [UX + 0.3, 32.6, CZ0 + 0.7], [UX + 1.5, 33.1, CZ1 - 0.7]);
// ================= Снаружи: доска заказов, бочки, ящики, сети =================
G('OrderBoard');
{ const x0 = -6.4, x1 = -4.3, z = -GZ - 2.0;
for (const x of [x0 - 0.12, x1 + 0.12]) box('OBPost', 'timber', [x - 0.14, 0, z - 0.14], [x + 0.14, 4.4, z + 0.14]);
box('OrderBoard_Face', 'woodLight', [x0, 1.5, z - 0.08], [x1, 3.8, z + 0.06]);
for (const [a, b] of [[1.4, 1.5], [3.8, 3.9]]) box('OBTrim', 'timber', [x0 - 0.1, a, z - 0.1], [x1 + 0.1, b, z + 0.08]);
for (const s of [-1, 1]) box('OBRoof', 'roof', [x0 - 0.45, 4.35, s < 0 ? z - 0.8 : z], [x1 + 0.45, 4.47, s < 0 ? z : z + 0.8], { rot: [s * 30, 0, 0], pivot: [0, 4.7, z] });
box('OBRidge', 'roof2', [x0 - 0.5, 4.6, z - 0.12], [x1 + 0.5, 4.78, z + 0.12]); }
G('Props');
barrel(m, 'BarrelA', 5.0, -GZ - 0.9, 0.85, 1.5, 0.6, 'wood', 'wood2', 'iron', 'timber');
barrel(m, 'BarrelB', 6.4, -GZ - 0.8, 0.85, 1.2, 0.5, 'wood2', 'timber', 'iron', 'wood');
crate(m, 'CrateA', 10.3, 0.85, -GZ - 1.7, 11.9, 2.2, -GZ - 0.2, 'wood', 'timber');
crate(m, 'CrateB', 10.5, 2.2, -GZ - 1.45, 11.6, 3.1, -GZ - 0.4, 'wood2', 'timber', true);
crate(m, 'CrateC', -15.8, 0.85, -GZ - 1.6, -14.2, 2.1, -GZ - 0.2, 'wood', 'timber');
G('WallNets');
{ const f = FACE.gl;
for (let u = -2.0; u <= 2.01; u += 0.45) fb('NetV', 'rope', f, u - 0.03, u + 0.03, 1.8, 4.2 - Math.abs(u) * 0.25 + 4, 0.02, 0.07);
for (let y = 2.0; y < 7.6; y += 0.45) fb('NetH', 'rope', f, -2.0, 2.0, y - 0.03, y + 0.03, 0.02, 0.07);
for (const u of [-2.2, 0, 2.2]) fb('NetPeg', 'timber', f, u - 0.1, u + 0.1, 8.0, 8.3, 0, 0.3);
for (let i = 0; i < 4; i++) fb('NetFloat', i % 2 ? 'cream' : 'red', f, -1.5 + i * 1.0 - 0.12, -1.5 + i * 1.0 + 0.12, 7.7, 8.0, 0.05, 0.2); }
// ================= Интерьер 1-го этажа =================
G('InteriorWalls');
interiorWall('igf', -IX, IX, F0, F1, [[-DOOR - 1.1, DOOR + 1.1]]);
interiorWall('igb', -IX, IX, F0, F1, [[-IX, -4.8]]); // за лестницей — без панелей
interiorWall('igl', -IZ, IZ, F0, F1, [[-1.2, IZ]]); // вдоль лестницы
interiorWall('igr', -IZ, IZ, F0, F1, [[0.6, 5.4]]); // камин
G('Ceiling');
for (const z of [-3.5, 3.5]) box('Girder', 'timber', [-IX, F1 - 0.9, z - 0.35], [IX, F1, z + 0.35]);
for (let x = -13.5; x <= 13.6; x += 2.25) box('Joist', 'timber2', [x - 0.2, F1 - 0.5, -IZ], [x + 0.2, F1, IZ]);
box('CeilingBoards', 'wood2', [-IX, F1 - 0.06, -IZ], [IX, F1, IZ]);
for (const x of [-6, 6]) for (const z of [-3.5, 3.5]) {
box('ColumnBase', 'stoneLight', [x - 0.6, F0, z - 0.6], [x + 0.6, F0 + 0.5, z + 0.6]);
box('Column', 'timber2', [x - 0.38, F0 + 0.5, z - 0.38], [x + 0.38, F1 - 0.9, z + 0.38]);
box('ColumnBand', 'iron', [x - 0.42, 4.0, z - 0.42], [x + 0.42, 4.2, z + 0.42]);
box('ColumnCap', 'timber', [x - 0.55, F1 - 1.25, z - 0.55], [x + 0.55, F1 - 0.9, z + 0.55]);
const fz = { n: 2, s: 1, p: z, u: 0 };
brace('ColumnBrace', 'timber', fz, x - 1.8, F1 - 0.9, x - 0.3, F1 - 2.4, 0.3, -0.15, 0.15);
brace('ColumnBrace', 'timber', fz, x + 1.8, F1 - 0.9, x + 0.3, F1 - 2.4, 0.3, -0.15, 0.15);
}
// --- лестница: пролёт A вдоль левой стены (+Z), площадка, пролёт B вдоль задней стены (+X)
G('Stairs');
const RISE = 0.8;
for (let i = 0; i < 8; i++) {
const z0 = -1 + i, top = F0 + (i + 1) * RISE;
box('StepA_' + i, i % 2 ? 'wood2' : 'wood', [-IX, F0, z0], [-12, top, z0 + 1]);
box('TreadA_' + i, 'woodLight', [-IX, top - 0.08, z0 - 0.05], [-12, top + 0.02, z0 + 0.95]);
}
box('Landing', 'wood2', [-IX, F0, 7], [-12, F0 + 9 * RISE, IZ]);
box('LandingTop', 'woodLight', [-IX, F0 + 9 * RISE - 0.08, 7], [-12, F0 + 9 * RISE + 0.02, IZ]);
for (let i = 0; i < 7; i++) {
const x0 = -12 + i, top = F0 + (10 + i) * RISE;
box('StepB_' + i, i % 2 ? 'wood2' : 'wood', [x0, F0, 7], [x0 + 1, top, IZ]);
box('TreadB_' + i, 'woodLight', [x0 - 0.05, top - 0.08, 7], [x0 + 0.95, top + 0.02, IZ]);
}
// обшивка-тетива и перила с открытой стороны (перила 0.3 — с коллизией)
const fA = { n: 0, s: 1, p: -12, u: 2 }, fB = { n: 2, s: -1, p: 7, u: 0 };
for (let i = 0; i < 8; i++) { const z0 = -1 + i, top = F0 + (i + 1) * RISE; fb('StringerA', 'timber2', fA, z0, z0 + 1, F0, top, 0, 0.06); fb('BalusterA', 'woodLight', fA, z0 + 0.4, z0 + 0.55, top, top + 1.1, -0.2, -0.05); }
brace('HandrailA', 'timber', fA, -1, F0 + RISE + 1.15, 7, F0 + 9 * RISE + 1.15, 0.3, -0.3, 0);
for (let i = 0; i < 7; i++) { const x0 = -12 + i, top = F0 + (10 + i) * RISE; fb('StringerB', 'timber2', fB, x0, x0 + 1, F0, top, 0, 0.06); fb('BalusterB', 'woodLight', fB, x0 + 0.4, x0 + 0.55, top, top + 1.1, -0.2, -0.05); }
brace('HandrailB', 'timber', fB, -12, F0 + 10 * RISE + 1.15, -5, F0 + 16 * RISE + 1.15, 0.3, -0.3, 0);
for (const [x, z, y] of [[-12, -1, F0 + 2.3], [-12, 7, F0 + 9 * RISE + 1.3], [-5, 7, U0 + 1.3]]) box('NewelPost', 'timber', [x - 0.25, F0, z - 0.25], [x + 0.25, y, z + 0.25]);
// под лестницей — бочки
barrel(m, 'StairBarrel1', -13.5, -2.5, F0, 1.4, 0.55, 'wood', 'wood2', 'iron', 'timber');
barrel(m, 'StairBarrel2', -13.6, -4.0, F0, 1.2, 0.5, 'wood2', 'timber', 'iron', 'wood');
// --- ковры
G('Rugs');
box('RugRunner', 'rug', [-1.6, F0, -IZ + 0.2], [1.6, F0 + 0.04, -3.6]);
for (const s of [-1, 1]) box('RugRunnerBorder', 'rugBorder', [s * 1.6 - (s < 0 ? 0 : 0.25), F0 + 0.04, -IZ + 0.2], [s * 1.6 + (s < 0 ? 0.25 : 0), F0 + 0.06, -3.6]);
box('RugMain', 'rug', [-4.5, F0, -3.4], [4.5, F0 + 0.04, 3.0]);
for (const [a, b, c, d] of [[-4.5, 4.5, -3.4, -3.0], [-4.5, 4.5, 2.6, 3.0], [-4.5, -4.1, -3.4, 3.0], [4.1, 4.5, -3.4, 3.0]]) box('RugBorder', 'rugBorder', [a, F0 + 0.04, c], [b, F0 + 0.06, d]);
box('RugCenter', 'rug2', [-2.0, F0 + 0.04, -1.6], [2.0, F0 + 0.06, 1.2]);
box('RugFire', 'rug2', [10.5, F0, 0.6], [13.4, F0 + 0.04, 5.4]);
// --- кафедра Старейшины
G('ElderDesk');
const DZ = 5.2;
box('Desk_Top', 'wood', [0.2, 2.35, DZ], [6.2, 2.6, DZ + 1.5]);
box('Desk_Front', 'timber2', [0.3, F0, DZ], [6.1, 2.35, DZ + 0.22]);
for (const x of [0.3, 5.85]) box('Desk_Side', 'timber2', [x, F0, DZ], [x + 0.25, 2.35, DZ + 1.5]);
for (const x of [1.2, 3.2, 5.2]) box('Desk_Panel', 'wood2', [x - 0.6, 1.4, DZ - 0.04], [x + 0.6, 2.1, DZ]);
anchor('DeskAnchor', 3.2, 1.75, DZ - 0.08, 0.32, 'brass');
box('Lectern', 'timber2', [2.7, 2.6, DZ + 0.6], [3.7, 2.9, DZ + 1.2], { rot: [-20, 0, 0], pivot: [3.2, 2.6, DZ + 0.9] });
box('Book', 'book1', [2.78, 2.9, DZ + 0.55], [3.62, 2.98, DZ + 1.15], { rot: [-20, 0, 0], pivot: [3.2, 2.6, DZ + 0.9] });
box('BookPages', 'cream', [2.82, 2.98, DZ + 0.6], [3.58, 3.01, DZ + 1.1], { rot: [-20, 0, 0], pivot: [3.2, 2.6, DZ + 0.9] });
box('Inkpot', 'iron', [4.6, 2.6, DZ + 0.5], [4.85, 2.8, DZ + 0.75]);
box('Quill', 'white', [4.7, 2.8, DZ + 0.6], [4.74, 3.2, DZ + 0.64], { rot: [0, 0, -15], pivot: [4.72, 2.8, DZ + 0.62] });
box('DeskCandle_Glow', 'candle', [1.0, 2.6, DZ + 0.5], [1.16, 3.0, DZ + 0.66]);
box('DeskScroll', 'parchment', [5.2, 2.6, DZ + 0.9], [5.9, 2.75, DZ + 1.05]);
box('Chair_Seat', 'wood', [2.5, 2.0, 7.3], [3.9, 2.15, 8.5]);
box('Chair_Back', 'timber2', [2.5, 2.15, 8.35], [3.9, 4.4, 8.55]);
box('Chair_Crest', 'brass', [2.9, 4.0, 8.3], [3.5, 4.3, 8.36]);
for (const [x, z] of [[2.6, 7.4], [3.8, 7.4], [2.6, 8.4], [3.8, 8.4]]) box('Chair_Leg', 'timber2', [x - 0.08, F0, z - 0.08], [x + 0.08, 2.0, z + 0.08]);
G('ElderSpot');
box('ElderSpot', 'rugBorder', [2.7, F0, 6.8], [3.7, F0 + 0.05, 7.8]);
// знамя гильдии за кафедрой
G('InteriorDecor');
box('HallBannerRod', 'iron', [1.6, 11.3, IZ - 0.3], [4.8, 11.4, IZ - 0.2]);
box('HallBanner', 'blue', [1.8, 6.0, IZ - 0.28], [4.6, 11.3, IZ - 0.22]);
box('HallBannerTailL', 'blue', [1.8, 5.2, IZ - 0.28], [3.1, 6.0, IZ - 0.22]);
box('HallBannerTailR', 'blue', [3.3, 5.2, IZ - 0.28], [4.6, 6.0, IZ - 0.22]);
anchor('HallBannerAnchor', 3.2, 8.7, IZ - 0.32, 1.1, 'cream', { body: 'fishSilver', belly: 'fishBelly', fin: 'fishFin' });
// стойка регистрации (справа от входа)
G('Reception');
box('Counter_Body', 'wood2', [7.5, F0, -6.6], [13.5, 2.3, -5.4]);
box('Counter_Return', 'wood2', [7.5, F0, -9.4], [8.7, 2.3, -6.6]);
box('Counter_Top', 'woodLight', [7.3, 2.3, -6.75], [13.6, 2.5, -5.25]);
box('Counter_TopR', 'woodLight', [7.35, 2.3, -9.5], [8.85, 2.5, -6.6]);
for (let x = 7.8; x < 13.4; x += 1.2) box('CounterPanel', 'wood', [x, 1.3, -6.68], [x + 0.9, 2.1, -6.6]);
box('Ledger', 'book2', [9.5, 2.5, -6.3], [10.6, 2.62, -5.6]);
box('Bell', 'brass', [11.6, 2.5, -6.2], [11.9, 2.75, -5.9]);
box('CounterCandle_Glow', 'candle', [12.8, 2.5, -6.2], [12.95, 2.9, -6.05]);
barrel(m, 'RecBarrel', 12.5, -8.5, F0, 1.4, 0.55, 'wood', 'wood2', 'iron', 'timber');
crate(m, 'RecCrate', 10.0, F0, -9.8, 11.4, 2.0, -8.4, 'wood2', 'timber');
// доска заказов внутри (на передней стене слева, лицом в +Z — в зал)
G('OrderBoardInside');
box('OBI_Frame', 'timber', [-11.4, 4.1, -IZ], [-5.6, 8.1, -IZ + 0.2]);
box('OrderBoardInside_Face', 'woodLight', [-11.1, 4.4, -IZ + 0.2], [-5.9, 7.8, -IZ + 0.3]);
if (false) for (const [x, y, c] of []) box('OBI_Note', c, [x - 0.5, y - 0.6, -IZ + 0.3], [x + 0.5, y + 0.4, -IZ + 0.33]);
box('OBI_Lantern_Glow', 'glow', [-12.0, 6.2, -IZ + 0.2], [-11.7, 6.8, -IZ + 0.5]);
// длинный стол с лавками
G('LongTable');
box('Table_Top', 'wood', [-10.5, 2.35, -8.2], [-7.5, 2.55, -1.8]);
for (const [x, z] of [[-10.2, -7.9], [-7.8, -7.9], [-10.2, -2.1], [-7.8, -2.1]]) box('Table_Leg', 'timber2', [x - 0.13, F0, z - 0.13], [x + 0.13, 2.35, z + 0.13]);
for (const x of [-11.3, -6.7]) { box('Bench', 'wood2', [x - 0.35, 1.75, -8.0], [x + 0.35, 1.92, -2.0]); for (const z of [-7.6, -2.4]) box('BenchLeg', 'timber2', [x - 0.25, F0, z - 0.1], [x + 0.25, 1.75, z + 0.1]); }
for (const [x, z] of [[-9.6, -7.0], [-8.4, -5.2], [-9.4, -3.0]]) box('Mug', 'woodLight', [x - 0.17, 2.55, z - 0.17], [x + 0.17, 2.9, z + 0.17]);
box('TableMap', 'parchment', [-9.6, 2.55, -5.0], [-8.4, 2.57, -3.8]);
box('TableCandle_Glow', 'candle', [-9.05, 2.55, -6.1], [-8.9, 2.95, -5.95]);
// полки с книгами и свитками (задняя стена справа)
G('Shelves');
for (let k = 0; k < 5; k++) {
const y = 1.9 + k * 1.35;
box('Shelf', 'wood', [8.0, y, IZ - 0.95], [14.6, y + 0.12, IZ]);
for (let i = 0; i < 9; i++) {
const x = 8.3 + i * 0.72 + (k % 2) * 0.15;
if ((i + k) % 4 === 3) { box('Scroll', 'parchment', [x - 0.3, y + 0.12, IZ - 0.7], [x + 0.3, y + 0.42, IZ - 0.4]); box('ScrollEnd', 'timber', [x - 0.33, y + 0.17, IZ - 0.65], [x - 0.3, y + 0.37, IZ - 0.45]); }
else box('ShelfBook', ['book1', 'book2', 'woodLight', 'blue'][(i + k) % 4], [x - 0.13, y + 0.12, IZ - 0.8], [x + 0.13, y + 0.95 - (i % 3) * 0.12, IZ - 0.15]);
}
}
for (const x of [7.9, 14.7]) box('ShelfSide', 'timber2', [x - 0.12, F0, IZ - 1.0], [x + 0.12, 8.8, IZ]);
box('ShelfTop', 'timber', [7.7, 8.8, IZ - 1.05], [14.9, 9.05, IZ]);
// камин (правая стена) с огнём
G('Fireplace');
const fR = FACE.igr;
fb('Hearth', 'stoneDark', fR, 0.4, 5.6, F0, F0 + 0.25, 0, 1.9);
fb('Surround', 'stone', fR, 0.7, 5.3, F0, 7.4, 0, 1.0);
for (let i = 0; i < 6; i++) fb('SurroundCourse', i % 2 ? 'stoneLight' : 'stoneDark', fR, 0.68, 5.32, F0 + 1.1 + i * 1.1, F0 + 1.18 + i * 1.1, 0.98, 1.04);
fb('Opening', 'stoneDeep', fR, 1.8, 4.2, F0 + 0.25, 4.6, 0.95, 1.06);
fb('ArchTop', 'stoneLight', fR, 1.6, 4.4, 4.6, 5.0, 0.95, 1.12);
fb('Mantel', 'timber', fR, 0.4, 5.6, 5.2, 5.6, 0, 1.35);
fb('Hood', 'stone', fR, 1.3, 4.7, 7.4, F1 - 0.5, 0, 0.8);
for (const z of [2.2, 3.8]) fb('Andiron', 'iron', fR, z - 0.08, z + 0.08, F0 + 0.25, F0 + 0.9, 0.4, 0.9);
fb('Logs', 'wood2', fR, 2.2, 3.8, F0 + 0.3, F0 + 0.7, 0.4, 0.85);
G('Fire');
fb('Fire_Glow', 'fire', fR, 2.3, 3.7, F0 + 0.6, 3.3, 0.5, 0.8);
fb('FireCore_Glow', 'fireCore', fR, 2.6, 3.4, F0 + 0.6, 2.4, 0.55, 0.75);
G('Fireplace');
fb('MantelCandle_Glow', 'candle', fR, 0.8, 1.0, 5.6, 6.1, 0.4, 0.6);
fb('MantelCandle2_Glow', 'candle', fR, 5.0, 5.2, 5.6, 6.0, 0.4, 0.6);
fb('MantelJar', 'stoneLight', fR, 1.9, 2.4, 5.6, 6.2, 0.4, 0.85);
fb('MantelBox', 'wood2', fR, 3.6, 4.5, 5.6, 5.95, 0.35, 0.95);
// трофейная рыба над камином, ещё одна на стене у двери, якорь, вёсла и сети на стенах
G('Trophies');
fb('TrophyPlaque', 'timber2', fR, 0.8, 5.2, 8.6, 10.6, 0.8, 0.95);
fb('TrophyTrim', 'brass', fR, 0.7, 5.3, 8.5, 10.7, 0.75, 0.82);
fish(m, 'FireTrophyFish', [IX - 1.12, 9.6, 3.0], 3.8, { a: 'z', w: 'y', t: 'x', dir: -1, body: 'fishGold', belly: 'fishBelly', fin: 'fishGoldFin' });
const fG = FACE.igf;
fb('DoorTrophyPlaque', 'timber2', fG, 4.8, 9.6, 8.5, 10.4, 0.2, 0.35);
fb('DoorTrophyTrim', 'brass', fG, 4.7, 9.7, 8.4, 10.5, 0.16, 0.22);
fish(m, 'DoorTrophyFish', [7.2, 9.45, -IZ + 0.55], 3.6, { a: 'x', w: 'y', t: 'z', dir: 1, body: 'fishSilver', belly: 'fishBelly', fin: 'fishFin' });
anchor('WallAnchor', 13.0, 7.0, IZ - 0.35, 1.6, 'iron', null, 1);
for (const sg of [-1, 1]) {
const cx = IX - 0.25, cy = 8.0, cz = -7.5;
box('OarShaft', 'woodLight', [cx - 0.05, cy - 0.05, cz - 2.2], [cx + 0.05, cy + 0.05, cz + 1.5], { rot: [sg * 40, 0, 0], pivot: [cx, cy, cz] });
box('OarBlade', 'woodLight', [cx - 0.04, cy - 0.24, cz + 1.5], [cx + 0.04, cy + 0.24, cz + 2.5], { rot: [sg * 40, 0, 0], pivot: [cx, cy, cz] });
}
{ const f = FACE.igr; for (let u = -4.4; u <= -1.6; u += 0.4) fb('InNetV', 'rope', f, u - 0.025, u + 0.025, 3.6, 7.0, 0.05, 0.1); for (let y = 3.8; y < 7.0; y += 0.4) fb('InNetH', 'rope', f, -4.4, -1.6, y - 0.025, y + 0.025, 0.05, 0.1); fb('InNetFloat', 'red', f, -3.2, -2.8, 6.9, 7.2, 0.05, 0.2); }
barrel(m, 'HallBarrel1', -13.6, -8.6, F0, 1.5, 0.6, 'wood', 'wood2', 'iron', 'timber');
barrel(m, 'HallBarrel2', -12.3, -9.2, F0, 1.2, 0.5, 'wood2', 'timber', 'iron', 'wood');
// люстры-колёса
G('Chandelier');
for (const [cx, cz] of [[0, -0.3], [-8, -5]]) {
const cy = 9.4;
for (const r of [0, 45, 90, 135]) box('ChWheel', 'timber', [cx - 1.5, cy, cz - 0.08], [cx + 1.5, cy + 0.16, cz + 0.08], { rot: [0, r, 0], pivot: [cx, cy, cz] });
box('ChChain', 'iron', [cx - 0.04, cy + 0.16, cz - 0.04], [cx + 0.04, F1 - 0.5, cz + 0.04]);
for (let k = 0; k < 8; k++) { const a = k * Math.PI / 4, x = cx + Math.cos(a) * 1.45, z = cz + Math.sin(a) * 1.45; box('ChCandle_Glow', 'candle', [x - 0.08, cy + 0.16, z - 0.08], [x + 0.08, cy + 0.55, z + 0.08]); }
}
// ================= Интерьер 2-го этажа: архив и зал рангов =================
G('UpperInterior');
for (let x = -14; x <= 14.1; x += 3.5) box('UBeam', 'timber', [x - 0.25, U1 - 1.1, -UIZ], [x + 0.25, U1 - 0.6, UIZ]);
for (const key of ['iuf', 'iub', 'iul', 'iur']) { const f = FACE[key], len = f.u === 0 ? UIX : UIZ; fb('USkirting', 'timber', f, -len, len, U0, U0 + 0.3, 0, 0.12); fb('UWainCap', 'timber', f, -len, len, U0 + 1.6, U0 + 1.8, 0, 0.14); for (let u = -len; u < len - 0.3; u += 0.7) fb('UWain', Math.round(u / 0.7) % 2 ? 'wood' : 'wood2', f, u, u + 0.66, U0 + 0.3, U0 + 1.6, 0, 0.06); }
// перила галереи вокруг проёма лестницы (с коллизией)
G('Gallery');
const gz = SW[2];
box('GalleryKick', 'timber', [-UIX, U0, gz - 0.3], [SW[1], U0 + 0.6, gz]);
for (let x = -UIX + 0.3; x < SW[1]; x += 0.7) box('GalleryBaluster', 'woodLight', [x - 0.08, U0 + 0.6, gz - 0.23], [x + 0.08, U0 + 1.3, gz - 0.07]);
box('GalleryRail', 'timber', [-UIX, U0 + 1.3, gz - 0.33], [SW[1] + 0.3, U0 + 1.6, gz + 0.03]);
box('GalleryPost', 'timber', [SW[1] - 0.05, U0, gz - 0.35], [SW[1] + 0.45, U0 + 1.9, gz + 0.05]);
// стена рангов F–S: 7 щитов и пустые плашки (RankPlate_*), лицом в −Z
G('RankWall');
const RZ = UIZ;
box('RankBackboard', 'timber2', [-2.6, U0 + 2.0, RZ - 0.12], [15.4, 21.0, RZ]);
box('RankBackboardTop', 'timber', [-2.8, 21.0, RZ - 0.25], [15.6, 21.3, RZ]);
['F', 'E', 'D', 'C', 'B', 'A', 'S'].forEach((r, i) => {
const x = 13.8 - i * 2.5, col = 'rank' + r, z = RZ - 0.12;
box(`Rank${r}_Shield`, col, [x - 0.8, 17.6, z - 0.15], [x + 0.8, 20.0, z]);
box(`Rank${r}_ShieldTip`, col, [x - 0.55, 17.2, z - 0.15], [x + 0.55, 17.6, z]);
box(`Rank${r}_ShieldTip2`, col, [x - 0.25, 16.9, z - 0.15], [x + 0.25, 17.2, z]);
for (const [a, b, c0, d0] of [[x - 0.9, x + 0.9, 20.0, 20.15], [x - 0.9, x - 0.8, 17.4, 20.0], [x + 0.8, x + 0.9, 17.4, 20.0]]) box(`Rank${r}_Trim`, r === 'S' ? 'gold' : 'brass', [a, c0, z - 0.18], [b, d0, z]);
box(`Rank${r}_Boss`, r === 'S' ? 'white' : 'gold', [x - 0.25, 18.55, z - 0.24], [x + 0.25, 19.05, z - 0.15], { rot: [0, 0, 45], pivot: [x, 18.8, z - 0.2] });
if (r === 'S') for (const dx of [-0.45, 0, 0.45]) box('RankS_Crown', 'gold', [x + dx - 0.1, 20.15, z - 0.12], [x + dx + 0.1, 20.6 + (dx ? 0 : 0.15), z]);
box(`RankPlate_${r}`, 'parchment', [x - 0.95, 15.6, z - 0.08], [x + 0.95, 16.5, z]);
box(`RankPlate_${r}_Frame`, 'timber', [x - 1.05, 15.5, z - 0.05], [x + 1.05, 16.6, z + 0.0]);
});
// витрина трофеев (по центру справа, открытая спереди и сзади)
G('TrophyCase');
const TX0 = 3, TX1 = 9.5, TZ0 = -1.8, TZ1 = 0.2;
box('Case_Base', 'timber2', [TX0, U0, TZ0], [TX1, U0 + 1.0, TZ1]);
for (const [x, z] of [[TX0, TZ0], [TX1 - 0.25, TZ0], [TX0, TZ1 - 0.25], [TX1 - 0.25, TZ1 - 0.25]]) box('Case_Post', 'timber', [x, U0 + 1.0, z], [x + 0.25, U0 + 4.6, z + 0.25]);
for (const y of [U0 + 1.0, U0 + 2.2, U0 + 3.4]) box('Case_Shelf', 'wood', [TX0, y, TZ0], [TX1, y + 0.12, TZ1]);
box('Case_Top', 'timber', [TX0 - 0.15, U0 + 4.6, TZ0 - 0.15], [TX1 + 0.15, U0 + 4.9, TZ1 + 0.15]);
box('Case_Back', 'wood2', [TX0, U0 + 1.0, -0.85], [TX1, U0 + 4.6, -0.75]);
[[4.0, 'gold'], [6.2, 'gold'], [8.4, 'brass']].forEach(([x, c], i) => {
const y = U0 + 1.12, z = -1.35;
box('Cup_Foot', c, [x - 0.3, y, z - 0.25], [x + 0.3, y + 0.12, z + 0.25]); box('Cup_Stem', c, [x - 0.08, y + 0.12, z - 0.08], [x + 0.08, y + 0.5, z + 0.08]);
box('Cup_Bowl', c, [x - 0.35, y + 0.5, z - 0.3], [x + 0.35, y + 0.95, z + 0.3]); for (const s of [-1, 1]) box('Cup_Handle', c, [x + s * 0.35 - (s < 0 ? 0.15 : 0), y + 0.6, z - 0.04], [x + s * 0.35 + (s > 0 ? 0.15 : 0), y + 0.85, z + 0.04]);
});
fish(m, 'CaseFish1', [5.0, U0 + 2.75, -1.3], 2.2, { a: 'x', w: 'y', t: 'z', dir: -1, body: 'fishGold', belly: 'fishBelly', fin: 'fishGoldFin' });
fish(m, 'CaseFish2', [7.9, U0 + 2.75, -1.3], 1.8, { a: 'x', w: 'y', t: 'z', dir: 1, body: 'fishSilver', belly: 'fishBelly', fin: 'fishFin' });
for (const [x, c] of [[4.2, 'rankS'], [5.6, 'rankA'], [7.0, 'rankB'], [8.4, 'rankC']]) { box('Medal', c, [x - 0.25, U0 + 3.55, -1.35], [x + 0.25, U0 + 4.05, -1.25]); box('MedalRibbon', 'blue', [x - 0.1, U0 + 4.05, -1.33], [x + 0.1, U0 + 4.4, -1.27]); }
// карта озера на правой стене
G('LakeMap');
const fM = FACE.iur;
fb('MapFrame', 'timber', fM, -8.2, 1.2, 15.2, 20.4, 0, 0.12);
fb('LakeMap_Face', 'mapSand', fM, -7.9, 0.9, 15.5, 20.1, 0.12, 0.16);
fb('MapWater', 'mapWater', fM, -7.4, 0.4, 15.9, 19.7, 0.16, 0.18);
fb('MapDeep', 'mapDeep', fM, -5.6, -1.4, 16.8, 18.8, 0.18, 0.2);
for (const [u0, u1, y0, y1] of [[-6.8, -5.9, 18.4, 19.2], [-1.0, 0.0, 16.2, 16.9], [-3.4, -2.6, 17.2, 17.8]]) fb('MapIsland', 'mapLand', fM, u0, u1, y0, y1, 0.2, 0.23);
for (const [u, y] of [[-4.6, 18.9], [-2.0, 16.6], [-6.2, 16.6]]) fb('MapPin', 'red', fM, u - 0.1, u + 0.1, y - 0.1, y + 0.1, 0.23, 0.3);
fb('MapBoat', 'timber', fM, -4.2, -3.5, 17.0, 17.2, 0.2, 0.24);
// архив: стеллажи со свитками на левой стене, стол писаря
G('Archive');
const fL = FACE.iul;
for (let k = 0; k < 5; k++) {
const y = U0 + 0.4 + k * 1.35;
fb('ArchiveShelf', 'wood', fL, -5.0, 5.0, y, y + 0.12, 0, 0.9);
for (let i = 0; i < 12; i++) {
const u = -4.6 + i * 0.8;
if ((i + k) % 3) { fb('ArchScroll', 'parchment', fL, u - 0.32, u + 0.32, y + 0.12, y + 0.42, 0.15, 0.75); fb('ArchScrollTie', 'red', fL, u - 0.05, u + 0.05, y + 0.12, y + 0.44, 0.14, 0.76); }
else fb('ArchBook', ['book1', 'book2', 'blue'][k % 3], fL, u - 0.15, u + 0.15, y + 0.12, y + 0.95, 0.1, 0.8);
}
}
for (const u of [-5.1, 5.1]) fb('ArchiveSide', 'timber2', fL, u - 0.12, u + 0.12, U0, U0 + 7.2, 0, 0.95);
box('ScribeDesk', 'wood', [-11.5, U0 + 2.3, -4.5], [-8.5, U0 + 2.5, -2.7]);
for (const [x, z] of [[-11.3, -4.3], [-8.7, -4.3], [-11.3, -2.9], [-8.7, -2.9]]) box('ScribeLeg', 'timber2', [x - 0.12, U0, z - 0.12], [x + 0.12, U0 + 2.3, z + 0.12]);
box('ScribeBook', 'book2', [-10.6, U0 + 2.5, -4.0], [-9.6, U0 + 2.62, -3.2]);
box('ScribeCandle_Glow', 'candle', [-9.0, U0 + 2.5, -4.1], [-8.85, U0 + 2.9, -3.95]);
box('ScribeStool', 'wood2', [-10.4, U0 + 1.5, -1.9], [-9.6, U0 + 1.65, -1.1]);
box('ScribeStoolLeg', 'timber2', [-10.1, U0, -1.6], [-9.9, U0 + 1.5, -1.4]);
// сундуки
G('Chests');
[[-14.6, -9.6], [-12.4, -9.6], [13.2, 3.2]].forEach(([x, z], i) => {
const w = 1.9, d = 1.2, h = 1.1, rot = i === 2 ? { rot: [0, 90, 0], pivot: [x + w / 2, 0, z + d / 2] } : {};
box('Chest_Body', i % 2 ? 'wood2' : 'wood', [x, U0, z], [x + w, U0 + h, z + d], rot);
box('Chest_Lid', 'timber2', [x - 0.05, U0 + h, z - 0.05], [x + w + 0.05, U0 + h + 0.35, z + d + 0.05], rot);
for (const bx of [x + 0.2, x + w - 0.35]) box('Chest_Band', 'iron', [bx, U0 - 0.01, z - 0.07], [bx + 0.15, U0 + h + 0.37, z + d + 0.07], rot);
box('Chest_Lock', 'brass', [x + w / 2 - 0.15, U0 + h - 0.35, z - 0.09], [x + w / 2 + 0.15, U0 + h + 0.05, z - 0.04], rot);
});
// люстра наверху
G('Chandelier');
for (const [cx, cz] of [[0, 3.5]]) {
const cy = U1 - 2.6;
for (const r of [0, 45, 90, 135]) box('UChWheel', 'timber', [cx - 1.3, cy, cz - 0.08], [cx + 1.3, cy + 0.15, cz + 0.08], { rot: [0, r, 0], pivot: [cx, cy, cz] });
box('UChChain', 'iron', [cx - 0.04, cy + 0.15, cz - 0.04], [cx + 0.04, U1 - 1.1, cz + 0.04]);
for (let k = 0; k < 8; k++) { const a = k * Math.PI / 4, x = cx + Math.cos(a) * 1.25, z = cz + Math.sin(a) * 1.25; box('UChCandle_Glow', 'candle', [x - 0.07, cy + 0.15, z - 0.07], [x + 0.07, cy + 0.5, z + 0.07]); }
}
G('UpperRug');
box('URug', 'rug2', [-3.5, U0 + 0.03, -6.5], [3.5, U0 + 0.07, 2.5]);
for (const [a, b, c, d] of [[-3.5, 3.5, -6.5, -6.1], [-3.5, 3.5, 2.1, 2.5], [-3.5, -3.1, -6.5, 2.5], [3.1, 3.5, -6.5, 2.5]]) box('URugBorder', 'rugBorder', [a, U0 + 0.07, c], [b, U0 + 0.09, d]);
m.write(path.resolve(__dirname, '../../assets/props'), process.argv[2]);
// ---------- снимки
if (process.argv[3]) {
const { render } = require('./render');
const pre = process.argv[3];
render([{ model: m }], pre + 'front.png', { yaw: 0, pitch: 8, width: 1600, height: 1200 });
render([{ model: m }], pre + '34.png', { yaw: 35, pitch: 20, width: 1600, height: 1200 });
const outerRoof = new Set(['Roof', 'Gables', 'Dormers']);
const ground = { cubes: m.cubes.filter(c => Math.max(c.from[1], c.to[1]) <= F1 + 0.001 && !['Jetty', 'UpperSlab', 'Banners', 'Sign'].includes(c.group) && !/^(Girder|Joist|CeilingBoards|WallBeam)$/.test(c.name)), colors: m.colors, colorIdx: m.colorIdx };
render([{ model: ground }], pre + 'floor1.png', { yaw: 20, pitch: 60, width: 1600, height: 1200 });
const upper = { cubes: m.cubes.filter(c => Math.min(c.from[1], c.to[1]) >= F1 - 0.01 && Math.max(c.from[1], c.to[1]) <= U1 + 0.01 && !outerRoof.has(c.group) && !/^(UCeiling|UBeam|UChWheel|UChChain|UChCandle_Glow)$/.test(c.name)), colors: m.colors, colorIdx: m.colorIdx };
render([{ model: upper }], pre + 'floor2.png', { yaw: 20, pitch: 60, width: 1600, height: 1200 });
console.log('renders:', pre + '{front,34,floor1,floor2}.png');
}