Files

353 lines
21 KiB
JavaScript
Raw Permalink Normal View History

2026-04-11 09:21:22 +02:00
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._container_101xd_1{background:radial-gradient(circle at top,rgba(99,102,241,.14),transparent 48%),linear-gradient(180deg,var(--gc-bg-secondary, #12121a),var(--gc-bg, #0a0a0f));color:var(--gc-text, #e8e8ec);box-sizing:border-box;font-family:Russo One,system-ui,-apple-system,sans-serif;line-height:1.5;width:100%;min-height:100%}._container_101xd_1,._container_101xd_1 *,._container_101xd_1 *:before,._container_101xd_1 *:after{box-sizing:inherit}._frame_101xd_20{width:100%;aspect-ratio:16 / 9;padding:var(--frame-pad, 1rem)}._squareLayout_101xd_26{width:100%;height:100%;display:flex;align-items:center;justify-content:center;gap:var(--panel-gap, 1rem)}._squarePanel_101xd_35{position:relative;flex:0 0 auto;overflow:hidden;border:1px solid color-mix(in srgb,var(--gc-border, #2a2a3a) 82%,transparent);border-radius:28px;box-shadow:0 28px 70px #00000040}._viewportPanel_101xd_44{background:radial-gradient(circle at 50% 18%,rgba(34,211,238,.2),transparent 32%),linear-gradient(160deg,rgba(18,18,26,.95),rgba(10,10,15,.98))}._contentPanel_101xd_50{background:linear-gradient(180deg,rgba(18,18,26,.96),rgba(10,10,15,.98)),var(--gc-bg, #0a0a0f)}._panelBody_101xd_56{width:100%;height:100%;padding:clamp(1rem,3vw,2rem);display:flex;flex-direction:column;justify-content:center;gap:1rem}._copy_101xd_66{margin:0;color:var(--gc-text, #e8e8ec);font-size:clamp(.95rem,1.9vw,1.15rem);line-height:1.65}._muted_101xd_73{color:var(--gc-text-muted, #9999a8)}._badge_101xd_77{align-self:flex-start;padding:.35rem .7rem;border-radius:999px;background:rgba(99,102,241,.14);color:var(--gc-primary, #6366f1);font-size:.75rem;letter-spacing:.08em;text-transform:uppercase}._startButton_101xd_88,._choiceButton_101xd_89,._completeButton_101xd_90{border:none;border-radius:14px;padding:.95rem 1.2rem;font:inherit;color:#fff;cursor:pointer;transition:transform .18s ease,filter .18s ease,border-color .18s ease,background .18s ease}._startButton_101xd_88:hover,._choiceButton_101xd_89:hover,._completeButton_101xd_90:hover{transform:translateY(-1px);filter:brightness(1.06)}._startButton_101xd_88,._completeButton_101xd_90{background:linear-gradient(135deg,var(--gc-primary, #6366f1),var(--gc-accent, #22d3ee))}._sliderSection_101xd_112{display:flex;flex-direction:column;gap:.8rem}._sliderHeader_101xd_118{display:flex;justify-content:space-between;align-items:baseline;gap:1rem}._sliderLabel_101xd_125{color:var(--gc-text-muted, #9999a8);font-size:.8rem;letter-spacing:.08em;text-transform:uppercase}._sliderValue_101xd_132{color:var(--gc-accent, #22d3ee);font-family:SF Mono,Monaco,Consolas,monospace;font-size:clamp(1.2rem,2.4vw,1.8rem)}._valueInfinity_101xd_138{color:#ef4444}._slider_101xd_112{width:100%;height:12px;border-radius:999px;background:rgba(255,255,255,.08);outline:none;-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:pointer}._slider_101xd_112::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:26px;height:26px;border-radius:50%;background:var(--gc-primary, #6366f1);box-shadow:0 0 0 6px #6366f129}._slider_101xd_112::-moz-range-thumb{width:26px;height:26px;border:0;border-radius:50%;background:var(--gc-primary, #6366f1);box-shadow:0 0 0 6px #6366f129}._sliderInfinity_101xd_170{background:linear-gradient(90deg,rgba(255,255,255,.08),rgba(239,68,68,.7))}._sliderInfinity_101xd_170::-webkit-slider-thumb{background:#ef4444;box-shadow:0 0 0 6px #ef44442e}._sliderInfinity_101xd_170::-moz-range-thumb{background:#ef4444;box-shadow:0 0 0 6px #ef44442e}._sliderHint_101xd_184{color:var(--gc-text-muted, #9999a8);font-size:.85rem}._statsOverlay_101xd_189{position:absolute;right:1rem;bottom:1rem;left:1rem;display:flex;justify-content:space-between;gap:.75rem;pointer-events:none}._stat_101xd_189{min-width:0;padding:.7rem .85rem;border-radius:16px;background:rgba(0,0,0,.55);-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}._statLabel_101xd_208{display:block;margin-bottom:.2rem;color:var(--gc-t
import { jsx as e, jsxs as a, Fragment as _ } from "react/jsx-runtime";
import { useState as N, useRef as F, useMemo as q, useEffect as z, useCallback as V } from "react";
import { Canvas as I, useFrame as Q } from "@react-three/fiber";
import { OrbitControls as W } from "@react-three/drei";
import * as te from "three";
const ne = "_container_101xd_1", ie = "_frame_101xd_20", se = "_squareLayout_101xd_26", ae = "_squarePanel_101xd_35", ce = "_viewportPanel_101xd_44", oe = "_contentPanel_101xd_50", re = "_panelBody_101xd_56", le = "_copy_101xd_66", de = "_muted_101xd_73", ue = "_badge_101xd_77", fe = "_startButton_101xd_88", he = "_choiceButton_101xd_89", me = "_completeButton_101xd_90", pe = "_sliderSection_101xd_112", _e = "_sliderHeader_101xd_118", ye = "_sliderLabel_101xd_125", xe = "_sliderValue_101xd_132", ge = "_valueInfinity_101xd_138", ve = "_slider_101xd_112", be = "_sliderInfinity_101xd_170", Se = "_sliderHint_101xd_184", we = "_statsOverlay_101xd_189", Ne = "_stat_101xd_189", Me = "_statLabel_101xd_208", Ie = "_statValue_101xd_217", $e = "_statInfinity_101xd_223", Re = "_warning_101xd_227", Le = "_warningText_101xd_233", Ce = "_warningQuestion_101xd_234", Be = "_warningChoices_101xd_245", Ve = "_choiceInfinity_101xd_257", ke = "_choiceFinite_101xd_265", qe = "_resultStats_101xd_273", ze = "_resultRow_101xd_280", Ae = "_resultMessage_101xd_298", Fe = "_resultSuccess_101xd_309", He = "_resultAccent_101xd_313", t = {
container: ne,
frame: ie,
squareLayout: se,
squarePanel: ae,
viewportPanel: ce,
contentPanel: oe,
panelBody: re,
copy: le,
muted: de,
badge: ue,
startButton: fe,
choiceButton: he,
completeButton: me,
sliderSection: pe,
sliderHeader: _e,
sliderLabel: ye,
sliderValue: xe,
valueInfinity: ge,
slider: ve,
sliderInfinity: be,
sliderHint: Se,
statsOverlay: we,
stat: Ne,
statLabel: Me,
statValue: Ie,
statInfinity: $e,
warning: Re,
warningText: Le,
warningQuestion: Ce,
warningChoices: Be,
choiceInfinity: Ve,
choiceFinite: ke,
resultStats: qe,
resultRow: ze,
resultMessage: Ae,
resultSuccess: Fe,
resultAccent: He
}, A = 5, y = 41;
function Oe(d) {
const r = Math.min(Math.max(d, A), y);
return r % 2 === 0 ? r + 1 : r;
}
function j(d) {
const r = [], n = d, f = 2 / n;
for (let u = 0; u < n; u++)
for (let m = 0; m < n; m++)
for (let o = 0; o < n; o++) {
const g = -1 + f * (u + 0.5), i = -1 + f * (m + 0.5), x = -1 + f * (o + 0.5), p = Math.sqrt(g * g + i * i + x * x), $ = f * 1.2;
p <= 1 && p > 1 - $ && r.push(g, i, x);
}
return { positions: r, count: r.length / 3 };
}
function Te({ resolution: d, isInfinity: r }) {
const s = F(null), n = q(() => new te.Object3D(), []), { positions: f, count: u, cubeSize: m } = q(() => {
const i = Math.min(d, y), x = j(i), p = 2 / i * 0.85;
return {
positions: x.positions,
count: x.count,
cubeSize: p
};
}, [d]);
z(() => {
if (!(!s.current || u === 0)) {
for (let i = 0; i < u; i++)
n.position.set(
f[i * 3],
f[i * 3 + 1],
f[i * 3 + 2]
), n.scale.setScalar(m), n.updateMatrix(), s.current.setMatrixAt(i, n.matrix);
s.current.instanceMatrix.needsUpdate = !0, s.current.count = u;
}
}, [f, u, m, n]), Q((i) => {
s.current && (s.current.rotation.y = i.clock.elapsedTime * 0.2);
});
const o = r ? "#ef4444" : "#818cf8";
return /* @__PURE__ */ a("instancedMesh", { ref: s, args: [void 0, void 0, 1e4], frustumCulled: !1, children: [
/* @__PURE__ */ e("boxGeometry", { args: [1, 1, 1] }),
/* @__PURE__ */ e(
"meshStandardMaterial",
{
color: o,
emissive: o,
emissiveIntensity: 0.05,
roughness: 0.4,
metalness: 0.3
}
)
] });
}
function k({ resolution: d, isInfinity: r }) {
return /* @__PURE__ */ a(_, { children: [
/* @__PURE__ */ e("ambientLight", { intensity: 0.3 }),
/* @__PURE__ */ e("directionalLight", { position: [5, 8, 5], intensity: 1.2, castShadow: !0 }),
/* @__PURE__ */ e("directionalLight", { position: [-3, -2, -4], intensity: 0.4, color: "#22d3ee" }),
/* @__PURE__ */ e("pointLight", { position: [0, 5, 0], intensity: 0.5 }),
/* @__PURE__ */ e(Te, { resolution: d, isInfinity: r }),
/* @__PURE__ */ e(
W,
{
enableZoom: !0,
enablePan: !1,
autoRotate: !1,
minDistance: 2,
maxDistance: 6
}
)
] });
}
function De() {
const d = F(null);
return Q((r) => {
d.current && (d.current.rotation.y = r.clock.elapsedTime * 0.3);
}), /* @__PURE__ */ a("mesh", { ref: d, children: [
/* @__PURE__ */ e("sphereGeometry", { args: [1, 128, 128] }),
/* @__PURE__ */ e(
"meshStandardMaterial",
{
color: "#22d3ee",
emissive: "#22d3ee",
emissiveIntensity: 0.08,
roughness: 0.15,
metalness: 0.9,
envMapIntensity: 1
}
)
] });
}
function Ee() {
return /* @__PURE__ */ a(_, { children: [
/* @__PURE__ */ e("ambientLight", { intensity: 0.3 }),
/* @__PURE__ */ e("directionalLight", { position: [5, 8, 5], intensity: 1.5 }),
/* @__PURE__ */ e("directionalLight", { position: [-4, -2, -3], intensity: 0.5, color: "#6366f1" }),
/* @__PURE__ */ e("pointLight", { position: [0, 3, 3], intensity: 0.8, color: "#ffffff" }),
/* @__PURE__ */ e(De, {}),
/* @__PURE__ */ e(
W,
{
enableZoom: !1,
enablePan: !1,
autoRotate: !0,
autoRotateSpeed: 1.5
}
)
] });
}
function Pe({
config: d,
onComplete: r,
onProgress: s,
theme: n,
className: f
}) {
const [u, m] = N("exploring"), [o, g] = N(A), [i, x] = N(null), [p, $] = N(!1), H = F(null), [v, K] = N({
stacked: !1,
panelSize: 320,
gap: 16,
padding: 16
}), M = o >= y, O = q(() => j(Math.min(o, y)).count, [o]);
z(() => {
const c = H.current;
if (!c || typeof ResizeObserver > "u")
return;
const l = () => {
const { width: h, height: S } = c.getBoundingClientRect();
if (!h || !S)
return;
const C = S > h, E = Math.min(h, S), w = Math.round(Math.max(12, Math.min(28, E * 0.04))), B = Math.round(Math.max(12, Math.min(22, E * 0.03))), X = C ? h - w * 2 : (h - w * 2 - B) / 2, ee = C ? (S - w * 2 - B) / 2 : S - w * 2;
K({
stacked: C,
panelSize: Math.max(0, Math.floor(Math.min(X, ee))),
gap: B,
padding: w
});
};
l();
const b = new ResizeObserver(l);
return b.observe(c), () => b.disconnect();
}, []);
const P = {
"--gc-primary": (n == null ? void 0 : n.primary) || "#6366f1",
"--gc-accent": (n == null ? void 0 : n.accent) || "#22d3ee",
"--gc-bg": (n == null ? void 0 : n.bg) || "#0a0a0f",
"--gc-bg-secondary": (n == null ? void 0 : n.bgSecondary) || "#12121a",
"--gc-text": (n == null ? void 0 : n.text) || "#e8e8ec",
"--gc-text-muted": (n == null ? void 0 : n.textMuted) || "#9999a8",
"--gc-border": (n == null ? void 0 : n.border) || "#2a2a3a",
"--panel-gap": `${v.gap}px`,
"--frame-pad": `${v.padding}px`
}, T = {
width: `${v.panelSize}px`,
height: `${v.panelSize}px`
};
z(() => {
s == null || s(10);
}, [s]);
const G = V((c) => {
const l = Oe(parseInt(c.target.value, 10));
g(l);
const b = 10 + l / y * 40;
s == null || s(Math.min(b, 50)), l >= y && !p && (m("warning"), $(!0), s == null || s(70));
}, [p, s, y]), D = V((c) => {
x(c), m("result"), s == null || s(100);
}, [s]), Z = V(() => {
r({
success: !0,
score: 100,
data: {
choice: i,
finalResolution: o,
exploredInfinity: p,
completedAt: (/* @__PURE__ */ new Date()).toISOString()
}
});
}, [i, o, p, r]), U = (c) => c >= y ? "" : c.toString(), Y = (c, l) => l ? "" : c.toLocaleString(), J = (c, l) => {
if (l)
return "";
const h = c * 80;
return h < 1024 ? `${h} B` : h < 1024 * 1024 ? `${(h / 1024).toFixed(1)} KB` : `${(h / (1024 * 1024)).toFixed(2)} MB`;
}, R = (c, l) => /* @__PURE__ */ a("div", { className: `${t.squarePanel} ${t.viewportPanel}`, style: T, children: [
c,
/* @__PURE__ */ a("div", { className: t.statsOverlay, children: [
/* @__PURE__ */ a("div", { className: t.stat, children: [
/* @__PURE__ */ e("span", { className: t.statLabel, children: "Blocks" }),
/* @__PURE__ */ e("span", { className: `${t.statValue} ${l ? t.statInfinity : ""}`, children: Y(O, l) })
] }),
/* @__PURE__ */ a("div", { className: t.stat, children: [
/* @__PURE__ */ e("span", { className: t.statLabel, children: "Memory" }),
/* @__PURE__ */ e("span", { className: `${t.statValue} ${l ? t.statInfinity : ""}`, children: J(O, l) })
] })
] })
] }), L = (c) => /* @__PURE__ */ e("div", { className: `${t.squarePanel} ${t.contentPanel}`, style: T, children: /* @__PURE__ */ e("div", { className: t.panelBody, children: c }) });
return /* @__PURE__ */ e("div", { className: `${t.container} ${f || ""}`, style: P, children: /* @__PURE__ */ e("div", { ref: H, className: t.frame, children: /* @__PURE__ */ a(
"div",
{
className: t.squareLayout,
style: { flexDirection: v.stacked ? "column" : "row" },
children: [
u === "exploring" && /* @__PURE__ */ a(_, { children: [
R(
/* @__PURE__ */ e(I, { camera: { position: [0, 0, 3.5], fov: 50 }, children: /* @__PURE__ */ e(k, { resolution: o, isInfinity: M }) }),
M
),
L(
/* @__PURE__ */ a(_, { children: [
/* @__PURE__ */ e("div", { className: t.badge, children: "Resolution" }),
/* @__PURE__ */ e("p", { className: `${t.copy} ${t.muted}`, children: "Every step adds more cubes to the shell. Keep sliding until the approximation breaks open." }),
/* @__PURE__ */ a("div", { className: t.sliderSection, children: [
/* @__PURE__ */ a("div", { className: t.sliderHeader, children: [
/* @__PURE__ */ e("span", { className: t.sliderLabel, children: "Current Level" }),
/* @__PURE__ */ e("span", { className: `${t.sliderValue} ${M ? t.valueInfinity : ""}`, children: U(o) })
] }),
/* @__PURE__ */ e(
"input",
{
type: "range",
min: A,
max: y,
step: "2",
value: o,
onChange: G,
className: `${t.slider} ${M ? t.sliderInfinity : ""}`
}
),
/* @__PURE__ */ e("div", { className: t.sliderHint, children: "Drag right to approach a perfectly smooth sphere." })
] })
] })
)
] }),
u === "warning" && /* @__PURE__ */ a(_, { children: [
R(
/* @__PURE__ */ e(I, { camera: { position: [0, 0, 3.5], fov: 50 }, children: /* @__PURE__ */ e(k, { resolution: o, isInfinity: !0 }) }),
!0
),
L(
/* @__PURE__ */ a("div", { className: t.warning, children: [
/* @__PURE__ */ e("div", { className: t.badge, children: "Limit Reached" }),
/* @__PURE__ */ e("p", { className: t.warningText, children: "At infinite resolution, the sphere needs infinitely many blocks." }),
/* @__PURE__ */ e("p", { className: t.warningText, children: "Infinitely many blocks means infinite information and unbounded memory." }),
/* @__PURE__ */ e("p", { className: t.warningQuestion, children: "Do you want the perfect sphere anyway?" }),
/* @__PURE__ */ a("div", { className: t.warningChoices, children: [
/* @__PURE__ */ e(
"button",
{
className: `${t.choiceButton} ${t.choiceInfinity}`,
onClick: () => D("infinity"),
children: "Embrace Infinity"
}
),
/* @__PURE__ */ e(
"button",
{
className: `${t.choiceButton} ${t.choiceFinite}`,
onClick: () => D("finite"),
children: "Keep It Finite"
}
)
] })
] })
)
] }),
u === "result" && /* @__PURE__ */ a(_, { children: [
R(
i === "infinity" ? /* @__PURE__ */ e(I, { camera: { position: [0, 0, 3], fov: 50 }, children: /* @__PURE__ */ e(Ee, {}) }) : /* @__PURE__ */ e(I, { camera: { position: [0, 0, 3.5], fov: 50 }, children: /* @__PURE__ */ e(k, { resolution: o, isInfinity: !1 }) }),
i === "infinity"
),
L(
/* @__PURE__ */ a(_, { children: [
/* @__PURE__ */ e("div", { className: t.badge, children: i === "finite" ? "Finite Wins" : "Infinity Chosen" }),
/* @__PURE__ */ a("div", { className: t.resultStats, children: [
/* @__PURE__ */ a("div", { className: t.resultRow, children: [
/* @__PURE__ */ e("span", { children: "Memory Required" }),
/* @__PURE__ */ e("span", { className: i === "finite" ? t.resultSuccess : t.resultAccent, children: i === "finite" ? "Finite" : "" })
] }),
/* @__PURE__ */ a("div", { className: t.resultRow, children: [
/* @__PURE__ */ e("span", { children: "Simulation Possible" }),
/* @__PURE__ */ e("span", { className: i === "finite" ? t.resultSuccess : t.resultAccent, children: i === "finite" ? "Yes" : "Only in theory" })
] })
] }),
/* @__PURE__ */ e("p", { className: t.resultMessage, children: i === "finite" ? /* @__PURE__ */ a(_, { children: [
/* @__PURE__ */ e("strong", { children: "Discreteness can be enough." }),
" A finite model never becomes perfect, but it can get close enough to feel continuous."
] }) : /* @__PURE__ */ a(_, { children: [
/* @__PURE__ */ e("strong", { children: "Perfect smoothness costs infinity." }),
" A mathematically exact sphere cannot be simulated without infinite information."
] }) }),
/* @__PURE__ */ e("button", { className: t.completeButton, onClick: Z, children: "Complete Challenge" })
] })
)
] })
]
}
) }) });
}
const Ge = {
name: "sphere-paradox",
displayName: "Create a Perfect Sphere",
version: "1.0.0",
paramSchema: {},
defaultParams: {}
};
export {
Pe as default,
Ge as metadata
};
//# sourceMappingURL=sphere-paradox.js.map