Files
gnommoplayer/public/glitch/glitch_gallery/assets/index-Be41ZfS7.js
T
2026-04-11 09:21:22 +02:00

2 lines
9.4 KiB
JavaScript

import{r as c,j as e,g as w,h as q,i as Z,a as z}from"./index-CEeZxcxj.js";const U="_container_101xd_1",Y="_frame_101xd_20",J="_squareLayout_101xd_26",X="_squarePanel_101xd_35",ee="_viewportPanel_101xd_44",te="_contentPanel_101xd_50",se="_panelBody_101xd_56",ne="_copy_101xd_66",ie="_muted_101xd_73",ae="_badge_101xd_77",ce="_choiceButton_101xd_89",re="_completeButton_101xd_90",oe="_sliderSection_101xd_112",le="_sliderHeader_101xd_118",de="_sliderLabel_101xd_125",ue="_sliderValue_101xd_132",xe="_valueInfinity_101xd_138",he="_slider_101xd_112",me="_sliderInfinity_101xd_170",fe="_sliderHint_101xd_184",pe="_statsOverlay_101xd_189",_e="_stat_101xd_189",ge="_statLabel_101xd_208",ye="_statValue_101xd_217",je="_statInfinity_101xd_223",ve="_warning_101xd_227",be="_warningText_101xd_233",Se="_warningQuestion_101xd_234",we="_warningChoices_101xd_245",Ne="_choiceInfinity_101xd_257",Me="_choiceFinite_101xd_265",Ie="_resultStats_101xd_273",Re="_resultRow_101xd_280",$e="_resultMessage_101xd_298",Ce="_resultSuccess_101xd_309",Le="_resultAccent_101xd_313",t={container:U,frame:Y,squareLayout:J,squarePanel:X,viewportPanel:ee,contentPanel:te,panelBody:se,copy:ne,muted:ie,badge:ae,choiceButton:ce,completeButton:re,sliderSection:oe,sliderHeader:le,sliderLabel:de,sliderValue:ue,valueInfinity:xe,slider:he,sliderInfinity:me,sliderHint:fe,statsOverlay:pe,stat:_e,statLabel:ge,statValue:ye,statInfinity:je,warning:ve,warningText:be,warningQuestion:Se,warningChoices:we,choiceInfinity:Ne,choiceFinite:Me,resultStats:Ie,resultRow:Re,resultMessage:$e,resultSuccess:Ce,resultAccent:Le},L=5,p=41;function Fe(d){const r=Math.min(Math.max(d,L),p);return r%2===0?r+1:r}function A(d){const r=[],i=d,x=2/i;for(let u=0;u<i;u++)for(let m=0;m<i;m++)for(let a=0;a<i;a++){const g=-1+x*(u+.5),s=-1+x*(m+.5),_=-1+x*(a+.5),f=Math.sqrt(g*g+s*s+_*_),N=x*1.2;f<=1&&f>1-N&&r.push(g,s,_)}return{positions:r,count:r.length/3}}function Pe({resolution:d,isInfinity:r}){const o=c.useRef(null),i=c.useMemo(()=>new Z,[]),{positions:x,count:u,cubeSize:m}=c.useMemo(()=>{const s=Math.min(d,p),_=A(s),f=2/s*.85;return{positions:_.positions,count:_.count,cubeSize:f}},[d]);c.useEffect(()=>{if(!(!o.current||u===0)){for(let s=0;s<u;s++)i.position.set(x[s*3],x[s*3+1],x[s*3+2]),i.scale.setScalar(m),i.updateMatrix(),o.current.setMatrixAt(s,i.matrix);o.current.instanceMatrix.needsUpdate=!0,o.current.count=u}},[x,u,m,i]),z(s=>{o.current&&(o.current.rotation.y=s.clock.elapsedTime*.2)});const a=r?"#ef4444":"#818cf8";return e.jsxs("instancedMesh",{ref:o,args:[void 0,void 0,1e4],frustumCulled:!1,children:[e.jsx("boxGeometry",{args:[1,1,1]}),e.jsx("meshStandardMaterial",{color:a,emissive:a,emissiveIntensity:.05,roughness:.4,metalness:.3})]})}function C({resolution:d,isInfinity:r}){return e.jsxs(e.Fragment,{children:[e.jsx("ambientLight",{intensity:.3}),e.jsx("directionalLight",{position:[5,8,5],intensity:1.2,castShadow:!0}),e.jsx("directionalLight",{position:[-3,-2,-4],intensity:.4,color:"#22d3ee"}),e.jsx("pointLight",{position:[0,5,0],intensity:.5}),e.jsx(Pe,{resolution:d,isInfinity:r}),e.jsx(q,{enableZoom:!0,enablePan:!1,autoRotate:!1,minDistance:2,maxDistance:6})]})}function Be(){const d=c.useRef(null);return z(r=>{d.current&&(d.current.rotation.y=r.clock.elapsedTime*.3)}),e.jsxs("mesh",{ref:d,children:[e.jsx("sphereGeometry",{args:[1,128,128]}),e.jsx("meshStandardMaterial",{color:"#22d3ee",emissive:"#22d3ee",emissiveIntensity:.08,roughness:.15,metalness:.9,envMapIntensity:1})]})}function ke(){return e.jsxs(e.Fragment,{children:[e.jsx("ambientLight",{intensity:.3}),e.jsx("directionalLight",{position:[5,8,5],intensity:1.5}),e.jsx("directionalLight",{position:[-4,-2,-3],intensity:.5,color:"#6366f1"}),e.jsx("pointLight",{position:[0,3,3],intensity:.8,color:"#ffffff"}),e.jsx(Be,{}),e.jsx(q,{enableZoom:!1,enablePan:!1,autoRotate:!0,autoRotateSpeed:1.5})]})}function qe({config:d,onComplete:r,onProgress:o,theme:i,className:x}){const[u,m]=c.useState("exploring"),[a,g]=c.useState(L),[s,_]=c.useState(null),[f,N]=c.useState(!1),F=c.useRef(null),[y,O]=c.useState({stacked:!1,panelSize:320,gap:16,padding:16}),S=a>=p,P=c.useMemo(()=>A(Math.min(a,p)).count,[a]);c.useEffect(()=>{const n=F.current;if(!n||typeof ResizeObserver>"u")return;const l=()=>{const{width:h,height:v}=n.getBoundingClientRect();if(!h||!v)return;const R=v>h,V=Math.min(h,v),b=Math.round(Math.max(12,Math.min(28,V*.04))),$=Math.round(Math.max(12,Math.min(22,V*.03))),K=R?h-b*2:(h-b*2-$)/2,G=R?(v-b*2-$)/2:v-b*2;O({stacked:R,panelSize:Math.max(0,Math.floor(Math.min(K,G))),gap:$,padding:b})};l();const j=new ResizeObserver(l);return j.observe(n),()=>j.disconnect()},[]);const H={"--gc-primary":i?.primary||"#6366f1","--gc-accent":i?.accent||"#22d3ee","--gc-bg":i?.bg||"#0a0a0f","--gc-bg-secondary":i?.bgSecondary||"#12121a","--gc-text":i?.text||"#e8e8ec","--gc-text-muted":i?.textMuted||"#9999a8","--gc-border":i?.border||"#2a2a3a","--panel-gap":`${y.gap}px`,"--frame-pad":`${y.padding}px`},B={width:`${y.panelSize}px`,height:`${y.panelSize}px`};c.useEffect(()=>{o?.(10)},[o]);const D=c.useCallback(n=>{const l=Fe(parseInt(n.target.value,10));g(l);const j=10+l/p*40;o?.(Math.min(j,50)),l>=p&&!f&&(m("warning"),N(!0),o?.(70))},[f,o,p]),k=c.useCallback(n=>{_(n),m("result"),o?.(100)},[o]),E=c.useCallback(()=>{r({success:!0,score:100,data:{choice:s,finalResolution:a,exploredInfinity:f,completedAt:new Date().toISOString()}})},[s,a,f,r]),T=n=>n>=p?"∞":n.toString(),Q=(n,l)=>l?"∞":n.toLocaleString(),W=(n,l)=>{if(l)return"∞";const h=n*80;return h<1024?`${h} B`:h<1024*1024?`${(h/1024).toFixed(1)} KB`:`${(h/(1024*1024)).toFixed(2)} MB`},M=(n,l)=>e.jsxs("div",{className:`${t.squarePanel} ${t.viewportPanel}`,style:B,children:[n,e.jsxs("div",{className:t.statsOverlay,children:[e.jsxs("div",{className:t.stat,children:[e.jsx("span",{className:t.statLabel,children:"Blocks"}),e.jsx("span",{className:`${t.statValue} ${l?t.statInfinity:""}`,children:Q(P,l)})]}),e.jsxs("div",{className:t.stat,children:[e.jsx("span",{className:t.statLabel,children:"Memory"}),e.jsx("span",{className:`${t.statValue} ${l?t.statInfinity:""}`,children:W(P,l)})]})]})]}),I=n=>e.jsx("div",{className:`${t.squarePanel} ${t.contentPanel}`,style:B,children:e.jsx("div",{className:t.panelBody,children:n})});return e.jsx("div",{className:`${t.container} ${x||""}`,style:H,children:e.jsx("div",{ref:F,className:t.frame,children:e.jsxs("div",{className:t.squareLayout,style:{flexDirection:y.stacked?"column":"row"},children:[u==="exploring"&&e.jsxs(e.Fragment,{children:[M(e.jsx(w,{camera:{position:[0,0,3.5],fov:50},children:e.jsx(C,{resolution:a,isInfinity:S})}),S),I(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:t.badge,children:"Resolution"}),e.jsx("p",{className:`${t.copy} ${t.muted}`,children:"Every step adds more cubes to the shell. Keep sliding until the approximation breaks open."}),e.jsxs("div",{className:t.sliderSection,children:[e.jsxs("div",{className:t.sliderHeader,children:[e.jsx("span",{className:t.sliderLabel,children:"Current Level"}),e.jsx("span",{className:`${t.sliderValue} ${S?t.valueInfinity:""}`,children:T(a)})]}),e.jsx("input",{type:"range",min:L,max:p,step:"2",value:a,onChange:D,className:`${t.slider} ${S?t.sliderInfinity:""}`}),e.jsx("div",{className:t.sliderHint,children:"Drag right to approach a perfectly smooth sphere."})]})]}))]}),u==="warning"&&e.jsxs(e.Fragment,{children:[M(e.jsx(w,{camera:{position:[0,0,3.5],fov:50},children:e.jsx(C,{resolution:a,isInfinity:!0})}),!0),I(e.jsxs("div",{className:t.warning,children:[e.jsx("div",{className:t.badge,children:"Limit Reached"}),e.jsx("p",{className:t.warningText,children:"At infinite resolution, the sphere needs infinitely many blocks."}),e.jsx("p",{className:t.warningText,children:"Infinitely many blocks means infinite information and unbounded memory."}),e.jsx("p",{className:t.warningQuestion,children:"Do you want the perfect sphere anyway?"}),e.jsxs("div",{className:t.warningChoices,children:[e.jsx("button",{className:`${t.choiceButton} ${t.choiceInfinity}`,onClick:()=>k("infinity"),children:"Embrace Infinity"}),e.jsx("button",{className:`${t.choiceButton} ${t.choiceFinite}`,onClick:()=>k("finite"),children:"Keep It Finite"})]})]}))]}),u==="result"&&e.jsxs(e.Fragment,{children:[M(s==="infinity"?e.jsx(w,{camera:{position:[0,0,3],fov:50},children:e.jsx(ke,{})}):e.jsx(w,{camera:{position:[0,0,3.5],fov:50},children:e.jsx(C,{resolution:a,isInfinity:!1})}),s==="infinity"),I(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:t.badge,children:s==="finite"?"Finite Wins":"Infinity Chosen"}),e.jsxs("div",{className:t.resultStats,children:[e.jsxs("div",{className:t.resultRow,children:[e.jsx("span",{children:"Memory Required"}),e.jsx("span",{className:s==="finite"?t.resultSuccess:t.resultAccent,children:s==="finite"?"Finite":"∞"})]}),e.jsxs("div",{className:t.resultRow,children:[e.jsx("span",{children:"Simulation Possible"}),e.jsx("span",{className:s==="finite"?t.resultSuccess:t.resultAccent,children:s==="finite"?"Yes":"Only in theory"})]})]}),e.jsx("p",{className:t.resultMessage,children:s==="finite"?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Discreteness can be enough."})," A finite model never becomes perfect, but it can get close enough to feel continuous."]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Perfect smoothness costs infinity."})," A mathematically exact sphere cannot be simulated without infinite information."]})}),e.jsx("button",{className:t.completeButton,onClick:E,children:"Complete Challenge"})]}))]})]})})})}const ze={name:"sphere-paradox",displayName:"Create a Perfect Sphere",version:"1.0.0",paramSchema:{},defaultParams:{}};export{qe as default,ze as metadata};