// Mekan: zemin, duvarlar, sahne, dans pisti (müzikle yanan karolar), disko topu, neon yazılar, ışık hüzmeleri.
import * as THREE from 'three';
import { ROOM, FLOOR, LOCA, DIVA } from './tables.js';
/** Kanvasla neon yazı tabelası. */
export function neonSign(text, color, { width = 6, height = 1.2, font = 'bold 120px "Arial Black", Arial, sans-serif' } = {}) {
const c = document.createElement('canvas');
c.width = 1024;
c.height = Math.round(1024 * (height / width));
const ctx = c.getContext('2d');
ctx.font = font;
let size = parseInt(font.match(/(\d+)px/)[1], 10);
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
while (ctx.measureText(text).width > c.width * 0.9 && size > 20) {
size -= 4;
ctx.font = font.replace(/\d+px/, size + 'px');
}
for (const blur of [40, 20, 8]) {
ctx.shadowColor = color;
ctx.shadowBlur = blur;
ctx.fillStyle = color;
ctx.fillText(text, c.width / 2, c.height / 2);
}
ctx.shadowBlur = 0;
ctx.fillStyle = '#ffffff';
ctx.globalAlpha = 0.85;
ctx.fillText(text, c.width / 2, c.height / 2);
const tex = new THREE.CanvasTexture(c);
tex.colorSpace = THREE.SRGBColorSpace;
tex.anisotropy = 4;
const m = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({ map: tex, transparent: true, depthWrite: false, toneMapped: false }),
);
return m;
}
export function buildVenue(scene) {
const W = ROOM.maxX - ROOM.minX;
const D = ROOM.maxZ - ROOM.minZ;
const cx = (ROOM.minX + ROOM.maxX) / 2;
const cz = (ROOM.minZ + ROOM.maxZ) / 2;
// --- Zemin (koyu bordo halı)
const floorTex = (() => {
const c = document.createElement('canvas');
c.width = c.height = 256;
const x = c.getContext('2d');
// koyu cilalı ceviz parke
x.fillStyle = '#1e0e0a';
x.fillRect(0, 0, 256, 256);
for (let r = 0; r < 8; r++) {
const off = (r % 2) * 64;
for (let k = -1; k < 3; k++) {
const l = 18 + Math.random() * 14;
x.fillStyle = `rgb(${l + 14},${l * 0.55},${l * 0.4})`;
x.fillRect(k * 128 + off + 1, r * 32 + 1, 126, 30);
x.strokeStyle = 'rgba(0,0,0,0.25)';
for (let g = 0; g < 4; g++) {
x.beginPath();
x.moveTo(k * 128 + off, r * 32 + 6 + g * 6 + Math.random() * 3);
x.lineTo(k * 128 + off + 128, r * 32 + 6 + g * 6 + Math.random() * 3);
x.stroke();
}
}
}
const t = new THREE.CanvasTexture(c);
t.wrapS = t.wrapT = THREE.RepeatWrapping;
t.repeat.set(W / 4, D / 4);
t.colorSpace = THREE.SRGBColorSpace;
return t;
})();
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(W + 4, D + 6),
new THREE.MeshStandardMaterial({ map: floorTex, roughness: 0.32, metalness: 0.15 }),
);
floor.rotation.x = -Math.PI / 2;
floor.position.set(cx, 0, cz + 1);
scene.add(floor);
// --- Duvarlar: arka + yanlar
const wallMat = new THREE.MeshStandardMaterial({ color: 0x4a0a1e, roughness: 0.95 });
const wallH = 4.5;
const back = new THREE.Mesh(new THREE.BoxGeometry(W + 0.6, wallH, 0.3), wallMat);
back.position.set(cx, wallH / 2, ROOM.minZ - 0.15);
const left = new THREE.Mesh(new THREE.BoxGeometry(0.3, wallH, D + 2), wallMat);
left.position.set(ROOM.minX - 0.15, wallH / 2, cz - 1);
const right = left.clone();
right.position.x = ROOM.maxX + 0.15;
scene.add(back, left, right);
// duvar süsleri: altın çerçeveli tablolar + neon şerit
const frameMat = new THREE.MeshStandardMaterial({ color: 0xd4a017, metalness: 0.7, roughness: 0.3 });
const artMats = [0x20103a, 0x0c2a3a, 0x3a0c1e].map((c) => new THREE.MeshStandardMaterial({ color: c, emissive: c, emissiveIntensity: 0.5 }));
for (let i = 0; i < 5; i++) {
const z = -2 + i * 3.6;
for (const side of [-1, 1]) {
const fr = new THREE.Mesh(new THREE.BoxGeometry(0.06, 1.2, 0.9), frameMat);
fr.position.set(side * (ROOM.maxX - 0.02), 2.4, z);
const art = new THREE.Mesh(new THREE.BoxGeometry(0.07, 0.95, 0.68), artMats[i % 3]);
art.position.copy(fr.position);
scene.add(fr, art);
}
}
const stripMat = new THREE.MeshBasicMaterial({ color: 0xff3dbb, toneMapped: false });
const strip = new THREE.Mesh(new THREE.BoxGeometry(W, 0.06, 0.06), stripMat);
strip.position.set(cx, wallH - 0.1, ROOM.minZ + 0.05);
scene.add(strip);
for (const side of [-1, 1]) {
const s = new THREE.Mesh(new THREE.BoxGeometry(0.06, 0.06, D), stripMat);
s.position.set(side * (ROOM.maxX - 0.05), wallH - 0.1, cz);
scene.add(s);
}
// --- Sahne (arka orta) + perde
const stage = new THREE.Mesh(
new THREE.BoxGeometry(7, 0.5, 3.2),
new THREE.MeshStandardMaterial({ color: 0x1a0a22, roughness: 0.4 }),
);
stage.position.set(0, 0.25, ROOM.minZ + 1.6);
scene.add(stage);
const edge = new THREE.Mesh(new THREE.BoxGeometry(7.05, 0.06, 0.06), new THREE.MeshBasicMaterial({ color: 0xffd24a, toneMapped: false }));
edge.position.set(0, 0.5, ROOM.minZ + 3.2);
scene.add(edge);
const curtainMat = new THREE.MeshStandardMaterial({ color: 0x6e0a1f, roughness: 0.8 });
for (let i = 0; i < 14; i++) {
const f = new THREE.Mesh(new THREE.CylinderGeometry(0.28, 0.28, 3.8, 8, 1, false, 0, Math.PI), curtainMat);
f.position.set(-3.25 + i * 0.5, 2.4, ROOM.minZ + 0.25);
f.rotation.y = Math.PI;
scene.add(f);
}
// sahnede saz ve mikrofon (dekor)
const mic = new THREE.Mesh(new THREE.CylinderGeometry(0.02, 0.02, 1.3, 6), new THREE.MeshStandardMaterial({ color: 0x999999, metalness: 0.9 }));
mic.position.set(0, 1.15, ROOM.minZ + 2.4);
const micHead = new THREE.Mesh(new THREE.SphereGeometry(0.07, 8, 6), new THREE.MeshStandardMaterial({ color: 0x333333, metalness: 0.6 }));
micHead.position.set(0, 1.82, ROOM.minZ + 2.4);
scene.add(mic, micHead);
const saz = new THREE.Group();
const bowl = new THREE.Mesh(new THREE.SphereGeometry(0.28, 10, 8), new THREE.MeshStandardMaterial({ color: 0x8b4a1c, roughness: 0.4 }));
bowl.scale.set(1, 1.25, 0.7);
const neck = new THREE.Mesh(new THREE.BoxGeometry(0.07, 1.3, 0.05), new THREE.MeshStandardMaterial({ color: 0x5a2e0e }));
neck.position.y = 0.9;
saz.add(bowl, neck);
saz.position.set(-1.8, 0.9, ROOM.minZ + 1.5);
saz.rotation.z = 0.3;
scene.add(saz);
// --- Dans pisti: müzikle yanan karolar (InstancedMesh)
const nx = FLOOR.maxX - FLOOR.minX;
const nz = FLOOR.maxZ - FLOOR.minZ;
const tiles = new THREE.InstancedMesh(
new THREE.BoxGeometry(0.96, 0.06, 0.96),
new THREE.MeshBasicMaterial({ toneMapped: false }),
nx * nz,
);
const m4 = new THREE.Matrix4();
const tileInfo = [];
let k = 0;
for (let iz = 0; iz < nz; iz++) {
for (let ix = 0; ix < nx; ix++) {
m4.makeTranslation(FLOOR.minX + ix + 0.5, 0.03, FLOOR.minZ + iz + 0.5);
tiles.setMatrixAt(k, m4);
tileInfo.push({ checker: (ix + iz) % 2, glow: 0, hue: Math.random() });
tiles.setColorAt(k, new THREE.Color(0x000000));
k++;
}
}
scene.add(tiles);
// --- Disko topu
const ball = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.6, 2),
new THREE.MeshStandardMaterial({ color: 0xffffff, metalness: 1, roughness: 0.15, flatShading: true, emissive: 0x333344 }),
);
ball.position.set(0, 5.5, (FLOOR.minZ + FLOOR.maxZ) / 2);
const wire = new THREE.Mesh(new THREE.CylinderGeometry(0.01, 0.01, 3, 4), new THREE.MeshBasicMaterial({ color: 0x888888 }));
wire.position.set(0, 7.3, ball.position.z);
scene.add(ball, wire);
// --- Neon tabelalar
const divaSign = neonSign('DİVALAR MASASI', '#ff3dbb', { width: 4.6, height: 0.95 });
divaSign.position.set(DIVA.x - 0.2, 0.9, DIVA.maxZ + 1.0);
divaSign.rotation.x = -1.0;
scene.add(divaSign);
const locaSign = neonSign('ÖZEL LOCA', '#ffcc33', { width: 3.6, height: 0.9 });
locaSign.position.set((LOCA.minX + LOCA.maxX) / 2, 1.5, LOCA.maxZ + 0.35);
locaSign.rotation.x = -0.7;
scene.add(locaSign);
const pistSign = neonSign('DANS PİSTİ', '#3de8ff', { width: 3.4, height: 0.8 });
pistSign.position.set(0, 0.07, FLOOR.maxZ + 0.6);
pistSign.rotation.x = -Math.PI / 2;
scene.add(pistSign);
const nameSign = neonSign('GECE KULÜBÜ', '#b46bff', { width: 5, height: 1 });
nameSign.position.set(0, 3.95, ROOM.minZ + 0.2);
scene.add(nameSign);
// --- Işıklar
scene.add(new THREE.HemisphereLight(0xff9ac8, 0x1a0510, 0.45));
const key = new THREE.DirectionalLight(0xffd6c0, 1.1);
key.position.set(5, 16, 9);
key.castShadow = true;
const qs = new URLSearchParams(location.search);
const lite = qs.has('lite') || (/Android|iPhone|iPad|Mobile/i.test(navigator.userAgent) && !qs.has('hq'));
key.shadow.mapSize.set(lite ? 1024 : 2048, lite ? 1024 : 2048);
key.shadow.camera.left = -13;
key.shadow.camera.right = 13;
key.shadow.camera.top = 18;
key.shadow.camera.bottom = -18;
key.shadow.camera.far = 50;
key.shadow.bias = -0.0005;
key.shadow.normalBias = 0.02;
scene.add(key);
// sahneye sıcak spot
const stageSpot = new THREE.SpotLight(0xffc890, 60, 18, 0.5, 0.6, 1.5);
stageSpot.position.set(0, 8, ROOM.minZ + 7);
stageSpot.target.position.set(0, 0.5, ROOM.minZ + 1.8);
scene.add(stageSpot, stageSpot.target);
// duvar aplikleri: sıcak, loş
const sconceMat = new THREE.MeshBasicMaterial({ color: 0xffb060, toneMapped: false });
const sconceGeo = new THREE.SphereGeometry(0.09, 10, 8);
for (let i = 0; i < 6; i++) {
const z = -4 + i * 3.6;
for (const side of [-1, 1]) {
const sc = new THREE.Mesh(sconceGeo, sconceMat);
sc.position.set(side * (ROOM.maxX - 0.12), 3.1, z + 1.8);
scene.add(sc);
}
}
for (const side of [-1, 1]) {
const wl = new THREE.PointLight(0xff9a50, 4, 9, 1.8);
wl.position.set(side * (ROOM.maxX - 0.6), 3, 4);
scene.add(wl);
}
const floorLights = [0xff3dbb, 0x3de8ff, 0xb46bff].map((c, i) => {
const l = new THREE.PointLight(c, 18, 12, 1.6);
l.position.set(-3 + i * 3, 3.5, (FLOOR.minZ + FLOOR.maxZ) / 2);
scene.add(l);
return l;
});
const divaLight = new THREE.PointLight(0xff4fb8, 14, 10, 1.6);
divaLight.position.set(DIVA.x, 3, (DIVA.minZ + DIVA.maxZ) / 2);
const locaLight = new THREE.PointLight(0xffc040, 12, 9, 1.6);
locaLight.position.set((LOCA.minX + LOCA.maxX) / 2, 3, (LOCA.minZ + LOCA.maxZ) / 2);
scene.add(divaLight, locaLight);
// ışık hüzmeleri (sahte, saydam koniler)
const beams = [];
const beamColors = [0xff3dbb, 0x3de8ff, 0xffd24a, 0xb46bff];
for (let i = 0; i < 4; i++) {
const h = 8;
const geom = new THREE.ConeGeometry(1.3, h, 20, 1, true);
geom.translate(0, -h / 2, 0);
const beam = new THREE.Mesh(geom, new THREE.MeshBasicMaterial({
color: beamColors[i], transparent: true, opacity: 0.12, blending: THREE.AdditiveBlending,
depthWrite: false, side: THREE.DoubleSide, toneMapped: false,
}));
const pivot = new THREE.Group();
pivot.position.set(i < 2 ? -8 + i * 3 : 5 + (i - 2) * 3, 6.5, ROOM.minZ + 1);
pivot.add(beam);
scene.add(pivot);
beams.push({ pivot, beam, phase: i * 1.7 });
}
// tavandan dökülen renkli kâğıt süsler (sabit dekor)
const decoGeo = new THREE.PlaneGeometry(0.12, 0.12);
const deco = new THREE.InstancedMesh(decoGeo, new THREE.MeshBasicMaterial({ side: THREE.DoubleSide, toneMapped: false }), 160);
const palette = [0xff3dbb, 0x3de8ff, 0xffd24a, 0x2ee59d, 0xb46bff, 0xffffff].map((c) => new THREE.Color(c));
const dm = new THREE.Matrix4();
const q = new THREE.Quaternion();
for (let i = 0; i < 160; i++) {
q.setFromEuler(new THREE.Euler(Math.random() * 3, Math.random() * 3, 0));
dm.compose(
new THREE.Vector3(ROOM.minX + Math.random() * W, 3.4 + Math.random() * 1, ROOM.minZ + 0.2 + Math.random() * 0.3),
q, new THREE.Vector3(1, 1, 1),
);
deco.setMatrixAt(i, dm);
deco.setColorAt(i, palette[i % palette.length]);
}
scene.add(deco);
const col = new THREE.Color();
let partyTime = 0;
let lastBeatCount = -1;
return {
/** Parti modu (beğeni hedefi): ışıklar çılgına döner. */
party(seconds = 8) {
partyTime = Math.max(partyTime, seconds);
},
update(dt, beat, t) {
partyTime = Math.max(0, partyTime - dt);
const party = partyTime > 0 ? 1 : 0;
const beatIdx = Math.floor(beat.phase);
const newBeat = beatIdx !== lastBeatCount;
lastBeatCount = beatIdx;
// karolar
for (let i = 0; i < tileInfo.length; i++) {
const ti = tileInfo[i];
if (newBeat && Math.random() < 0.25 + party * 0.4) {
ti.glow = 1;
ti.hue = Math.random();
}
ti.glow = Math.max(0, ti.glow - dt * 1.6);
const base = ti.checker ? 0.18 : 0.1;
const l = base + ti.glow * 0.45 + beat.pulse * 0.08;
const h = ti.glow > 0 ? ti.hue : (ti.checker ? 0.83 : 0.75);
col.setHSL(h, 0.9, l);
tiles.setColorAt(i, col);
}
tiles.instanceColor.needsUpdate = true;
ball.rotation.y += dt * (0.6 + party * 2);
floorLights.forEach((l, i) => {
l.intensity = 10 + beat.pulse * 22 + party * 15 * (0.5 + 0.5 * Math.sin(t * 9 + i * 2));
});
divaLight.intensity = 12 + Math.sin(t * 2) * 3;
beams.forEach((b, i) => {
const speed = 0.6 + party * 2.2;
b.pivot.rotation.z = Math.sin(t * speed + b.phase) * 0.55;
b.pivot.rotation.x = 0.45 + Math.cos(t * speed * 0.8 + b.phase) * 0.3;
b.beam.material.opacity = 0.08 + beat.pulse * 0.1 + party * 0.12 * (i % 2 ? Math.sin(t * 14) * 0.5 + 0.5 : 1);
});
stripMat.color.setHSL((t * 0.05 + party * t * 0.3) % 1, 1, 0.6);
},
};
}
Lisans bilgisi projenin LICENSE dosyasında.