// Princess Sugarbell, Princess Mintly and the Royal Trophy (procedural models). import * as THREE from 'three'; import { furMaterial, furSphere, softMaterial } from '../render/fur'; import { starGeo } from '../cats/catModel'; export class Princess { root = new THREE.Group(); private arm = new THREE.Group(); private body = new THREE.Group(); private t = Math.random() * 5; cheer = 0; constructor(dress: string, dress2: string, hair: string) { this.root.add(this.body); for (let i = 0; i < 3; i++) { const tier = new THREE.Mesh(new THREE.ConeGeometry(0.75 - i * 0.17, 0.55, 18, 1, true), softMaterial(i % 2 ? dress2 : dress, 0.3)); tier.position.y = 0.3 + i * 0.32; this.body.add(tier); const ruffle = new THREE.Mesh(new THREE.TorusGeometry(0.72 - i * 0.17, 0.06, 6, 24), softMaterial('#ffffff', 0.2)); ruffle.rotation.x = Math.PI / 2; ruffle.position.y = 0.05 + i * 0.32; this.body.add(ruffle); } const torso = new THREE.Mesh(new THREE.SphereGeometry(0.24, 14, 10), softMaterial(dress, 0.3)); torso.scale.y = 1.2; torso.position.y = 1.12; this.body.add(torso); const head = new THREE.Group(); head.position.y = 1.62; this.body.add(head); head.add(new THREE.Mesh(new THREE.SphereGeometry(0.34, 22, 16), softMaterial('#ffe0cc', 0.1))); const hairM = furMaterial({ top: hair, bottom: hair, length: 0.12, density: 28 }); const back = new THREE.Mesh(furSphere(), hairM); back.scale.set(0.38, 0.38, 0.36); back.position.set(0, 0.06, -0.08); head.add(back); for (const sx of [-1, 1]) { const bun = new THREE.Mesh(furSphere(), hairM); bun.scale.setScalar(0.17); bun.position.set(sx * 0.34, 0.2, -0.05); head.add(bun); const eye = new THREE.Mesh(new THREE.SphereGeometry(0.055, 10, 8), softMaterial('#3a2340', 1.2)); eye.scale.set(0.85, 1.2, 0.5); eye.position.set(sx * 0.11, 0.0, 0.31); head.add(eye); const hl = new THREE.Mesh(new THREE.SphereGeometry(0.018, 6, 4), softMaterial('#ffffff', 0, 2)); hl.position.set(sx * 0.11 + 0.015, 0.03, 0.345); head.add(hl); const bl = new THREE.Mesh(new THREE.SphereGeometry(0.05, 8, 6), softMaterial('#ff9ec0', 0, 0.2)); bl.scale.set(1, 0.5, 0.3); bl.position.set(sx * 0.19, -0.09, 0.28); head.add(bl); } const smile = new THREE.Mesh(new THREE.TorusGeometry(0.06, 0.014, 6, 12, Math.PI), softMaterial('#9a3d5c')); smile.rotation.z = Math.PI; smile.position.set(0, -0.1, 0.32); head.add(smile); const crown = new THREE.Group(); crown.position.y = 0.36; head.add(crown); crown.add(new THREE.Mesh(new THREE.CylinderGeometry(0.16, 0.18, 0.1, 14, 1, true), softMaterial('#ffd34d', 1.4, 0.25))); for (let i = 0; i < 5; i++) { const a = i / 5 * Math.PI * 2; const sp = new THREE.Mesh(new THREE.SphereGeometry(0.04, 6, 4), softMaterial('#ff6fa8', 1.5, 0.3)); sp.position.set(Math.cos(a) * 0.17, 0.08, Math.sin(a) * 0.17); crown.add(sp); } this.arm.position.set(0.25, 1.2, 0); this.body.add(this.arm); const a = new THREE.Mesh(new THREE.CapsuleGeometry(0.06, 0.3, 4, 8), softMaterial('#ffe0cc')); a.position.y = 0.18; this.arm.add(a); const wand = new THREE.Mesh(new THREE.CylinderGeometry(0.02, 0.02, 0.5, 6), softMaterial('#ffffff', 1)); wand.position.y = 0.5; this.arm.add(wand); const star = new THREE.Mesh(starGeo(), softMaterial('#ffe066', 1, 0.6)); star.scale.setScalar(0.14); star.position.y = 0.8; this.arm.add(star); const la = new THREE.Mesh(new THREE.CapsuleGeometry(0.06, 0.3, 4, 8), softMaterial('#ffe0cc')); la.position.set(-0.27, 1.05, 0); la.rotation.z = 0.5; this.body.add(la); } update(dt: number, lookAt?: THREE.Vector3) { this.t += dt; this.cheer = Math.max(0, this.cheer - dt); const c = this.cheer > 0 ? 1 : 0; this.body.position.y = Math.abs(Math.sin(this.t * (c ? 9 : 2))) * (c ? 0.35 : 0.06); this.arm.rotation.z = -0.5 - Math.sin(this.t * (c ? 14 : 3)) * (c ? 0.6 : 0.35); if (lookAt) { const a = Math.atan2(lookAt.x - this.root.position.x, lookAt.z - this.root.position.z); this.root.rotation.y += ((a - this.root.rotation.y + Math.PI * 3) % (Math.PI * 2) - Math.PI) * Math.min(1, dt * 4); } } } export function makeTrophy(): THREE.Group { const g = new THREE.Group(); const gold = softMaterial('#ffcf3f', 1.6, 0.25); const base = new THREE.Mesh(new THREE.CylinderGeometry(0.7, 0.8, 0.4, 20), softMaterial('#b07dff', 0.8)); base.position.y = 0.2; g.add(base); const stem = new THREE.Mesh(new THREE.CylinderGeometry(0.15, 0.3, 0.7, 16), gold); stem.position.y = 0.75; g.add(stem); const cup = new THREE.Mesh(new THREE.SphereGeometry(0.75, 24, 16, 0, Math.PI * 2, 0, Math.PI * 0.55), gold); cup.rotation.x = Math.PI; cup.position.y = 1.75; g.add(cup); const lip = new THREE.Mesh(new THREE.TorusGeometry(0.72, 0.08, 8, 28), gold); lip.rotation.x = Math.PI / 2; lip.position.y = 1.78; g.add(lip); for (const sx of [-1, 1]) { const h = new THREE.Mesh(new THREE.TorusGeometry(0.3, 0.07, 8, 16, Math.PI * 1.2), gold); h.position.set(sx * 0.75, 1.45, 0); h.rotation.z = sx > 0 ? -0.9 : Math.PI + 0.9; g.add(h); } // cat ears on the trophy! for (const sx of [-1, 1]) { const e = new THREE.Mesh(new THREE.ConeGeometry(0.2, 0.4, 4), gold); e.position.set(sx * 0.45, 2.0, 0); e.rotation.z = -sx * 0.3; g.add(e); } const star = new THREE.Mesh(starGeo(), softMaterial('#fff5a8', 1, 0.8)); star.scale.setScalar(0.32); star.position.set(0, 1.3, 0.62); g.add(star); return g; }