{ const $=id=>document.getElementById(id); if(!window.THREE){$('fail').style.display='grid';throw new Error('three.js did not load')} const V3=THREE.Vector3,Q=THREE.Quaternion,Y=new V3(0,1,0),PI=Math.PI; const clamp=(v,a,b)=>Math.max(a,Math.min(b,v)),lerp=(a,b,t)=>a+(b-a)*t; const C=h=>new THREE.Color(h).convertSRGBToLinear(); const still=matchMedia('(prefers-reduced-motion:reduce)').matches; /* ---------- renderer, scene, light ---------- */ const cv=$('c'); let renderer; try{renderer=new THREE.WebGLRenderer({canvas:cv,antialias:true,powerPreference:'high-performance'})}catch(e){$('fail').style.display='grid';throw e} renderer.setPixelRatio(Math.min(devicePixelRatio||1,2)); renderer.outputEncoding=THREE.sRGBEncoding;renderer.toneMapping=THREE.ACESFilmicToneMapping;renderer.toneMappingExposure=1; renderer.shadowMap.enabled=true;renderer.shadowMap.type=THREE.PCFSoftShadowMap; const scene=new THREE.Scene(),BG=C(0x170d08);scene.background=BG;scene.fog=new THREE.Fog(BG,15,34); const camera=new THREE.PerspectiveCamera(36,1,.1,80); {const pm=new THREE.PMREMGenerator(renderer),es=new THREE.Scene(); es.add(new THREE.Mesh(new THREE.SphereGeometry(30,16,8),new THREE.MeshBasicMaterial({color:C(0x4a2c18),side:THREE.BackSide}))); const pan=(c,k,w,h,p)=>{const m=new THREE.Mesh(new THREE.PlaneGeometry(w,h),new THREE.MeshBasicMaterial({color:C(c).multiplyScalar(k),side:THREE.DoubleSide}));m.position.set(p[0],p[1],p[2]);m.lookAt(0,0,0);es.add(m)}; pan(0xffe2b8,7,12,12,[0,14,3]);pan(0xffc890,4,7,9,[-13,6,5]);pan(0xfff0dc,1.3,7,7,[11,5,-9]);pan(0xffb070,2,5,5,[9,3,10]); scene.environment=pm.fromScene(es,.03).texture;pm.dispose()} const key=new THREE.DirectionalLight(C(0xffe0b0),1.9);key.position.set(-5,10,6);key.castShadow=true; key.shadow.mapSize.set(2048,2048);Object.assign(key.shadow.camera,{left:-7,right:7,top:8,bottom:-8,near:1,far:30});key.shadow.bias=-.0004;key.shadow.normalBias=.02;key.shadow.radius=4; scene.add(key,new THREE.HemisphereLight(C(0xffd9b0),C(0x2a1408),.5)); const rim=new THREE.DirectionalLight(C(0xa9c0ff),.7);rim.position.set(5,5,-8);scene.add(rim); /* ---------- textures ---------- */ const R=(a=1,b)=>b===undefined?Math.random()*a:a+Math.random()*(b-a); function tex(w,h,draw,srgb=true){const c=document.createElement('canvas');c.width=w;c.height=h;draw(c.getContext('2d'),w,h);const t=new THREE.CanvasTexture(c);if(srgb)t.encoding=THREE.sRGBEncoding;t.wrapS=t.wrapT=THREE.RepeatWrapping;t.anisotropy=8;return t} const skinTex=tex(512,512,(g,w,h)=>{g.fillStyle='#ececec';g.fillRect(0,0,w,h); for(let i=0;i<900;i++){const v=R(120,255)|0,r=R(5,30),x=R(w),y=R(h),gr=g.createRadialGradient(x,y,0,x,y,r);gr.addColorStop(0,`rgba(${v},${v*.92|0},${v*.85|0},${R(.1,.28)})`);gr.addColorStop(1,'rgba(0,0,0,0)');g.fillStyle=gr;g.fillRect(x-r,y-r,r*2,r*2)} for(let i=0;i<2600;i++){g.fillStyle=R()<.35?`rgba(40,60,20,${R(.25,.6)})`:`rgba(30,14,6,${R(.2,.55)})`;g.beginPath();g.ellipse(R(w),R(h),R(.5,1.7),R(.5,1.2),R(3),0,7);g.fill()}}); const bumpTex=tex(512,512,(g,w,h)=>{g.fillStyle='#808080';g.fillRect(0,0,w,h); for(let i=0;i<5200;i++){const x=R(w),y=R(h),r=R(1.5,4.5),gr=g.createRadialGradient(x,y,0,x,y,r);gr.addColorStop(0,'rgba(255,255,255,.55)');gr.addColorStop(1,'rgba(255,255,255,0)');g.fillStyle=gr;g.fillRect(x-r,y-r,r*2,r*2)} for(let i=0;i<60;i++){g.strokeStyle='rgba(0,0,0,.25)';g.lineWidth=R(1,3);g.beginPath();const x=R(w),y=R(h);g.moveTo(x,y);g.quadraticCurveTo(x+R(-40,40),y+R(-40,40),x+R(-70,70),y+R(-70,70));g.stroke()}},false); skinTex.repeat.set(2,2);bumpTex.repeat.set(2,2); const grainTex=tex(256,256,(g,w,h)=>{g.fillStyle='#fff';g.fillRect(0,0,w,h);for(let i=0;i<420;i++){g.strokeStyle=`rgba(${R(150,205)|0},${R(110,150)|0},${R(80,115)|0},${R(.1,.3)})`;g.lineWidth=R(.6,1.8);const y=R(h),x=R(w);g.beginPath();g.moveTo(x,y);g.bezierCurveTo(x+25,y+R(-5,5),x+55,y+R(-7,7),x+R(60,110),y+R(-9,9));g.stroke()}}); grainTex.repeat.set(2.2,2.6); const wood=(base,a,b,n,groove)=>tex(1024,1024,(g,w,h)=>{g.fillStyle=base;g.fillRect(0,0,w,h); for(let i=0;i{const h=Math.sin(x*127.1+y*311.7+z*74.7)*43758.5453;return h-Math.floor(h)}; function vn(x,y,z){const xi=Math.floor(x),yi=Math.floor(y),zi=Math.floor(z),s=t=>t*t*(3-2*t),u=s(x-xi),v=s(y-yi),w=s(z-zi); return lerp(lerp(lerp(hash(xi,yi,zi),hash(xi+1,yi,zi),u),lerp(hash(xi,yi+1,zi),hash(xi+1,yi+1,zi),u),v),lerp(lerp(hash(xi,yi,zi+1),hash(xi+1,yi,zi+1),u),lerp(hash(xi,yi+1,zi+1),hash(xi+1,yi+1,zi+1),u),v),w)} const fbm=(p,f)=>vn(p.x*f,p.y*f,p.z*f)*.6+vn(p.x*f*2.7,p.y*f*2.7,p.z*f*2.7)*.4; const tmpC=new THREE.Color(); function skinCol(p,n,bias=0){const k=clamp(.42*n.y+.4+(fbm(p,2.1)-.5)*.95+bias,0,1);return k<.5?tmpC.copy(cRoast[0]).lerp(cRoast[1],k*2):tmpC.copy(cRoast[1]).lerp(cRoast[2],(k-.5)*2)} function paint(m,fn){m.updateWorldMatrix(true,false);const g=m.geometry,P=g.attributes.position,N=g.attributes.normal,c=new Float32Array(P.count*3),p=new V3,n=new V3,nm=new THREE.Matrix3().getNormalMatrix(m.matrixWorld); for(let i=0;i((p.x-c.x)/(r.x+pad))**2+((p.y-c.y)/(r.y+pad))**2+((p.z-c.z)/(r.z+pad))**2<1; const inBody=(p,pad)=>inE(p,CC,CR,pad)||inE(p,BC,BR,pad); /* ---------- table, board, tray, leaves ---------- */ const TY=-.27,TZ=-3.85; {const t=wood('#33150a','#1c0903','#57260f',260,false);t.repeat.set(7,7); const table=new THREE.Mesh(new THREE.PlaneGeometry(70,70).rotateX(-PI/2),new THREE.MeshStandardMaterial({map:t,roughness:.6,envMapIntensity:.22}));table.position.y=-.31;table.receiveShadow=true;scene.add(table); const bt=wood('#472a17','#22110a','#6d4526',220,true);bt.repeat.set(1/5.4,1/4.2);bt.offset.set(.5,.5); const sh=new THREE.Shape(),w=2.7,h=2.1,r=.28;sh.moveTo(-w+r,-h);sh.lineTo(w-r,-h);sh.quadraticCurveTo(w,-h,w,-h+r);sh.lineTo(w,h-r);sh.quadraticCurveTo(w,h,w-r,h);sh.lineTo(-w+r,h);sh.quadraticCurveTo(-w,h,-w,h-r);sh.lineTo(-w,-h+r);sh.quadraticCurveTo(-w,-h,-w+r,-h); const board=new THREE.Mesh(new THREE.ExtrudeGeometry(sh,{depth:.25,bevelEnabled:true,bevelSize:.03,bevelThickness:.03,bevelSegments:3,curveSegments:10}).rotateX(PI/2).translate(0,-.03,.6),[new THREE.MeshStandardMaterial({map:bt,roughness:.5,envMapIntensity:.7}),new THREE.MeshStandardMaterial({color:C(0x3d2414),roughness:.55,envMapIntensity:.6})]); board.receiveShadow=true;board.castShadow=true;scene.add(board); const al=new THREE.MeshStandardMaterial({color:C(0xa9acae),metalness:.9,roughness:.6,envMapIntensity:.45}),tray=new THREE.Group(); const bx=(w,h,d,x,y,z)=>{const m=new THREE.Mesh(new THREE.BoxGeometry(w,h,d),al);m.position.set(x,y,z);m.receiveShadow=true;m.castShadow=true;tray.add(m)}; bx(4.7,.04,4.3,0,-.29,TZ);bx(4.8,.16,.06,0,-.23,TZ-2.15);bx(4.8,.16,.06,0,-.23,TZ+2.15);bx(.06,.16,4.3,-2.37,-.23,TZ);bx(.06,.16,4.3,2.37,-.23,TZ);scene.add(tray); const leaf=new THREE.Shape();for(let i=0;i<=90;i++){const a=i/90*PI*2,c=Math.cos(a),k=1+.07*Math.cos(11*a),x=.62*c*k,y=.27*Math.sin(a)*Math.pow(1-.45*c*c,1.2)*(1+.25*c)*k;i?leaf.lineTo(x,y):leaf.moveTo(x,y)} const lg=new THREE.ShapeGeometry(leaf).rotateX(-PI/2),cols=[0x8e2c12,0xb87a1e,0x5f5220,0x6a1824,0xbd8a2c,0x7d3a14]; [[3.6,1.9],[4.3,1.0],[3.9,2.9],[4.9,2.2],[-3.7,2.6],[-4.4,1.6],[-3.6,-.6],[3.5,-.2],[4.7,.1],[-4.6,.3]].forEach((p,i)=>{const m=new THREE.Mesh(lg,new THREE.MeshStandardMaterial({color:C(cols[i%6]).multiplyScalar(.4),roughness:.9,envMapIntensity:.3,side:THREE.DoubleSide}));m.position.set(p[0],-.3+i*.002,p[1]);m.rotation.y=R(6.3);m.scale.setScalar(R(.8,1.25));m.receiveShadow=true;scene.add(m)})} /* ---------- geometry helpers ---------- */ const shadow=o=>{o.traverse(m=>{if(m.isMesh){m.castShadow=true;m.receiveShadow=true}});return o}; const lathe=(prof,L)=>new THREE.LatheGeometry(prof.map(a=>new THREE.Vector2(a[1],a[0]*L)),26); function rod(a,b,r,ball=0,mat=boneMat){const d=b.clone().sub(a),L=d.length(),g=new THREE.Group();g.add(new THREE.Mesh(new THREE.CylinderGeometry(r,r,L,10),mat)); if(ball)for(const s of[-1,1]){const k=new THREE.Mesh(new THREE.SphereGeometry(ball,14,10),mat);k.position.y=s*L/2;k.scale.set(1.15,.85,1);g.add(k)} g.position.copy(a).addScaledVector(d,.5);g.quaternion.setFromUnitVectors(Y,d.normalize());return g} const v=(x,y,z)=>new V3(x,y,z); const mov=[];const M=o=>{mov.push(o);return o}; /* ---------- carcass and fixed bones ---------- */ const carcass=new THREE.Mesh(new THREE.SphereGeometry(1,72,44).scale(CR.x,CR.y,CR.z).translate(CC.x,CC.y,CC.z),skinMat); {const P=carcass.geometry.attributes.position;for(let i=0;i0){const u=Math.min(1,x/1.2);P.setZ(i,P.getZ(i)*(1-.22*u*u*(3-2*u)))}if(x>1.15)P.setX(i,1.15+(x-1.15)*.12);if(x<-1.2)P.setX(i,-1.2+(x+1.2)*.25)}carcass.geometry.computeVertexNormals(); scene.add(carcass);paint(carcass,(p,n)=>{if(p.x>1.148&&n.x>.6)return cCav;if(p.y>.85&&inE(p,BC,BR,-.03)){const s=.5+.5*Math.sin(p.x*21);return tmpC.copy(cRib).lerp(cBone,Math.pow(s,6))}return skinCol(p,n,-.12)})} const bones=new THREE.Group();scene.add(bones); {bones.add(rod(v(-.9,.32,0),v(.95,.3,0),.06)); for(const x of[-.8,-.55,-.3,-.05,.2]){const t=new THREE.Mesh(new THREE.TorusGeometry(1,.035,8,44).rotateY(PI/2),boneMat);const f=Math.sqrt(1-(x/1.3)**2);t.scale.set(1,.5*f,.7*f);t.position.set(x,.6,0);t.rotation.z=.12;bones.add(t)} const k=new THREE.Shape();k.moveTo(-.95,.93);k.quadraticCurveTo(-.8,1.3,-.45,1.37);k.quadraticCurveTo(0,1.43,.5,1.25);k.quadraticCurveTo(.75,1.12,.82,.98);k.lineTo(.5,.94);k.lineTo(-.5,.9); bones.add(new THREE.Mesh(new THREE.ExtrudeGeometry(k,{depth:.07,bevelEnabled:false,curveSegments:14}).translate(0,0,-.035),keelMat)); const pel=new THREE.Mesh(new THREE.SphereGeometry(1,20,12).scale(.5,.11,.44),boneMat);pel.position.set(.62,.3,0);bones.add(pel)} /* ---------- joint markers ---------- */ const ringT=tex(128,128,(g,w)=>{const c=w/2,gr=g.createRadialGradient(c,c,30,c,c,63);gr.addColorStop(0,'rgba(255,50,90,.5)');gr.addColorStop(1,'rgba(255,50,90,0)');g.fillStyle=gr;g.fillRect(0,0,w,w); const ring=(r,lw,col)=>{g.lineWidth=lw;g.strokeStyle=col;g.beginPath();g.arc(c,c,r,0,7);g.stroke()},dot=(r,col)=>{g.fillStyle=col;g.beginPath();g.arc(c,c,r,0,7);g.fill()}; ring(33,18,'#fff');ring(33,10,'#ff3358');dot(10,'#fff');dot(5.5,'#ff3358')}); const pulseT=tex(128,128,g=>{g.lineWidth=6;g.strokeStyle='#fff';g.beginPath();g.arc(64,64,58,0,7);g.stroke()}); const marks=[]; function mark(p,parent,id,s){const mk=(t,ro)=>{const m=new THREE.Sprite(new THREE.SpriteMaterial({map:t,depthTest:false,depthWrite:false,transparent:true,opacity:0}));m.position.copy(p);m.renderOrder=ro;parent.add(m);return m}; const m=mk(ringT,31);m.userData={k:1,id,s,p:mk(pulseT,30)};marks.push(m);return m} /* ---------- legs ---------- */ const HIP=s=>v(.7,.42,.5*s),KNEE=s=>v(.12,.92,.86*s),ANK=s=>v(1.45,1.02,.44*s); const DRUM=[[0,.02],[.03,.17],[.13,.3],[.3,.335],[.48,.27],[.66,.18],[.8,.115],[.88,.085],[.9,.02]]; function flatPose(P1,P2,s,head,target,rad){const n=P1.clone().cross(P2.clone().sub(P1)).normalize();if(n.z*s<0)n.negate(); const q1=new Q().setFromUnitVectors(n,Y),d=P2.clone().applyQuaternion(q1),q=new Q().setFromAxisAngle(Y,Math.atan2(d.z,d.x)+head).multiply(q1); const c=P1.clone().add(P2).multiplyScalar(1/3).applyQuaternion(q);return{p:v(target.x-c.x,target.y+rad,target.z-c.z),q}} const leg={},wing={},lobe={}; function sliceSet(n,dim,face,s){const g=M(new THREE.Group());g.visible=false;scene.add(g);const T=.13; for(let i=0;i({full:1,w:.3-.03*Math.abs(i-2),h:.2-.02*Math.abs(i-2),x:(i-2)*.16}),faceD,1); leg[s]={g,K,A,D,th,fem,kg,dr,kneeM,hipM,sl,flat:flatPose(K,A,s,0,v(1.2*s,0,1.98),.31)}} /* ---------- wings ---------- */ const SH=s=>v(-.72,.78,.6*s),EL=s=>v(-.12,.42,.9*s),WR=s=>v(-.74,.26,.98*s),TP=s=>v(-1.02,.2,.74*s); for(const s of[1,-1]){ const g=M(new THREE.Group());g.position.copy(SH(s));scene.add(g); const E=EL(s).sub(SH(s)),W=WR(s).sub(SH(s)),T=TP(s).sub(SH(s)); const seg=(a,b,prof)=>{const d=b.clone().sub(a),m=new THREE.Mesh(lathe(prof,d.length()),skinMat);m.position.copy(a);m.quaternion.setFromUnitVectors(Y,d.clone().normalize());g.add(m);return m}; const parts=[seg(v(0,0,0),E,[[0,.03],[.06,.15],[.35,.18],[.75,.14],[.96,.115],[1,.03]]),seg(E,W,[[0,.03],[.05,.115],[.5,.13],[.92,.09],[1,.03]]),seg(W,T,[[0,.03],[.08,.085],[.6,.06],[1,.008]])]; g.add(rod(v(0,0,0),E,.03,.05,wingMat),rod(E,W,.022,.035,wingMat),rod(W,T,.014,0,wingMat)); const shM=mark(SH(s),scene,'shoulder',s);shadow(g); wing[s]={g,parts,shM,tray:flatPose(E,W,s,PI/2*s,v(1.95*s,TY,-2.7),.15)}; bones.add(rod(SH(s).multiplyScalar(.93),v(-.9,.94,0),.03),rod(SH(s).multiplyScalar(.93),v(-.05,.3,.36*s),.02),rod(v(-1.05,.72,0),SH(s).multiplyScalar(.9),.018)); } /* ---------- breast lobes ---------- */ {const te=Math.acos((Y0-BC.y)/BR.y),a0=Math.asin((Y0-BC.y)/BR.y),f=Math.cos(a0); const kc=new THREE.Shape();for(let i=0;i<=40;i++){const a=a0+(PI-2*a0)*i/40,x=BR.x*Math.cos(a),y=BR.y*Math.sin(a)-(Y0-BC.y);i?kc.lineTo(x,y):kc.moveTo(x,y)} const rc=new THREE.Shape();for(let i=0;i<=40;i++){const a=PI*i/40,x=BR.x*f*Math.cos(a),y=BR.z*f*Math.sin(a);i?rc.lineTo(x,y):rc.moveTo(x,y)} for(const s of[1,-1]){const g=M(new THREE.Group());g.position.set(BC.x,Y0,.004*s);scene.add(g); const dome=new THREE.Mesh(new THREE.SphereGeometry(1,56,30,s>0?0:PI,PI,0,te).scale(BR.x,BR.y,BR.z),skinMat);dome.position.y=BC.y-Y0; const c1=new THREE.Mesh(new THREE.ShapeGeometry(kc),meatMat),c2=new THREE.Mesh(new THREE.ShapeGeometry(rc).rotateX(PI/2*s),meatMat); g.add(dome,c1,c2);shadow(g); const n=10,sl=sliceSet(n,i=>{const x=-.93+i*1.86/(n-1),k=Math.sqrt(1-(x/BR.x)**2);return{w:.7*k,h:.56*k,x}},faceW,s); lobe[s]={g,dome,sl,work:v(1.3*s,.004,s>0?1.5:2.3)}}} /* paint every skin part in its assembled place */ scene.updateMatrixWorld(true); for(const s of[1,-1]){paint(leg[s].th,(p,n)=>inBody(p,.05)?cDark:skinCol(p,n,.2+.25*Math.abs(n.z)));paint(leg[s].dr,(p,n)=>skinCol(p,n,.16+.2*Math.abs(n.z)));wing[s].parts.forEach(m=>paint(m,(p,n)=>inBody(p,.02)?cMeat:skinCol(p,n,.02)));paint(lobe[s].dome,(p,n)=>skinCol(p,n,.06))} /* ---------- knife and cut line ---------- */ const knife=new THREE.Group();knife.rotation.order='YZX';knife.visible=false;scene.add(knife); {const b=new THREE.Shape();b.moveTo(-.75,0);b.lineTo(.6,0);b.quadraticCurveTo(.84,.02,.88,.13);b.lineTo(-.75,.17); const blade=new THREE.Mesh(new THREE.ExtrudeGeometry(b,{depth:.014,bevelEnabled:false}).translate(0,0,-.007),new THREE.MeshStandardMaterial({color:C(0xf2f4f6),metalness:.55,roughness:.28})); const hd=new THREE.Mesh(new THREE.BoxGeometry(.62,.15,.075),new THREE.MeshStandardMaterial({color:C(0x24140c),roughness:.45}));hd.position.set(-1.07,.095,0); const bo=new THREE.Mesh(new THREE.BoxGeometry(.06,.17,.085),blade.material);bo.position.set(-.76,.09,0);knife.add(blade,hd,bo);knife.traverse(m=>m.castShadow=true)} const cutLine=new THREE.Mesh(new THREE.BufferGeometry(),new THREE.MeshBasicMaterial({color:0xfff6dd,depthTest:false,transparent:true,opacity:.95}));cutLine.renderOrder=25;cutLine.frustumCulled=false;cutLine.visible=false;scene.add(cutLine); /* knife path preview and the part that moves */ const guides=new THREE.Group();scene.add(guides); const guideMat=new THREE.MeshBasicMaterial({color:0xfff6dd,depthTest:false,transparent:true,opacity:.85}),guideFar=new THREE.MeshBasicMaterial({color:0xfff6dd,depthTest:false,transparent:true,opacity:.14}),guideEdge=new THREE.MeshBasicMaterial({color:0x1d0c05,depthTest:false,transparent:true,opacity:.6}); function setGuides(list,sided){for(const m of[...guides.children]){m.geometry.dispose();guides.remove(m)} (list||[]).forEach((pts,i)=>{const cur=new THREE.CatmullRomCurve3(pts.map(a=>a.isVector3?a:new V3(a[0],a[1],a[2]))),n=Math.max(6,Math.round(cur.getLength()/.06)); for(const[r,mat,ro]of[[.034,guideEdge,23],[.021,guideMat,24]]){const g=new THREE.TubeGeometry(cur,n,r,5,false),ix=g.index.array,keep=[]; for(let j=0;jObject.assign({q0:w.o.quaternion.clone()},w)):null} /* steam */ const steam=new THREE.Group();scene.add(steam); {const st=tex(64,64,(g,w)=>{const gr=g.createRadialGradient(32,32,0,32,32,32);gr.addColorStop(0,'rgba(255,255,255,.9)');gr.addColorStop(1,'rgba(255,255,255,0)');g.fillStyle=gr;g.fillRect(0,0,w,w)}); for(let i=0;i<9;i++){const s=new THREE.Sprite(new THREE.SpriteMaterial({map:st,transparent:true,opacity:0,depthWrite:false}));s.userData={ph:i/9,x:R(-.8,.8),z:R(-.4,.4)};steam.add(s)}} /* ---------- tweens ---------- */ const tweens=new Set(),eio=k=>k<.5?4*k*k*k:1-((-2*k+2)**3)/2,lin=k=>k,back=k=>{const c=1.9;return 1+(c+1)*((k-1)**3)+c*((k-1)**2)}; const tw=(d,fn,ease=eio)=>new Promise(res=>tweens.add({t:0,d:Math.max(.01,d),fn,ease,res})); const wait=ms=>tw(ms/1000,()=>{}); function moveTo(o,p,q,d,lift=.8){scene.attach(o);const p0=o.position.clone(),q0=o.quaternion.clone();return tw(d,k=>{o.position.lerpVectors(p0,p,k);o.position.y+=Math.sin(k*PI)*lift;o.quaternion.copy(q0).slerp(q,k)})} async function knifeCut(arr,d,saw=3){const pts=arr.map(a=>a.isVector3?a:v(a[0],a[1],a[2])),cur=new THREE.CatmullRomCurve3(pts);cutLine.geometry.dispose();const lineGeo=cutLine.geometry=new THREE.TubeGeometry(cur,48,.016,6,false);lineGeo.setDrawRange(0,0);cutLine.visible=true;knife.visible=true; const p=new V3,t=new V3,place=(k,lift)=>{cur.getPoint(k,p);cur.getTangent(k,t);knife.rotation.set(0,Math.atan2(-t.z,t.x),Math.asin(clamp(t.y,-1,1))*.7);knife.position.copy(p);knife.position.y+=lift;knife.translateX(Math.sin(k*saw*PI*2)*.15)}; await tw(.35,k=>place(0,(1-k)*.9));await tw(d,k=>{place(k,0);lineGeo.setDrawRange(0,Math.ceil(k*48)*36)},lin);await tw(.3,k=>place(1,k*.9));knife.visible=false} async function chops(a,b,n,d){knife.visible=true;const dir=b.clone().sub(a),yaw=Math.atan2(-dir.z,dir.x)+PI/2;await tw(d,k=>{knife.position.lerpVectors(a,b,k);knife.position.y+=Math.abs(Math.cos(k*n*PI))*.4;knife.rotation.set(0,yaw,0)},lin);knife.visible=false} const flash=m=>tw(.9,k=>{m.userData.k=1+Math.sin(k*PI)*2.2},lin); const fan=(g,gap,lean,d)=>{const n=g.children.length,x0=g.children.map(c=>c.position.x);return tw(d,k=>g.children.forEach((c,i)=>{c.position.x=lerp(x0[i],(i-(n-1)/2)*gap,k);c.rotation.z=lean*k}))}; /* ---------- camera ---------- */ const cam={tx:0,ty:.75,tz:.1,th:.5,ph:1.02,r:9.5};let goal=null,W=1,H=1,cardH=0; const SIDE=matchMedia('(min-width:900px),(max-height:520px) and (min-width:560px)');let availW=1,cardW=0; const fitR=(w,h)=>{const t=Math.tan(18*PI/180),a=W/H;return clamp(Math.max(w/(2*t*a*availW),h/(2*t*clamp((H-cardH-(SIDE.matches?70:50))/H,.3,1))),2,17)}; const fly=g=>{goal=Object.assign({},g);if(g.w){goal.r=fitR(g.w,g.h);delete goal.w;delete goal.h}}; const VIEW={all:{tx:0,ty:.6,tz:.2,th:.42,ph:1,w:3.8,h:4.2},top:{tx:0,ty:.9,tz:0,th:.32,ph:.66,w:3.4,h:3.6},tray:{tx:0,ty:-.2,tz:-3.75,th:PI-.3,ph:.5,w:5.4,h:5.2}}; VIEW.both={tx:0,ty:.3,tz:1.2,th:.25,ph:.72,w:4.8,h:4.4}; const workV=(s,th=.3,w=2.7)=>({tx:1.2*s,ty:.25,tz:1.9,th:th*s,ph:.8,w,h:2.8}); const hipV=s=>({tx:.5,ty:.65,tz:.3*s,th:s>0?.62:PI-.62,ph:1.02,w:3,h:3.3}),shV=s=>({tx:-.55,ty:.7,tz:.3*s,th:s>0?-.5:PI+.5,ph:1,w:2.9,h:3.3}); function placeCam(dt){if(goal){const a=1-Math.exp(-dt*3.2);for(const k in goal)cam[k]+=(goal[k]-cam[k])*a} const r=cam.r,sp=Math.sin(cam.ph);camera.position.set(cam.tx+r*sp*Math.sin(cam.th),cam.ty+r*Math.cos(cam.ph),cam.tz+r*sp*Math.cos(cam.th));camera.lookAt(cam.tx,cam.ty,cam.tz)} function size(){W=cv.clientWidth;H=cv.clientHeight;renderer.setSize(W,H,false);const a=W/H;camera.aspect=a;const side=SIDE.matches,cd=$('card');cardW=side?cd.offsetWidth+cd.offsetLeft*2:0;cardH=side?0:cd.offsetHeight+20;availW=side?clamp((W-cardW)/W,.3,1):1;camera.setViewOffset(W,H,-cardW/2,side?-22:cardH*.46,W,H);camera.updateProjectionMatrix()} const ro=new ResizeObserver(size);ro.observe(document.body);ro.observe($('card')); /* ---------- pointer control ---------- */ const ptr=new Map();let pin=0,moved=0,downT=0,lastTap=0; const pd=()=>{const a=[...ptr.values()];return Math.hypot(a[0].x-a[1].x,a[0].y-a[1].y)}; cv.addEventListener('pointerdown',e=>{cv.setPointerCapture(e.pointerId);ptr.set(e.pointerId,{x:e.clientX,y:e.clientY});if(ptr.size===1){moved=0;downT=performance.now()}else pin=pd();$('hint').style.opacity=0}); cv.addEventListener('pointermove',e=>{const p=ptr.get(e.pointerId);if(!p)return;const dx=e.clientX-p.x,dy=e.clientY-p.y;p.x=e.clientX;p.y=e.clientY; if(ptr.size===1){moved+=Math.abs(dx)+Math.abs(dy);if(moved>6){goal=null;cam.th-=dx*.0065;cam.ph=clamp(cam.ph-dy*.005,.12,1.5)}} else if(ptr.size===2){goal=null;moved=99;const d=pd();cam.r=clamp(cam.r*pin/d,1.5,18);pin=d;const k=cam.r*.0009;cam.tx-=dx*k*Math.cos(cam.th);cam.tz+=dx*k*Math.sin(cam.th);cam.ty=clamp(cam.ty+dy*k,-.3,2.5)}}); const up=e=>{if(!ptr.delete(e.pointerId))return;if(ptr.size===0&&moved<8&&performance.now()-downT<400){const now=performance.now();if(now-lastTap<320&&!awaiting)fly(STEPS[si].cam);else tap(e.clientX,e.clientY);lastTap=now}}; cv.addEventListener('pointerup',up);cv.addEventListener('pointercancel',e=>ptr.delete(e.pointerId)); cv.addEventListener('wheel',e=>{e.preventDefault();goal=null;cam.r=clamp(cam.r*Math.exp(e.deltaY*.0012),1.5,18)},{passive:false}); /* ---------- labels ---------- */ const kneeW=s=>leg[s].kneeM.getWorldPosition(new V3); const LBL=[['hip',1,'Hip joint',()=>HIP(1)],['hip',-1,'Hip joint',()=>HIP(-1)],['knee',1,'Knee joint',()=>kneeW(1)],['knee',-1,'Knee joint',()=>kneeW(-1)],['shoulder',1,'Shoulder joint',()=>SH(1)],['shoulder',-1,'Shoulder joint',()=>SH(-1)],['keel',0,'Keel bone',()=>v(-.1,1.5,0)],['wishbone',0,'Wishbone',()=>v(-1.05,.72,0)]] .map(a=>{const el=document.createElement('button');el.className='lb'+(a[1]?'':' bone');el.textContent=a[2];el.onclick=()=>focus(a[0],a[1]||1);$('labels').appendChild(el);return{id:a[0],s:a[1],pos:a[3],el}}); const FACT={hip:['Hip joint','Ball and socket. It sits deep, where the thigh meets the back. Push the leg down and out, and the ball comes out of the socket.'], knee:['Knee joint','A hinge between the thigh and the drumstick. A thin line of fat marks it. Bend the leg and you can feel it move.'], shoulder:['Shoulder joint','A small ball joint low on the side, near the neck end. Pull the wing away from the body and the joint opens.'], keel:['Keel bone','This is not a joint. It is the flat bone between the two breasts. It guides the long breast cut.'], wishbone:['Wishbone','A thin V at the neck end. Cut it out first and the breast comes off cleaner.']}; function focus(id,s=1){if(busy||awaiting)return;const p=LBL.find(l=>l.id===id&&(l.s===s||!l.s)).pos();setX(true); fly({tx:p.x,ty:p.y-.1,tz:p.z*.6,th:id==='keel'?.35:id==='wishbone'?-1.25:(p.x>0?.7:-.6)*(s>0?1:-1)+(s>0?0:PI),ph:id==='keel'?.55:.98,w:1.9,h:2.1}); if(si)return say(FACT[id][1]);$('t').textContent=FACT[id][0];$('b').textContent=FACT[id][1];$('fig').innerHTML=FIG[{hip:'ball',knee:'hinge',shoulder:'ball',keel:'keel'}[id]]||'';$('tip').textContent='';picked=id;chips()} const pv=new V3; function placeLabels(){const st=STEPS[si],show=labelsOn&&!awaiting;for(const l of LBL){let on=show&&(picked?l.id===picked:st.lab.includes(l.id)); if(on){pv.copy(l.pos());if(l.s&&(camera.position.z-cam.tz)*l.s<-.4)on=false;else{pv.project(camera);const x=(pv.x*.5+.5)*W,y=(-pv.y*.5+.5)*H;if(pv.z>1||y>H-cardH-6||y<56||xa=>v(a[0],a[1],a[2]*s),qId=new Q(); const P_HIP=s=>[[-.3,1.12,.7],[.25,1.04,.68],[.7,.86,.66],[1.02,.58,.56]].map(sgn(s)),P_SH=s=>[[-.82,1.08,.56],[-.74,.82,.66],[-.66,.52,.74]].map(sgn(s)),P_KEEL=s=>[[-.98,1.26,.04],[-.5,1.46,.04],[.1,1.48,.04],[.6,1.36,.04],[.9,1.16,.04]].map(sgn(s)); function P_KNEE(s){const L=leg[s],kp=kneeW(s),q0=L.kg.getWorldQuaternion(new Q),d=L.D.clone().applyQuaternion(q0).setY(0).normalize(),n=v(-d.z,0,d.x);return[kp.clone().addScaledVector(n,.42).setY(.68),kp.clone().setY(.6),kp.clone().addScaledVector(n,-.42).setY(.5)]} function P_THIGH(s){const a=leg[s].g.getWorldPosition(new V3),b=kneeW(s);return[a.clone().setY(.64),a.clone().lerp(b,.5).setY(.66),b.clone().setY(.64)]} function P_SLICE(s){const p=lobe[s].g.position,out=[];for(let i=0;i<9;i++){const x=-.83+i*1.66/8,m=1-(x/BR.x)**2,zm=BR.z*Math.sqrt(m);out.push([.04,.5,.95].map(t=>{const z=t*zm;return v(p.x+x,p.y+BR.y*Math.sqrt(Math.max(0,m-(z/BR.z)**2))+.02,p.z+z*s)}))}return out} const twoSides=fn=>()=>[fn(1),fn(-1)]; async function cutLeg(s,sp){const L=leg[s];fly(hipV(s));await wait(s>0?800:1100); await knifeCut(P_HIP(s),1.5/sp); await tw(.7/sp,k=>{L.g.rotation.x=s*.8*k},back);flash(L.hipM);say('Pop. The hip joint is open.');await wait(450/sp); await knifeCut([[.52,.8,.7],[.7,.45,.58],[.86,.2,.5]].map(sgn(s)),.7/sp,1);cutLine.visible=false; await moveTo(L.g,L.flat.p,L.flat.q,1.1/sp)} async function splitKnee(s,sp){fly(workV(s));await wait(s>0?300:900);const L=leg[s],q0=L.kg.getWorldQuaternion(new Q),d=L.D.clone().applyQuaternion(q0).setY(0).normalize(); await knifeCut(P_KNEE(s),.9/sp,2);cutLine.visible=false; const q=new Q().setFromAxisAngle(Y,Math.atan2(d.z,d.x)+(s>0?0:PI)).multiply(q0),c=L.D.clone().multiplyScalar(.5).applyQuaternion(q); await moveTo(L.kg,v(.95*s-c.x,TY+.31,-5.25-c.z),q,1.1/sp)} async function boneThigh(s,sp){fly(workV(s));await wait(s>0?300:900);const L=leg[s],a=L.g.getWorldPosition(new V3),b=kneeW(s),c=L.th.getWorldPosition(new V3),d=b.clone().sub(a).setY(0).normalize(); await knifeCut(P_THIGH(s),.8/sp,2);cutLine.visible=false; await moveTo(L.fem,v(-2.2,.06,-.95+.16*s),new Q().setFromUnitVectors(Y,v(.25*s,0,1).normalize()),.9/sp,.9); L.sl.position.set(c.x,.004,c.z);L.sl.rotation.set(0,Math.atan2(-d.z,d.x),0); await chops(a.clone().setY(.42),b.clone().setY(.42),5,.9/sp);L.th.visible=false;L.kneeM.visible=false;L.sl.visible=true; await fan(L.sl,.2,-1,.5/sp);await moveTo(L.sl,v(.95*s,TY,-4.3),qId,1/sp)} async function cutWing(s,sp){const Wg=wing[s];fly(shV(s));await wait(s>0?800:1100); await tw(.6/sp,k=>{Wg.g.rotation.x=s*.55*k},back);flash(Wg.shM); await knifeCut(P_SH(s),.9/sp,2);cutLine.visible=false; await moveTo(Wg.g,Wg.tray.p,Wg.tray.q,1.1/sp)} async function cutBreast(s,sp){const B=lobe[s];fly({tx:0,ty:.9,tz:0,th:s>0?.32:PI-.32,ph:.66,w:3.4,h:3.6});await wait(s>0?700:1000); await knifeCut(P_KEEL(s),1.6/sp,3); await Promise.all([tw(.6/sp,k=>{B.g.rotation.x=s*.28*k;B.g.position.z=s*(.004+.12*k)}),knifeCut([[.8,1.02,.5],[0,.98,.72],[-.85,.98,.58]].map(sgn(s)),1.1/sp,3)]);cutLine.visible=false; await moveTo(B.g,B.work,qId,1.2/sp,1)} async function sliceBreast(s,sp){fly(workV(s,.85,3));await wait(s>0?300:900);const B=lobe[s],p=B.g.position; await chops(v(p.x-.95,.3,p.z+.35*s),v(p.x+.95,.3,p.z+.35*s),10,1.5/sp);B.sl.position.copy(p);B.g.visible=false;B.sl.visible=true; await fan(B.sl,.25,-1.05,.6/sp);await moveTo(B.sl,v(-.1,TY,s>0?-2.62:-3.1),qId,1.1/sp)} const both=fn=>async()=>{await fn(1,1);await fn(-1,1.7)}; /* ---------- steps ---------- */ const STEPS=[ {t:'Find the six joints',b:'A turkey comes apart at six joints: two hips, two knees and two shoulders. A red ring marks each joint. Cut at the joint, not through bone.',tip:'Tap a name to go to that joint. Rest the bird for 20 to 30 minutes before you cut.',cam:VIEW.all,lab:['hip','knee','shoulder','keel'],tour:1}, {t:'Open the hip',find:'Hold the drumstick end and move the leg. The leg turns at one point, deep against the body. That point is the hip.',cut:'Cut the skin between the breast and the leg. Push the leg down flat until the joint pops. Cut through the gap.',tip:'If the knife stops, it is on bone. Move it 1 cm and try again.', cam:hipV(1),lab:['hip'],hi:'leg',fig:'ball',sided:1,pre:twoSides(P_HIP),wig:()=>[1,-1].map(s=>({o:leg[s].g,ax:XA,amp:s*.3})),q:['hip joint',()=>[HIP(1),HIP(-1)]],act:both(cutLeg)}, {t:'Split the knee',find:'Put the leg skin side down and bend it. A thin line of fat goes across the bend. The knee is under that line.',cut:'Cut straight down on the fat line. The knife goes between the two bone ends.',tip:'Force is not necessary. If you must push hard, you are not in the joint.', cam:workV(1),lab:['knee'],hi:'leg',fig:'hinge',pre:twoSides(P_KNEE),wig:()=>[1,-1].map(s=>({o:leg[s].kg,ax:leg[s].K.clone().cross(leg[s].D).normalize(),amp:-.32})),q:['knee joint',()=>[kneeW(1),kneeW(-1)]],act:both(splitKnee)}, {t:'Bone the thigh',find:'Feel the one bone that goes along the middle of the thigh.',cut:'Cut along each side of the bone and lift it out. Then slice the meat across the grain.',tip:'Slices across the grain are tender. Slices along the grain are stringy.', cam:workV(1),lab:[],hi:'leg',fig:'bone',pre:twoSides(P_THIGH),act:both(boneThigh)}, {t:'Take off the wings',find:'Move the wing. It turns at a point low on the side of the breast, near the neck end. That point is the shoulder.',cut:'Pull the wing away from the body. The joint opens. Cut through the gap.',tip:'The shoulder is lower than most people think.', cam:shV(1),lab:['shoulder'],hi:'wing',fig:'ball',sided:1,pre:twoSides(P_SH),wig:()=>[1,-1].map(s=>({o:wing[s].g,ax:XA,amp:s*.3})),q:['shoulder joint',()=>[SH(1),SH(-1)]],act:both(cutWing)}, {t:'Lift off the breast',find:'Feel the hard ridge along the top middle of the breast. That ridge is the keel bone.',cut:'Cut down along one side of the keel. Keep the blade flat against the bone, then follow the ribs outward. Use long strokes.',tip:'Do not slice the breast on the bird. Take it off in one piece first.', cam:VIEW.top,lab:['keel','wishbone'],hi:'keel',fig:'keel',pre:twoSides(P_KEEL),q:['keel bone',()=>[v(-.6,1.42,0),v(-.1,1.48,0),v(.45,1.4,0)]],act:both(cutBreast)}, {t:'Slice across the grain',find:'Look at the lines in the meat. They go along the length of the breast. Those lines are the grain.',cut:'Put the breast skin side up. Slice across the lines, about ½ inch thick.',tip:'Use one long stroke for each slice. Do not saw.', cam:workV(1,.85,3),lab:[],fig:'grain',pre:()=>[...P_SLICE(1),...P_SLICE(-1)],act:both(sliceBreast)}, {t:'Serve',b:'White meat goes in the middle. Dark meat, drumsticks and wings go around it. Keep the carcass for stock.',tip:'',cam:VIEW.tray,lab:[]}]; const BONE='#f4ead4',CUT='#ff4f6a',DSH=`fill="none" stroke="${CUT}" stroke-width="3.5" stroke-dasharray="6 5" stroke-linecap="round"`; const FIG={ ball:``, hinge:``, keel:``, bone:``, grain:``}; let si=0,done=true,busy=false,quiz=false,awaiting=false,labelsOn=true,xGoal=0,xr=0,picked=null,userX=false;const snaps=[],scores=[]; const snap=()=>mov.map(o=>({o,par:o.parent,p:o.position.clone(),q:o.quaternion.clone(),vis:o.visible})); const restore=s=>{unwig();s.forEach(a=>{a.par.add(a.o);a.o.position.copy(a.p);a.o.quaternion.copy(a.q);a.o.visible=a.vis});knife.visible=cutLine.visible=false}; const total=()=>scores.reduce((a,b)=>a+(b||0),0); function setX(on){xGoal=on?1:0;$('bx').setAttribute('aria-pressed',on)} let toastT;function say(m){const t=$('toast');t.textContent=m;t.classList.add('on');clearTimeout(toastT);toastT=setTimeout(()=>t.classList.remove('on'),1800+m.length*45)} function chips(){$('chips').innerHTML=STEPS[si].tour?Object.keys(FACT).map(k=>``).join(''):''} $('chips').onclick=e=>{const k=e.target.dataset&&e.target.dataset.k;if(k)focus(k)}; function draw(){const st=STEPS[si],last=si===STEPS.length-1; $('bar').innerHTML=STEPS.map((_,i)=>``).join(''); $('k').textContent=si?(quiz&&st.q?'Quiz, ':'')+`step ${si} of ${STEPS.length-1}`.replace(/^s/,quiz&&st.q?'s':'S'):'Before you cut'; $('t').textContent=st.t; if(st.find&&!awaiting)$('b').innerHTML=`Find it${st.find}Cut${st.cut}`; else $('b').textContent=awaiting?`Tap the place on the bird where the ${st.q[0]} is. X-ray is off. Turn the bird if you need to.`:last&&quiz?`You scored ${total()} of 12. ${total()>=10?'You know where the joints are.':total()>=6?'Good. Do it again and you will have it.':'Use X-ray, look again, then try once more.'} ${st.b}`:st.b; $('fig').innerHTML=st.fig&&!awaiting?FIG[st.fig]:'';$('lg').style.visibility=awaiting?'hidden':''; $('tip').textContent=awaiting?'':st.tip;chips(); $('back').hidden=si===0;$('back').disabled=busy;$('back').textContent=done&&st.act?'Replay':'Back'; const go=$('go'),alt=$('alt');go.disabled=busy;alt.disabled=busy; go.textContent=busy?'Cutting':si===0?'Start carving':last?'Carve again':awaiting?'Show me':!done?'Make the cut':'Next'; alt.hidden=si!==0;alt.textContent='Play the quiz'; $('score').style.display=quiz?'block':'none';document.body.classList.toggle('quiz',quiz);$('score').textContent=`Score ${total()}`; steam.visible=si<6&&!still;size()} function enter(i,fwd){si=i;picked=null;const st=STEPS[i];if(fwd||!snaps[i])snaps[i]=snap();done=!st.act;awaiting=quiz&&!!st.q;if(awaiting){scores[i]=0;setX(false)}else if(!userX&&i>0)setX(!!st.q);const live=!done&&!awaiting;setGuides(live&&st.pre?st.pre():null,st.sided);setWig(live&&st.wig&&!still?st.wig():null);fly(st.cam);draw()} async function run(){const st=STEPS[si];unwig();setGuides(null);awaiting=false;busy=true;draw();await st.act();busy=false;done=true;fly([0,VIEW.all,VIEW.both,VIEW.tray,VIEW.all,VIEW.both,VIEW.tray][si]);draw()} $('go').onclick=()=>{if(busy)return;const last=si===STEPS.length-1; if(si===0){quiz=false;enter(1,true)}else if(last){restore(snaps[1]);scores.length=0;enter(0,false)}else if(!done)run();else enter(si+1,true)}; $('alt').onclick=()=>{quiz=true;scores.length=0;userX=false;enter(1,true);say('Quiz on. Find each joint without X-ray.')}; $('back').onclick=()=>{if(busy)return;if(done&&STEPS[si].act||si===STEPS.length-1&&false){restore(snaps[si]);enter(si,false)}else{restore(snaps[si-1]||snaps[si]);enter(si-1,false)}}; $('bx').onclick=()=>{if(awaiting)return say('X-ray is off in the quiz. Tap your answer first.');userX=true;setX(!xGoal)}; $('bh').onclick=()=>{$('help').hidden=false};$('hx').onclick=()=>{$('help').hidden=true};$('help').onclick=e=>{if(e.target.id==='help')$('help').hidden=true}; const ray=new THREE.Raycaster(); function tap(x,y){if(!awaiting||busy)return;const st=STEPS[si];ray.setFromCamera({x:x/W*2-1,y:-(y/H)*2+1},camera); const d=Math.min(...st.q[1]().map(p=>ray.ray.distanceToPoint(p))),cm=Math.round(d*15),pts=d<.17?3:d<.36?2:d<.6?1:0;scores[si]=pts; say(pts===3?'Exactly on the joint. 3 points.':pts===2?`Close. About ${cm} cm off. 2 points.`:pts===1?`About ${cm} cm off. 1 point.`:`Missed by about ${cm} cm. Look at the red point.`); setX(true);awaiting=false;busy=true;draw();st.q[1]().length<3&&marks.forEach(m=>flash(m));wait(1500).then(run)} /* ---------- frame loop ---------- */ let last=performance.now(),tt=0,xPrev=-1,ts=1,slowN=0,slowT=0,pr=Math.min(devicePixelRatio||1,2); function frame(now){const raw=(now-last)/1000,dt=Math.min(.05,raw)*ts;last=now;tt+=dt; if(raw<.5){slowT+=raw;if(++slowN>=90){if(slowT/slowN>1/26&&pr>1){pr=Math.max(1,pr-.5);renderer.setPixelRatio(pr);size()}slowN=slowT=0}} for(const t of[...tweens]){t.t+=dt;const k=Math.min(1,t.t/t.d);t.fn(t.ease(k));if(k>=1){tweens.delete(t);t.res()}} xr+=(xGoal-xr)*(1-Math.exp(-dt*5));if(Math.abs(xr-xPrev)>.002){xPrev=xr;const tr=xr>.02; for(const m of flesh){if(m.transparent!==tr){m.transparent=tr;m.needsUpdate=true}m.opacity=1-.64*xr;m.depthWrite=xr<.45} skinMat.clearcoat=.75*(1-xr);boneMat.emissiveIntensity=.04+.2*xr;boneMat.color.copy(B0).lerp(B1,xr)} const st=STEPS[si],side=camera.position.z-cam.tz; for(const m of marks){const u=m.userData,tg=!awaiting&&st.lab.includes(u.id)&&(!picked||picked===u.id);let o=m.visible&&!awaiting?(tg?1:xr*.32):0; if((u.id!=='knee'||si<2)&&side*u.s<-.4)o*=.3;m.material.opacity=o;m.scale.setScalar(.34*u.k); const f=still?.35:(tt*.8+(u.s>0?0:.5))%1;u.p.visible=m.visible;u.p.material.opacity=tg?o*(1-f)*.85:0;u.p.scale.setScalar(.34*(1+f*1.2)*u.k)} const hi=awaiting?'':st.hi;for(const[m,k]of BM){const on=hi===k;m.color.copy(B0).lerp(GOLD,on?xr:0);m.emissive.copy(on?HI:LO);m.emissiveIntensity=.04+xr*(on?.45+(still?0:.2*Math.sin(tt*4)):.3)} guideMat.opacity=still?.95:.8+.2*Math.sin(tt*4);for(const g of guides.children){const far=g.userData.s&&side*g.userData.s<-.4;if(g.userData.edge)g.visible=!far;else g.material=far?guideFar:guideMat} if(wigs&&!busy){const a=.5-.5*Math.cos(tt*2.6);for(const w of wigs)w.o.quaternion.copy(w.q0).multiply(qT.setFromAxisAngle(w.ax,w.amp*a))} if(steam.visible)for(const s of steam.children){const u=(tt*.16+s.userData.ph)%1;s.position.set(s.userData.x+Math.sin(tt+s.userData.ph*9)*.15,1.4+u*2,s.userData.z);s.scale.setScalar(.5+u*1.3);s.material.opacity=Math.sin(u*PI)*.085*(1-xr)} placeCam(dt);placeLabels();renderer.render(scene,camera);requestAnimationFrame(frame)} size();enter(0,true);cam.th=1.5;cam.r=fitR(3.8,4.2)*1.3; setTimeout(()=>{if(!userX&&si===0)setX(true)},2300);setTimeout(()=>$('hint').style.opacity=0,7000); requestAnimationFrame(frame); window.__t={STEPS,cam,get pr(){return pr},get xr(){return xr},leg,wing,lobe,get busy(){return busy},get si(){return si},set ts(v){ts=v}}; }