// Masa ve koltuk yerleşimi. Tüm konumlar burada tanımlı; koltuklar bölgelere ayrılmış.
import * as THREE from 'three';
export const ROOM = { minX: -10, maxX: 10, minZ: -17, maxZ: 15 };
export const DOOR = { x: 0, z: 17 };
export const FLOOR = { minX: -4, maxX: 4, minZ: -13, maxZ: -5 }; // dans pisti (8x8 karo)
export const LOCA = { minX: -10, maxX: -5.5, minZ: -17, maxZ: -9.5, h: 0.5 };
export const DIVA = { x: 7.0, minZ: -15, maxZ: -6.5 };
// Sahne (venue.js'deki 7 x 3.2 platform, 0.5 yüksek). Şarkıcı mikrofonun yanında durur.
export const STAGE = { minX: -3.5, maxX: 3.5, minZ: -17, maxZ: -13.8, h: 0.5 };
export const STAGE_SPOT = { zone: 'sahne', x: 0.75, z: -14.7, facing: 0, seatY: 0, occupant: null };
const mats = {
// beyaz keten masa örtüsü; diva masasında pembe saten
tableTop: new THREE.MeshStandardMaterial({ color: 0xf0e8de, roughness: 0.85 }),
divaTop: new THREE.MeshStandardMaterial({ color: 0xf6b8d6, roughness: 0.35, metalness: 0.1, emissive: 0x401028, emissiveIntensity: 0.3 }),
leg: new THREE.MeshStandardMaterial({ color: 0x2a1530, roughness: 0.6 }),
chair: new THREE.MeshStandardMaterial({ color: 0x7a0c1e, roughness: 0.92 }), // kırmızı kadife
divaChair: new THREE.MeshStandardMaterial({ color: 0xffffff, roughness: 0.4, emissive: 0xff7fc8, emissiveIntensity: 0.15 }),
sofa: new THREE.MeshStandardMaterial({ color: 0x3e0f5e, roughness: 0.95 }),
candle: new THREE.MeshStandardMaterial({ color: 0xf4ead8, roughness: 0.6 }),
flame: new THREE.MeshBasicMaterial({ color: 0xffb040, toneMapped: false }),
plate: new THREE.MeshStandardMaterial({ color: 0xffffff, roughness: 0.25 }),
glass: new THREE.MeshStandardMaterial({ color: 0xbfe9ff, transparent: true, opacity: 0.55, roughness: 0.1 }),
bottle: new THREE.MeshStandardMaterial({ color: 0x1d5c2e, roughness: 0.08, metalness: 0.1, transparent: true, opacity: 0.85 }),
raki: new THREE.MeshStandardMaterial({ color: 0xe8f2f0, roughness: 0.05, transparent: true, opacity: 0.7 }),
};
function box(w, h, d, m) {
return new THREE.Mesh(new THREE.BoxGeometry(w, h, d), m);
}
function chair(m) {
const g = new THREE.Group();
const seat = box(0.55, 0.1, 0.55, m);
seat.position.y = 0.4;
const back = box(0.55, 0.6, 0.1, m);
back.position.set(0, 0.7, -0.25);
g.add(seat, back);
return g;
}
function tableDecor(g, x, z, top) {
const candle = new THREE.Mesh(new THREE.CylinderGeometry(0.035, 0.035, 0.14, 8), mats.candle);
candle.position.set(x, top + 0.07, z);
const flame = new THREE.Mesh(new THREE.SphereGeometry(0.025, 8, 6), mats.flame);
flame.scale.y = 1.6;
flame.position.set(x, top + 0.17, z);
const bottle = new THREE.Mesh(new THREE.CylinderGeometry(0.045, 0.06, 0.3, 10), Math.random() < 0.5 ? mats.raki : mats.bottle);
bottle.position.set(x + 0.28, top + 0.15, z - 0.12);
const neck = new THREE.Mesh(new THREE.CylinderGeometry(0.018, 0.025, 0.1, 8), bottle.material);
neck.position.set(x + 0.28, top + 0.35, z - 0.12);
g.add(candle, flame, bottle, neck);
for (let i = 0; i < 3; i++) {
const a = i * 2.1 + 0.6;
const plate = new THREE.Mesh(new THREE.CylinderGeometry(0.11, 0.08, 0.02, 14), mats.plate);
plate.position.set(x + Math.cos(a) * 0.4, top + 0.01, z + Math.sin(a) * 0.4);
g.add(plate);
}
for (let i = 0; i < 2; i++) {
const glass = new THREE.Mesh(new THREE.CylinderGeometry(0.035, 0.03, 0.14, 10), mats.glass);
glass.position.set(x - 0.25 + i * 0.5, top + 0.07, z + 0.28 - i * 0.56);
g.add(glass);
}
}
/** Koltuk: oturulacak nokta + bakış yönü. */
function seat(zone, x, z, facing, seatY = 0.45) {
return { zone, x, z, facing, seatY, occupant: null };
}
export function buildTables(scene) {
const g = new THREE.Group();
scene.add(g);
const seats = { normal: [], diva: [], loca: [] };
// --- Normal masalar: ön bölüm, 3 sütun x 4 sıra, her masada 4 koltuk
const cols = [-5.6, 0, 5.6];
const rows = [-1.5, 2.6, 6.7, 10.8];
for (const z of rows) {
for (const x of cols) {
const top = box(1.5, 0.34, 1.5, mats.tableTop); // örtü kenarlardan sarkar
top.position.set(x, 0.62, z);
const leg = box(0.15, 0.75, 0.15, mats.leg);
leg.position.set(x, 0.375, z);
g.add(top, leg);
tableDecor(g, x, z, 0.79);
const off = 1.15;
for (const [dx, dz] of [[0, -off], [0, off], [-off, 0], [off, 0]]) {
const facing = Math.atan2(-dx, -dz);
const c = chair(mats.chair);
c.position.set(x + dx, 0, z + dz);
c.rotation.y = facing;
g.add(c);
seats.normal.push(seat('normal', x + dx * 0.9, z + dz * 0.9, facing));
}
}
}
// --- Divalar Masası: sağ arka, uzun beyaz-pembe masa, 8 koltuk
const len = DIVA.maxZ - DIVA.minZ;
const cz = (DIVA.minZ + DIVA.maxZ) / 2;
const dTop = box(1.6, 0.1, len - 0.6, mats.divaTop);
dTop.position.set(DIVA.x, 0.78, cz);
g.add(dTop);
for (const dz of [-len / 2 + 0.8, len / 2 - 0.8]) {
const l = box(0.2, 0.78, 0.2, mats.leg);
l.position.set(DIVA.x, 0.39, cz + dz);
g.add(l);
}
for (let i = 0; i < 4; i++) {
const z = DIVA.minZ + 1.2 + i * ((len - 2.4) / 3);
tableDecor(g, DIVA.x, z, 0.83);
for (const side of [-1, 1]) {
const x = DIVA.x + side * 1.15;
const facing = side < 0 ? Math.PI / 2 : -Math.PI / 2;
const c = chair(mats.divaChair);
c.position.set(x, 0, z);
c.rotation.y = facing;
g.add(c);
seats.diva.push(seat('diva', DIVA.x + side * 1.05, z, facing));
}
}
// --- Özel Loca: sol arka yükseltilmiş platform + U şeklinde koltuk, 6 kişilik
const lw = LOCA.maxX - LOCA.minX;
const ld = LOCA.maxZ - LOCA.minZ;
const lcx = (LOCA.minX + LOCA.maxX) / 2;
const lcz = (LOCA.minZ + LOCA.maxZ) / 2;
const plat = box(lw, LOCA.h, ld, new THREE.MeshStandardMaterial({ color: 0x2a0f3d, roughness: 0.5 }));
plat.position.set(lcx, LOCA.h / 2, lcz);
g.add(plat);
const rug = box(lw - 0.6, 0.02, ld - 0.6, new THREE.MeshStandardMaterial({ color: 0x8a1c5a, roughness: 0.9 }));
rug.position.set(lcx, LOCA.h + 0.01, lcz);
g.add(rug);
// koltuk: arka (duvar tarafı) ve sağ kol
const backSofa = box(lw - 1, 0.45, 0.8, mats.sofa);
backSofa.position.set(lcx, LOCA.h + 0.22, LOCA.minZ + 0.7);
const backRest = box(lw - 1, 0.6, 0.25, mats.sofa);
backRest.position.set(lcx, LOCA.h + 0.6, LOCA.minZ + 0.35);
g.add(backSofa, backRest);
const lt = box(1.6, 0.08, 1.0, mats.divaTop);
lt.position.set(lcx, LOCA.h + 0.55, lcz);
const ltl = box(0.2, 0.5, 0.2, mats.leg);
ltl.position.set(lcx, LOCA.h + 0.25, lcz);
g.add(lt, ltl);
tableDecor(g, lcx, lcz, LOCA.h + 0.59);
for (let i = 0; i < 4; i++) {
const x = LOCA.minX + 1.1 + i * ((lw - 2.2) / 3);
seats.loca.push(seat('loca', x, LOCA.minZ + 0.85, 0, 0.45));
}
// sağ ve sol pufa iki kişi
for (const side of [-1, 1]) {
const pouf = new THREE.Mesh(new THREE.CylinderGeometry(0.35, 0.35, 0.4, 12), mats.sofa);
const x = lcx + side * 1.4;
pouf.position.set(x, LOCA.h + 0.2, lcz + 1.3);
g.add(pouf);
seats.loca.push(seat('loca', x, lcz + 1.3, Math.PI, 0.42));
}
// altın kordon (loca önü)
const rope = new THREE.Mesh(
new THREE.CylinderGeometry(0.03, 0.03, lw, 6),
new THREE.MeshStandardMaterial({ color: 0xffcc33, metalness: 0.8, roughness: 0.3, emissive: 0x664400 }),
);
rope.rotation.z = Math.PI / 2;
rope.position.set(lcx, LOCA.h + 0.7, LOCA.maxZ - 0.1);
g.add(rope);
for (const x of [LOCA.minX + 0.15, LOCA.maxX - 0.15]) {
const post = new THREE.Mesh(new THREE.CylinderGeometry(0.06, 0.08, 0.75, 8), rope.material);
post.position.set(x, LOCA.h + 0.37, LOCA.maxZ - 0.1);
g.add(post);
}
// --- Dans noktaları: pist üzerinde ızgara
const danceSpots = [];
for (let iz = 0; iz < 5; iz++) {
for (let ix = 0; ix < 4; ix++) {
danceSpots.push({
zone: 'dans',
x: FLOOR.minX + 1 + ix * 2 + (iz % 2) * 0.5 - 0.25,
z: FLOOR.minZ + 0.9 + iz * 1.6,
facing: 0,
occupant: null,
});
}
}
return { seats, danceSpots };
}
/** Masa sıraları arasındaki en yakın boş koridorun z değeri. */
function gapZ(z) {
const g = Math.round((z - 0.55) / 4.1) * 4.1 + 0.55;
return Math.max(-3.55, Math.min(12.85, g));
}
/** Zemin yüksekliği (loca platformu yüksek). */
export function groundAt(x, z) {
if (x > STAGE.minX && x < STAGE.maxX && z > STAGE.minZ && z < STAGE.maxZ) return STAGE.h;
return x > LOCA.minX && x < LOCA.maxX && z > LOCA.minZ && z < LOCA.maxZ ? LOCA.h : 0;
}
/** Bir noktadan diğerine basit yol: koridorlar üzerinden gider ki masaların içinden geçmesin. */
export function routeBetween(from, to) {
const pts = [];
const aisleXs = [-2.8, 2.8, -8.4, 8.4];
const nearestAisle = (x) => aisleXs.reduce((a, b) => (Math.abs(b - x) < Math.abs(a - x) ? b : a));
const inTables = (p) => p.z > -3.2;
// Masalı bölgedeysek önce en yakın koridora çık
let cur = { x: from.x, z: from.z };
if (inTables(cur)) {
const ax = nearestAisle(cur.x);
const zRow = gapZ(cur.z);
pts.push({ x: cur.x, z: zRow });
pts.push({ x: ax, z: zRow });
cur = { x: ax, z: zRow };
}
if (inTables(to)) {
const ax = nearestAisle(to.x);
const zRow = gapZ(to.z);
pts.push({ x: ax, z: cur.z });
pts.push({ x: ax, z: zRow });
pts.push({ x: to.x, z: zRow });
} else {
// arka bölgeye: önce pist önündeki boşluğa çık
if (inTables(cur)) pts.push({ x: cur.x, z: -3.6 });
if (to.zone === 'loca') {
pts.push({ x: LOCA.maxX + 0.6, z: -3.6 > cur.z ? cur.z : -3.6 });
pts.push({ x: LOCA.maxX + 0.6, z: LOCA.maxZ + 0.6 });
pts.push({ x: (LOCA.minX + LOCA.maxX) / 2, z: LOCA.maxZ - 0.4 });
} else if (to.zone === 'sahne') {
// pistin kenarından sahnenin önüne, oradan mikrofona
pts.push({ x: 4.6, z: Math.min(cur.z, -3.6) });
pts.push({ x: 4.6, z: STAGE.maxZ + 0.5 });
pts.push({ x: to.x, z: STAGE.maxZ + 0.5 });
} else if (to.zone === 'diva') {
pts.push({ x: 5.1, z: Math.min(cur.z, -3.6) });
pts.push({ x: 5.1, z: to.z });
}
}
pts.push({ x: to.x, z: to.z });
return pts;
}
Lisans bilgisi projenin LICENSE dosyasında.