// Wardrobe: hoodie colours and hats bought with candy. Cosmetic only, always earned by playing. import * as THREE from 'three'; import { softMaterial } from '../render/fur'; import { starGeo } from '../cats/catModel'; export interface Hood { id: string; name: string; emoji: string; price: number; top: string; bottom: string } export interface Hat { id: string; name: string; emoji: string; price: number } export const HOODS: Hood[] = [ { id: 'lilac', name: 'Lilac hoodie', emoji: '๐Ÿ’œ', price: 0, top: '#b58cff', bottom: '#e6d8ff' }, { id: 'pink', name: 'Bubblegum hoodie', emoji: '๐Ÿฉท', price: 10, top: '#ff7fb8', bottom: '#ffd3e7' }, { id: 'mint', name: 'Mint hoodie', emoji: '๐Ÿ’š', price: 10, top: '#5fd6aa', bottom: '#cdf5e5' }, { id: 'sky', name: 'Sky hoodie', emoji: '๐Ÿ’™', price: 10, top: '#6fb4ff', bottom: '#d3e8ff' }, { id: 'orange', name: 'Orange cat hoodie', emoji: '๐Ÿงก', price: 20, top: '#ff8a1f', bottom: '#ffd6a8' }, ]; export const HATS: Hat[] = [ { id: 'none', name: 'No hat', emoji: '๐Ÿ™‚', price: 0 }, { id: 'bow', name: 'Big bow', emoji: '๐ŸŽ€', price: 10 }, { id: 'flowers', name: 'Flower crown', emoji: '๐ŸŒธ', price: 15 }, { id: 'party', name: 'Party hat', emoji: '๐Ÿฅณ', price: 15 }, { id: 'tiara', name: 'Princess tiara', emoji: '๐Ÿ‘ธ', price: 25 }, { id: 'wizard', name: 'Star wizard hat', emoji: '๐Ÿง™', price: 30 }, ]; export function makeHat(id: string): THREE.Group | null { const g = new THREE.Group(); const M = (geo: THREE.BufferGeometry, c: string, gloss = 0.4, em = 0) => new THREE.Mesh(geo, softMaterial(c, gloss, em)); if (id === 'bow') { for (const sx of [-1, 1]) { const w = M(new THREE.SphereGeometry(0.13, 12, 8), '#ff5c9d'); w.scale.set(1.2, 0.8, 0.5); w.position.set(sx * 0.13, 0.02, 0.02); w.rotation.z = sx * 0.4; g.add(w); } const k = M(new THREE.SphereGeometry(0.06, 10, 8), '#ff8fbf'); k.position.z = 0.05; g.add(k); g.position.set(0.12, 0.02, 0.05); g.rotation.z = -0.3; } else if (id === 'flowers') { const cols = ['#ff8fbf', '#ffe066', '#ffffff', '#b79bff', '#8fd3ff']; for (let i = 0; i < 9; i++) { const a = i / 9 * Math.PI * 2; const f = M(new THREE.IcosahedronGeometry(0.075, 1), cols[i % 5], 0.3); f.position.set(Math.cos(a) * 0.3, -0.06, Math.sin(a) * 0.3); g.add(f); } const band = M(new THREE.TorusGeometry(0.3, 0.025, 6, 24), '#8fe39b'); band.rotation.x = Math.PI / 2; band.position.y = -0.06; g.add(band); } else if (id === 'party') { const cone = M(new THREE.ConeGeometry(0.16, 0.42, 16), '#7cc8ff', 0.6); cone.position.y = 0.2; g.add(cone); for (let i = 0; i < 3; i++) { const d = M(new THREE.SphereGeometry(0.035, 8, 6), ['#ffe066', '#ff7fb0', '#ffffff'][i]); d.position.set(Math.sin(i * 2.1) * 0.1, 0.1 + i * 0.09, Math.cos(i * 2.1) * 0.1); g.add(d); } const pom = M(new THREE.SphereGeometry(0.07, 10, 8), '#ffffff'); pom.position.y = 0.43; g.add(pom); g.rotation.z = 0.15; } else if (id === 'tiara') { const gold = '#ffd34d'; const band = M(new THREE.TorusGeometry(0.24, 0.03, 6, 24, Math.PI), gold, 1.2, 0.2); band.rotation.y = 0; band.position.set(0, -0.02, 0.06); band.rotation.x = -0.2; g.add(band); for (let i = -2; i <= 2; i++) { const p = M(new THREE.ConeGeometry(0.035, 0.12 - Math.abs(i) * 0.02, 6), gold, 1.2, 0.2); const a = Math.PI / 2 + i * 0.45; p.position.set(Math.cos(a) * 0.24, 0.05, Math.sin(a) * 0.24 * 0.4 + 0.12); g.add(p); } const gem = M(new THREE.OctahedronGeometry(0.05), '#ff7fb0', 1, 0.6); gem.position.set(0, 0.05, 0.25); g.add(gem); } else if (id === 'wizard') { const cone = M(new THREE.ConeGeometry(0.26, 0.6, 18), '#9d7bff', 0.4); cone.position.y = 0.28; cone.rotation.z = 0.2; g.add(cone); const brim = M(new THREE.CylinderGeometry(0.4, 0.4, 0.04, 24), '#9d7bff'); g.add(brim); for (let i = 0; i < 3; i++) { const st = new THREE.Mesh(starGeo(), softMaterial('#fff5a8', 1, 0.8)); st.scale.setScalar(0.07); st.position.set(Math.sin(i * 2) * 0.17, 0.15 + i * 0.12, Math.cos(i * 2) * 0.17); g.add(st); } } else return null; return g; } /** Dress a player in the saved outfit. */ export function applyOutfit(p: { setHood(top: string, bottom?: string): void; setHat(h: THREE.Object3D | null): void }, outfit: { hood: string; hat: string }) { const h = HOODS.find(k => k.id === outfit.hood) ?? HOODS[0]; p.setHood(h.top, h.bottom); p.setHat(makeHat(outfit.hat)); }