← Back to Research Index View Raw Source

aldi-aros-hq-2027-ar-go-kart-hud-track-architect.html

<!-- Copyright © Albert Lane. All Rights Reserved. Proprietary and Confidential — Albert Lane Proprietary Software License. Unauthorized use, copying, or distribution is prohibited. License inquiries: https://albertlane.net --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="copyright" content="© Albert Lane. All Rights Reserved. Albert Lane Proprietary Software License. https://albertlane.net" /> <title>1 Other Hacker Sucks Ln — 2027 AR Go-Kart HUD & Track Architect</title> <script src="https://cdn.tailwindcss.com"></script> <link rel="preconnect" href="https://fonts.googleapis.com" /> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600;700;800&family=Orbitron:wght@600;700;800;900&display=swap" rel="stylesheet" /> <style> :root { --hud-cyan: #22d3ee; --hud-magenta: #e879f9; --hud-amber: #fbbf24; --hud-emerald: #10b981; --hud-rose: #f43f5e; --bg-void: #05080f; } * { box-sizing: border-box; user-select: none; } body { margin: 0; font-family: 'Inter', sans-serif; background-color: var(--bg-void); color: #e2e8f0; overflow-x: hidden; } .font-mono-tech { font-family: 'JetBrains Mono', monospace; } .font-visor { font-family: 'Orbitron', sans-serif; } .visor-glass { background: rgba(8, 13, 24, 0.72); backdrop-filter: blur(12px); border: 1px solid rgba(34, 211, 238, 0.28); box-shadow: 0 0 24px rgba(34, 211, 238, 0.12), inset 0 0 12px rgba(34, 211, 238, 0.06); } .visor-glow-cyan { box-shadow: 0 0 20px rgba(34, 211, 238, 0.35); } .visor-glow-magenta { box-shadow: 0 0 22px rgba(232, 121, 249, 0.4); } @keyframes pulseRainbow { 0% { border-color: #22d3ee; box-shadow: 0 0 16px rgba(34, 211, 238, 0.45); } 33% { border-color: #e879f9; box-shadow: 0 0 16px rgba(232, 121, 249, 0.45); } 66% { border-color: #fbbf24; box-shadow: 0 0 16px rgba(251, 191, 36, 0.45); } 100% { border-color: #22d3ee; box-shadow: 0 0 16px rgba(34, 211, 238, 0.45); } } .item-box-active { animation: pulseRainbow 1.4s linear infinite; } ::-webkit-scrollbar { width: 6px; height: 6px; } ::-webkit-scrollbar-track { background: #070b14; } ::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 9999px; } </style> </head> <body class="min-h-screen flex flex-col bg-[#05080f] text-slate-100"> <!-- TOP COMMAND HEADER --> <header class="border-b border-cyan-500/25 bg-[#070c17]/95 backdrop-blur px-3 sm:px-5 py-2.5 flex flex-wrap items-center justify-between gap-2 z-30"> <div class="flex items-center gap-3"> <div class="w-9 h-9 rounded-xl bg-gradient-to-br from-cyan-500/20 to-fuchsia-500/20 border border-cyan-400/50 flex items-center justify-center font-visor font-black text-xs text-cyan-300 visor-glow-cyan"> MK27 </div> <div> <div class="flex items-center gap-2 flex-wrap"> <h1 class="text-xs sm:text-sm md:text-base font-visor font-extrabold tracking-wider text-white"> 1 OTHER HACKER SUCKS LN </h1> <span class="text-[10px] font-mono-tech uppercase tracking-widest px-2 py-0.5 rounded bg-fuchsia-950/80 text-fuchsia-300 border border-fuchsia-500/40"> AR KART VISOR OS v27.9 </span> </div> <p class="text-[11px] text-slate-400 hidden md:block"> Former Fairway Electric Kart Circuit • Catmull-Rom Spline Telemetry &amp; Z-Axis Banking Heuristics </p> </div> </div> <!-- MODE SWITCHER & SPEC DRAWER BUTTON --> <div class="flex flex-wrap items-center gap-2"> <div class="inline-flex rounded-xl bg-slate-900/90 p-1 border border-slate-700/80"> <button id="btnModeDriver" onclick="switchMode('DRIVER')" class="px-3 py-1.5 rounded-lg text-xs font-visor font-bold tracking-wide transition bg-cyan-400 text-slate-950 shadow"> 🏎️ DRIVER AR VISOR HUD </button> <button id="btnModeArchitect" onclick="switchMode('ARCHITECT')" class="px-3 py-1.5 rounded-lg text-xs font-visor font-bold tracking-wide transition text-slate-300 hover:text-white"> 📐 KID TRACK ARCHITECT </button> </div> <button onclick="toggleMathDrawer(true)" class="px-3 py-1.5 rounded-xl text-xs font-mono-tech font-semibold bg-fuchsia-500/15 hover:bg-fuchsia-500/25 text-fuchsia-300 border border-fuchsia-500/40 transition"> ∑ MATH &amp; CAN-FD SPEC </button> </div> </header> <!-- ======================================================================= --> <!-- MODE A: DRIVER AR VISOR HUD (FIRST-PERSON 3D PROJECTION) --> <!-- ======================================================================= --> <section id="viewDriver" class="relative flex-1 flex flex-col overflow-hidden min-h-[540px]"> <!-- Full-Viewport 3D Visor Canvas --> <canvas id="visorCanvas" class="block w-full flex-1 cursor-crosshair"></canvas> <!-- TOP HUD OVERLAY: POSITION, LAP, TIMER & AUTOPILOT --> <div class="absolute top-3 left-3 right-3 flex flex-wrap items-start justify-between gap-2 pointer-events-none"> <!-- Left: Position & Lap Pill --> <div class="flex items-center gap-2 pointer-events-auto"> <div class="visor-glass rounded-2xl px-3.5 py-2 flex items-baseline gap-1"> <span id="hudPosNum" class="font-visor font-black text-2xl sm:text-3xl text-amber-400 drop-shadow">1st</span> <span class="font-mono-tech text-xs text-slate-400">/ 8</span> </div> <div class="visor-glass rounded-2xl px-3.5 py-2"> <div class="text-[10px] font-mono-tech uppercase tracking-wider text-cyan-300">LAP</div> <div id="hudLapText" class="font-visor font-extrabold text-lg sm:text-xl text-white">1 / 3</div> </div> <div class="visor-glass rounded-2xl px-3.5 py-2 hidden sm:block"> <div class="text-[10px] font-mono-tech uppercase tracking-wider text-slate-400">COURSE TIME</div> <div id="hudTimerText" class="font-mono-tech font-bold text-base sm:text-lg text-emerald-300">00:00.00</div> </div> </div> <!-- Center: Item Roulette Box --> <div class="pointer-events-auto flex flex-col items-center"> <div id="itemRouletteCard" onclick="useActiveItem()" title="Click or press [E] / [Shift] to fire item!" class="visor-glass item-box-active rounded-2xl px-4 py-2 flex items-center gap-3 cursor-pointer hover:scale-105 transition"> <div id="hudItemIcon" class="text-2xl sm:text-3xl">🍄</div> <div> <div class="text-[9px] font-mono-tech uppercase tracking-widest text-fuchsia-300">AR ITEM SLOT [E]</div> <div id="hudItemName" class="font-visor font-bold text-xs sm:text-sm text-white">TURBO MUSHROOM</div> </div> </div> <div id="activeEffectBanner" class="hidden mt-1.5 px-3 py-0.5 rounded-full text-[11px] font-mono-tech font-bold bg-amber-400 text-slate-950 shadow-lg"> BOOST OVERDRIVE ACTIVE! </div> </div> <!-- Right: Autopilot Toggle & Track Name --> <div class="flex flex-col items-end gap-1.5 pointer-events-auto"> <div class="visor-glass rounded-2xl p-1.5 flex items-center gap-1.5"> <button id="btnAutopilot" onclick="toggleAutopilot()" class="px-3 py-1.5 rounded-xl text-xs font-mono-tech font-bold bg-emerald-500 text-slate-950 shadow transition"> 🤖 AUTOPILOT: ON </button> <button onclick="resetRace()" class="px-2.5 py-1.5 rounded-xl text-xs font-mono-tech bg-slate-800 hover:bg-slate-700 text-slate-200 border border-slate-700"> ↺ RESET </button> </div> <div class="visor-glass rounded-xl px-3 py-1 text-[10px] font-mono-tech text-cyan-300"> TRACK: <span id="hudTrackTitle" class="text-white font-bold">FAIRWAY HYPER-LOOP</span> </div> </div> </div> <!-- BOTTOM HUD OVERLAY: RADAR MINI-MAP, G-FORCE TELEMETRY, DRIFT CHARGE & SPEEDOMETER --> <div class="absolute bottom-3 left-3 right-3 flex flex-wrap items-end justify-between gap-3 pointer-events-none"> <!-- Bottom-Left: Live Spline Radar Mini-Map --> <div class="visor-glass rounded-2xl p-2 pointer-events-auto"> <div class="flex items-center justify-between px-1 mb-1"> <span class="text-[9px] font-mono-tech uppercase tracking-wider text-cyan-300">FAIRWAY RADAR</span> <span id="hudBankingReadout" class="text-[9px] font-mono-tech text-amber-300">BANK: 14°</span> </div> <canvas id="miniMapCanvas" width="144" height="104" class="rounded-xl bg-slate-950/90 border border-slate-800 block"></canvas> </div> <!-- Bottom-Center: Drift Mini-Turbo Charge & Lateral G-Force --> <div class="visor-glass rounded-2xl px-4 py-2.5 flex flex-col items-center gap-1.5 pointer-events-auto min-w-[230px] sm:min-w-[290px]"> <div class="w-full flex items-center justify-between text-[10px] font-mono-tech"> <span class="text-slate-400">LAT-G: <strong id="hudLatG" class="text-cyan-300">0.00 G</strong></span> <span id="hudDriftTierLabel" class="font-bold text-slate-300">DRIFT [SPACE]: READY</span> <span class="text-slate-400">SLIP: <strong id="hudSlipAngle" class="text-fuchsia-300">0.0°</strong></span> </div> <!-- Drift Charge Progress Bar --> <div class="w-full h-2.5 rounded-full bg-slate-950 border border-slate-700 overflow-hidden p-0.5"> <div id="hudDriftBar" class="h-full rounded-full transition-all duration-75 bg-cyan-400" style="width: 0%"></div> </div> <div class="text-[10px] font-mono-tech text-slate-400 text-center"> <span class="text-slate-200">WASD / Arrows</span> Steer • <span class="text-cyan-300">SPACE</span> Drift Charge • <span class="text-fuchsia-300">E</span> Fire Item </div> </div> <!-- Bottom-Right: Digital Speedometer & Electric Torque --> <div class="visor-glass rounded-2xl px-4 py-2.5 text-right pointer-events-auto"> <div class="flex items-baseline justify-end gap-1.5"> <span id="hudSpeedMph" class="font-visor font-black text-3xl sm:text-4xl text-white tracking-tight">00</span> <span class="font-mono-tech text-xs font-bold text-cyan-400">MPH</span> </div> <div class="text-[11px] font-mono-tech text-slate-400"> <span id="hudSpeedKph">0</span> KPH • <span id="hudTorqueKw" class="text-emerald-400">0.0 kW</span> </div> </div> </div> <!-- MOBILE TOUCH CONTROLS (Visible on touch/small screens when Autopilot is off) --> <div id="mobileTouchBar" class="sm:hidden absolute bottom-28 left-3 right-3 flex items-center justify-between pointer-events-none"> <div class="flex gap-2 pointer-events-auto"> <button ontouchstart="touchKeys.left=true" ontouchend="touchKeys.left=false" class="w-12 h-12 rounded-2xl visor-glass font-visor font-bold text-lg text-cyan-300 active:bg-cyan-500/30">◀</button> <button ontouchstart="touchKeys.right=true" ontouchend="touchKeys.right=false" class="w-12 h-12 rounded-2xl visor-glass font-visor font-bold text-lg text-cyan-300 active:bg-cyan-500/30">▶</button> </div> <div class="flex gap-2 pointer-events-auto"> <button ontouchstart="touchKeys.drift=true" ontouchend="touchKeys.drift=false" class="px-3 h-12 rounded-2xl visor-glass font-mono-tech font-bold text-xs text-amber-300 active:bg-amber-500/30">DRIFT</button> <button ontouchstart="touchKeys.up=true" ontouchend="touchKeys.up=false" class="px-4 h-12 rounded-2xl visor-glass font-mono-tech font-bold text-xs text-emerald-300 active:bg-emerald-500/30">GAS</button> </div> </div> </section> <!-- ======================================================================= --> <!-- MODE B: KID TRACK ARCHITECT (SPLINE & BANKING STUDIO) --> <!-- ======================================================================= --> <section id="viewArchitect" class="hidden flex-1 grid grid-cols-1 lg:grid-cols-12 overflow-hidden"> <!-- LEFT SIDEBAR: TRACK PRESETS, SPLINE & BANKING CONTROLS --> <aside class="lg:col-span-3 border-b lg:border-b-0 lg:border-r border-slate-800 bg-[#070c17] p-3.5 flex flex-col gap-3 overflow-y-auto max-h-[calc(100vh-95px)]"> <div> <div class="text-[11px] font-mono-tech uppercase tracking-wider text-cyan-400 mb-1.5"> 1. Fairway Circuit Presets </div> <div class="grid grid-cols-1 gap-1.5"> <button onclick="loadTrackPreset('HYPER_LOOP')" class="text-left p-2.5 rounded-xl bg-slate-900/90 hover:bg-slate-800 border border-cyan-500/30 transition"> <div class="text-xs font-bold text-white">⛳ Fairway Hyper-Loop (Balanced)</div> <div class="text-[10px] font-mono-tech text-slate-400">Smooth clothoid sweepers • 16° banking • Safe</div> </button> <button onclick="loadTrackPreset('BOWL_GP')" class="text-left p-2.5 rounded-xl bg-slate-900/90 hover:bg-slate-800 border border-fuchsia-500/30 transition"> <div class="text-xs font-bold text-white">🛹 Skate Bowl &amp; Graffiti GP</div> <div class="text-[10px] font-mono-tech text-slate-400">Technical chicane + Graffiti Spine straight</div> </button> <button onclick="loadTrackPreset('KID_CHAOS')" class="text-left p-2.5 rounded-xl bg-slate-900/90 hover:bg-slate-800 border border-rose-500/30 transition"> <div class="text-xs font-bold text-white">⚠️ Kid Hairpin Chaos (Tight R_min)</div> <div class="text-[10px] font-mono-tech text-slate-400">Tests rollover &amp; WFH pod clearance alarms</div> </button> </div> </div> <!-- Selected Spline Control Node Editor --> <div class="rounded-xl bg-[#0d1424] border border-slate-800 p-3"> <div class="flex items-center justify-between mb-2"> <span class="text-[11px] font-mono-tech uppercase tracking-wider text-amber-400"> 2. Selected Spline Node </span> <span id="archNodeBadge" class="text-[10px] font-mono-tech px-2 py-0.5 rounded bg-amber-500/20 text-amber-300 border border-amber-500/40"> NODE #1 </span> </div> <label class="block text-[11px] font-mono-tech text-slate-300 mb-1"> Corner Banking Angle (θ): <strong id="archBankVal" class="text-cyan-300">15°</strong> </label> <input id="archBankSlider" type="range" min="0" max="32" value="15" oninput="updateSelectedNodeBank(this.value)" class="w-full accent-cyan-400 mb-3 cursor-pointer" /> <label class="block text-[11px] font-mono-tech text-slate-300 mb-1"> AR Track Feature at Node </label> <div class="grid grid-cols-2 gap-1.5 text-[11px] font-mono-tech"> <button onclick="setNodeFeature('NONE')" class="py-1.5 px-2 rounded-lg bg-slate-800 hover:bg-slate-700 text-slate-300 border border-slate-700"> Clean Asphalt </button> <button onclick="setNodeFeature('BOOST')" class="py-1.5 px-2 rounded-lg bg-cyan-500/20 hover:bg-cyan-500/30 text-cyan-300 border border-cyan-500/40"> ⚡ Boost Pad </button> <button onclick="setNodeFeature('ITEM')" class="py-1.5 px-2 rounded-lg bg-fuchsia-500/20 hover:bg-fuchsia-500/30 text-fuchsia-300 border border-fuchsia-500/40"> 🎁 Item Boxes </button> <button onclick="setNodeFeature('RAMP')" class="py-1.5 px-2 rounded-lg bg-amber-500/20 hover:bg-amber-500/30 text-amber-300 border border-amber-500/40"> 🚀 Jump Ramp </button> </div> <div class="mt-3 pt-2.5 border-t border-slate-800 flex gap-1.5"> <button onclick="insertNodeAfterSelected()" class="flex-1 py-1.5 rounded-lg text-[11px] font-mono-tech font-semibold bg-emerald-500/20 hover:bg-emerald-500/30 text-emerald-300 border border-emerald-500/40"> + Split / Add Node </button> <button onclick="removeSelectedNode()" class="px-2.5 py-1.5 rounded-lg text-[11px] font-mono-tech bg-rose-500/20 hover:bg-rose-500/30 text-rose-300 border border-rose-500/40"> Delete </button> </div> </div> <!-- Launch Into AR Visor CTA --> <button onclick="launchCustomTrackInAR()" class="mt-auto w-full py-3 px-4 rounded-2xl font-visor font-black text-xs sm:text-sm tracking-wider bg-gradient-to-r from-cyan-400 via-sky-400 to-fuchsia-400 text-slate-950 shadow-lg hover:brightness-110 transition"> 🏎️ TEST IN AR VISOR HUD → </button> </aside> <!-- CENTER: INTERACTIVE GOLF-COURSE FAIRWAY SPLINE CANVAS --> <div class="lg:col-span-6 relative flex flex-col bg-[#060a12] min-h-[430px]"> <div class="px-3 py-2 bg-[#0a101d] border-b border-slate-800 flex flex-wrap items-center justify-between gap-2 text-[11px] font-mono-tech"> <span class="text-emerald-300">DRAG CONTROL NODES TO SCULPT CATMULL-ROM FAIRWAY SPLINE</span> <span id="archCursorInfo" class="text-slate-400">180m × 120m Former Golf Fairway</span> </div> <div id="archCanvasWrap" class="relative flex-1 w-full h-full"> <canvas id="architectCanvas" class="block w-full h-full cursor-grab"></canvas> </div> </div> <!-- RIGHT SIDEBAR: Z-AXIS CURVATURE, BANKING & POD CLEARANCE HEURISTICS --> <aside class="lg:col-span-3 border-t lg:border-t-0 lg:border-l border-slate-800 bg-[#070c17] p-3.5 flex flex-col gap-3 overflow-y-auto max-h-[calc(100vh-95px)]"> <!-- Safety Gate Status --> <div id="archSafetyCard" class="rounded-xl p-3 border bg-emerald-950/30 border-emerald-500/50"> <div class="flex items-center justify-between"> <span class="text-[10px] font-mono-tech uppercase tracking-widest text-slate-400">Track Safety Heuristic</span> <span id="archSafetyBadge" class="text-[10px] font-mono-tech font-bold px-2 py-0.5 rounded bg-emerald-500 text-slate-950"> APPROVED </span> </div> <div id="archSafetyTitle" class="text-sm font-extrabold text-emerald-300 mt-1"> Z-AXIS DYNAMICS: NOMINAL </div> <p id="archSafetyDesc" class="text-[11px] text-slate-300 mt-0.5 leading-snug"> Curvature R_min, banking lateral friction &amp; WFH pod standoff buffers cleared. </p> </div> <!-- Curvature & Dynamics Telemetry --> <div class="rounded-xl bg-[#0d1424] border border-slate-800 p-3 space-y-2 font-mono-tech"> <div class="text-[11px] uppercase tracking-wider text-slate-400">Spline &amp; Vehicle Dynamics</div> <div class="grid grid-cols-2 gap-2"> <div class="p-2 rounded-lg bg-slate-950 border border-slate-800"> <div class="text-[10px] text-slate-400">Track Length</div> <div id="statTrackLen" class="text-sm font-bold text-white">0 m</div> </div> <div class="p-2 rounded-lg bg-slate-950 border border-slate-800"> <div class="text-[10px] text-slate-400">Min Radius R_min</div> <div id="statMinRadius" class="text-sm font-bold text-cyan-300">0.0 m</div> </div> <div class="p-2 rounded-lg bg-slate-950 border border-slate-800"> <div class="text-[10px] text-slate-400">Max Safe Apex V</div> <div id="statMaxApexV" class="text-sm font-bold text-emerald-300">0 MPH</div> </div> <div class="p-2 rounded-lg bg-slate-950 border border-slate-800"> <div class="text-[10px] text-slate-400">WFH Pod Buffer</div> <div id="statPodDist" class="text-sm font-bold text-amber-300">0.0 m</div> </div> </div> </div> <!-- Diagnostic Feed --> <div class="rounded-xl bg-[#0d1424] border border-slate-800 p-3 flex-1 flex flex-col min-h-[160px]"> <div class="text-[11px] font-mono-tech uppercase tracking-wider text-slate-400 mb-2"> Live Heuristics Feed </div> <div id="archDiagnosticsList" class="space-y-1.5 text-[11px] font-mono-tech overflow-y-auto flex-1"></div> </div> </aside> </section> <!-- ======================================================================= --> <!-- COLLAPSIBLE MATHEMATICAL SPEC & CAN-FD TELEMETRY DRAWER --> <!-- ======================================================================= --> <div id="mathSpecModal" class="hidden fixed inset-0 z-50 bg-black/75 backdrop-blur-sm flex items-center justify-center p-3 sm:p-6"> <div class="visor-glass rounded-2xl max-w-3xl w-full max-h-[88vh] flex flex-col overflow-hidden border border-cyan-400/50"> <div class="px-5 py-3.5 border-b border-slate-800 flex items-center justify-between bg-[#090f1d]"> <div> <span class="text-[10px] font-mono-tech uppercase tracking-widest text-fuchsia-300">albertlane.net/research • 2027 Motorsport Heuristics</span> <h2 class="text-sm sm:text-base font-visor font-bold text-white"> MATHEMATICAL SPECIFICATION &amp; CAN-FD KART TELEMETRY STACK </h2> </div> <button onclick="toggleMathDrawer(false)" class="px-3 py-1 rounded-lg bg-slate-800 hover:bg-slate-700 text-xs font-mono-tech text-slate-200"> [ESC / CLOSE] </button> </div> <div class="p-5 overflow-y-auto space-y-4 text-xs sm:text-sm text-slate-300 leading-relaxed"> <div class="p-3.5 rounded-xl bg-slate-950/90 border border-cyan-500/30"> <h3 class="font-visor font-bold text-cyan-300 text-xs uppercase tracking-wider mb-1"> 1. Centripetal Catmull-Rom Spline &amp; Curvature κ(s) </h3> <p class="text-xs text-slate-400 mb-2"> Kids sculpt control nodes P_i on the former golf fairway. The engine fits a C1-continuous centripetal Catmull-Rom spline r(s) and evaluates instantaneous curvature κ(s) and osculating radius R(s): </p> <div class="font-mono-tech text-xs bg-[#070b14] p-2.5 rounded-lg border border-slate-800 text-cyan-200"> κ(s) = |x'(s)y''(s) - y'(s)x''(s)| / (x'(s)² + y'(s)²)^(3/2) , &nbsp;&nbsp; R_min = min_s (1 / κ(s)) </div> </div> <div class="p-3.5 rounded-xl bg-slate-950/90 border border-amber-500/30"> <h3 class="font-visor font-bold text-amber-300 text-xs uppercase tracking-wider mb-1"> 2. Banked Corner Force Balance &amp; Rollover Standoff </h3> <p class="text-xs text-slate-400 mb-2"> With fairway corner banking angle θ and tire-asphalt static friction μ = 0.85, the maximum non-skid cornering velocity V_max and lateral G-load are bounded by: </p> <div class="font-mono-tech text-xs bg-[#070b14] p-2.5 rounded-lg border border-slate-800 text-amber-200"> V_max(s) = sqrt( g · R(s) · (tan θ + μ) / (1 - μ · tan θ) ) , &nbsp;&nbsp; d_WFH_pod ≥ 8.5 m </div> </div> <div class="p-3.5 rounded-xl bg-slate-950/90 border border-fuchsia-500/30"> <h3 class="font-visor font-bold text-fuchsia-300 text-xs uppercase tracking-wider mb-1"> 3. Pinhole Visor Homography Projection </h3> <p class="text-xs text-slate-400 mb-2"> Every virtual boost chevron, glowing boundary pylon, and floating item cube in world coordinates X_w = (X, Y, Z) is transformed into the driver's head-tracked AR visor frame X_c = R_head(X_w - P_kart) and projected via focal length f: </p> <div class="font-mono-tech text-xs bg-[#070b14] p-2.5 rounded-lg border border-slate-800 text-fuchsia-200"> u = u_0 + f · (X_c / Z_c) , &nbsp;&nbsp; v = v_0 - f · (Y_c / Z_c) &nbsp;&nbsp; (Z_c &gt; 0) </div> </div> <div class="p-3.5 rounded-xl bg-slate-950/90 border border-emerald-500/30"> <h3 class="font-visor font-bold text-emerald-300 text-xs uppercase tracking-wider mb-1"> 4. Closed-Loop CAN-FD Electric Kart Torque Modulation </h3> <p class="text-xs text-slate-400 mb-2"> Physical dual-hub 15 kW electric motors on the go-karts receive real-time torque scaling commands over CAN-FD (10.27.0.0/16 OT VLAN) when the kart intersects AR track triggers: </p> <div class="font-mono-tech text-xs bg-[#070b14] p-2.5 rounded-lg border border-slate-800 text-emerald-200"> τ_cmd(t) = τ_pedal(t) · Γ_item(t) , &nbsp;&nbsp; Γ_item ∈ { 1.45 (Mushroom/Boost), 0.35 (EMP/Banana), 1.00 (Nominal) } </div> </div> </div> </div> </div> <!-- FOOTER LICENSE NOTICE --> <footer class="border-t border-slate-800/90 bg-[#05080f] px-4 py-1.5 text-[10px] font-mono-tech text-slate-500 flex flex-wrap items-center justify-between gap-2 z-20"> <span>© Albert Lane. All Rights Reserved. | Proprietary and Confidential</span> <span>Albert Lane Proprietary Software License • https://albertlane.net</span> </footer> <script> // ========================================================================= // COPYRIGHT © ALBERT LANE. ALL RIGHTS RESERVED. // PROPRIETARY AND CONFIDENTIAL — ALBERT LANE PROPRIETARY SOFTWARE LICENSE. // UNAUTHORIZED USE, COPYING, OR DISTRIBUTION IS PROHIBITED. // LICENSE INQUIRIES: https://albertlane.net // ========================================================================= const GRAVITY = 9.80665; const TIRE_MU = 0.85; const MIN_POD_CLEARANCE_M = 8.5; const TRACK_HALF_WIDTH = 4.6; // 9.2m total racing surface width // Former Golf Course Landmarks (180m x 120m campus coordinates) const CAMPUS_LANDMARKS = [ { id: 'WFH-PODS', label: 'ZONE 5: WFH ACOUSTIC GLASS PODS', x: 18, y: 12, w: 68, h: 16, color: '#10b981' }, { id: 'GRAFFITI', label: 'ZONE 4: MICROLED GRAFFITI SPINE', x: 18, y: 32, w: 68, h: 5, color: '#e879f9' }, { id: 'SKATE-BOWL', label: 'ZONE 1: TONY HAWK VERT BOWL', x: 132, y: 16, w: 34, h: 24, color: '#22d3ee' }, { id: 'LINK-LOGS', label: 'ZONE 3: LINKINGLOGS SANDBOX', x: 96, y: 14, w: 28, h: 18, color: '#fbbf24' } ]; // Item Roulette Catalog const AR_ITEMS = [ { id: 'MUSHROOM', icon: '🍄', name: 'TURBO MUSHROOM', color: '#fbbf24', duration: 2.6, torqueMult: 1.48 }, { id: 'EMP', icon: '⚡', name: 'EMP OVERDRIVE', color: '#22d3ee', duration: 2.4, torqueMult: 1.42 }, { id: 'GRAVITY', icon: '🌀', name: 'GRAVITY GRIP FLIP', color: '#e879f9', duration: 3.5, torqueMult: 1.28 }, { id: 'BANANA', icon: '🍌', name: 'HOLO BANANA TRAP', color: '#facc15', duration: 1.8, torqueMult: 1.32 } ]; // Application State let appState = { mode: 'DRIVER', // 'DRIVER' | 'ARCHITECT' trackName: 'FAIRWAY HYPER-LOOP', controlNodes: [], selectedNodeIdx: 0, draggingNodeIdx: -1, splineSamples: [], // Dense sampled track curve [{x, y, tx, ty, nx, ny, bankRad, curvature, radius, s, feature}] totalLength: 0, trackFeatures: [], // Interactive world objects [{s, offset, type, cooldown}] autopilot: true, race: { s: 0, // Distance along spline (m) lateralOffset: 0, // Offset from centerline (m) speedMps: 18.0, // Current speed (m/s) headingErr: 0, // Visual slip/yaw angle (rad) driftCharge: 0, // 0 to 100 isDrifting: false, driftDir: 0, boostTimer: 0, boostColor: '#22d3ee', activeItemIdx: 0, lap: 1, maxLaps: 3, elapsedSec: 0, lastS: 0, aiKarts: [] } }; const keys = { up: false, down: false, left: false, right: false, drift: false }; const touchKeys = { up: false, left: false, right: false, drift: false }; // ========================================================================= // TRACK PRESETS & SPLINE MATHEMATICS (CATMULL-ROM + CURVATURE + BANKING) // ========================================================================= function loadTrackPreset(presetKey) { if (presetKey === 'HYPER_LOOP') { appState.trackName = 'FAIRWAY HYPER-LOOP'; appState.controlNodes = [ { x: 35, y: 55, bankDeg: 6, feature: 'BOOST' }, { x: 90, y: 52, bankDeg: 10, feature: 'ITEM' }, { x: 152, y: 56, bankDeg: 22, feature: 'NONE' }, { x: 162, y: 92, bankDeg: 24, feature: 'BOOST' }, { x: 112, y: 104, bankDeg: 14, feature: 'ITEM' }, { x: 52, y: 100, bankDeg: 18, feature: 'RAMP' }, { x: 24, y: 80, bankDeg: 20, feature: 'NONE' } ]; } else if (presetKey === 'BOWL_GP') { appState.trackName = 'SKATE BOWL & GRAFFITI GP'; appState.controlNodes = [ { x: 30, y: 46, bankDeg: 4, feature: 'BOOST' }, { x: 86, y: 46, bankDeg: 8, feature: 'ITEM' }, { x: 122, y: 58, bankDeg: 18, feature: 'NONE' }, { x: 156, y: 52, bankDeg: 25, feature: 'BOOST' }, { x: 160, y: 98, bankDeg: 22, feature: 'ITEM' }, { x: 98, y: 92, bankDeg: 14, feature: 'NONE' }, { x: 55, y: 106, bankDeg: 20, feature: 'RAMP' }, { x: 22, y: 78, bankDeg: 18, feature: 'NONE' } ]; } else if (presetKey === 'KID_CHAOS') { appState.trackName = 'KID HAIRPIN CHAOS'; appState.controlNodes = [ { x: 40, y: 34, bankDeg: 2, feature: 'BOOST' }, // Very close to WFH Pods! { x: 105, y: 48, bankDeg: 5, feature: 'ITEM' }, { x: 118, y: 62, bankDeg: 4, feature: 'NONE' }, // Sharp hairpin with low bank { x: 102, y: 72, bankDeg: 4, feature: 'BOOST' }, { x: 155, y: 95, bankDeg: 12, feature: 'RAMP' }, { x: 50, y: 104, bankDeg: 8, feature: 'ITEM' }, { x: 26, y: 68, bankDeg: 6, feature: 'NONE' } ]; } appState.selectedNodeIdx = 0; rebuildSplineAndValidate(); resetRace(); syncArchitectUI(); renderArchitect(); } // Closed Catmull-Rom interpolation helper function catmullRomPoint(p0, p1, p2, p3, t) { const t2 = t * t; const t3 = t2 * t; return { x: 0.5 * ((2 * p1.x) + (-p0.x + p2.x) * t + (2 * p0.x - 5 * p1.x + 4 * p2.x - p3.x) * t2 + (-p0.x + 3 * p1.x - 3 * p2.x + p3.x) * t3), y: 0.5 * ((2 * p1.y) + (-p0.y + p2.y) * t + (2 * p0.y - 5 * p1.y + 4 * p2.y - p3.y) * t2 + (-p0.y + 3 * p1.y - 3 * p2.y + p3.y) * t3) }; } function rebuildSplineAndValidate() { const nodes = appState.controlNodes; const n = nodes.length; if (n < 3) return; const samplesPerSeg = 45; const raw = []; for (let i = 0; i < n; i++) { const p0 = nodes[(i - 1 + n) % n]; const p1 = nodes[i]; const p2 = nodes[(i + 1) % n]; const p3 = nodes[(i + 2) % n]; for (let step = 0; step < samplesPerSeg; step++) { const t = step / samplesPerSeg; const pt = catmullRomPoint(p0, p1, p2, p3, t); const bankDeg = p1.bankDeg * (1 - t) + p2.bankDeg * t; raw.push({ x: pt.x, y: pt.y, bankRad: (bankDeg * Math.PI) / 180, bankDeg: bankDeg, nodeIdx: i, isNodeOrigin: step === 0, feature: step === 0 ? p1.feature : 'NONE' }); } } // Compute arc-length s, unit tangent, normal, curvature kappa(s), and osculating radius R(s) const totalSamples = raw.length; let accumS = 0; const features = []; for (let i = 0; i < totalSamples; i++) { const prev = raw[(i - 1 + totalSamples) % totalSamples]; const curr = raw[i]; const next = raw[(i + 1) % totalSamples]; if (i > 0) { accumS += Math.hypot(curr.x - prev.x, curr.y - prev.y); } curr.s = accumS; const dx = (next.x - prev.x) * 0.5; const dy = (next.y - prev.y) * 0.5; const len = Math.hypot(dx, dy) || 1; curr.tx = dx / len; curr.ty = dy / len; curr.nx = -curr.ty; curr.ny = curr.tx; // Discrete Menger / 3-point curvature kappa = 2*Area / (a*b*c) const ax = curr.x - prev.x, ay = curr.y - prev.y; const bx = next.x - curr.x, by = next.y - curr.y; const cx = next.x - prev.x, cy = next.y - prev.y; const a = Math.hypot(ax, ay) || 0.01; const b = Math.hypot(bx, by) || 0.01; const c = Math.hypot(cx, cy) || 0.01; const cross = Math.abs(ax * by - ay * bx); const kappa = (2 * cross) / (a * b * c); curr.curvature = kappa; curr.radius = kappa > 0.002 ? Math.min(250, 1 / kappa) : 250; if (curr.feature && curr.feature !== 'NONE') { features.push({ s: curr.s, offset: curr.feature === 'ITEM' ? 0 : (i % 2 === 0 ? -1.4 : 1.4), type: curr.feature, cooldown: 0 }); } } const lastPt = raw[totalSamples - 1]; const firstPt = raw[0]; appState.totalLength = accumS + Math.hypot(firstPt.x - lastPt.x, firstPt.y - lastPt.y); appState.splineSamples = raw; appState.trackFeatures = features; evaluateTrackHeuristics(); } function getSampleAtS(sQuery) { const list = appState.splineSamples; if (!list.length) return { x: 50, y: 50, tx: 1, ty: 0, nx: 0, ny: 1, bankRad: 0, bankDeg: 0, radius: 100 }; const L = appState.totalLength; const s = ((sQuery % L) + L) % L; const approxIdx = Math.floor((s / L) * list.length) % list.length; return list[approxIdx]; } function evaluateTrackHeuristics() { let minR = Infinity; let minApexV = Infinity; let minPodBuffer = Infinity; const errors = []; const warnings = []; const podZone = CAMPUS_LANDMARKS[0]; // WFH Acoustic Glass Pods appState.splineSamples.forEach(pt => { if (pt.radius < minR) { minR = pt.radius; } // Banked corner max non-skid velocity: V = sqrt(g * R * (tan(theta) + mu) / (1 - mu * tan(theta))) const tanT = Math.tan(pt.bankRad); const vMax = Math.sqrt((GRAVITY * pt.radius * (tanT + TIRE_MU)) / Math.max(0.2, 1 - TIRE_MU * tanT)); if (vMax < minApexV) { minApexV = vMax; } // Distance from track outer edge to WFH Acoustic Pods rectangle const clampedX = Math.max(podZone.x, Math.min(podZone.x + podZone.w, pt.x)); const clampedY = Math.max(podZone.y, Math.min(podZone.y + podZone.h, pt.y)); const distToPodEdge = Math.hypot(pt.x - clampedX, pt.y - clampedY) - TRACK_HALF_WIDTH; if (distToPodEdge < minPodBuffer) { minPodBuffer = distToPodEdge; } }); const minApexMph = minApexV * 2.23694; if (minR < 11.0) { errors.push(`Tight hairpin radius R_min = ${minR.toFixed(1)}m (< 11.0m minimum kart turning envelope).`); } if (minApexMph < 26.0) { errors.push(`Low-bank corner caps safe apex speed at ${minApexMph.toFixed(0)} MPH — increase banking angle θ.`); } if (minPodBuffer < MIN_POD_CLEARANCE_M) { errors.push(`Track runoff comes within ${Math.max(0, minPodBuffer).toFixed(1)}m of WFH Glass Pods (min ${MIN_POD_CLEARANCE_M}m).`); } if (appState.trackFeatures.filter(f => f.type === 'BOOST').length === 0) { warnings.push('No AR Boost Pads placed — add at least one chevron strip on a straightaway.'); } // Update Architect Right Sidebar UI document.getElementById('statTrackLen').textContent = `${Math.round(appState.totalLength)} m`; document.getElementById('statMinRadius').textContent = `${minR.toFixed(1)} m`; document.getElementById('statMaxApexV').textContent = `${Math.round(minApexMph)} MPH`; document.getElementById('statPodDist').textContent = `${Math.max(0, minPodBuffer).toFixed(1)} m`; const card = document.getElementById('archSafetyCard'); const badge = document.getElementById('archSafetyBadge'); const title = document.getElementById('archSafetyTitle'); const desc = document.getElementById('archSafetyDesc'); if (errors.length === 0) { card.className = 'rounded-xl p-3 border bg-emerald-950/30 border-emerald-500/50'; badge.className = 'text-[10px] font-mono-tech font-bold px-2 py-0.5 rounded bg-emerald-500 text-slate-950'; badge.textContent = 'APPROVED'; title.className = 'text-sm font-extrabold text-emerald-300 mt-1'; title.textContent = 'Z-AXIS DYNAMICS: NOMINAL'; desc.textContent = 'Curvature R_min, banking lateral friction & WFH pod standoff buffers cleared.'; } else { card.className = 'rounded-xl p-3 border bg-rose-950/40 border-rose-500/60'; badge.className = 'text-[10px] font-mono-tech font-bold px-2 py-0.5 rounded bg-rose-500 text-white'; badge.textContent = 'WARNING'; title.className = 'text-sm font-extrabold text-rose-300 mt-1'; title.textContent = 'GEOMETRY / RUNOFF ALERT'; desc.textContent = 'Adjust spline nodes or banking angle before full-speed kart deployment.'; } const diagList = document.getElementById('archDiagnosticsList'); if (errors.length === 0 && warnings.length === 0) { diagList.innerHTML = `<div class="p-2 rounded bg-emerald-950/30 border border-emerald-500/30 text-emerald-300">✓ Clothoid transitions smooth. All 8 electric karts cleared for 48 MPH peak torque.</div>`; } else { diagList.innerHTML = [ ...errors.map(e => `<div class="p-2 rounded bg-rose-950/40 border border-rose-500/50 text-rose-200">ERR: ${e}</div>`), ...warnings.map(w => `<div class="p-2 rounded bg-amber-950/30 border border-amber-500/40 text-amber-200">NOTE: ${w}</div>`) ].join(''); } } // ========================================================================= // RACE SIMULATION & CLOSED-LOOP VEHICLE PHYSICS // ========================================================================= function resetRace() { const r = appState.race; r.s = 0; r.lastS = 0; r.lateralOffset = 0; r.speedMps = appState.autopilot ? 20.5 : 0; r.headingErr = 0; r.driftCharge = 0; r.isDrifting = false; r.boostTimer = 0; r.lap = 1; r.elapsedSec = 0; r.activeItemIdx = 0; // Spawn 7 AI Electric Karts around the track const aiColors = ['#f43f5e', '#38bdf8', '#fbbf24', '#a855f7', '#34d399', '#fb923c', '#f472b6']; r.aiKarts = aiColors.map((col, idx) => ({ name: `KART-0${idx + 2}`, s: (idx + 1) * 14, offset: (idx % 2 === 0 ? -1.8 : 1.8), baseSpeed: 18.2 + (idx % 4) * 1.15, color: col })); document.getElementById('hudTrackTitle').textContent = appState.trackName; updateItemSlotUI(); } function toggleAutopilot() { appState.autopilot = !appState.autopilot; const btn = document.getElementById('btnAutopilot'); if (appState.autopilot) { btn.className = 'px-3 py-1.5 rounded-xl text-xs font-mono-tech font-bold bg-emerald-500 text-slate-950 shadow transition'; btn.textContent = '🤖 AUTOPILOT: ON'; } else { btn.className = 'px-3 py-1.5 rounded-xl text-xs font-mono-tech font-bold bg-slate-800 text-cyan-300 border border-cyan-500/40 transition'; btn.textContent = '🎮 MANUAL DRIVE'; } } function updateItemSlotUI() { const item = AR_ITEMS[appState.race.activeItemIdx]; document.getElementById('hudItemIcon').textContent = item.icon; document.getElementById('hudItemName').textContent = item.name; } function useActiveItem() { const r = appState.race; const item = AR_ITEMS[r.activeItemIdx]; r.boostTimer = item.duration; r.boostColor = item.color; r.speedMps = Math.min(28.5, r.speedMps + 6.5); r.activeItemIdx = (r.activeItemIdx + 1) % AR_ITEMS.length; updateItemSlotUI(); } function stepRacePhysics(dt) { const r = appState.race; const L = appState.totalLength || 300; r.elapsedSec += dt; const currSample = getSampleAtS(r.s); // Update feature cooldowns appState.trackFeatures.forEach(f => { if (f.cooldown > 0) f.cooldown = Math.max(0, f.cooldown - dt); }); if (appState.autopilot) { // Autopilot follows optimal racing line & drifts through tight curves! const targetOffset = Math.sin(r.s * 0.04) * 1.3; r.lateralOffset += (targetOffset - r.lateralOffset) * Math.min(1, dt * 3.5); const isCornering = currSample.radius < 42; if (isCornering) { r.isDrifting = true; r.driftCharge = Math.min(100, r.driftCharge + dt * 52); r.headingErr = (currSample.tx * 0.12); } else { if (r.isDrifting && r.driftCharge > 40) { r.boostTimer = 1.4; r.boostColor = r.driftCharge > 80 ? '#e879f9' : '#fb923c'; } r.isDrifting = false; r.driftCharge = Math.max(0, r.driftCharge - dt * 90); r.headingErr *= 0.88; } const targetSpeed = r.boostTimer > 0 ? 25.8 : (isCornering ? 18.8 : 22.0); r.speedMps += (targetSpeed - r.speedMps) * Math.min(1, dt * 3.2); } else { // Manual Player Controls (Keyboard + Touch) const gas = keys.up || touchKeys.up; const brake = keys.down; const steerLeft = keys.left || touchKeys.left; const steerRight = keys.right || touchKeys.right; const driftHeld = keys.drift || touchKeys.drift; const maxNominalSpeed = r.boostTimer > 0 ? 27.5 : 21.8; if (gas) { r.speedMps += (maxNominalSpeed - r.speedMps) * Math.min(1, dt * 2.4); } else if (brake) { r.speedMps = Math.max(0, r.speedMps - dt * 18.0); } else { r.speedMps = Math.max(0, r.speedMps - dt * 6.5); } const steerInput = (steerRight ? 1 : 0) - (steerLeft ? 1 : 0); // Drift & Mini-Turbo Tier Logic if (driftHeld && r.speedMps > 9.0 && steerInput !== 0) { r.isDrifting = true; r.driftDir = steerInput; r.driftCharge = Math.min(100, r.driftCharge + dt * 48); r.lateralOffset += steerInput * dt * 7.8; r.headingErr = steerInput * 0.24; } else { if (r.isDrifting && r.driftCharge >= 35) { // Release Mini-Turbo! r.boostTimer = r.driftCharge >= 80 ? 2.1 : 1.25; r.boostColor = r.driftCharge >= 80 ? '#e879f9' : '#fb923c'; r.speedMps = Math.min(28.0, r.speedMps + (r.driftCharge >= 80 ? 6.0 : 3.8)); } r.isDrifting = false; r.driftCharge = Math.max(0, r.driftCharge - dt * 110); r.lateralOffset += steerInput * dt * 6.2; r.headingErr += (steerInput * 0.12 - r.headingErr) * Math.min(1, dt * 10); } // Fairway grass slowdown if outside track boundaries if (Math.abs(r.lateralOffset) > TRACK_HALF_WIDTH) { r.speedMps *= Math.pow(0.45, dt); r.lateralOffset = Math.max(-TRACK_HALF_WIDTH - 1.6, Math.min(TRACK_HALF_WIDTH + 1.6, r.lateralOffset)); } } if (r.boostTimer > 0) { r.boostTimer = Math.max(0, r.boostTimer - dt); } // Advance distance s r.lastS = r.s; r.s += r.speedMps * dt; if (r.s >= L) { r.s -= L; r.lap = (r.lap % r.maxLaps) + 1; } // Check collision with AR Boost Pads, Item Boxes & Jump Ramps appState.trackFeatures.forEach(feat => { if (feat.cooldown > 0) return; let ds = Math.abs(r.s - feat.s); if (ds > L / 2) ds = L - ds; if (ds < 2.4 && Math.abs(r.lateralOffset - feat.offset) < 2.2) { feat.cooldown = 3.0; if (feat.type === 'BOOST' || feat.type === 'RAMP') { r.boostTimer = 1.7; r.boostColor = '#22d3ee'; r.speedMps = Math.min(28.5, r.speedMps + 5.5); } else if (feat.type === 'ITEM') { r.activeItemIdx = Math.floor(Math.random() * AR_ITEMS.length); updateItemSlotUI(); } } }); // Advance AI Karts let aheadCount = 0; r.aiKarts.forEach((ai, idx) => { const aiSpeed = ai.baseSpeed + Math.sin(r.elapsedSec * 0.8 + idx) * 1.4; ai.s = (ai.s + aiSpeed * dt) % L; // Compare relative progress const relDist = ((ai.s - r.s + L) % L); if (relDist > 0 && relDist < L * 0.45) { aheadCount++; } }); // Update HUD DOM Elements const mph = Math.round(r.speedMps * 2.23694); const kph = Math.round(r.speedMps * 3.6); const powerKw = ((r.speedMps / 25) * (r.boostTimer > 0 ? 15.0 : 10.8)).toFixed(1); const latG = ((r.speedMps * r.speedMps) / (GRAVITY * Math.max(12, currSample.radius))).toFixed(2); const slipDeg = Math.abs((r.headingErr * 180) / Math.PI).toFixed(1); document.getElementById('hudSpeedMph').textContent = String(mph).padStart(2, '0'); document.getElementById('hudSpeedKph').textContent = kph; document.getElementById('hudTorqueKw').textContent = `${powerKw} kW`; document.getElementById('hudLatG').textContent = `${latG} G`; document.getElementById('hudSlipAngle').textContent = `${slipDeg}°`; document.getElementById('hudBankingReadout').textContent = `BANK: ${Math.round(currSample.bankDeg)}°`; document.getElementById('hudLapText').textContent = `${r.lap} / ${r.maxLaps}`; const posNames = ['1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th']; document.getElementById('hudPosNum').textContent = posNames[Math.min(7, aheadCount)]; const mins = String(Math.floor(r.elapsedSec / 60)).padStart(2, '0'); const secs = (r.elapsedSec % 60).toFixed(2).padStart(5, '0'); document.getElementById('hudTimerText').textContent = `${mins}:${secs}`; // Drift bar & Boost banner const driftBar = document.getElementById('hudDriftBar'); const driftLabel = document.getElementById('hudDriftTierLabel'); driftBar.style.width = `${r.driftCharge}%`; if (r.driftCharge >= 80) { driftBar.style.backgroundColor = '#e879f9'; driftLabel.textContent = 'ULTRA MINI-TURBO READY!'; driftLabel.className = 'font-bold text-fuchsia-300'; } else if (r.driftCharge >= 35) { driftBar.style.backgroundColor = '#fb923c'; driftLabel.textContent = 'SUPER SPARK CHARGE'; driftLabel.className = 'font-bold text-amber-300'; } else { driftBar.style.backgroundColor = '#22d3ee'; driftLabel.textContent = r.isDrifting ? 'CHARGING DRIFT...' : 'DRIFT [SPACE]: READY'; driftLabel.className = 'font-bold text-cyan-300'; } const boostBanner = document.getElementById('activeEffectBanner'); if (r.boostTimer > 0) { boostBanner.classList.remove('hidden'); } else { boostBanner.classList.add('hidden'); } } // ========================================================================= // MODE A RENDERER: FIRST-PERSON 3D AR VISOR & MINI-MAP RADAR // ========================================================================= function renderDriverVisor() { const canvas = document.getElementById('visorCanvas'); if (!canvas) return; const rect = canvas.getBoundingClientRect(); const dpr = window.devicePixelRatio || 1; if (canvas.width !== Math.floor(rect.width * dpr) || canvas.height !== Math.floor(rect.height * dpr)) { canvas.width = Math.floor(rect.width * dpr); canvas.height = Math.floor(rect.height * dpr); } const ctx = canvas.getContext('2d'); ctx.setTransform(dpr, 0, 0, dpr, 0, 0); const W = rect.width; const H = rect.height; const r = appState.race; const playerSample = getSampleAtS(r.s); // Camera world position & forward basis (including slip/yaw angle) const camX = playerSample.x + playerSample.nx * r.lateralOffset; const camY = playerSample.y + playerSample.ny * r.lateralOffset; const cosH = Math.cos(r.headingErr); const sinH = Math.sin(r.headingErr); const fwdX = playerSample.tx * cosH - playerSample.ty * sinH; const fwdY = playerSample.tx * sinH + playerSample.ty * cosH; const rightX = -fwdY; const rightY = fwdX; const horizonY = H * 0.42; const fovScale = W * 0.68; const camHeight = 1.18; // Driver eye height in meters // 1. Pacific Northwest Twilight Sky & Golf Fairway Turf const skyGrad = ctx.createLinearGradient(0, 0, 0, horizonY); skyGrad.addColorStop(0, '#040814'); skyGrad.addColorStop(0.65, '#0b192c'); skyGrad.addColorStop(1, '#133146'); ctx.fillStyle = skyGrad; ctx.fillRect(0, 0, W, horizonY); // Rolling Fairway Grass Ground const turfGrad = ctx.createLinearGradient(0, horizonY, 0, H); turfGrad.addColorStop(0, '#06261c'); turfGrad.addColorStop(0.35, '#093828'); turfGrad.addColorStop(1, '#051c14'); ctx.fillStyle = turfGrad; ctx.fillRect(0, horizonY, W, H - horizonY); // Horizon Silhouettes: Suburban Ridge, Cedar Trees & Glowing WFH Glass Pods drawBackgroundCampusHorizon(ctx, W, horizonY, Math.atan2(fwdY, fwdX)); // Helper: Project world point (wx, wy, wz) to visor screen (sx, sy) const projectWorld = (wx, wy, wz = 0) => { const dx = wx - camX; const dy = wy - camY; const zCam = dx * fwdX + dy * fwdY; // Forward depth const xCam = dx * rightX + dy * rightY; // Lateral offset if (zCam <= 0.6) return null; const sx = W * 0.5 + (xCam / zCam) * fovScale; const sy = horizonY + ((camHeight - wz) / zCam) * fovScale; return { sx, sy, z: zCam }; }; // 2. Slice-by-Slice Forward Track Projection (Painter's Algorithm back-to-front) const numSlices = 68; const stepDist = 1.65; const slices = []; for (let i = 1; i <= numSlices; i++) { const sSample = r.s + i * stepDist; const pt = getSampleAtS(sSample); const bankLift = Math.sin(pt.bankRad) * TRACK_HALF_WIDTH; const pLeft = projectWorld(pt.x - pt.nx * TRACK_HALF_WIDTH, pt.y - pt.ny * TRACK_HALF_WIDTH, -bankLift * 0.35); const pRight = projectWorld(pt.x + pt.nx * TRACK_HALF_WIDTH, pt.y + pt.ny * TRACK_HALF_WIDTH, bankLift * 0.65); const pCenter = projectWorld(pt.x, pt.y, 0); if (pLeft && pRight && pCenter) { slices.push({ i, sSample, pt, pLeft, pRight, pCenter }); } } // Draw Asphalt Ribbon & Glowing AR Curbs back-to-front for (let idx = slices.length - 1; idx >= 1; idx--) { const far = slices[idx]; const near = slices[idx - 1]; const stripe = Math.floor(far.sSample / 3.3) % 2 === 0; // Track surface quad ctx.fillStyle = stripe ? '#111827' : '#0d1320'; ctx.beginPath(); ctx.moveTo(near.pLeft.sx, near.pLeft.sy); ctx.lineTo(near.pRight.sx, near.pRight.sy); ctx.lineTo(far.pRight.sx, far.pRight.sy); ctx.lineTo(far.pLeft.sx, far.pLeft.sy); ctx.closePath(); ctx.fill(); // AR Neon Boundary Curbs (Alternating Cyan & Magenta) ctx.strokeStyle = stripe ? '#22d3ee' : '#e879f9'; ctx.lineWidth = Math.max(1.5, 22 / near.pCenter.z); ctx.beginPath(); ctx.moveTo(near.pLeft.sx, near.pLeft.sy); ctx.lineTo(far.pLeft.sx, far.pLeft.sy); ctx.moveTo(near.pRight.sx, near.pRight.sy); ctx.lineTo(far.pRight.sx, far.pRight.sy); ctx.stroke(); // Optimal AR Apex Racing Line (center-to-apex holographic guide) ctx.strokeStyle = 'rgba(16, 185, 129, 0.45)'; ctx.lineWidth = Math.max(1, 10 / near.pCenter.z); ctx.beginPath(); ctx.moveTo(near.pCenter.sx, near.pCenter.sy); ctx.lineTo(far.pCenter.sx, far.pCenter.sy); ctx.stroke(); } // 3. Project AR Track Features (Boost Chevrons, Floating Holographic Item Cubes, Jump Ramps) const L = appState.totalLength; appState.trackFeatures.forEach(feat => { const aheadDist = ((feat.s - r.s + L) % L); if (aheadDist > 1.5 && aheadDist < numSlices * stepDist) { const pt = getSampleAtS(feat.s); const wx = pt.x + pt.nx * feat.offset; const wy = pt.y + pt.ny * feat.offset; if (feat.type === 'BOOST' || feat.type === 'RAMP') { const p0 = projectWorld(wx, wy, 0.04); const p1 = projectWorld(wx + pt.tx * 2.5, wy + pt.ty * 2.5, feat.type === 'RAMP' ? 0.55 : 0.04); if (p0 && p1) { const padW = Math.max(10, (1.5 / p0.z) * fovScale); ctx.save(); ctx.fillStyle = feat.type === 'RAMP' ? 'rgba(251, 191, 36, 0.75)' : 'rgba(34, 211, 238, 0.78)'; ctx.strokeStyle = '#ffffff'; ctx.lineWidth = 1.5; ctx.beginPath(); ctx.moveTo(p0.sx - padW, p0.sy); ctx.lineTo(p0.sx + padW, p0.sy); ctx.lineTo(p1.sx + padW * 0.85, p1.sy); ctx.lineTo(p1.sx - padW * 0.85, p1.sy); ctx.closePath(); ctx.fill(); ctx.stroke(); ctx.restore(); } } else if (feat.type === 'ITEM') { const bobZ = 0.95 + Math.sin(r.elapsedSec * 5 + feat.s) * 0.18; const pCube = projectWorld(wx, wy, bobZ); if (pCube) { const size = Math.max(10, (1.15 / pCube.z) * fovScale); ctx.save(); ctx.translate(pCube.sx, pCube.sy); ctx.rotate(r.elapsedSec * 2.2); const hue = (r.elapsedSec * 140 + feat.s * 10) % 360; ctx.fillStyle = `hsla(${hue}, 92%, 62%, 0.42)`; ctx.strokeStyle = `hsl(${hue}, 95%, 72%)`; ctx.lineWidth = 2; ctx.fillRect(-size / 2, -size / 2, size, size); ctx.strokeRect(-size / 2, -size / 2, size, size); ctx.fillStyle = '#ffffff'; ctx.font = `900 ${Math.max(9, Math.floor(size * 0.55))}px Orbitron, sans-serif`; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; ctx.fillText('?', 0, 1); ctx.restore(); } } } }); // 4. Project Rival Electric Go-Karts Ahead const visibleAi = r.aiKarts .map(ai => { const distAhead = ((ai.s - r.s + L) % L); return { ai, distAhead }; }) .filter(item => item.distAhead > 1.2 && item.distAhead < numSlices * stepDist) .sort((a, b) => b.distAhead - a.distAhead); visibleAi.forEach(({ ai }) => { const pt = getSampleAtS(ai.s); const wx = pt.x + pt.nx * ai.offset; const wy = pt.y + pt.ny * ai.offset; const proj = projectWorld(wx, wy, 0.35); if (proj) { const kw = Math.max(14, (1.45 / proj.z) * fovScale); const kh = kw * 0.52; ctx.save(); // Kart chassis ctx.fillStyle = ai.color; ctx.strokeStyle = '#0f172a'; ctx.lineWidth = 2; ctx.beginPath(); ctx.roundRect(proj.sx - kw / 2, proj.sy - kh / 2, kw, kh, 5); ctx.fill(); ctx.stroke(); // Rear tires ctx.fillStyle = '#020617'; ctx.fillRect(proj.sx - kw * 0.56, proj.sy - kh * 0.25, kw * 0.16, kh * 0.55); ctx.fillRect(proj.sx + kw * 0.40, proj.sy - kh * 0.25, kw * 0.16, kh * 0.55); // AR Target Lock Tag above rival kart if (kw > 18) { ctx.fillStyle = 'rgba(15, 23, 42, 0.8)'; ctx.fillRect(proj.sx - 24, proj.sy - kh - 14, 48, 12); ctx.fillStyle = '#22d3ee'; ctx.font = '700 8px "JetBrains Mono", monospace'; ctx.textAlign = 'center'; ctx.fillText(ai.name, proj.sx, proj.sy - kh - 5); } ctx.restore(); } }); // 5. Speed Lines & Boost Visor Vignette if (r.boostTimer > 0) { ctx.save(); const edgeGrad = ctx.createRadialGradient(W / 2, H / 2, W * 0.28, W / 2, H / 2, W * 0.62); edgeGrad.addColorStop(0, 'rgba(0,0,0,0)'); edgeGrad.addColorStop(1, r.boostColor + '44'); ctx.fillStyle = edgeGrad; ctx.fillRect(0, 0, W, H); ctx.restore(); } // 6. Player Electric Go-Kart Nose Cone & Drift Sparks (Bottom Center Foreground) drawPlayerKartForeground(ctx, W, H, r); // 7. Render Mini-Map Radar renderMiniMapRadar(); } function drawBackgroundCampusHorizon(ctx, W, horizonY, headingAngle) { const shift = ((headingAngle / (Math.PI * 2)) * W * 1.5) % W; ctx.save(); // Rolling Golf Fairway Hills ctx.fillStyle = '#08201a'; ctx.beginPath(); ctx.moveTo(0, horizonY); for (let x = 0; x <= W + 40; x += 40) { const h = Math.sin((x + shift) * 0.008) * 18 + Math.cos((x + shift) * 0.015) * 10 + 26; ctx.lineTo(x, horizonY - h); } ctx.lineTo(W, horizonY); ctx.closePath(); ctx.fill(); // Glowing WFH Glass Pods & Graffiti Spine silhouettes on the ridge for (let i = 0; i < 6; i++) { const bx = (((i * 260 - shift) % (W + 300)) + (W + 300)) % (W + 300) - 100; ctx.fillStyle = i % 2 === 0 ? 'rgba(16, 185, 129, 0.16)' : 'rgba(232, 121, 249, 0.18)'; ctx.strokeStyle = i % 2 === 0 ? 'rgba(52, 211, 153, 0.45)' : 'rgba(232, 121, 249, 0.5)'; ctx.lineWidth = 1; ctx.fillRect(bx, horizonY - 22, 54, 16); ctx.strokeRect(bx, horizonY - 22, 54, 16); } ctx.restore(); } function drawPlayerKartForeground(ctx, W, H, r) { const cx = W * 0.5 + r.headingErr * 160; const cy = H - 36 + Math.sin(r.elapsedSec * 28) * (r.speedMps > 2 ? 1.5 : 0); ctx.save(); // Front Tires ctx.fillStyle = '#090d16'; ctx.strokeStyle = '#334155'; ctx.lineWidth = 2; ctx.beginPath(); ctx.roundRect(cx - 92, cy - 16, 26, 42, 6); ctx.roundRect(cx + 66, cy - 16, 26, 42, 6); ctx.fill(); ctx.stroke(); // Sleek Electric Kart Aero Nose Cone const bodyGrad = ctx.createLinearGradient(cx, cy - 28, cx, cy + 28); bodyGrad.addColorStop(0, '#22d3ee'); bodyGrad.addColorStop(1, '#0284c7'); ctx.fillStyle = bodyGrad; ctx.beginPath(); ctx.moveTo(cx - 24, cy - 24); ctx.lineTo(cx + 24, cy - 24); ctx.lineTo(cx + 58, cy + 26); ctx.lineTo(cx - 58, cy + 26); ctx.closePath(); ctx.fill(); // Visor AR Centerline Reticle ctx.strokeStyle = 'rgba(34, 211, 238, 0.55)'; ctx.lineWidth = 1.5; ctx.beginPath(); ctx.moveTo(cx - 16, cy - 36); ctx.lineTo(cx, cy - 44); ctx.lineTo(cx + 16, cy - 36); ctx.stroke(); // Drift Sparks Emitter if (r.isDrifting && r.driftCharge > 10) { const sparkCol = r.driftCharge >= 80 ? '#e879f9' : (r.driftCharge >= 35 ? '#fb923c' : '#22d3ee'); ctx.fillStyle = sparkCol; for (let i = 0; i < 10; i++) { const sx = cx + (i % 2 === 0 ? -78 : 78) + (Math.random() - 0.5) * 26; const sy = cy + 6 + (Math.random() - 0.5) * 20; ctx.beginPath(); ctx.arc(sx, sy, 2.2 + Math.random() * 2.5, 0, Math.PI * 2); ctx.fill(); } } ctx.restore(); } function renderMiniMapRadar() { const mc = document.getElementById('miniMapCanvas'); if (!mc) return; const ctx = mc.getContext('2d'); const W = mc.width; const H = mc.height; ctx.clearRect(0, 0, W, H); const scaleX = (W - 18) / 180; const scaleY = (H - 18) / 120; const scale = Math.min(scaleX, scaleY); const ox = (W - 180 * scale) / 2; const oy = (H - 120 * scale) / 2; // Track loop const pts = appState.splineSamples; if (pts.length > 2) { ctx.strokeStyle = '#334155'; ctx.lineWidth = 4; ctx.beginPath(); pts.forEach((p, idx) => { const px = ox + p.x * scale; const py = oy + p.y * scale; if (idx === 0) ctx.moveTo(px, py); else ctx.lineTo(px, py); }); ctx.closePath(); ctx.stroke(); } // AI Karts dots appState.race.aiKarts.forEach(ai => { const pt = getSampleAtS(ai.s); ctx.fillStyle = ai.color; ctx.beginPath(); ctx.arc(ox + pt.x * scale, oy + pt.y * scale, 2.2, 0, Math.PI * 2); ctx.fill(); }); // Player Kart dot const pPt = getSampleAtS(appState.race.s); ctx.fillStyle = '#22d3ee'; ctx.strokeStyle = '#ffffff'; ctx.lineWidth = 1.5; ctx.beginPath(); ctx.arc(ox + pPt.x * scale, oy + pPt.y * scale, 3.6, 0, Math.PI * 2); ctx.fill(); ctx.stroke(); } // ========================================================================= // MODE B RENDERER & INTERACTION: KID TRACK ARCHITECT STUDIO // ========================================================================= function getArchitectTransform() { const canvas = document.getElementById('architectCanvas'); const rect = canvas.getBoundingClientRect(); const pad = 26; const scale = Math.min((rect.width - pad * 2) / 180, (rect.height - pad * 2) / 120); const ox = (rect.width - 180 * scale) / 2; const oy = (rect.height - 120 * scale) / 2; return { scale, ox, oy, W: rect.width, H: rect.height }; } function renderArchitect() { const canvas = document.getElementById('architectCanvas'); if (!canvas) return; const rect = canvas.getBoundingClientRect(); if (rect.width === 0) return; const dpr = window.devicePixelRatio || 1; canvas.width = Math.floor(rect.width * dpr); canvas.height = Math.floor(rect.height * dpr); const ctx = canvas.getContext('2d'); ctx.setTransform(dpr, 0, 0, dpr, 0, 0); const t = getArchitectTransform(); // Background ctx.fillStyle = '#060c14'; ctx.fillRect(0, 0, t.W, t.H); // Golf Course Fairway Boundary ctx.fillStyle = '#081d17'; ctx.strokeStyle = '#1e3a32'; ctx.lineWidth = 2; ctx.fillRect(t.ox, t.oy, 180 * t.scale, 120 * t.scale); ctx.strokeRect(t.ox, t.oy, 180 * t.scale, 120 * t.scale); // 10m Survey Grid ctx.strokeStyle = 'rgba(30, 58, 50, 0.55)'; ctx.lineWidth = 1; for (let x = 0; x <= 180; x += 10) { ctx.beginPath(); ctx.moveTo(t.ox + x * t.scale, t.oy); ctx.lineTo(t.ox + x * t.scale, t.oy + 120 * t.scale); ctx.stroke(); } for (let y = 0; y <= 120; y += 10) { ctx.beginPath(); ctx.moveTo(t.ox, t.oy + y * t.scale); ctx.lineTo(t.ox + 180 * t.scale, t.oy + y * t.scale); ctx.stroke(); } // Former Golf Course Landmarks (WFH Pods, Graffiti Wall, Skate Bowl, LinkingLogs) CAMPUS_LANDMARKS.forEach(lm => { const lx = t.ox + lm.x * t.scale; const ly = t.oy + lm.y * t.scale; const lw = lm.w * t.scale; const lh = lm.h * t.scale; ctx.fillStyle = lm.color + '1c'; ctx.strokeStyle = lm.color + '88'; ctx.setLineDash([4, 3]); ctx.fillRect(lx, ly, lw, lh); ctx.strokeRect(lx, ly, lw, lh); ctx.setLineDash([]); ctx.fillStyle = lm.color; ctx.font = '700 9px "JetBrains Mono", monospace'; ctx.fillText(lm.label, lx + 5, ly + 11); }); // Draw Catmull-Rom Track Ribbon const pts = appState.splineSamples; if (pts.length > 2) { ctx.save(); ctx.lineCap = 'round'; ctx.lineJoin = 'round'; ctx.strokeStyle = '#1e293b'; ctx.lineWidth = TRACK_HALF_WIDTH * 2 * t.scale; ctx.beginPath(); pts.forEach((p, idx) => { const sx = t.ox + p.x * t.scale; const sy = t.oy + p.y * t.scale; if (idx === 0) ctx.moveTo(sx, sy); else ctx.lineTo(sx, sy); }); ctx.closePath(); ctx.stroke(); // Centerline colored by local corner curvature / banking safety for (let i = 0; i < pts.length; i++) { const p0 = pts[i]; const p1 = pts[(i + 1) % pts.length]; ctx.strokeStyle = p0.radius < 11.0 ? '#f43f5e' : (p0.bankDeg >= 16 ? '#e879f9' : '#22d3ee'); ctx.lineWidth = 2.5; ctx.beginPath(); ctx.moveTo(t.ox + p0.x * t.scale, t.oy + p0.y * t.scale); ctx.lineTo(t.ox + p1.x * t.scale, t.oy + p1.y * t.scale); ctx.stroke(); } ctx.restore(); } // Draw Draggable Control Nodes appState.controlNodes.forEach((node, idx) => { const nx = t.ox + node.x * t.scale; const ny = t.oy + node.y * t.scale; const isSel = idx === appState.selectedNodeIdx; ctx.save(); ctx.fillStyle = isSel ? '#fbbf24' : '#0f172a'; ctx.strokeStyle = isSel ? '#ffffff' : '#22d3ee'; ctx.lineWidth = isSel ? 2.5 : 2; ctx.beginPath(); ctx.arc(nx, ny, isSel ? 8.5 : 6.5, 0, Math.PI * 2); ctx.fill(); ctx.stroke(); // Node index + banking + feature pill const featIcon = node.feature === 'BOOST' ? '⚡' : (node.feature === 'ITEM' ? '🎁' : (node.feature === 'RAMP' ? '🚀' : '')); ctx.fillStyle = '#f8fafc'; ctx.font = '700 10px "JetBrains Mono", monospace'; ctx.fillText(`#${idx + 1} (${node.bankDeg}°) ${featIcon}`, nx + 11, ny + 3); ctx.restore(); }); } function syncArchitectUI() { const node = appState.controlNodes[appState.selectedNodeIdx]; if (!node) return; document.getElementById('archNodeBadge').textContent = `NODE #${appState.selectedNodeIdx + 1}`; document.getElementById('archBankVal').textContent = `${node.bankDeg}°`; document.getElementById('archBankSlider').value = node.bankDeg; } function updateSelectedNodeBank(val) { const node = appState.controlNodes[appState.selectedNodeIdx]; if (!node) return; node.bankDeg = Number(val); document.getElementById('archBankVal').textContent = `${node.bankDeg}°`; rebuildSplineAndValidate(); renderArchitect(); } function setNodeFeature(feat) { const node = appState.controlNodes[appState.selectedNodeIdx]; if (!node) return; node.feature = feat; rebuildSplineAndValidate(); renderArchitect(); } function insertNodeAfterSelected() { const nodes = appState.controlNodes; const i = appState.selectedNodeIdx; const next = nodes[(i + 1) % nodes.length]; const curr = nodes[i]; nodes.splice(i + 1, 0, { x: Math.round((curr.x + next.x) / 2), y: Math.round((curr.y + next.y) / 2), bankDeg: Math.round((curr.bankDeg + next.bankDeg) / 2), feature: 'NONE' }); appState.selectedNodeIdx = i + 1; rebuildSplineAndValidate(); syncArchitectUI(); renderArchitect(); } function removeSelectedNode() { if (appState.controlNodes.length <= 4) return; appState.controlNodes.splice(appState.selectedNodeIdx, 1); appState.selectedNodeIdx = Math.max(0, appState.selectedNodeIdx - 1); rebuildSplineAndValidate(); syncArchitectUI(); renderArchitect(); } function setupArchitectInteractions() { const canvas = document.getElementById('architectCanvas'); const getEventWorld = (e) => { const rect = canvas.getBoundingClientRect(); const cx = e.touches ? e.touches[0].clientX : e.clientX; const cy = e.touches ? e.touches[0].clientY : e.clientY; const t = getArchitectTransform(); return { wx: (cx - rect.left - t.ox) / t.scale, wy: (cy - rect.top - t.oy) / t.scale }; }; const onDown = (e) => { const { wx, wy } = getEventWorld(e); let bestIdx = -1; let bestDist = 7.5; // meters hit radius appState.controlNodes.forEach((n, idx) => { const d = Math.hypot(n.x - wx, n.y - wy); if (d < bestDist) { bestDist = d; bestIdx = idx; } }); if (bestIdx !== -1) { appState.selectedNodeIdx = bestIdx; appState.draggingNodeIdx = bestIdx; syncArchitectUI(); renderArchitect(); } }; const onMove = (e) => { const { wx, wy } = getEventWorld(e); const clampedX = Math.max(6, Math.min(174, wx)); const clampedY = Math.max(6, Math.min(114, wy)); document.getElementById('archCursorInfo').textContent = `FAIRWAY POS: (${clampedX.toFixed(1)}m, ${clampedY.toFixed(1)}m)`; if (appState.draggingNodeIdx !== -1) { e.preventDefault(); const node = appState.controlNodes[appState.draggingNodeIdx]; node.x = Math.round(clampedX * 2) / 2; node.y = Math.round(clampedY * 2) / 2; rebuildSplineAndValidate(); renderArchitect(); } }; const onUp = () => { appState.draggingNodeIdx = -1; }; canvas.addEventListener('mousedown', onDown); canvas.addEventListener('mousemove', onMove); window.addEventListener('mouseup', onUp); canvas.addEventListener('touchstart', onDown, { passive: false }); canvas.addEventListener('touchmove', onMove, { passive: false }); window.addEventListener('touchend', onUp); } // ========================================================================= // MODE SWITCHING, KEYBOARD CONTROLS & ANIMATION LOOP // ========================================================================= function switchMode(mode) { appState.mode = mode; const vDriver = document.getElementById('viewDriver'); const vArch = document.getElementById('viewArchitect'); const bDriver = document.getElementById('btnModeDriver'); const bArch = document.getElementById('btnModeArchitect'); if (mode === 'DRIVER') { vDriver.classList.remove('hidden'); vArch.classList.add('hidden'); bDriver.className = 'px-3 py-1.5 rounded-lg text-xs font-visor font-bold tracking-wide transition bg-cyan-400 text-slate-950 shadow'; bArch.className = 'px-3 py-1.5 rounded-lg text-xs font-visor font-bold tracking-wide transition text-slate-300 hover:text-white'; } else { vDriver.classList.add('hidden'); vArch.classList.remove('hidden'); bArch.className = 'px-3 py-1.5 rounded-lg text-xs font-visor font-bold tracking-wide transition bg-cyan-400 text-slate-950 shadow'; bDriver.className = 'px-3 py-1.5 rounded-lg text-xs font-visor font-bold tracking-wide transition text-slate-300 hover:text-white'; renderArchitect(); } } function launchCustomTrackInAR() { appState.trackName = 'CUSTOM KID CIRCUIT'; rebuildSplineAndValidate(); resetRace(); switchMode('DRIVER'); } function toggleMathDrawer(show) { const modal = document.getElementById('mathSpecModal'); if (show) modal.classList.remove('hidden'); else modal.classList.add('hidden'); } function setupKeyboardControls() { window.addEventListener('keydown', (e) => { if (e.key === 'Escape') toggleMathDrawer(false); if (e.key === 'w' || e.key === 'W' || e.key === 'ArrowUp') keys.up = true; if (e.key === 's' || e.key === 'S' || e.key === 'ArrowDown') keys.down = true; if (e.key === 'a' || e.key === 'A' || e.key === 'ArrowLeft') keys.left = true; if (e.key === 'd' || e.key === 'D' || e.key === 'ArrowRight') keys.right = true; if (e.code === 'Space') { if (appState.mode === 'DRIVER') e.preventDefault(); keys.drift = true; } if ((e.key === 'e' || e.key === 'E' || e.key === 'Shift') && appState.mode === 'DRIVER') { useActiveItem(); } }); window.addEventListener('keyup', (e) => { if (e.key === 'w' || e.key === 'W' || e.key === 'ArrowUp') keys.up = false; if (e.key === 's' || e.key === 'S' || e.key === 'ArrowDown') keys.down = false; if (e.key === 'a' || e.key === 'A' || e.key === 'ArrowLeft') keys.left = false; if (e.key === 'd' || e.key === 'D' || e.key === 'ArrowRight') keys.right = false; if (e.code === 'Space') keys.drift = false; }); } let lastFrameTime = performance.now(); function mainLoop(now) { const dt = Math.min(0.05, (now - lastFrameTime) / 1000); lastFrameTime = now; if (appState.mode === 'DRIVER') { stepRacePhysics(dt); renderDriverVisor(); } requestAnimationFrame(mainLoop); } window.onload = () => { loadTrackPreset('HYPER_LOOP'); setupArchitectInteractions(); setupKeyboardControls(); window.addEventListener('resize', () => { if (appState.mode === 'ARCHITECT') renderArchitect(); }); requestAnimationFrame(mainLoop); }; </script> </body> </html>