// Pist kostümü: iki katlı fırfırlı desenli etek (mor kenarlı), boncuklu bel kuşağı, çapraz yelek.
// Paneldeki butonla açılır; sadece dans pistindekiler giyer.
import * as THREE from 'three';
export const costumeOn = { value: false };
function canvasTex(w, h, draw, repeatX = 1) {
const c = document.createElement('canvas');
c.width = w;
c.height = h;
draw(c.getContext('2d'), w, h);
const t = new THREE.CanvasTexture(c);
t.colorSpace = THREE.SRGBColorSpace;
t.wrapS = THREE.RepeatWrapping;
t.repeat.x = repeatX;
return t;
}
// Yaprak / çiçek desenli kumaş
function fabric(base, leaf, flower) {
return canvasTex(256, 128, (x, w, h) => {
x.fillStyle = base;
x.fillRect(0, 0, w, h);
let seed = 7;
const r = () => ((seed = (seed * 16807) % 2147483647) / 2147483647);
for (let i = 0; i < 26; i++) {
x.save();
x.translate(r() * w, r() * h);
x.rotate(r() * Math.PI * 2);
x.fillStyle = leaf;
x.beginPath();
x.ellipse(0, 0, 22 + r() * 14, 6 + r() * 4, 0, 0, Math.PI * 2);
x.fill();
x.restore();
}
for (let i = 0; i < 10; i++) {
const cx = r() * w;
const cy = r() * h;
x.fillStyle = flower;
for (let k = 0; k < 5; k++) {
const a = (k / 5) * Math.PI * 2;
x.beginPath();
x.arc(cx + Math.cos(a) * 6, cy + Math.sin(a) * 6, 5, 0, Math.PI * 2);
x.fill();
}
x.fillStyle = '#ffd84a';
x.beginPath();
x.arc(cx, cy, 3.5, 0, Math.PI * 2);
x.fill();
}
// fırfır gölge çizgileri
x.fillStyle = 'rgba(0,0,0,0.12)';
for (let i = 0; i < w; i += 16) x.fillRect(i, 0, 3, h);
}, 2);
}
// Çapraz yelek: şeffaf zemin üstünde pembe-turuncu çapraz şeritler (önü açık, beyaz tişört görünür)
function vestTex() {
return canvasTex(256, 128, (x, w, h) => {
x.clearRect(0, 0, w, h);
const strip = (x1, y1, x2, y2) => {
x.lineCap = 'round';
x.strokeStyle = '#ff9a2e';
x.lineWidth = 30;
x.beginPath(); x.moveTo(x1, y1); x.lineTo(x2, y2); x.stroke();
x.strokeStyle = '#ff4fa3';
x.lineWidth = 20;
x.beginPath(); x.moveTo(x1, y1); x.lineTo(x2, y2); x.stroke();
};
// ön (u ≈ 0.25 civarı) çapraz X; arka tamamen kapalı
strip(20, 0, 110, h);
strip(110, 0, 20, h);
x.fillStyle = '#ff4fa3';
x.fillRect(128, 0, 128, h);
x.fillStyle = '#ff9a2e';
for (let i = 128; i < w; i += 24) x.fillRect(i, 0, 8, h);
});
}
let shared = null;
function getShared() {
if (shared) return shared;
const tier1 = new THREE.MeshStandardMaterial({ map: fabric('#f28a24', '#ff4fa3', '#ffffff'), roughness: 0.8, side: THREE.DoubleSide });
const tier2 = new THREE.MeshStandardMaterial({ map: fabric('#ec3f98', '#f7a23a', '#ffe1f0'), roughness: 0.8, side: THREE.DoubleSide });
const purple = new THREE.MeshStandardMaterial({ color: 0x4b2bb8, roughness: 0.6 });
const white = new THREE.MeshStandardMaterial({ color: 0xf6f2ea, roughness: 0.8 });
const bead = new THREE.MeshStandardMaterial({ color: 0xd8203a, roughness: 0.4 });
const vest = new THREE.MeshStandardMaterial({ map: vestTex(), transparent: true, alphaTest: 0.4, roughness: 0.7, side: THREE.DoubleSide });
shared = {
tier1, tier2, purple, white, bead, vest,
tier1Geo: new THREE.CylinderGeometry(0.21, 0.31, 0.27, 18, 1, true),
tier2Geo: new THREE.CylinderGeometry(0.28, 0.42, 0.3, 20, 1, true),
band1Geo: new THREE.CylinderGeometry(0.315, 0.315, 0.035, 18, 1, true),
band2Geo: new THREE.CylinderGeometry(0.425, 0.425, 0.04, 20, 1, true),
beltGeo: new THREE.CylinderGeometry(0.225, 0.235, 0.08, 16),
beadGeo: new THREE.SphereGeometry(0.022, 6, 4),
vestGeo: new THREE.CylinderGeometry(0.215, 0.215, 0.24, 16, 1, true),
};
return shared;
}
/** Bir karaktere takılacak kostüm grubu (hips grubuna eklenir). */
export function buildCostume() {
const s = getShared();
const g = new THREE.Group();
// etek: bel (y≈0.12) -> ayak bileği
const t1 = new THREE.Mesh(s.tier1Geo, s.tier1);
t1.position.y = 0.0;
const b1 = new THREE.Mesh(s.band1Geo, s.purple);
b1.position.y = -0.135;
const t2 = new THREE.Mesh(s.tier2Geo, s.tier2);
t2.position.y = -0.24;
const b2 = new THREE.Mesh(s.band2Geo, s.purple);
b2.position.y = -0.39;
// boncuklu beyaz kuşak + kırmızı püsküller
const belt = new THREE.Mesh(s.beltGeo, s.white);
belt.position.y = 0.13;
g.add(t1, b1, t2, b2, belt);
for (let i = 0; i < 14; i++) {
const a = (i / 14) * Math.PI * 2;
const bd = new THREE.Mesh(s.beadGeo, s.bead);
bd.position.set(Math.sin(a) * 0.24, 0.07 - (i % 2) * 0.025, Math.cos(a) * 0.24);
g.add(bd);
}
// yelek (gövdenin üst kısmı)
const vest = new THREE.Mesh(s.vestGeo, s.vest);
vest.position.y = 0.4;
vest.rotation.y = -Math.PI / 2; // deseni öne çevir
g.add(vest);
g.visible = false;
return g;
}
export const costumeShirt = () => getShared().white;
// ---------- Yöresel kostümler: halay (Doğu/Güneydoğu) ve horon (Karadeniz) ----------
// Halay/horon modunda pisttekiler, sahnedeki şarkıcı ve müzisyenler giyer.
function stripes(colors, vertical = false) {
return canvasTex(128, 64, (x, w, h) => {
const n = colors.length;
colors.forEach((c, i) => {
x.fillStyle = c;
if (vertical) x.fillRect((i * w) / n, 0, w / n + 1, h);
else x.fillRect(0, (i * h) / n, w, h / n + 1);
});
});
}
// Kadife yelek: koyu zemin, kenarlarda altın sırma
function velvetVest(base, trim) {
return canvasTex(256, 128, (x, w, h) => {
x.clearRect(0, 0, w, h);
// ön açık (u≈0.15-0.35 arası boş), gerisi kadife
x.fillStyle = base;
x.fillRect(90, 0, w - 90, h);
x.fillRect(0, 0, 38, h);
x.strokeStyle = trim;
x.lineWidth = 6;
for (const ex of [38, 90]) {
x.beginPath(); x.moveTo(ex, 0); x.lineTo(ex, h); x.stroke();
}
// sırma kıvrımları
x.lineWidth = 3;
for (let y = 14; y < h; y += 26) {
for (const cx of [20, 120, 180, 230]) {
x.beginPath();
x.arc(cx, y, 7, 0, Math.PI * 1.5);
x.stroke();
}
}
});
}
// Yazma / keşan: renkli zemin, küçük çiçekler
function scarfTex(base, dots) {
return canvasTex(128, 64, (x, w, h) => {
x.fillStyle = base;
x.fillRect(0, 0, w, h);
let seed = 3;
const r = () => ((seed = (seed * 16807) % 2147483647) / 2147483647);
for (let i = 0; i < 40; i++) {
x.fillStyle = dots[i % dots.length];
x.beginPath();
x.arc(r() * w, r() * h, 2.5 + r() * 2, 0, Math.PI * 2);
x.fill();
}
});
}
// Puşi: siyah-beyaz kareli
function pusiTex() {
return canvasTex(64, 64, (x, w, h) => {
x.fillStyle = '#f2f0ea';
x.fillRect(0, 0, w, h);
x.fillStyle = '#111';
for (let i = 0; i < w; i += 8) for (let j = 0; j < h; j += 8) if (((i + j) / 8) % 2 === 0) x.fillRect(i, j, 5, 5);
});
}
let folkShared = null;
function getFolk() {
if (folkShared) return folkShared;
const m = (o) => new THREE.MeshStandardMaterial({ roughness: 0.75, side: THREE.DoubleSide, ...o });
folkShared = {
// halay
halayShirt: m({ color: 0xc9bfae }), // sahne ışığında parlamasın diye kırık beyaz
halayVest: m({ map: velvetVest('#7a0f1f', '#e8c04a'), transparent: true, alphaTest: 0.4 }),
halayKusak: m({ map: stripes(['#c8102e', '#f2c230', '#1f7a3a', '#c8102e', '#f2c230']) }),
salvar: m({ color: 0x1c1c22, roughness: 0.9 }),
fistan: m({ map: fabric('#6b1a7a', '#2f9a4f', '#ffd84a') }),
yazma: m({ map: scarfTex('#d81e3c', ['#ffe14a', '#ffffff', '#2fae5a']) }),
oya: new THREE.MeshStandardMaterial({ color: 0xffd23a, roughness: 0.5 }),
pusi: m({ map: pusiTex() }),
// horon
horonBlack: m({ color: 0x15151a, roughness: 0.85 }),
horonShirtF: m({ color: 0xc9c2b4 }),
horonKusak: m({ map: stripes(['#d22a2a', '#1b3f9a', '#f0c419', '#d22a2a', '#1b3f9a'], true) }),
silver: new THREE.MeshStandardMaterial({ color: 0xd8dce4, metalness: 0.9, roughness: 0.25 }),
kesan: m({ map: scarfTex('#e8621a', ['#7a1027', '#ffd84a', '#1b3f9a']) }),
onluk: m({ map: stripes(['#b01a3a', '#f0c419', '#1f6a3a', '#b01a3a', '#ffffff', '#1b3f9a']) }),
skirtDark: m({ color: 0x1a1830 }),
// ortak geometriler (hips grubuna göre; kalça y=0)
vestGeo: new THREE.CylinderGeometry(0.2, 0.19, 0.27, 16, 1, true),
kusakGeo: new THREE.CylinderGeometry(0.205, 0.205, 0.1, 16, 1, true),
// şalvar: belden dizlere balon gibi şişip daralır
salvarGeo: new THREE.LatheGeometry(
[[0.12, -0.42], [0.2, -0.36], [0.26, -0.22], [0.27, -0.06], [0.24, 0.08], [0.2, 0.17]].map(([x, y]) => new THREE.Vector2(x, y)),
18,
),
longSkirtGeo: new THREE.CylinderGeometry(0.2, 0.36, 0.78, 18, 1, true),
onlukGeo: new THREE.PlaneGeometry(0.3, 0.52),
capGeo: new THREE.SphereGeometry(0.138, 16, 10, 0, Math.PI * 2, 0, Math.PI * 0.56),
flapGeo: new THREE.BoxGeometry(0.22, 0.2, 0.03),
beadGeo: new THREE.SphereGeometry(0.013, 6, 4),
pusiGeo: new THREE.TorusGeometry(0.07, 0.032, 8, 16),
fisekGeo: new THREE.BoxGeometry(0.016, 0.07, 0.016),
};
return folkShared;
}
/**
* Yöresel kostüm. kind: 'halay' | 'horon'.
* Döner: { hips: Group (kalçaya), head: Group (başa), shirt: gövde/kol malzemesi, legs: bacak malzemesi }
*/
export function buildFolkCostume(kind, fem) {
const s = getFolk();
const hips = new THREE.Group();
const head = new THREE.Group();
const add = (g, geo, mat, x, y, z) => {
const o = new THREE.Mesh(geo, mat);
o.position.set(x, y, z);
o.castShadow = true;
g.add(o);
return o;
};
const w = fem ? 0.92 : 1.08; // gövde genişliği
let shirt;
let legs;
if (kind === 'halay') {
shirt = s.halayShirt;
legs = fem ? s.salvar : s.salvar;
const vest = add(hips, s.vestGeo, s.halayVest, 0, 0.4, 0);
vest.scale.set(w, 1, 0.64);
vest.rotation.y = -Math.PI / 2;
add(hips, s.kusakGeo, s.halayKusak, 0, 0.13, 0).scale.set(w * 0.95, 1, 0.78);
if (fem) {
add(hips, s.longSkirtGeo, s.fistan, 0, -0.3, 0).scale.set(0.95, 1, 0.82);
// yazma + oyalı kenar
const cap = add(head, s.capGeo, s.yazma, 0, 0.012, -0.006);
cap.rotation.x = -0.32;
add(head, s.flapGeo, s.yazma, 0, -0.1, -0.09);
for (let i = 0; i < 12; i++) {
const a = -Math.PI * 0.62 + (i / 11) * Math.PI * 1.24;
add(head, s.beadGeo, s.oya, Math.sin(a) * 0.128, 0.05, Math.cos(a) * 0.12);
}
} else {
add(hips, s.salvarGeo, s.salvar, 0, -0.04, 0).scale.set(1, 1, 0.8);
const p = add(hips, s.pusiGeo, s.pusi, 0, 0.6, 0.01);
p.rotation.x = Math.PI / 2;
p.scale.set(1.1, 1, 0.9);
}
} else {
// horon: Karadeniz. Erkek: siyah zıpka + gümüş fişeklik; kadın: keşan, önlük, koyu etek
shirt = fem ? s.horonShirtF : s.horonBlack;
legs = s.horonBlack;
add(hips, s.kusakGeo, s.horonKusak, 0, 0.13, 0).scale.set(w * 0.95, 1.3, 0.78);
if (fem) {
const vest = add(hips, s.vestGeo, s.horonBlack, 0, 0.4, 0);
vest.scale.set(w, 1, 0.64);
add(hips, s.longSkirtGeo, s.skirtDark, 0, -0.3, 0).scale.set(0.95, 1, 0.82);
add(hips, s.onlukGeo, s.onluk, 0, -0.18, 0.2).rotation.x = -0.12;
const cap = add(head, s.capGeo, s.kesan, 0, 0.012, -0.006);
cap.rotation.x = -0.32;
add(head, s.flapGeo, s.kesan, 0, -0.1, -0.09);
} else {
// göğüste iki sıra gümüş fişek
for (const side of [-1, 1]) {
for (let i = 0; i < 5; i++) {
add(hips, s.fisekGeo, s.silver, side * (0.045 + i * 0.024), 0.42, 0.118 - i * 0.004).rotation.z = side * 0.12;
}
}
const cap = add(head, s.capGeo, s.horonBlack, 0, 0.02, -0.01);
cap.rotation.x = -0.25;
add(head, s.flapGeo, s.horonBlack, 0, -0.08, -0.095);
}
}
hips.visible = false;
head.visible = false;
return { hips, head, shirt, legs };
}
Lisans bilgisi projenin LICENSE dosyasında.