Ling 3.2 Flash: Four HTML Benchmarks, Original Files & Browser Checks

A glass crane, procedural globe, wizard adventure, and interrupted saber game—tested sequentially through the free route.
Accelerated Logic AI
Model, route, and settings
inclusionai/ling-3.2-flash:free with a 1,048,576-token context window, a 262,144-token maximum completion listing, and zero input/output token prices. The catalog lists text and image input and text output; our tests used text only. These are catalog limits, not measured long-context or vision results. Read our catalog snapshot. We used an API key: free token pricing does not mean unlimited availability or no sign-up.article-html-v2-2026-11-11 prompt pack: an SVG glass crane, a procedural Three.js globe, a floating-island wizard adventure, and Neon Saber Arena with combat and autonomous play. The Three.js prompts pin r170 and prohibit external image assets. Read all four exact prompts. This is an HTML artifact evaluation, not a full LogicMark suite run.Recorded delivery
| Task | Request duration | Saved HTML | Finish | Delivery |
|---|---|---|---|---|
| Glass crane | 151 s | 15,332 bytes | stop | Complete document |
| Procedural globe | 213 s | 15,681 bytes | stop | Complete document |
| Wizard islands | 437 s | 23,680 bytes | stop | Complete document |
| Neon Saber Arena | 500 s | 27,851 bytes | error | Incomplete script |
1. Glass sphere and origami crane
Ling 3.2 Flash original SVG crane in a shaded glass sphere
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Glass Sphere with Origami Crane</title>
<style>
:root{
--ink:#e9effb;
--ink-dim:#9fb0cc;
--bg0:#04060d;
--bg1:#0b1226;
}
*{margin:0;padding:0;box-sizing:border-box}
html,body{height:100%}
body{
min-height:100vh;
display:flex;
flex-direction:column;
align-items:center;
justify-content:center;
gap:clamp(14px,2.4vh,26px);
padding:clamp(16px,4vw,48px);
background:
radial-gradient(1100px 700px at 50% 18%, #16224a 0%, #0b1226 45%, var(--bg0) 100%);
font-family:Georgia,'Times New Roman',serif;
color:var(--ink);
overflow-x:hidden;
}
.stage{
width:min(78vmin,560px);
aspect-ratio:1/1;
filter:drop-shadow(0 30px 60px rgba(0,0,0,.55));
}
svg{display:block;width:100%;height:auto}
.caption{
text-align:center;
letter-spacing:.28em;
text-transform:uppercase;
font-size:clamp(.6rem,1.6vmin,.78rem);
color:var(--ink-dim);
}
.caption b{
display:block;
font-size:clamp(.95rem,2.6vmin,1.25rem);
letter-spacing:.12em;
color:var(--ink);
font-weight:normal;
margin-bottom:.5em;
}
.tw{animation:tw 4s ease-in-out infinite}
.tw.d2{animation-delay:1.4s}
.tw.d3{animation-delay:2.6s}
@keyframes tw{0%,100%{opacity:.15}50%{opacity:.9}}
@media (prefers-reduced-motion: no-preference){
.float{animation:float 7s ease-in-out infinite}
.shadowPulse{animation:sh 7s ease-in-out infinite;transform-box:fill-box;transform-origin:center}
.glowPulse{animation:gl 7s ease-in-out infinite;transform-box:fill-box;transform-origin:center}
.caustic{animation:ca 9s ease-in-out infinite}
@keyframes float{0%,100%{transform:translateY(0)}50%{transform:translateY(-10px)}}
@keyframes sh{0%,100%{transform:scale(1);opacity:.85}50%{transform:scale(.93);opacity:.6}}
@keyframes gl{0%,100%{transform:scale(1);opacity:.5}50%{transform:scale(1.06);opacity:.75}}
@keyframes ca{0%,100%{opacity:.35}50%{opacity:.6}}
}
</style>
</head>
<body>
<div class="stage">
<svg viewBox="0 0 800 800" role="img" aria-labelledby="t d" xmlns="http://www.w3.org/2000/svg">
<title id="t">A folded paper origami crane suspended inside a photorealistic glass sphere</title>
<desc id="d">An intricate illustration of a cream-colored origami crane with faceted paper folds and fine crease lines, floating inside a transparent glass orb. The sphere shows layered reflections, a bright specular highlight, refracted light caustics on the surface below, and a soft ambient glow against a deep midnight-blue backdrop.</desc>
<defs>
<!-- background & atmosphere -->
<radialGradient id="bgGlow" cx="50%" cy="42%" r="65%">
<stop offset="0%" stop-color="#2a3d6e" stop-opacity=".55"/>
<stop offset="55%" stop-color="#141d3d" stop-opacity=".25"/>
<stop offset="100%" stop-color="#04060d" stop-opacity="0"/>
</radialGradient>
<radialGradient id="halo" cx="50%" cy="50%" r="50%">
<stop offset="0%" stop-color="#7fa8ff" stop-opacity=".28"/>
<stop offset="60%" stop-color="#5f83d6" stop-opacity=".10"/>
<stop offset="100%" stop-color="#5f83d6" stop-opacity="0"/>
</radialGradient>
<radialGradient id="floor" cx="50%" cy="50%" r="50%">
<stop offset="0%" stop-color="#000" stop-opacity=".55"/>
<stop offset="70%" stop-color="#000" stop-opacity=".22"/>
<stop offset="100%" stop-color="#000" stop-opacity="0"/>
</radialGradient>
<!-- glass body -->
<radialGradient id="glassBody" cx="36%" cy="28%" r="80%">
<stop offset="0%" stop-color="#ffffff" stop-opacity=".10"/>
<stop offset="35%" stop-color="#bcd6ff" stop-opacity=".05"/>
<stop offset="70%" stop-color="#7fa4e6" stop-opacity=".07"/>
<stop offset="92%" stop-color="#3a5aa0" stop-opacity=".22"/>
<stop offset="100%" stop-color="#16244a" stop-opacity=".45"/>
</radialGradient>
<radialGradient id="glassInner" cx="50%" cy="45%" r="60%">
<stop offset="0%" stop-color="#dfeaff" stop-opacity="0"/>
<stop offset="78%" stop-color="#a9c4f2" stop-opacity=".04"/>
<stop offset="100%" stop-color="#8fb0e8" stop-opacity=".16"/>
</radialGradient>
<linearGradient id="rim" x1="0" y1="0" x2="1" y2="1">
<stop offset="0%" stop-color="#ffffff" stop-opacity=".9"/>
<stop offset="30%" stop-color="#cfe0ff" stop-opacity=".25"/>
<stop offset="60%" stop-color="#8fb0e8" stop-opacity=".10"/>
<stop offset="100%" stop-color="#ffffff" stop-opacity=".55"/>
</linearGradient>
<radialGradient id="spec" cx="50%" cy="50%" r="50%">
<stop offset="0%" stop-color="#ffffff" stop-opacity=".95"/>
<stop offset="45%" stop-color="#eaf2ff" stop-opacity=".45"/>
<stop offset="100%" stop-color="#eaf2ff" stop-opacity="0"/>
</radialGradient>
<linearGradient id="band" x1="0" y1="0" x2="1" y2="0">
<stop offset="0%" stop-color="#ffffff" stop-opacity="0"/>
<stop offset="45%" stop-color="#ffffff" stop-opacity=".5"/>
<stop offset="55%" stop-color="#ffffff" stop-opacity=".5"/>
<stop offset="100%" stop-color="#ffffff" stop-opacity="0"/>
</linearGradient>
<radialGradient id="caustic" cx="50%" cy="50%" r="50%">
<stop offset="0%" stop-color="#bfe0ff" stop-opacity=".55"/>
<stop offset="55%" stop-color="#8fb8f0" stop-opacity=".22"/>
<stop offset="100%" stop-color="#8fb8f0" stop-opacity="0"/>
</radialGradient>
<!-- paper -->
<linearGradient id="pA" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#fffdf6"/><stop offset="100%" stop-color="#f0e6cf"/></linearGradient>
<linearGradient id="pB" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#f4ead2"/><stop offset="100%" stop-color="#e2d2ae"/></linearGradient>
<linearGradient id="pC" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#e9dcc0"/><stop offset="100%" stop-color="#d3c096"/></linearGradient>
<linearGradient id="pD" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#d9c9a4"/><stop offset="100%" stop-color="#bfa87a"/></linearGradient>
<linearGradient id="pE" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#cbb98f"/><stop offset="100%" stop-color="#a8946a"/></linearGradient>
<linearGradient id="pF" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#b3a077"/><stop offset="100%" stop-color="#8f7c55"/></linearGradient>
<linearGradient id="pNeck" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#fdf8ec"/><stop offset="100%" stop-color="#e8dcc0"/></linearGradient>
<linearGradient id="pNeckSh" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#e2d4b2"/><stop offset="100%" stop-color="#c4ae82"/></linearGradient>
<linearGradient id="pTail" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#f6eeda"/><stop offset="100%" stop-color="#dccca6"/></linearGradient>
<linearGradient id="pTailSh" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#d8c8a2"/><stop offset="100%" stop-color="#b39d6e"/></linearGradient>
<linearGradient id="pWingL" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#fffef9"/><stop offset="100%" stop-color="#efe3c8"/></linearGradient>
<linearGradient id="pWingL2" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#f2e8d0"/><stop offset="100%" stop-color="#dccaa4"/></linearGradient>
<linearGradient id="pWingR" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#e6d8b6"/><stop offset="100%" stop-color="#c9b384"/></linearGradient>
<linearGradient id="pWingR2" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#d3c29a"/><stop offset="100%" stop-color="#ab9468"/></linearGradient>
<linearGradient id="pHead" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#fffdf4"/><stop offset="100%" stop-color="#e9dcbc"/></linearGradient>
<linearGradient id="pBeak" x1="0" y1="0" x2="1" y2="0"><stop offset="0%" stop-color="#d9c8a0"/><stop offset="100%" stop-color="#a8946a"/></linearGradient>
<filter id="soft" x="-40%" y="-40%" width="180%" height="180%">
<feGaussianBlur stdDeviation="6"/>
</filter>
<filter id="soft2" x="-40%" y="-40%" width="180%" height="180%">
<feGaussianBlur stdDeviation="2.2"/>
</filter>
<filter id="grain" x="0" y="0" width="100%" height="100%">
<feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="2" result="n"/>
<feColorMatrix in="n" type="matrix" values="0 0 0 0 0.55 0 0 0 0 0.5 0 0 0 0 0.42 0 0 0 0.05 0"/>
</filter>
<clipPath id="orbClip"><circle cx="400" cy="380" r="212"/></clipPath>
<!-- the origami crane, drawn in its own local coordinate space -->
<g id="crane">
<!-- contact shadow beneath the bird -->
<ellipse cx="400" cy="472" rx="96" ry="15" fill="#1a1408" opacity=".28" filter="url(#soft)"/>
<!-- tail (rear, pointing left) -->
<polygon points="400,430 268,352 300,392 396,446" fill="url(#pTail)"/>
<polygon points="400,430 268,352 300,392 340,420" fill="url(#pTailSh)" opacity=".85"/>
<polyline points="400,430 300,392 268,352" fill="none" stroke="#8a744c" stroke-width="1.1" opacity=".5"/>
<line x1="400" y1="430" x2="268" y2="352" stroke="#7a6644" stroke-width="1" opacity=".45"/>
<!-- far wing (darker, behind body) -->
<polygon points="404,318 300,196 430,300" fill="url(#pWingR2)"/>
<polygon points="404,318 430,300 470,214" fill="url(#pWingR)"/>
<polyline points="300,196 404,318 470,214" fill="none" stroke="#6f5c3c" stroke-width="1.2" opacity=".55"/>
<line x1="404" y1="318" x2="366" y2="252" stroke="#6f5c3c" stroke-width="1" opacity=".4"/>
<!-- body / central hull -->
<polygon points="400,300 452,392 400,452" fill="url(#pC)"/>
<polygon points="400,300 400,452 348,392" fill="url(#pB)"/>
<polygon points="400,300 452,392 400,410" fill="url(#pD)" opacity=".9"/>
<polygon points="400,300 400,410 348,392" fill="url(#pA)" opacity=".9"/>
<polyline points="452,392 400,452 348,392 400,300 452,392" fill="none" stroke="#7a6644" stroke-width="1.2" opacity=".5"/>
<line x1="400" y1="300" x2="400" y2="452" stroke="#6f5c3c" stroke-width="1" opacity=".4"/>
<line x1="400" y1="410" x2="452" y2="392" stroke="#6f5c3c" stroke-width="1" opacity=".35"/>
<line x1="400" y1="410" x2="348" y2="392" stroke="#6f5c3c" stroke-width="1" opacity=".35"/>
<!-- near wing (raised, brightest) -->
<polygon points="396,312 252,178 402,296" fill="url(#pWingL)"/>
<polygon points="396,312 402,296 470,190" fill="url(#pWingL2)"/>
<polygon points="396,312 470,190 520,300" fill="url(#pWingL)"/>
<polygon points="396,312 520,300 452,392" fill="url(#pWingL2)"/>
<polygon points="396,312 402,296 470,190" fill="#ffffff" opacity=".18"/>
<polyline points="252,178 396,312 520,300 470,190 252,178" fill="none" stroke="#8a744c" stroke-width="1.3" opacity=".55"/>
<line x1="396" y1="312" x2="470" y2="190" stroke="#7a6644" stroke-width="1.1" opacity=".5"/>
<line x1="396" y1="312" x2="402" y2="296" stroke="#7a6644" stroke-width="1" opacity=".4"/>
<line x1="324" y1="245" x2="396" y2="312" stroke="#8a744c" stroke-width=".9" opacity=".3"/>
<!-- neck (front, rising right) -->
<polygon points="448,372 508,236 528,246 470,392" fill="url(#pNeck)"/>
<polygon points="448,372 470,392 528,246 516,262" fill="url(#pNeckSh)" opacity=".9"/>
<line x1="448" y1="372" x2="508" y2="236" stroke="#7a6644" stroke-width="1.1" opacity=".5"/>
<line x1="470" y1="392" x2="528" y2="246" stroke="#7a6644" stroke-width="1" opacity=".45"/>
<!-- head + beak -->
<polygon points="508,236 528,246 546,214" fill="url(#pHead)"/>
<polygon points="508,236 546,214 534,226" fill="url(#pNeckSh)" opacity=".8"/>
<polygon points="546,214 534,226 584,232" fill="url(#pBeak)"/>
<polygon points="546,214 584,232 560,218" fill="#8f7c55" opacity=".8"/>
<line x1="508" y1="236" x2="546" y2="214" stroke="#7a6644" stroke-width="1" opacity=".5"/>
<line x1="546" y1="214" x2="584" y2="232" stroke="#6f5c3c" stroke-width="1" opacity=".55"/>
<circle cx="530" cy="226" r="2.2" fill="#4a3c26" opacity=".8"/>
<!-- paper grain -->
<rect x="240" y="160" width="350" height="300" filter="url(#grain)" opacity=".5"/>
</g>
</defs>
<!-- backdrop -->
<rect width="800" height="800" fill="url(#bgGlow)"/>
<g fill="#cfe0ff">
<circle class="tw" cx="120" cy="140" r="1.6"/>
<circle class="tw d2" cx="680" cy="110" r="1.3"/>
<circle class="tw d3" cx="730" cy="300" r="1.8"/>
<circle class="tw d2" cx="90" cy="420" r="1.2"/>
<circle class="tw" cx="200" cy="640" r="1.5"/>
<circle class="tw d3" cx="640" cy="660" r="1.4"/>
<circle class="tw d2" cx="420" cy="80" r="1.2"/>
</g>
<!-- ambient halo + floor shadow + caustics -->
<ellipse class="glowPulse" cx="400" cy="380" rx="300" ry="290" fill="url(#halo)"/>
<ellipse class="shadowPulse" cx="400" cy="668" rx="185" ry="30" fill="url(#floor)"/>
<ellipse class="caustic" cx="400" cy="664" rx="120" ry="16" fill="url(#caustic)" filter="url(#soft2)"/>
<ellipse class="caustic" cx="360" cy="660" rx="46" ry="7" fill="url(#caustic)" filter="url(#soft2)" style="animation-delay:1.2s"/>
<ellipse class="caustic" cx="448" cy="668" rx="34" ry="6" fill="url(#caustic)" filter="url(#soft2)" style="animation-delay:2.4s"/>
<!-- glass sphere -->
<g class="float">
<!-- refracted / magnified crane, clipped to the orb -->
<g clip-path="url(#orbClip)">
<circle cx="400" cy="380" r="212" fill="url(#glassBody)"/>
<use href="#crane" transform="translate(400 380) scale(1.06) translate(-400 -380)"/>
<circle cx="400" cy="380" r="212" fill="url(#glassInner)"/>
<!-- internal refraction streaks -->
<path d="M232 300 Q400 250 568 320" fill="none" stroke="#ffffff" stroke-width="10" opacity=".06" filter="url(#soft)"/>
<path d="M250 470 Q400 520 552 460" fill="none" stroke="#dfeaff" stroke-width="8" opacity=".05" filter="url(#soft)"/>
</g>
<!-- rim, caustic ring, reflections -->
<circle cx="400" cy="380" r="212" fill="none" stroke="url(#rim)" stroke-width="2.4"/>
<circle cx="400" cy="380" r="206" fill="none" stroke="#eaf2ff" stroke-width="1" opacity=".18"/>
<path d="M232 470 A212 212 0 0 0 568 470" fill="none" stroke="#cfe4ff" stroke-width="5" opacity=".22" filter="url(#soft2)"/>
<ellipse cx="330" cy="238" rx="86" ry="42" fill="url(#spec)" transform="rotate(-24 330 238)"/>
<ellipse cx="300" cy="208" rx="26" ry="13" fill="#ffffff" opacity=".85" transform="rotate(-24 300 208)" filter="url(#soft2)"/>
<path d="M520 250 A190 190 0 0 1 596 420" fill="none" stroke="url(#band)" stroke-width="14" opacity=".35" filter="url(#soft2)"/>
<path d="M214 330 A200 200 0 0 1 268 236" fill="none" stroke="#ffffff" stroke-width="3" opacity=".35" filter="url(#soft2)"/>
<ellipse cx="470" cy="540" rx="60" ry="18" fill="url(#spec)" opacity=".18" transform="rotate(18 470 540)"/>
</g>
</svg>
</div>
<p class="caption"><b>Glass Orb & Paper Crane</b>layered gradients · faceted folds · refracted light</p>
</body>
</html>
2. Procedural globe
Actual Ling procedural globe after exercising rotation speed, dragging, and zoom
Mobile globe showing cropped framing and overlapping title/status text
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Procedural Globe — Three.js</title>
<style>
:root{
--bg0:#04060e; --bg1:#0a1230;
--ink:#e8eefc; --dim:#93a3c4;
--accent:#6fd3ff; --accent2:#8a7bff;
--panel:rgba(13,20,40,.58); --line:rgba(140,180,255,.18);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
margin:0; overflow:hidden; color:var(--ink);
font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
background:
radial-gradient(1200px 800px at 72% 18%, #101c44 0%, transparent 60%),
radial-gradient(900px 700px at 18% 85%, #0b1030 0%, transparent 55%),
linear-gradient(180deg,var(--bg0),var(--bg1));
}
#scene{position:fixed; inset:0; width:100%; height:100%; display:block; touch-action:none; cursor:grab}
#scene.dragging{cursor:grabbing}
.vignette{position:fixed; inset:0; pointer-events:none;
background:radial-gradient(120% 90% at 50% 42%, transparent 55%, rgba(2,4,12,.55) 100%)}
.hud{position:fixed; inset:0; pointer-events:none; display:flex; flex-direction:column;
justify-content:space-between; padding:clamp(14px,2.5vw,28px)}
header h1{margin:0; font-size:clamp(1.05rem,2.2vw,1.45rem); font-weight:650; letter-spacing:.02em}
header h1 .grad{background:linear-gradient(90deg,var(--accent),var(--accent2));
-webkit-background-clip:text; background-clip:text; color:transparent}
header p{margin:.35rem 0 0; color:var(--dim); font-size:.82rem; max-width:46ch}
.bottom{display:flex; flex-wrap:wrap; gap:12px; align-items:flex-end; justify-content:space-between}
.panel{pointer-events:auto; background:var(--panel); border:1px solid var(--line);
border-radius:16px; padding:14px 16px; backdrop-filter:blur(10px);
box-shadow:0 10px 30px rgba(0,0,0,.35)}
.controls{display:flex; flex-direction:column; gap:12px; min-width:min(320px,86vw)}
.row{display:flex; align-items:center; gap:12px}
.row label{font-size:.78rem; color:var(--dim); letter-spacing:.04em; text-transform:uppercase; white-space:nowrap}
input[type=range]{flex:1; accent-color:var(--accent); height:22px; cursor:pointer}
.speedval{font-variant-numeric:tabular-nums; font-size:.8rem; color:var(--accent); min-width:3.2em; text-align:right}
.zoom{display:flex; gap:8px; align-items:center}
.zoom button{
width:42px; height:42px; border-radius:12px; border:1px solid var(--line);
background:rgba(111,211,255,.08); color:var(--ink); font-size:1.25rem; line-height:1;
cursor:pointer; transition:background .15s, transform .1s, border-color .15s}
.zoom button:hover{background:rgba(111,211,255,.2); border-color:rgba(140,180,255,.45)}
.zoom button:active{transform:scale(.94)}
.zoom button:focus-visible, input[type=range]:focus-visible{outline:2px solid var(--accent); outline-offset:2px}
.hint{font-size:.72rem; color:var(--dim); margin:0}
.status{position:fixed; top:14px; right:14px; font-size:.72rem; color:var(--dim);
background:var(--panel); border:1px solid var(--line); border-radius:999px; padding:6px 12px;
backdrop-filter:blur(8px); pointer-events:none}
.status .dot{display:inline-block; width:8px; height:8px; border-radius:50%; background:#57e389;
margin-right:7px; box-shadow:0 0 8px #57e389}
#overlay{position:fixed; inset:0; z-index:10; display:flex; align-items:center; justify-content:center;
background:rgba(4,6,14,.72); backdrop-filter:blur(6px); transition:opacity .5s ease}
#overlay.hidden{opacity:0; pointer-events:none}
.card{max-width:min(420px,88vw); text-align:center; background:var(--panel);
border:1px solid var(--line); border-radius:20px; padding:34px 30px;
box-shadow:0 20px 60px rgba(0,0,0,.5)}
.spinner{width:46px; height:46px; margin:0 auto 18px; border-radius:50%;
border:3px solid rgba(111,211,255,.18); border-top-color:var(--accent);
animation:spin 1s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
.card h2{margin:0 0 8px; font-size:1.05rem}
.card p{margin:0; color:var(--dim); font-size:.85rem; line-height:1.5}
.card.error{border-color:rgba(255,120,120,.4)}
.card.error h2{color:#ff9b9b}
@media (prefers-reduced-motion: reduce){
.spinner{animation:none; border-top-color:rgba(111,211,255,.35)}
*{transition:none !important}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive 3D globe. Drag to rotate, use zoom buttons to change distance."></canvas>
<div class="vignette"></div>
<div class="hud">
<header>
<h1><span class="grad">Procedural Globe</span> · Three.js</h1>
<p>Continents generated on a canvas texture, with atmosphere glow and an orbiting particle ring.</p>
</header>
<div class="bottom">
<div class="panel controls">
<div class="row">
<label for="speed">Rotation speed</label>
<input id="speed" type="range" min="0" max="2" step="0.05" value="0.5"
aria-label="Continuous rotation speed">
<span class="speedval" id="speedVal">0.50×</span>
</div>
<div class="row zoom" role="group" aria-label="Zoom controls">
<button id="zoomOut" aria-label="Zoom out">−</button>
<button id="zoomIn" aria-label="Zoom in">+</button>
<button id="resetView" aria-label="Reset view" style="width:auto;padding:0 14px;font-size:.8rem">Reset view</button>
</div>
<p class="hint">Drag with mouse or touch to spin the globe. Scroll also zooms.</p>
</div>
</div>
</div>
<div class="status" id="status"><span class="dot"></span>initializing</div>
<div id="overlay">
<div class="card" id="overlayCard">
<div class="spinner" aria-hidden="true"></div>
<h2>Building globe…</h2>
<p>Generating procedural continents, atmosphere and particle ring.</p>
</div>
</div>
<script type="importmap">
{ "imports": { "three": "https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js" } }
</script>
<script type="module">
import * as THREE from 'three';
const REDUCED = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
const overlay = document.getElementById('overlay');
const overlayCard = document.getElementById('overlayCard');
const statusEl = document.getElementById('status');
const canvas = document.getElementById('scene');
function fail(title, msg){
overlayCard.className = 'card error';
overlayCard.innerHTML = `<h2>${title}</h2><p>${msg}</p>`;
overlay.classList.remove('hidden');
statusEl.innerHTML = '<span class="dot" style="background:#ff7b7b;box-shadow:0 0 8px #ff7b7b"></span>error';
}
/* ---------- Procedural continent texture ---------- */
function hash2(x, y){
let h = Math.sin(x * 127.1 + y * 311.7) * 43758.5453;
return h - Math.floor(h);
}
function vnoise(x, y){
const xi = Math.floor(x), yi = Math.floor(y);
const xf = x - xi, yf = y - yi;
const u = xf * xf * (3 - 2 * xf), v = yf * yf * (3 - 2 * yf);
const a = hash2(xi, yi), b = hash2(xi + 1, yi), c = hash2(xi, yi + 1), d = hash2(xi + 1, yi + 1);
return a + (b - a) * u + (c - a) * v + (a - b - c + d) * u * v;
}
function fbm(x, y, oct){
let amp = .5, f = 1, sum = 0, norm = 0;
for (let i = 0; i < oct; i++){ sum += amp * vnoise(x * f, y * f); norm += amp; amp *= .5; f *= 2.03; }
return sum / norm;
}
function makeEarthTexture(){
const W = 1024, H = 512;
const c = document.createElement('canvas'); c.width = W; c.height = H;
const ctx = c.getContext('2d');
const img = ctx.createImageData(W, H);
const d = img.data;
for (let y = 0; y < H; y++){
const lat = (y / H - .5) * Math.PI; // -PI/2 .. PI/2
const latDeg = Math.abs(lat * 180 / Math.PI);
const ice = latDeg > 62 ? Math.min(1, (latDeg - 62) / 22) : 0;
for (let x = 0; x < W; x++){
const lon = (x / W) * Math.PI * 2;
// seamless in longitude: sample noise on a cylinder
const nx = Math.cos(lon) * 1.6, ny = Math.sin(lon) * 1.6;
let e = fbm(nx * 1.4 + 7.3, ny * 1.4 + lat * 2.2 + 3.1, 5);
e += .18 * fbm(nx * 4.2 + 13.7, ny * 4.2 + lat * 6.0, 3);
e -= .12 * Math.pow(Math.abs(Math.sin(lat * 2.0)), 1.5); // ocean bias near equator bands
const i = (y * W + x) * 4;
let r, g, b;
if (e > .52){ // land
const t = Math.min(1, (e - .52) / .28);
r = 46 + t * 96; g = 96 + t * 74; b = 52 + t * 40; // green -> tan
if (t > .62){ const s = (t - .62) / .38; r += s * 70; g += s * 60; b += s * 55; }
if (ice > 0){ const k = ice * .9; r += (235 - r) * k; g += (240 - g) * k; b += (248 - b) * k; }
} else { // ocean, depth shading
const t = Math.min(1, e / .52);
r = 8 + t * 16; g = 34 + t * 40; b = 74 + t * 70;
if (e > .49){ r += 26; g += 40; b += 34; } // shallow coast glow
if (ice > .35){ const k = (ice - .35) * .8; r += (200 - r) * k; g += (220 - g) * k; b += (235 - b) * k; }
}
d[i] = r; d[i + 1] = g; d[i + 2] = b; d[i + 3] = 255;
}
}
ctx.putImageData(img, 0, 0);
const tex = new THREE.CanvasTexture(c);
tex.colorSpace = THREE.SRGBColorSpace;
tex.anisotropy = 4;
return tex;
}
/* ---------- Scene setup ---------- */
let renderer;
try {
renderer = new THREE.WebGLRenderer({ canvas, antialias: true, alpha: true });
if (!renderer.getContext()) throw new Error('no context');
} catch (e) {
fail('WebGL unavailable', 'Your browser or device could not initialize WebGL, so the 3D globe cannot be displayed. Try a recent browser with hardware acceleration enabled.');
throw e;
}
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(42, window.innerWidth / window.innerHeight, .1, 100);
const CAM_START = 3.4, CAM_MIN = 1.9, CAM_MAX = 7;
let camDist = CAM_START, camTarget = CAM_START;
camera.position.set(0, 0, camDist);
scene.add(new THREE.AmbientLight(0x8fa8ff, .55));
const key = new THREE.DirectionalLight(0xffffff, 1.6); key.position.set(4, 2.5, 3); scene.add(key);
const rim = new THREE.DirectionalLight(0x6fd3ff, .8); rim.position.set(-5, -1, -4); scene.add(rim);
const globeGroup = new THREE.Group();
scene.add(globeGroup);
let earth;
try {
earth = new THREE.Mesh(
new THREE.SphereGeometry(1, 96, 64),
new THREE.MeshStandardMaterial({ map: makeEarthTexture(), roughness: .85, metalness: .05 })
);
} catch (e) {
fail('Texture generation failed', 'The procedural continent texture could not be built on this device.');
throw e;
}
globeGroup.add(earth);
// Translucent atmospheric glow (back-side fresnel shell)
const atmosphere = new THREE.Mesh(
new THREE.SphereGeometry(1.16, 64, 48),
new THREE.ShaderMaterial({
transparent: true, blending: THREE.AdditiveBlending, side: THREE.BackSide, depthWrite: false,
uniforms: { uColor: { value: new THREE.Color(0x5fb8ff) } },
vertexShader: `varying vec3 vN; varying vec3 vP;
void main(){ vN = normalize(normalMatrix * normal);
vec4 mv = modelViewMatrix * vec4(position,1.0); vP = mv.xyz;
gl_Position = projectionMatrix * mv; }`,
fragmentShader: `uniform vec3 uColor; varying vec3 vN; varying vec3 vP;
void main(){ float f = pow(1.0 - abs(dot(normalize(vN), normalize(-vP))), 2.6);
gl_FragColor = vec4(uColor, f * .9); }`
})
);
scene.add(atmosphere);
// Orbiting ring of light particles
const RING_N = 900, RING_R = 1.55;
const ringGeo = new THREE.BufferGeometry();
const pos = new Float32Array(RING_N * 3), col = new Float32Array(RING_N * 3);
const cA = new THREE.Color(0x6fd3ff), cB = new THREE.Color(0x9d8bff), tmp = new THREE.Color();
for (let i = 0; i < RING_N; i++){
const a = Math.random() * Math.PI * 2;
const r = RING_R + (Math.random() - .5) * .12;
pos[i*3] = Math.cos(a) * r;
pos[i*3+1] = (Math.random() - .5) * .07;
pos[i*3+2] = Math.sin(a) * r;
tmp.copy(cA).lerp(cB, Math.random());
col[i*3] = tmp.r; col[i*3+1] = tmp.g; col[i*3+2] = tmp.b;
}
ringGeo.setAttribute('position', new THREE.BufferAttribute(pos, 3));
ringGeo.setAttribute('color', new THREE.BufferAttribute(col, 3));
const ring = new THREE.Points(ringGeo, new THREE.PointsMaterial({
size: .022, vertexColors: true, transparent: true, opacity: .9,
blending: THREE.AdditiveBlending, depthWrite: false, sizeAttenuation: true
}));
ring.rotation.x = Math.PI * .22;
scene.add(ring);
// Faint starfield
{
const n = 700, p = new Float32Array(n * 3);
for (let i = 0; i < n; i++){
const v = new THREE.Vector3().randomDirection().multiplyScalar(14 + Math.random() * 10);
p[i*3] = v.x; p[i*3+1] = v.y; p[i*3+2] = v.z;
}
const g = new THREE.BufferGeometry();
g.setAttribute('position', new THREE.BufferAttribute(p, 3));
scene.add(new THREE.Points(g, new THREE.PointsMaterial({ color: 0xaFC4ff, size: .05, transparent: true, opacity: .55, depthWrite: false })));
}
/* ---------- Interaction: drag rotation ---------- */
let dragging = false, px = 0, py = 0;
let velX = 0, velY = 0;
let rotY = 0, rotX = -.12;
const BASE_SPIN = .12;
canvas.addEventListener('pointerdown', e => {
dragging = true; px = e.clientX; py = e.clientY;
canvas.classList.add('dragging');
canvas.setPointerCapture(e.pointerId);
});
canvas.addEventListener('pointermove', e => {
if (!dragging) return;
const dx = e.clientX - px, dy = e.clientY - py;
px = e.clientX; py = e.clientY;
rotY += dx * .005; rotX += dy * .005;
rotX = Math.max(-1.2, Math.min(1.2, rotX));
velY = dx * .005; velX = dy * .005;
});
function endDrag(){ dragging = false; canvas.classList.remove('dragging'); }
canvas.addEventListener('pointerup', endDrag);
canvas.addEventListener('pointercancel', endDrag);
canvas.addEventListener('wheel', e => {
e.preventDefault();
camTarget = Math.max(CAM_MIN, Math.min(CAM_MAX, camTarget + e.deltaY * .002));
}, { passive: false });
/* ---------- UI controls ---------- */
const speedInput = document.getElementById('speed');
const speedVal = document.getElementById('speedVal');
let speed = parseFloat(speedInput.value);
speedInput.addEventListener('input', () => {
speed = parseFloat(speedInput.value);
speedVal.textContent = speed.toFixed(2) + '×';
});
function zoom(f){ camTarget = Math.max(CAM_MIN, Math.min(CAM_MAX, camTarget * f)); }
document.getElementById('zoomIn').addEventListener('click', () => zoom(.82));
document.getElementById('zoomOut').addEventListener('click', () => zoom(1.22));
document.getElementById('resetView').addEventListener('click', () => {
camTarget = CAM_START; rotX = -.12;
});
/* ---------- Resize ---------- */
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
/* ---------- Render loop ---------- */
const clock = new THREE.Clock();
function tick(){
requestAnimationFrame(tick);
const dt = Math.min(clock.getDelta(), .05);
const t = clock.elapsedTime;
if (!dragging){
rotY += velY * .94; rotX += velX * .94; // inertia
velX *= .94; velY *= .94;
rotX = Math.max(-1.2, Math.min(1.2, rotX));
}
const spin = REDUCED ? 0 : speed * BASE_SPIN;
globeGroup.rotation.y = rotY + t * spin;
globeGroup.rotation.x = rotX;
ring.rotation.z += REDUCED ? 0 : dt * .12 * (0.4 + speed);
ring.rotation.x = Math.PI * .22 + Math.sin(t * .3) * .02;
camDist += (camTarget - camDist) * .08;
camera.position.set(0, 0, camDist);
camera.lookAt(0, 0, 0);
renderer.render(scene, camera);
}
tick();
overlay.classList.add('hidden');
statusEl.innerHTML = '<span class="dot"></span>live · drag to rotate';
</script>
</body>
</html>
3. Floating-island wizard adventure
Cannot read properties of undefined (reading 'position') in fireShot. The code stores the turret head beside its group but later accesses t.g.head, which does not exist. Our input trace observed no spawned shots. A separate console error reports a NaN bounding sphere: the star-position buffer is constructed from nested arrays without flattening them. The player-position checks remained finite, so this geometry failure should not be confused with a demonstrated player-physics NaN.
Ling wizard adventure with floating grass islands, wooden bridges, and crystal HUD
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<title>Sky Isles — Wizard's Quest</title>
<style>
*{margin:0;padding:0;box-sizing:border-box}
html,body{width:100%;height:100%;overflow:hidden;background:#87b7e8;font-family:'Segoe UI',system-ui,sans-serif;color:#fff;user-select:none}
#app{position:fixed;inset:0}
canvas{display:block}
.panel{position:fixed;z-index:10;background:rgba(20,28,60,.55);backdrop-filter:blur(6px);border:1px solid rgba(255,255,255,.25);border-radius:12px;padding:10px 16px;box-shadow:0 4px 18px rgba(0,0,0,.25)}
#hud{top:14px;left:14px;min-width:210px}
#hud .row{display:flex;align-items:center;gap:8px;margin:4px 0;font-size:14px;letter-spacing:.5px}
#hearts{font-size:18px;letter-spacing:2px}
#bar{width:120px;height:10px;background:rgba(255,255,255,.2);border-radius:6px;overflow:hidden}
#hpfill{height:100%;width:100%;background:linear-gradient(90deg,#ff6b81,#ffb3c1);transition:width .2s}
#score{color:#ffe27a;font-weight:700}
#crys{color:#8ef6ff;font-weight:700}
#time{color:#c9d6ff}
#hint{bottom:14px;left:14px;font-size:12px;line-height:1.6;max-width:340px}
#hint b{color:#ffe27a}
#phase{top:14px;right:14px;font-size:13px;text-align:right;min-width:150px}
#phase .dot{display:inline-block;width:10px;height:10px;border-radius:50%;background:#ffd75e;margin-right:6px;vertical-align:middle}
#overlay{position:fixed;inset:0;z-index:20;display:flex;align-items:center;justify-content:center;background:rgba(10,14,35,.55);backdrop-filter:blur(4px)}
#overlay .card{background:linear-gradient(160deg,rgba(40,50,100,.92),rgba(25,30,70,.95));border:1px solid rgba(255,255,255,.3);border-radius:18px;padding:34px 44px;text-align:center;max-width:440px;box-shadow:0 12px 50px rgba(0,0,0,.5)}
#overlay h1{font-size:30px;margin-bottom:10px;color:#ffe27a;text-shadow:0 2px 12px rgba(255,200,80,.4)}
#overlay p{font-size:14px;line-height:1.7;color:#dfe6ff;margin-bottom:18px}
#overlay kbd{background:rgba(255,255,255,.15);border:1px solid rgba(255,255,255,.35);border-radius:5px;padding:1px 7px;font-family:inherit;font-size:12px}
#restartBtn{cursor:pointer;border:none;border-radius:10px;padding:12px 34px;font-size:16px;font-weight:700;letter-spacing:1px;color:#2a1a4a;background:linear-gradient(90deg,#ffd75e,#ff9d7a);box-shadow:0 4px 16px rgba(255,180,90,.45);transition:transform .15s,box-shadow .15s}
#restartBtn:hover{transform:translateY(-2px) scale(1.04);box-shadow:0 8px 24px rgba(255,180,90,.6)}
#err{position:fixed;inset:0;z-index:50;display:none;align-items:center;justify-content:center;background:#1a1030;color:#ffb3c1;font-size:16px;text-align:center;padding:30px;line-height:1.8}
#paused{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);z-index:15;display:none;font-size:26px;letter-spacing:4px;color:#fff;text-shadow:0 0 18px #8ef6ff;background:rgba(20,28,60,.6);padding:14px 34px;border-radius:14px;border:1px solid rgba(255,255,255,.3)}
#vignette{position:fixed;inset:0;pointer-events:none;z-index:5;box-shadow:inset 0 0 120px rgba(255,40,60,0);transition:box-shadow .3s}
#vignette.hurt{box-shadow:inset 0 0 140px rgba(255,40,60,.55)}
</style>
</head>
<body>
<div id="app"></div>
<div id="vignette"></div>
<div id="hud" class="panel">
<div class="row"><span id="hearts">♥♥♥</span><div id="bar"><div id="hpfill"></div></div></div>
<div class="row">Score <span id="score">0</span></div>
<div class="row">Crystals <span id="crys">0/8</span></div>
<div class="row">Time <span id="time">0:00</span></div>
</div>
<div id="phase" class="panel"><span class="dot" id="phasedot"></span><span id="phasetxt">Day</span></div>
<div id="hint" class="panel"><b>WASD</b> move · <b>Space</b> jump · <b>Drag mouse</b> orbit camera<br>Collect all crystals, dodge the turrets. Fall = lose 1 ♥.</div>
<div id="paused">❚❚ PAUSED</div>
<div id="overlay"><div class="card">
<h1 id="ovTitle">Sky Isles</h1>
<p id="ovText">Guide the little wizard across the floating isles. Gather every glowing crystal while the elemental turrets patrol. Bridges connect each island — mind the gaps!</p>
<p><kbd>W A S D</kbd> move · <kbd>Space</kbd> jump · <kbd>Mouse drag</kbd> camera</p>
<button id="restartBtn">▶ Start Adventure</button>
</div></div>
<div id="err"><div>⚠️ Could not load Three.js from the CDN.<br/>Please check your internet connection and reload the page.</div></div>
<script>
window.addEventListener('error',function(e){if(!window.__gameReady)document.getElementById('err').style.display='flex';});
setTimeout(function(){if(!window.__gameReady)document.getElementById('err').style.display='flex';},4000);
</script>
<script type="importmap">
{"imports":{"three":"https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js","three/addons/":"https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/"}}
</script>
<script type="module">
import * as THREE from 'three';
try{ main(); }catch(err){ document.getElementById('err').style.display='flex'; console.error(err); }
function main(){
window.__gameReady=true;
/* ---------- renderer / scene ---------- */
const app=document.getElementById('app');
const renderer=new THREE.WebGLRenderer({antialias:true});
renderer.setPixelRatio(Math.min(devicePixelRatio,2));
renderer.setSize(innerWidth,innerHeight);
renderer.shadowMap.enabled=true; renderer.shadowMap.type=THREE.PCFSoftShadowMap;
app.appendChild(renderer.domElement);
const scene=new THREE.Scene();
scene.fog=new THREE.Fog(0xbfd9f5,60,190);
const camera=new THREE.PerspectiveCamera(60,innerWidth/innerHeight,0.1,500);
camera.position.set(0,14,22);
/* ---------- lights ---------- */
const hemi=new THREE.HemisphereLight(0xcfe8ff,0x8a7ab8,0.9); scene.add(hemi);
const sun=new THREE.DirectionalLight(0xfff2d8,1.6);
sun.castShadow=true; sun.shadow.mapSize.set(1024,1024);
sun.shadow.camera.left=-40;sun.shadow.camera.right=40;sun.shadow.camera.top=40;sun.shadow.camera.bottom=-40;sun.shadow.camera.far=160;
scene.add(sun); scene.add(sun.target);
const amb=new THREE.AmbientLight(0x8899cc,0.25); scene.add(amb);
/* ---------- sky dome ---------- */
const skyMat=new THREE.ShaderMaterial({side:THREE.BackSide,depthWrite:false,
uniforms:{top:{value:new THREE.Color(0x6fb7ff)},bot:{value:new THREE.Color(0xffe8d6)}},
vertexShader:'varying vec3 vP;void main(){vP=position;gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.);}',
fragmentShader:'varying vec3 vP;uniform vec3 top;uniform vec3 bot;void main(){float h=normalize(vP).y*.5+.5;gl_FragColor=vec4(mix(bot,top,smoothstep(0.,.6,h)),1.);}'});
scene.add(new THREE.Mesh(new THREE.SphereGeometry(220,24,16),skyMat));
const stars=new THREE.Points(new THREE.BufferGeometry().setAttribute('position',new THREE.BufferAttribute(new Float32Array(Array.from({length:300},()=>{const a=Math.random()*6.283,b=Math.acos(2*Math.random()-1),r=190;return[r*Math.sin(b)*Math.cos(a),Math.abs(r*Math.cos(b))*0.9+10,r*Math.sin(b)*Math.sin(a)];})),3)),new THREE.PointsMaterial({color:0xffffff,size:1.4,sizeAttenuation:false,transparent:true,opacity:0}));
scene.add(stars);
/* ---------- audio (gesture-activated) ---------- */
let AC=null;
function audio(){ if(!AC){ try{AC=new (window.AudioContext||window.webkitAudioContext)();}catch(e){} } if(AC&&AC.state==='suspended')AC.resume(); return AC; }
function tone(f0,f1,dur,type,vol){ const ac=audio(); if(!ac)return; const o=ac.createOscillator(),g=ac.createGain(); o.type=type; o.frequency.setValueAtTime(f0,ac.currentTime); o.frequency.exponentialRampToValueAtTime(Math.max(f1,1),ac.currentTime+dur); g.gain.setValueAtTime(vol,ac.currentTime); g.gain.exponentialRampToValueAtTime(0.001,ac.currentTime+dur); o.connect(g).connect(ac.destination); o.start(); o.stop(ac.currentTime+dur); }
const sfxJump=()=>tone(280,620,0.18,'square',0.12);
const sfxCollect=()=>{tone(660,660,0.09,'sine',0.18);setTimeout(()=>tone(990,990,0.14,'sine',0.18),80);};
const sfxHurt=()=>tone(220,80,0.3,'sawtooth',0.15);
const sfxWin=()=>{[523,659,784,1046].forEach((f,i)=>setTimeout(()=>tone(f,f,0.22,'triangle',0.2),i*140));};
const sfxLose=()=>{[400,300,200,120].forEach((f,i)=>setTimeout(()=>tone(f,f*0.8,0.3,'sawtooth',0.15),i*180));};
/* ---------- world data ---------- */
const islands=[
{x:0,z:0,r:7,h:2.2,top:2.2},
{x:16,z:6,r:5,h:1.8,top:3.4},
{x:-15,z:9,r:5,h:1.8,top:3.0},
{x:6,z:-17,r:4.5,h:1.6,top:4.0},
{x:-8,z:-15,r:4,h:1.6,top:3.6},
{x:22,z:-10,r:4,h:1.6,top:4.6},
{x:-24,z:-6,r:4,h:1.6,top:3.8},
{x:2,z:20,r:4.5,h:1.8,top:3.2},
];
const bridges=[[0,1],[0,2],[0,3],[0,4],[1,5],[2,6],[0,7]];
const crystalSpots=[[16,6],[-15,9],[6,-17],[-8,-15],[22,-10],[-24,-6],[2,20],[0,0]];
const turretSpots=[[16,6],[-15,9],[6,-17],[22,-10]];
/* ---------- materials ---------- */
const M={
grass:new THREE.MeshStandardMaterial({color:0x8fd98a,flatShading:true,roughness:0.9}),
rock:new THREE.MeshStandardMaterial({color:0x9b8fc4,flatShading:true,roughness:1}),
bridge:new THREE.MeshStandardMaterial({color:0xd9b98a,flatShading:true,roughness:0.9}),
robe:new THREE.MeshStandardMaterial({color:0x7a5fd0,flatShading:true}),
hat:new THREE.MeshStandardMaterial({color:0x5a3fb0,flatShading:true}),
skin:new THREE.MeshStandardMaterial({color:0xffd9b3,flatShading:true}),
gold:new THREE.MeshStandardMaterial({color:0xffc94d,flatShading:true,emissive:0xaa7711,emissiveIntensity:0.4}),
crystal:new THREE.MeshStandardMaterial({color:0x7ff3ff,flatShading:true,emissive:0x33ccff,emissiveIntensity:1.4}),
turret:new THREE.MeshStandardMaterial({color:0x55607a,flatShading:true,roughness:0.6}),
fire:new THREE.MeshStandardMaterial({color:0xff7a3c,flatShading:true,emissive:0xff5500,emissiveIntensity:0.9}),
cloud:new THREE.MeshStandardMaterial({color:0xffffff,flatShading:true,roughness:1,transparent:true,opacity:0.9}),
};
/* ---------- build islands ---------- */
const colliders=[]; // {x,z,r,top}
function addIsland(d){
const g=new THREE.Group();
const top=new THREE.Mesh(new THREE.CylinderGeometry(d.r,d.r*0.92,0.7,9),M.grass);
top.position.y=d.top-0.35; top.castShadow=top.receiveShadow=true; g.add(top);
const rock=new THREE.Mesh(new THREE.CylinderGeometry(d.r*0.92,0.4,d.h+2.4,8),M.rock);
rock.position.y=d.top-0.7-(d.h+2.4)/2; rock.castShadow=true; g.add(rock);
// grass tufts
for(let i=0;i<5;i++){const a=Math.random()*6.28,rr=Math.random()*d.r*0.7;
const t=new THREE.Mesh(new THREE.ConeGeometry(0.18,0.5,5),new THREE.MeshStandardMaterial({color:0x6fc46a,flatShading:true}));
t.position.set(Math.cos(a)*rr,d.top+0.25,Math.sin(a)*rr); g.add(t);}
g.position.set(d.x,0,d.z); scene.add(g);
colliders.push({x:d.x,z:d.z,r:d.r*0.95,top:d.top});
}
islands.forEach(addIsland);
/* bridges */
function addBridge(a,b){
const A=islands[a],B=islands[b];
const dx=B.x-A.x,dz=B.z-A.z,dist=Math.hypot(dx,dz);
const len=dist-A.r-B.r+2.4;
const mid=new THREE.Vector3((A.x+B.x)/2,(A.top+B.top)/2-0.15,(A.z+B.z)/2);
const m=new THREE.Mesh(new THREE.BoxGeometry(len,0.35,1.6),M.bridge);
m.position.copy(mid); m.rotation.y=-Math.atan2(dz,dx); m.castShadow=m.receiveShadow=true; scene.add(m);
// collider as segment of small discs
const n=Math.ceil(len/1.2);
for(let i=0;i<=n;i++){const t=i/n;
colliders.push({x:A.x+dx*(A.r-0.6+t*(dist-A.r-B.r+1.2)/dist*1+ (1-t)*0 + t*0) ,z:0,r:0,top:0}); // placeholder removed below
}
colliders.splice(colliders.length-n-1,n+1);
for(let i=0;i<=n;i++){const t=i/n;
const x=A.x+dx*( (A.r-0.8)/dist + t*(dist-(A.r-0.8)-(B.r-0.8))/dist );
const z=A.z+dz*( (A.r-0.8)/dist + t*(dist-(A.r-0.8)-(B.r-0.8))/dist );
colliders.push({x,z,r:0.95,top:mid.y+0.18});
}
}
bridges.forEach(([a,b])=>addBridge(a,b));
/* clouds */
const clouds=[];
for(let i=0;i<10;i++){
const c=new THREE.Group();
for(let j=0;j<3;j++){const s=new THREE.Mesh(new THREE.IcosahedronGeometry(1.2+Math.random(),0),M.cloud);
s.position.set(j*1.6-1.6,Math.random()*0.5,Math.random()*1.2); s.scale.y=0.55; c.add(s);}
c.position.set((Math.random()-0.5)*90,8+Math.random()*10,(Math.random()-0.5)*90);
scene.add(c); clouds.push({g:c,sp:0.3+Math.random()*0.5});
}
/* ---------- wizard ---------- */
const wiz=new THREE.Group();
{
const body=new THREE.Mesh(new THREE.ConeGeometry(0.55,1.3,7),M.robe); body.position.y=0.65; body.castShadow=true; wiz.add(body);
const head=new THREE.Mesh(new THREE.SphereGeometry(0.3,8,7),M.skin); head.position.y=1.5; head.castShadow=true; wiz.add(head);
const hat=new THREE.Mesh(new THREE.ConeGeometry(0.42,0.85,7),M.hat); hat.position.y=2.0; hat.castShadow=true; wiz.add(hat);
const brim=new THREE.Mesh(new THREE.CylinderGeometry(0.55,0.55,0.06,9),M.hat); brim.position.y=1.68; wiz.add(brim);
const star=new THREE.Mesh(new THREE.OctahedronGeometry(0.09),M.gold); star.position.set(0,1.55,0.28); wiz.add(star);
}
scene.add(wiz);
/* ---------- crystals ---------- */
const crystals=[];
crystalSpots.forEach(([x,z],i)=>{
const isl=islands.find(s=>Math.hypot(s.x-x,s.z-z)<s.r);
const top=isl?isl.top:2;
const g=new THREE.Group();
const c=new THREE.Mesh(new THREE.OctahedronGeometry(0.42),M.crystal.clone());
c.position.y=1.1; c.castShadow=true; g.add(c);
const halo=new THREE.PointLight(0x66eaff,1.2,6); halo.position.y=1.2; g.add(halo);
g.position.set(x,top,z); scene.add(g);
crystals.push({g,c,taken:false,phase:i*0.8});
});
const TOTAL=crystals.length;
/* ---------- turrets ---------- */
const turrets=[];
turretSpots.forEach(([x,z],i)=>{
const isl=islands.find(s=>Math.hypot(s.x-x,s.z-z)<s.r);
const top=isl?isl.top:2;
const g=new THREE.Group();
const base=new THREE.Mesh(new THREE.CylinderGeometry(0.45,0.6,0.7,7),M.turret); base.position.y=0.35; base.castShadow=true; g.add(base);
const head=new THREE.Mesh(new THREE.IcosahedronGeometry(0.4,0),M.fire.clone()); head.position.y=1.15; head.castShadow=true; g.add(head);
const eye=new THREE.Mesh(new THREE.SphereGeometry(0.14,6,6),new THREE.MeshStandardMaterial({color:0xffffff,emissive:0xff2222,emissiveIntensity:1.5}));
eye.position.set(0,1.15,0.35); g.add(eye);
g.position.set(x,top,z); scene.add(g);
turrets.push({g,head,eye,x,z,top,ang:i*1.7,spd:0.5+0.15*(i%3),cd:1+Math.random()*2,range:9});
});
/* ---------- projectiles & particles ---------- */
const shots=[];
const shotGeo=new THREE.SphereGeometry(0.18,6,6);
const shotMat=new THREE.MeshStandardMaterial({color:0xff8844,emissive:0xff4400,emissiveIntensity:2});
function fireShot(t){
const dir=new THREE.Vector3(wiz.position.x-t.g.position.x,0,wiz.position.z-t.g.position.z).normalize();
const m=new THREE.Mesh(shotGeo,shotMat);
m.position.set(t.g.position.x+t.g.head.position.x*0.5,t.g.position.y+1.15,t.g.position.z);
m.userData.v=dir.multiplyScalar(11); m.userData.life=3;
scene.add(m); shots.push(m);
}
const parts=[];
const partGeo=new THREE.TetrahedronGeometry(0.12);
function burst(pos,color,n,spread,up){
for(let i=0;i<n;i++){
const m=new THREE.Mesh(partGeo,new THREE.MeshBasicMaterial({color,transparent:true}));
m.position.copy(pos);
m.userData.v=new THREE.Vector3((Math.random()-0.5)*spread,Math.random()*up+1,(Math.random()-0.5)*spread);
m.userData.life=0.7+Math.random()*0.4; m.userData.max=m.userData.life;
scene.add(m); parts.push(m);
}
}
/* ---------- game state ---------- */
let hp=3,score=0,got=0,state='menu',paused=false,elapsed=0,dayT=0.3,invuln=0,shake=0;
const P={pos:new THREE.Vector3(0,islands[0].top,0),vel:new THREE.Vector3(),yaw:0,grounded:true,coyote:0};
const keys={};
let camYaw=0.6,camPitch=0.42,dragging=false,lx=0,ly=0;
/* ---------- input ---------- */
addEventListener('keydown',e=>{keys[e.code]=true; if(e.code==='Space')e.preventDefault(); audio();});
addEventListener('keyup',e=>keys[e.code]=false);
renderer.domElement.addEventListener('pointerdown',e=>{dragging=true;lx=e.clientX;ly=e.clientY;audio();});
addEventListener('pointermove',e=>{if(dragging){camYaw-=(e.clientX-lx)*0.005;camPitch=Math.min(1.2,Math.max(0.08,camPitch+(e.clientY-ly)*0.004));lx=e.clientX;ly=e.clientY;}});
addEventListener('pointerup',()=>dragging=false);
addEventListener('wheel',e=>{camPitch=Math.min(1.2,Math.max(0.08,camPitch+e.deltaY*0.001));});
document.addEventListener('visibilitychange',()=>{if(document.hidden&&state==='play'){paused=true;document.getElementById('paused').style.display='block';}});
addEventListener('pointerdown',()=>{if(paused&&state==='play'){paused=false;document.getElementById('paused').style.display='none';}});
/* ---------- HUD ---------- */
const $=id=>document.getElementById(id);
function hud(){
$('hearts').textContent='♥'.repeat(hp)+'♡'.repeat(Math.max(0,3-hp));
$('hpfill').style.width=(hp/3*100)+'%';
$('score').textContent=score;
$('crys').textContent=got+'/'+TOTAL;
const m=Math.floor(elapsed/60),s=Math.floor(elapsed%60);
$('time').textContent=m+':'+String(s).padStart(2,'0');
}
function showOverlay(title,text,btn){
$('ovTitle').textContent=title; $('ovText').innerHTML=text;
$('restartBtn').textContent=btn; $('overlay').style.display='flex';
}
function hideOverlay(){$('overlay').style.display='none';}
/* ---------- restart ---------- */
function restart(){
hp=3;score=0;got=0;elapsed=0;dayT=0.3;invuln=0;shake=0;paused=false;
P.pos.set(0,islands[0].top,0);P.vel.set(0,0,0);P.yaw=0;camYaw=0.6;camPitch=0.42;
crystals.forEach(c=>{c.taken=false;c.g.visible=true;});
turrets.forEach(t=>{t.cd=1+Math.random()*2;});
shots.forEach(s=>scene.remove(s)); shots.length=0;
parts.forEach(p=>scene.remove(p)); parts.length=0;
$('paused').style.display='none';
hideOverlay(); state='play'; hud();
}
$('restartBtn').addEventListener('click',()=>{audio();restart();});
/* ---------- helpers ---------- */
function groundAt(x,z){
let best=-Infinity;
for(const c of colliders){const d=Math.hypot(x-c.x,z-c.z); if(d<c.r&&c.top>best)best=c.top;}
return best;
}
function hurt(){
if(invuln>0||state!=='play')return;
hp--; invuln=1.2; shake=0.5; sfxHurt();
$('vignette').classList.add('hurt'); setTimeout(()=>$('vignette').classList.remove('hurt'),350);
burst(P.pos.clone().add(new THREE.Vector3(0,1,0)),0xff5566,14,4,3);
if(hp<=0){state='over';sfxLose();showOverlay('Game Over','The elements overwhelmed you...<br/>Score: <b>'+score+'</b> · Crystals: '+got+'/'+TOTAL,'↻ Try Again');}
hud();
}
/* ---------- day/night ---------- */
const dayC=new THREE.Color(0x6fb7ff),nightC=new THREE.Color(0x1a2350);
const sunC=new THREE.Color(0xfff2d8),moonC=new THREE.Color(0x8fa8ff);
const fogD=new THREE.Color(0xbfd9f5),fogN=new THREE.Color(0x141a3a);
function updateDayNight(dt){
dayT+=dt/90; if(dayT>1)dayT-=1;
const a=dayT*Math.PI*2;
const dayF=Math.max(0,Math.sin(a)); // 1 = noon
const isDay=dayF>0.25;
$('phasetxt').textContent=isDay?'Day':'Night';
$('phasedot').style.background=isDay?'#ffd75e':'#a8b8ff';
const t=THREE.MathUtils.smoothstep(dayF,-0.1,0.35);
skyMat.uniforms.top.value.lerpColors(nightC,dayC,t);
skyMat.uniforms.bot.value.lerpColors(new THREE.Color(0x2a2350),new THREE.Color(0xffe8d6),t);
scene.fog.color.lerpColors(fogN,fogD,t);
sun.intensity=0.15+1.5*t; sun.color.lerpColors(moonC,sunC,t);
hemi.intensity=0.25+0.65*t; amb.intensity=0.1+0.2*t;
stars.material.opacity=1-t;
const sx=Math.cos(a)*60,sy=Math.sin(a)*70+10,sz=30;
sun.position.set(sx,sy,sz); sun.target.position.set(0,0,0);
}
/* ---------- main loop ---------- */
const clock=new THREE.Clock();
const tmpV=new THREE.Vector3();
function animate(){
requestAnimationFrame(animate);
const dt=Math.min(clock.getDelta(),0.05);
if(state==='play'&&!paused){
elapsed+=dt; invuln=Math.max(0,invuln-dt);
/* movement */
let ix=(keys.KeyD?1:0)-(keys.KeyA?1:0), iz=(keys.KeyS?1:0)-(keys.KeyW?1:0);
const mag=Math.hypot(ix,iz);
if(mag>0){ix/=mag;iz/=mag;
const sin=Math.sin(camYaw),cos=Math.cos(camYaw);
const wx=ix*cos-iz*sin, wz=-ix*sin-iz*cos;
P.yaw=Math.atan2(wx,wz);
P.vel.x=wx*7; P.vel.z=wz*7;
} else {P.vel.x*=0.8;P.vel.z*=0.8;}
if(keys.Space&&P.grounded){P.vel.y=9.5;P.grounded=false;P.coyote=0;sfxJump();burst(P.pos.clone(),0xffffff,8,2,2);}
P.vel.y-=26*dt;
P.pos.x+=P.vel.x*dt; P.pos.z+=P.vel.z*dt; P.pos.y+=P.vel.y*dt;
/* platform collision */
const g=groundAt(P.pos.x,P.pos.z);
if(g>-Infinity&&P.pos.y<=g+0.05&&P.vel.y<=0){P.pos.y=g;P.vel.y=0;P.grounded=true;P.coyote=0.12;}
else {P.grounded=false;P.coyote-=dt;}
/* fall recovery */
if(P.pos.y<-18){hp--;hud();sfxHurt();
if(hp<=0){state='over';sfxLose();showOverlay('Game Over','You fell into the clouds...<br/>Score: <b>'+score+'</b> · Crystals: '+got+'/'+TOTAL,'↻ Try Again');}
else{let bi=0,bd=1e9;islands.forEach((s,i)=>{const d=Math.hypot(s.x-P.pos.x,s.z-P.pos.z);if(d<bd){bd=d;bi=i;}});
P.pos.set(islands[bi].x,islands[bi].top+0.5,islands[bi].z);P.vel.set(0,0,0);invuln=1.5;
burst(P.pos,0xffffff,16,4,4);}
}
/* wizard transform */
wiz.position.copy(P.pos);
wiz.rotation.y+=((P.yaw)-wiz.rotation.y)*Math.min(1,dt*12);
const bob=P.grounded?Math.abs(Math.sin(elapsed*10))*0.06:0;
wiz.position.y+=bob;
wiz.visible=invuln<=0||Math.floor(elapsed*12)%2===0;
/* crystals */
crystals.forEach(c=>{
if(c.taken)return;
c.g.rotation.y+=dt*2; c.c.position.y=1.1+Math.sin(elapsed*2.5+c.phase)*0.15;
if(c.g.position.distanceTo(P.pos)<1.4){
c.taken=true;c.g.visible=false;got++;score+=100;sfxCollect();
burst(c.g.position.clone().add(new THREE.Vector3(0,1.2,0)),0x7ff3ff,18,5,4);
if(got>=TOTAL){state='win';score+=Math.max(0,300-Math.floor(elapsed)*2);sfxWin();
showOverlay('✨ Victory! ✨','Every crystal gathered!<br/>Final score: <b>'+score+'</b> · Time: '+Math.floor(elapsed)+'s','↻ Play Again');}
hud();
}
});
/* turrets */
turrets.forEach(t=>{
t.ang+=t.spd*dt;
t.head.position.set(Math.cos(t.ang)*0.55,1.15,Math.sin(t.ang)*0.55);
t.eye.position.set(t.head.position.x,1.15,t.head.position.z);
t.head.rotation.y=-t.ang;
const d=Math.hypot(P.pos.x-t.x,P.pos.z-t.z);
t.cd-=dt;
if(d<t.range&&t.cd<=0){t.cd=1.6+Math.random()*0.8;fireShot(t);tone(180,90,0.15,'square',0.08);}
if(d<1.3&&P.pos.y-t.top<1.6)hurt();
});
/* shots */
for(let i=shots.length-1;i>=0;i--){const s=shots[i];
s.position.addScaledVector(s.userData.v,dt); s.userData.life-=dt;
if(s.position.distanceTo(P.pos.clone().add(new THREE.Vector3(0,0.8,0)))<0.9){hurt();s.userData.life=0;}
if(s.userData.life<=0||groundAt(s.position.x,s.position.z)>s.position.y){scene.remove(s);shots.splice(i,1);}
}
/* particles */
for(let i=parts.length-1;i>=0;i--){const p=parts[i];
p.userData.life-=dt; p.userData.v.y-=12*dt;
p.position.addScaledVector(p.userData.v,dt);
p.material.opacity=Math.max(0,p.userData.life/p.userData.max);
p.rotation.x+=dt*5;p.rotation.y+=dt*7;
if(p.userData.life<=0){scene.remove(p);p.material.dispose();parts.splice(i,1);}
}
/* ambient sparkles */
if(Math.random()<0.15)burst(new THREE.Vector3(P.pos.x+(Math.random()-0.5)*6,P.pos.y+1+Math.random()*2,P.pos.z+(Math.random()-0.5)*6),0xfff2a8,1,0.5,0.5);
hud();
}
updateDayNight(dt);
clouds.forEach(c=>{c.g.position.x+=c.sp*dt;if(c.g.position.x>60)c.g.position.x=-60;});
/* camera follow + orbit */
const dist=9+camPitch*4;
const tx=P.pos.x+Math.sin(camYaw)*Math.cos(camPitch)*dist;
const tz=P.pos.z+Math.cos(camYaw)*Math.cos(camPitch)*dist;
const ty=P.pos.y+2.2+Math.sin(camPitch)*dist;
camera.position.lerp(tmpV.set(tx,ty,tz),1-Math.pow(0.001,dt));
if(shake>0){shake-=dt;camera.position.x+=(Math.random()-0.5)*shake*0.6;camera.position.y+=(Math.random()-0.5)*shake*0.6;}
camera.lookAt(P.pos.x,P.pos.y+1.4,P.pos.z);
renderer.render(scene,camera);
}
animate();
addEventListener('resize',()=>{camera.aspect=innerWidth/innerHeight;camera.updateProjectionMatrix();renderer.setSize(innerWidth,innerHeight);});
hud();
}
</script>
</body>
</html>
4. Neon Saber Arena: interrupted, not playable
Upstream idle timeout exceeded while writing killEnemy, before the script and HTML were closed. The retained file fails JavaScript parsing with an end-of-file error. Its neon title menu renders from static markup, but Play does not launch a game and no WebGL draw calls were observed. Combat, waves, and autonomous play could not be exercised. This is an incomplete delivery, not a functioning game or a fair measurement of those mechanics.
Static menu from the incomplete saber submission; the Play control does not start gameplay
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NEON SABER ARENA</title>
<style>
*{margin:0;padding:0;box-sizing:border-box}
html,body{width:100%;height:100%;overflow:hidden;background:#04060c;font-family:'Segoe UI',Arial,sans-serif;color:#cfefff;user-select:none}
#game{position:fixed;inset:0}
canvas{display:block}
.hidden{display:none!important}
/* ---------- overlays ---------- */
.overlay{position:fixed;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;z-index:50;background:radial-gradient(ellipse at center,rgba(8,14,30,.82),rgba(2,4,10,.95));backdrop-filter:blur(4px)}
.title{font-size:64px;font-weight:900;letter-spacing:8px;color:#eaffff;text-shadow:0 0 18px #00e5ff,0 0 60px #00e5ff,0 0 120px #0891b2;animation:pulse 2.4s ease-in-out infinite}
.title span{color:#ff2d78;text-shadow:0 0 18px #ff2d78,0 0 60px #ff2d78}
@keyframes pulse{0%,100%{filter:brightness(1)}50%{filter:brightness(1.35)}}
.subtitle{margin-top:6px;font-size:15px;letter-spacing:6px;color:#7fd8ff;opacity:.85}
.panel{margin-top:26px;padding:18px 26px;border:1px solid rgba(0,229,255,.35);border-radius:10px;background:rgba(4,12,24,.6);box-shadow:0 0 24px rgba(0,229,255,.15) inset;font-size:14px;line-height:1.9;color:#a8d8f0}
.panel b{color:#fff}
.key{display:inline-block;min-width:26px;text-align:center;padding:1px 7px;margin:0 2px;border:1px solid #0e5;border-color:rgba(0,229,255,.6);border-radius:4px;background:rgba(0,229,255,.08);color:#bff;font-weight:700;font-size:12px}
.btn{margin-top:26px;padding:14px 54px;font-size:20px;font-weight:800;letter-spacing:4px;color:#02131a;background:linear-gradient(180deg,#5ff3ff,#00c8e0);border:none;border-radius:6px;cursor:pointer;box-shadow:0 0 24px rgba(0,229,255,.7),0 0 60px rgba(0,229,255,.3);transition:transform .12s,box-shadow .12s}
.btn:hover{transform:scale(1.06);box-shadow:0 0 34px rgba(0,229,255,1),0 0 90px rgba(0,229,255,.5)}
.btn.pink{background:linear-gradient(180deg,#ff7ab0,#ff2d78);box-shadow:0 0 24px rgba(255,45,120,.7);color:#1a020a}
.btn.ghost{background:transparent;color:#7fd8ff;border:1px solid rgba(0,229,255,.5);box-shadow:none}
.btnrow{display:flex;gap:16px}
#goTitle{font-size:52px;font-weight:900;letter-spacing:6px;color:#ff5c8a;text-shadow:0 0 20px #ff2d78,0 0 70px #ff2d78}
#goStats{margin-top:14px;font-size:18px;color:#a8d8f0;line-height:2}
#goStats b{color:#fff}
/* ---------- HUD ---------- */
#hud{position:fixed;inset:0;pointer-events:none;z-index:20}
#topbar{position:absolute;top:14px;left:50%;transform:translateX(-50%);display:flex;gap:34px;align-items:center;background:rgba(3,10,22,.55);border:1px solid rgba(0,229,255,.35);border-radius:10px;padding:8px 26px;box-shadow:0 0 18px rgba(0,229,255,.15)}
.hudItem{font-size:13px;letter-spacing:2px;color:#7fd8ff;text-align:center}
.hudItem .val{font-size:22px;font-weight:800;color:#fff;text-shadow:0 0 10px #00e5ff}
#hpwrap{position:absolute;left:24px;bottom:24px;width:320px}
#hpbar{height:20px;border:1px solid rgba(0,229,255,.5);border-radius:5px;background:rgba(0,20,30,.6);overflow:hidden;box-shadow:0 0 14px rgba(0,229,255,.25)}
#hpfill{height:100%;width:100%;background:linear-gradient(90deg,#00e5ff,#4dff9d);box-shadow:0 0 14px #00e5ff;transition:width .15s}
#hpfill.low{background:linear-gradient(90deg,#ff2d55,#ff7a5c);box-shadow:0 0 14px #ff2d55}
#hplabel{font-size:12px;letter-spacing:3px;color:#7fd8ff;margin-bottom:4px;text-shadow:0 0 8px #00e5ff}
#combo{position:absolute;right:30px;bottom:30px;font-size:15px;letter-spacing:3px;color:#ffd75c;text-shadow:0 0 10px #ffb400;opacity:0;transition:opacity .2s}
#banner{position:absolute;top:22%;left:50%;transform:translateX(-50%);font-size:44px;font-weight:900;letter-spacing:10px;color:#fff;text-shadow:0 0 20px #00e5ff,0 0 60px #00e5ff;opacity:0;transition:opacity .3s;white-space:nowrap}
#crosshair{position:absolute;left:50%;top:50%;width:6px;height:6px;margin:-3px;border-radius:50%;background:rgba(160,240,255,.8);box-shadow:0 0 8px #00e5ff}
#dmgflash{position:fixed;inset:0;pointer-events:none;background:radial-gradient(ellipse at center,transparent 40%,rgba(255,20,60,.55));opacity:0;z-index:30}
/* ---------- autoplay ---------- */
#autoplayBtn{position:fixed;right:22px;bottom:22px;z-index:40;padding:16px 34px;font-size:18px;font-weight:900;letter-spacing:3px;color:#02131a;background:linear-gradient(180deg,#ffd75c,#ff9d00);border:none;border-radius:8px;cursor:pointer;box-shadow:0 0 26px rgba(255,170,0,.75);transition:transform .12s}
#autoplayBtn:hover{transform:scale(1.07)}
#autoplayBtn.active{background:linear-gradient(180deg,#ff7ab0,#ff2d78);color:#1a020a;box-shadow:0 0 30px rgba(255,45,120,.9);animation:pulse 1.2s infinite}
#aiStatus{position:fixed;right:22px;bottom:86px;z-index:40;padding:8px 16px;font-size:13px;letter-spacing:2px;font-weight:700;color:#02131a;background:linear-gradient(90deg,#5ff3ff,#4dff9d);border-radius:6px;box-shadow:0 0 16px rgba(0,229,255,.6);min-width:170px;text-align:center}
#aiStatus.off{background:rgba(10,20,35,.7);color:#5b7f95;border:1px solid rgba(0,229,255,.3);box-shadow:none}
#hint{position:absolute;left:24px;top:14px;font-size:11px;letter-spacing:1px;color:#5b8aa5;line-height:1.8}
#vignette{position:fixed;inset:0;pointer-events:none;z-index:10;background:radial-gradient(ellipse at center,transparent 55%,rgba(0,0,10,.55))}
#pauseBtn{position:fixed;top:14px;right:18px;z-index:40;width:40px;height:40px;border-radius:8px;border:1px solid rgba(0,229,255,.5);background:rgba(3,10,22,.6);color:#7fd8ff;font-size:18px;cursor:pointer}
</style>
</head>
<body>
<div id="game"></div>
<div id="vignette"></div>
<div id="hud" class="hidden">
<div id="topbar">
<div class="hudItem">WAVE<div class="val" id="uiWave">1</div></div>
<div class="hudItem">SCORE<div class="val" id="uiScore">0</div></div>
<div class="hudItem">ENEMIES<div class="val" id="uiEnemies">0</div></div>
</div>
<div id="hint">WASD move · Mouse look · LMB attack · RMB block · SPACE dodge · SHIFT sprint · R restart · ESC pause</div>
<div id="hpwrap"><div id="hplabel">INTEGRITY</div><div id="hpbar"><div id="hpfill"></div></div></div>
<div id="combo">COMBO ×1</div>
<div id="banner"></div>
<div id="crosshair"></div>
</div>
<div id="dmgflash"></div>
<button id="autoplayBtn" class="hidden">AUTO PLAY</button>
<div id="aiStatus" class="off hidden">AI: OFFLINE</div>
<button id="pauseBtn" class="hidden">II</button>
<div id="menu" class="overlay">
<div class="title">NEON SABER <span>ARENA</span></div>
<div class="subtitle">SURVIVE THE MACHINE UPRISING</div>
<div class="panel">
<b>WASD</b> move <b>MOUSE</b> aim <b>LMB</b> strike <b>RMB</b> block<br>
<b>SPACE</b> dodge-dash <b>SHIFT</b> sprint <b>R</b> restart <b>ESC</b> pause<br>
Chain 3 hits for a combo. Guardians block — strike from behind. Elites dodge and counter.
</div>
<button class="btn" id="playBtn">ENTER ARENA</button>
</div>
<div id="pauseMenu" class="overlay hidden">
<div class="title" style="font-size:44px">PAUSED</div>
<div class="btnrow">
<button class="btn" id="resumeBtn">RESUME</button>
<button class="btn pink" id="restartBtn">RESTART</button>
</div>
</div>
<div id="gameover" class="overlay hidden">
<div id="goTitle">SIGNAL LOST</div>
<div id="goStats"></div>
<div class="btnrow">
<button class="btn" id="againBtn">FIGHT AGAIN</button>
<button class="btn ghost" id="menuBtn">MAIN MENU</button>
</div>
</div>
<script type="importmap">
{"imports":{"three":"https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js","three/addons/":"https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/"}}
</script>
<script type="module">
import * as THREE from 'three';
/* ================= CORE ================= */
const container=document.getElementById('game');
const renderer=new THREE.WebGLRenderer({antialias:true});
renderer.setSize(innerWidth,innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio,2));
renderer.shadowMap.enabled=true;
renderer.shadowMap.type=THREE.PCFSoftShadowMap;
renderer.toneMapping=THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure=1.15;
container.appendChild(renderer.domElement);
const scene=new THREE.Scene();
scene.background=new THREE.Color(0x05070f);
scene.fog=new THREE.FogExp2(0x070b16,0.016);
const camera=new THREE.PerspectiveCamera(62,innerWidth/innerHeight,0.1,300);
camera.position.set(0,4,9);
scene.add(new THREE.AmbientLight(0x334466,0.7));
const hemi=new THREE.HemisphereLight(0x3a5a8a,0x0a0c14,0.5); scene.add(hemi);
const moon=new THREE.DirectionalLight(0x88aaff,0.7);
moon.position.set(20,35,12); moon.castShadow=true;
moon.shadow.mapSize.set(2048,2048);
moon.shadow.camera.left=-32;moon.shadow.camera.right=32;moon.shadow.camera.top=32;moon.shadow.camera.bottom=-32;
moon.shadow.camera.far=90; moon.shadow.bias=-0.0004;
scene.add(moon);
/* ================= AUDIO ================= */
let AC=null,masterGain=null;
function audio(){ if(!AC){AC=new (window.AudioContext||window.webkitAudioContext)();masterGain=AC.createGain();masterGain.gain.value=0.5;masterGain.connect(AC.destination);} if(AC.state==='suspended')AC.resume(); return AC;}
function tone(f0,f1,dur,type,vol,delay=0){ try{const ac=audio(),t=ac.currentTime+delay;const o=ac.createOscillator(),g=ac.createGain();o.type=type;o.frequency.setValueAtTime(f0,t);o.frequency.exponentialRampToValueAtTime(Math.max(f1,1),t+dur);g.gain.setValueAtTime(vol,t);g.gain.exponentialRampToValueAtTime(0.001,t+dur);o.connect(g);g.connect(masterGain);o.start(t);o.stop(t+dur+0.02);}catch(e){} }
function noiseBurst(dur,vol,freq,delay=0){ try{const ac=audio(),t=ac.currentTime+delay;const len=Math.floor(ac.sampleRate*dur);const buf=ac.createBuffer(1,len,ac.sampleRate);const d=buf.getChannelData(0);for(let i=0;i<len;i++)d[i]=(Math.random()*2-1)*(1-i/len);const s=ac.createBufferSource();s.buffer=buf;const f=ac.createBiquadFilter();f.type='bandpass';f.frequency.value=freq;f.Q.value=0.8;const g=ac.createGain();g.gain.setValueAtTime(vol,t);g.gain.exponentialRampToValueAtTime(0.001,t+dur);s.connect(f);f.connect(g);g.connect(masterGain);s.start(t);}catch(e){} }
const SFX={
swing:()=>noiseBurst(0.16,0.25,900),
swing2:()=>noiseBurst(0.14,0.22,1400),
hit:()=>{tone(220,60,0.12,'square',0.25);noiseBurst(0.1,0.3,2500);},
clang:()=>{tone(1800,900,0.18,'triangle',0.2);tone(2400,1200,0.12,'triangle',0.12);noiseBurst(0.08,0.2,4000);},
block:()=>{tone(500,300,0.1,'square',0.15);noiseBurst(0.06,0.15,3000);},
dash:()=>noiseBurst(0.18,0.18,600),
explode:()=>{tone(120,30,0.5,'sawtooth',0.35);noiseBurst(0.5,0.4,300);noiseBurst(0.3,0.25,1200,0.05);},
hurt:()=>{tone(300,90,0.25,'sawtooth',0.3);},
warn:()=>tone(880,880,0.09,'square',0.12),
wave:()=>{tone(440,880,0.3,'triangle',0.2);tone(660,1320,0.3,'triangle',0.15,0.12);},
over:()=>{tone(400,60,1.2,'sawtooth',0.3);},
};
/* ================= ARENA ================= */
const ARENA_R=30;
const obstacles=[]; // {x,z,r}
{
// floor
const floorGeo=new THREE.CircleGeometry(ARENA_R+6,64);
const floorMat=new THREE.MeshStandardMaterial({color:0x11161f,metalness:0.85,roughness:0.35});
const floor=new THREE.Mesh(floorGeo,floorMat);
floor.rotation.x=-Math.PI/2; floor.receiveShadow=true; scene.add(floor);
// grid
const grid=new THREE.GridHelper(ARENA_R*2,40,0x00e5ff,0x0a2a3a);
grid.position.y=0.02; grid.material.transparent=true; grid.material.opacity=0.35; scene.add(grid);
// outer wall
const wallGeo=new THREE.CylinderGeometry(ARENA_R+2,ARENA_R+2,6,64,1,true);
const wallMat=new THREE.MeshStandardMaterial({color:0x0a1220,metalness:0.9,roughness:0.3,side:THREE.DoubleSide});
const wall=new THREE.Mesh(wallGeo,wallMat); wall.position.y=3; scene.add(wall);
// wall glow strips
for(let i=0;i<16;i++){
const a=i/16*Math.PI*2;
const strip=new THREE.Mesh(new THREE.BoxGeometry(0.15,3,1.6),new THREE.MeshBasicMaterial({color:i%2?0x00e5ff:0xff2d78}));
strip.position.set(Math.cos(a)*(ARENA_R+1.6),2.2,Math.sin(a)*(ARENA_R+1.6));
strip.lookAt(0,2.2,0); scene.add(strip);
}
// pillars
const pilMat=new THREE.MeshStandardMaterial({color:0x2a3444,metalness:0.9,roughness:0.3});
const capMat=new THREE.MeshBasicMaterial({color:0x00e5ff});
for(let i=0;i<8;i++){
const a=i/8*Math.PI*2+0.4, r=22;
const p=new THREE.Mesh(new THREE.CylinderGeometry(1.1,1.4,9,8),pilMat);
p.position.set(Math.cos(a)*r,4.5,Math.sin(a)*r); p.castShadow=true; p.receiveShadow=true; scene.add(p);
const cap=new THREE.Mesh(new THREE.BoxGeometry(0.5,0.5,0.5),capMat);
cap.position.set(p.position.x,9.2,p.position.z); scene.add(cap);
obstacles.push({x:p.position.x,z:p.position.z,r:1.7});
}
// central block
const core=new THREE.Mesh(new THREE.BoxGeometry(5,2.2,5),new THREE.MeshStandardMaterial({color:0x1a2436,metalness:0.9,roughness:0.25}));
core.position.y=1.1; core.castShadow=true; core.receiveShadow=true; scene.add(core);
const coreGlow=new THREE.Mesh(new THREE.BoxGeometry(5.2,0.25,5.2),new THREE.MeshBasicMaterial({color:0xff2d78}));
coreGlow.position.y=2.3; scene.add(coreGlow);
obstacles.push({x:0,z:0,r:3.6});
// scattered crates
const crateMat=new THREE.MeshStandardMaterial({color:0x22304a,metalness:0.8,roughness:0.4});
const cratePos=[[8,6],[-9,4],[6,-10],[-7,-9],[12,-4],[-13,-3],[3,13],[-4,-14]];
for(const [x,z] of cratePos){
const c=new THREE.Mesh(new THREE.BoxGeometry(2.2,2.2,2.2),crateMat);
c.position.set(x,1.1,z); c.rotation.y=Math.random(); c.castShadow=true; c.receiveShadow=true; scene.add(c);
const edge=new THREE.LineSegments(new THREE.EdgesGeometry(c.geometry),new THREE.LineBasicMaterial({color:0x00e5ff,transparent:true,opacity:0.6}));
edge.position.copy(c.position); edge.rotation.copy(c.rotation); scene.add(edge);
obstacles.push({x,z,r:1.7});
}
// stars
const starGeo=new THREE.BufferGeometry(); const sp=[];
for(let i=0;i<600;i++){const a=Math.random()*Math.PI*2,e=Math.random()*Math.PI*0.5,r=120+Math.random()*80;sp.push(Math.cos(a)*Math.cos(e)*r,Math.sin(e)*r*0.6+8,Math.sin(a)*Math.cos(e)*r);}
starGeo.setAttribute('position',new THREE.Float32BufferAttribute(sp,3));
scene.add(new THREE.Points(starGeo,new THREE.PointsMaterial({color:0x88bbff,size:0.6,sizeAttenuation:true})));
}
/* ================= PARTICLES ================= */
const P_MAX=900;
const pGeo=new THREE.BufferGeometry();
const pPos=new Float32Array(P_MAX*3), pCol=new Float32Array(P_MAX*3);
pGeo.setAttribute('position',new THREE.BufferAttribute(pPos,3));
pGeo.setAttribute('color',new THREE.BufferAttribute(pCol,3));
const pMat=new THREE.PointsMaterial({size:0.16,vertexColors:true,blending:THREE.AdditiveBlending,transparent:true,depthWrite:false});
const pPoints=new THREE.Points(pGeo,pMat); pPoints.frustumCulled=false; scene.add(pPoints);
const parts=[]; // {x,y,z,vx,vy,vz,life,maxLife,r,g,b,grav}
function spawnSparks(x,y,z,color,n=14,power=6){
const c=new THREE.Color(color);
for(let i=0;i<n;i++){
if(parts.length>=P_MAX)parts.shift();
const a=Math.random()*Math.PI*2, e=(Math.random()-0.3)*Math.PI;
const s=power*(0.4+Math.random()*0.8);
parts.push({x,y,z,vx:Math.cos(a)*Math.cos(e)*s,vy:Math.abs(Math.sin(e))*s+2,vz:Math.sin(a)*Math.cos(e)*s,life:0.5+Math.random()*0.4,maxLife:0.9,r:c.r,g:c.g,b:c.b,grav:14});
}
}
function spawnDebris(x,y,z,color,n=10){
const c=new THREE.Color(color);
for(let i=0;i<n;i++){
if(parts.length>=P_MAX)parts.shift();
parts.push({x:x+(Math.random()-0.5),y:y+Math.random()*1.5,z:z+(Math.random()-0.5),vx:(Math.random()-0.5)*7,vy:3+Math.random()*5,vz:(Math.random()-0.5)*7,life:0.8+Math.random()*0.6,maxLife:1.4,r:c.r,g:c.g,b:c.b,grav:22});
}
}
function updateParticles(dt){
for(let i=parts.length-1;i>=0;i--){
const p=parts[i]; p.life-=dt;
if(p.life<=0){parts.splice(i,1);continue;}
p.vy-=p.grav*dt; p.x+=p.vx*dt; p.y+=p.vy*dt; p.z+=p.vz*dt;
if(p.y<0.03){p.y=0.03;p.vy*=-0.4;p.vx*=0.7;p.vz*=0.7;}
}
for(let i=0;i<P_MAX;i++){
if(i<parts.length){const p=parts[i];const f=p.life/p.maxLife;
pPos[i*3]=p.x;pPos[i*3+1]=p.y;pPos[i*3+2]=p.z;
pCol[i*3]=p.r*f;pCol[i*3+1]=p.g*f;pCol[i*3+2]=p.b*f;
}else{pPos[i*3+1]=-100;}
}
pGeo.attributes.position.needsUpdate=true; pGeo.attributes.color.needsUpdate=true;
}
/* shockwave rings */
const rings=[];
function spawnRing(x,z,color){
const m=new THREE.Mesh(new THREE.RingGeometry(0.4,0.6,32),new THREE.MeshBasicMaterial({color,transparent:true,opacity:0.9,side:THREE.DoubleSide,depthWrite:false}));
m.rotation.x=-Math.PI/2; m.position.set(x,0.06,z); scene.add(m);
rings.push({m,life:0.5});
}
function updateRings(dt){
for(let i=rings.length-1;i>=0;i--){const r=rings[i];r.life-=dt;
r.m.scale.multiplyScalar(1+dt*10); r.m.material.opacity=Math.max(0,r.life*1.8);
if(r.life<=0){scene.remove(r.m);r.m.geometry.dispose();r.m.material.dispose();rings.splice(i,1);}
}
}
/* ================= CHARACTERS ================= */
function makeHumanoid(color,accent){
const g=new THREE.Group();
const mat=new THREE.MeshStandardMaterial({color,metalness:0.85,roughness:0.35});
const acc=new THREE.MeshStandardMaterial({color:accent,metalness:0.5,roughness:0.4,emissive:accent,emissiveIntensity:0.6});
const torso=new THREE.Mesh(new THREE.BoxGeometry(0.7,0.9,0.4),mat); torso.position.y=1.15; torso.castShadow=true; g.add(torso);
const chest=new THREE.Mesh(new THREE.BoxGeometry(0.5,0.2,0.1),acc); chest.position.set(0,1.3,0.22); g.add(chest);
const head=new THREE.Mesh(new THREE.BoxGeometry(0.4,0.35,0.4),mat); head.position.y=1.85; head.castShadow=true; g.add(head);
const visor=new THREE.Mesh(new THREE.BoxGeometry(0.3,0.08,0.05),acc); visor.position.set(0,1.87,0.21); g.add(visor);
const legL=new THREE.Mesh(new THREE.BoxGeometry(0.24,0.75,0.26),mat); legL.position.set(-0.18,0.38,0); legL.castShadow=true; g.add(legL);
const legR=legL.clone(); legR.position.x=0.18; g.add(legR);
const armL=new THREE.Mesh(new THREE.BoxGeometry(0.18,0.7,0.2),mat); armL.position.set(-0.48,1.25,0); armL.castShadow=true; g.add(armL);
const armR=armL.clone(); armR.position.x=0.48; g.add(armR);
g.userData={legL,legR,armL,armR,torso,head};
return g;
}
/* ---- Player ---- */
const player={
group:makeHumanoid(0x1c2a3a,0x00e5ff),
pos:new THREE.Vector3(0,0,8), vel:new THREE.Vector3(),
yaw:Math.PI, hp:100,maxHp:100, alive:true,
state:'idle', stateT:0, combo:0, comboTimer:0,
attackHitDone:false, attackPhase:0,
blocking:false, blockStun:0,
dodgeDir:new THREE.Vector3(), dodgeT:0,
swingId:0,
};
player.group.position.copy(player.pos);
scene.add(player.group);
/* sword */
const swordGroup=new THREE.Group();
const bladeMat=new THREE.MeshBasicMaterial({color:0x66f6ff});
const blade=new THREE.Mesh(new THREE.BoxGeometry(0.07,1.5,0.16),bladeMat);
blade.position.y=0.85; swordGroup.add(blade);
const bladeCore=new THREE.Mesh(new THREE.BoxGeometry(0.03,1.5,0.06),new THREE.MeshBasicMaterial({color:0xffffff}));
bladeCore.position.y=0.85; swordGroup.add(bladeCore);
const guard=new THREE.Mesh(new THREE.BoxGeometry(0.3,0.06,0.22),new THREE.MeshStandardMaterial({color:0x333f55,metalness:0.9,roughness:0.3}));
swordGroup.add(guard);
const hilt=new THREE.Mesh(new THREE.CylinderGeometry(0.045,0.05,0.3,8),new THREE.MeshStandardMaterial({color:0x222a38,metalness:0.9,roughness:0.3}));
hilt.position.y=-0.16; swordGroup.add(hilt);
swordGroup.position.set(0.55,1.0,0.25);
player.group.add(swordGroup);
const swordLight=new THREE.PointLight(0x33e0ff,2.2,9); swordLight.position.set(0.55,1.6,0.4); player.group.add(swordLight);
/* sword trail */
const TRAIL_N=16;
const trailGeo=new THREE.BufferGeometry();
const tPos=new Float32Array(TRAIL_N*3*2), tCol=new Float32Array(TRAIL_N*3*2);
trailGeo.setAttribute('position',new THREE.BufferAttribute(tPos,3));
trailGeo.setAttribute('color',new THREE.BufferAttribute(tCol,3));
const trailIdx=[]; for(let i=0;i<TRAIL_N-1;i++){const a=i*2;trailIdx.push(a,a+1,a+2,a+1,a+3,a+2);}
trailGeo.setIndex(trailIdx);
const trailMesh=new THREE.Mesh(trailGeo,new THREE.MeshBasicMaterial({vertexColors:true,transparent:true,blending:THREE.AdditiveBlending,side:THREE.DoubleSide,depthWrite:false}));
trailMesh.frustumCulled=false; scene.add(trailMesh);
const trailPts=[]; let trailActive=false, trailLife=0;
function tipWorld(){ const v=new THREE.Vector3(0,1.6,0); swordGroup.localToWorld(v); return v; }
function updateTrail(dt){
if(trailActive){
trailLife-=dt;
const tip=tipWorld();
trailPts.unshift(tip.clone());
if(trailPts.length>TRAIL_N)trailPts.pop();
if(trailLife<=0)trailActive=false;
}else{
if(trailPts.length)trailPts.pop();
else return;
}
const n=trailPts.length;
for(let i=0;i<TRAIL_N;i++){
const p=trailPts[Math.min(i,n-1)]||trailPts[0]||new THREE.Vector3();
const f=n>1?1-i/TRAIL_N:0;
tPos[i*6]=p.x; tPos[i*6+1]=p.y; tPos[i*6+2]=p.z;
tPos[i*6+3]=p.x; tPos[i*6+4]=p.y-0.06; tPos[i*6+5]=p.z;
const b=f*f*0.9;
tCol[i*6]=0.2*b;tCol[i*6+1]=0.9*b;tCol[i*6+2]=1.0*b;
tCol[i*6+3]=0.1*b;tCol[i*6+4]=0.4*b;tCol[i*6+5]=0.6*b;
}
trailGeo.attributes.position.needsUpdate=true; trailGeo.attributes.color.needsUpdate=true;
}
/* ---- Enemies ---- */
const enemies=[];
const ETYPES={
scout:{hp:30,speed:5.2,dmg:8,range:2.4,windup:0.45,recover:0.7,score:100,color:0x8a2a3a,accent:0xff4455,scale:0.85,block:false},
guardian:{hp:110,speed:2.4,dmg:18,range:2.7,windup:0.8,recover:1.1,score:250,color:0x3a4a5a,accent:0xffaa00,scale:1.35,block:true},
elite:{hp:70,speed:4.2,dmg:14,range:2.5,windup:0.5,recover:0.55,score:400,color:0x4a2a6a,accent:0xcc44ff,scale:1.05,block:false},
};
function buildEnemy(type){
const t=ETYPES[type];
const g=makeHumanoid(t.color,t.accent);
g.scale.setScalar(t.scale);
if(type==='guardian'){
const shield=new THREE.Mesh(new THREE.BoxGeometry(0.12,1.3,0.9),new THREE.MeshStandardMaterial({color:0x556677,metalness:0.9,roughness:0.3}));
shield.position.set(-0.62,1.2,0.1); shield.castShadow=true; g.add(shield);
const shGlow=new THREE.Mesh(new THREE.BoxGeometry(0.05,1.1,0.7),new THREE.MeshBasicMaterial({color:0xffaa00}));
shGlow.position.set(-0.68,1.2,0.1); g.add(shGlow);
g.userData.shield=shield;
}
if(type==='elite'){
const ant=new THREE.Mesh(new THREE.CylinderGeometry(0.02,0.02,0.5),new THREE.MeshStandardMaterial({color:0x333}));
ant.position.y=2.2; g.add(ant);
const tip=new THREE.Mesh(new THREE.SphereGeometry(0.06),new THREE.MeshBasicMaterial({color:0xcc44ff}));
tip.position.y=2.45; g.add(tip);
}
// health bar
const hbBg=new THREE.Sprite(new THREE.SpriteMaterial({color:0x111122,depthTest:false}));
hbBg.scale.set(1.1,0.12,1); hbBg.position.y=2.5; g.add(hbBg);
const hbFg=new THREE.Sprite(new THREE.SpriteMaterial({color:0x4dff9d,depthTest:false}));
hbFg.scale.set(1.04,0.08,1); hbFg.position.set(-0.02,2.5,0.001); g.add(hbFg);
// telegraph ring
const ring=new THREE.Mesh(new THREE.RingGeometry(0.5,0.72,24),new THREE.MeshBasicMaterial({color:0xff2233,transparent:true,opacity:0,side:THREE.DoubleSide,depthWrite:false}));
ring.rotation.x=-Math.PI/2; ring.position.y=0.05; g.add(ring);
scene.add(g);
const e={type,group:g,hp:t.hp,maxHp:t.hp,pos:new THREE.Vector3(),vel:new THREE.Vector3(),
yaw:0,state:'chase',stateT:0,atkCount:0,blockT:0,dodgeT:0,staggerT:0,
hbFg,ring,windupDur:t.windup,flashT:0,side:1,dead:false,deathT:0,attackHitDone:false};
return e;
}
function spawnEnemy(type,angle){
const e=buildEnemy(type);
const r=ARENA_R-6;
e.pos.set(Math.cos(angle)*r,0,Math.sin(angle)*r);
e.group.position.copy(e.pos);
enemies.push(e);
spawnRing(e.pos.x,e.pos.z,ETYPES[type].accent);
}
/* ================= GAME STATE ================= */
let state='menu'; // menu, playing, paused, over
let wave=0, score=0, waveTimer=0, waveActive=false, spawnQueue=[];
let autoplay=false, aiState='idle', aiTimer=0, aiTarget=null, aiDodgeCd=0, aiBlockT=0, aiAtkCd=0;
let camYaw=Math.PI, camPitch=0.32, camDist=7.5;
let shake=0, time=0;
const keys={};
let mouseDown=false;
const $=id=>document.getElementById(id);
function show(el){el.classList.remove('hidden')} function hide(el){el.classList.add('hidden')}
function banner(txt,ms=1800){ const b=$('banner'); b.textContent=txt; b.style.opacity=1; clearTimeout(b._t); b._t=setTimeout(()=>b.style.opacity=0,ms);}
function resetGame(){
for(const e of enemies)scene.remove(e.group);
enemies.length=0; parts.length=0; rings.length=0; trailPts.length=0;
player.pos.set(0,0,8); player.vel.set(0,0,0); player.hp=player.maxHp; player.alive=true;
player.state='idle'; player.combo=0; player.blocking=false; player.yaw=Math.PI;
score=0; wave=0; waveActive=false; spawnQueue=[];
$('uiScore').textContent='0';
startWave(1);
}
function startWave(n){
wave=n; waveActive=true;
spawnQueue=[];
const count=2+Math.min(n*2,14);
for(let i=0;i<count;i++){
let type='scout';
const r=Math.random();
if(n>=3&&r<0.18+Math.min(n*0.02,0.15))type='elite';
else if(n>=2&&r<0.45)type='guardian';
spawnQueue.push(type);
}
banner('WAVE '+n); SFX.wave();
waveTimer=1.2;
}
function updateWaves(dt){
if(!waveActive)return;
if(spawnQueue.length&&enemies.length<8){
waveTimer-=dt;
if(waveTimer<=0){
const type=spawnQueue.shift();
const a=Math.random()*Math.PI*2;
spawnEnemy(type,a);
waveTimer=0.7;
}
}
if(!spawnQueue.length&&enemies.length===0){
waveActive=false;
score+=wave*50;
banner('WAVE '+wave+' CLEARED +'+wave*50);
setTimeout(()=>{if(state==='playing')startWave(wave+1);},2200);
}
}
/* ================= COMBAT ================= */
const ATTACKS=[
{dur:0.42,hitT:0.16,arc:1.6,range:2.6,dmg:14,knock:5},
{dur:0.40,hitT:0.15,arc:1.6,range:2.6,dmg:14,knock:5},
{dur:0.55,hitT:0.24,arc:2.4,range:3.0,dmg:26,knock:11},
];
function startAttack(){
if(!player.alive||player.state==='dodge')return;
if(player.state==='attack'&&player.stateT<0.15)return;
player.combo=(player.comboTimer>0)?(player.combo%3):0;
player.comboTimer=1.1;
player.state='attack'; player.stateT=0; player.attackHitDone=false;
player.swingId++;
SFX[player.combo===2?'swing2':'swing']();
trailActive=true; trailLife=ATTACKS[player.combo].dur*0.8;
}
function attackHitCheck(){
const A=ATTACKS[player.combo];
const fwd=new THREE.Vector3(Math.sin(player.yaw),0,Math.cos(player.yaw));
let hitAny=false;
for(const e of enemies){
if(e.dead)continue;
const toE=new THREE.Vector3().subVectors(e.pos,player.pos); toE.y=0;
const d=toE.length();
if(d>A.range+e.group.scale.x*0.4)continue;
toE.normalize();
if(fwd.dot(toE)<Math.cos(A.arc/2))continue;
hitAny=true;
// guardian block
if(e.type==='guardian'&&e.state!=='stagger'){
const toP=new THREE.Vector3().subVectors(player.pos,e.pos).normalize();
const eFwd=new THREE.Vector3(Math.sin(e.yaw),0,Math.cos(e.yaw));
if(eFwd.dot(toP)>0.2){
e.hp-=2; SFX.clang(); spawnSparks(e.pos.x,1.3,e.pos.z,0xffcc44,8,4);
e.staggerT=0.15; e.state='stagger';
player.vel.addScaledVector(toE,-3);
continue;
}
}
damageEnemy(e,A.dmg,fwd,A.knock);
}
if(hitAny)shake=Math.min(shake+0.12,0.4);
}
function damageEnemy(e,dmg,dir,knock){
e.hp-=dmg; e.flashT=0.12;
e.vel.addScaledVector(dir,knock);
e.state='stagger'; e.stateT=0.28; e.staggerT=0.28;
spawnSparks(e.pos.x,1.2,e.pos.z,0xffe08a,16,7);
SFX.hit();
score+=10;
if(e.hp<=0)killEnemy(e);
}
function killEnemy(e){
e.dead=true; e.deathT=0;
score+=ETYPES[e.type].score;
spawnDebris(e.pos.x,0.5,e.pos.z,ETYPES[e.type].color,22);
spawnSparks(e.pos.x,1.2,e.pos.z,ETYPES[e.type].accent,26,9);
spawnRing(e.pos.x,e.pos.z,ETYPES[e.type].ac
The Kilo Gateway alternative
inclusionai/ling-3.2-flash:free route as free, matching the endpoint supplied for this test. After the interrupted OpenRouter saber response, we sent the original saber prompt through Kilo as a separate fresh request, without the partial code. Its three serial HTTP attempts all returned 429 with a daily Ant Digital route cap; no HTML was generated. This is an availability failure, not a zero coding score or a successful replacement result. We stopped; we did not rotate accounts, pay for a fallback, or substitute another model.How we checked and what to download
node scripts/check-ling32-article-benchmarks.mjs in this repository. The generation helper is node --import tsx scripts/run-article-benchmarks.mjs; use a new evidence folder and keep requests sequential. A free listing does not guarantee the route will be available on a later run.Read Next
MiniMax M3.1 Flash: Four HTML Coding Benchmarks on Free OpenCode
MiniMax M3.1 Flash tested through free OpenCode: original crane, globe, wizard-game and task-board HTML, browser screenshots, timings, downloadable evidence, 16 passing board checks and a reproduced game physics failure.
DeepSeek V4.1 Flash Review: Three Hands-On Coding Benchmarks
A hands-on DeepSeek V4.1 Flash review covering its 552B MoE architecture, compressed KV cache, official agent benchmarks, and three interactive creative-coding tests.
Tencent Hy4 Preview: Specs, Release Details, and How to Evaluate It
Tencent describes Hy4-preview as a 770B model with 49B active parameters and a context window over one million tokens. Review the company's internal benchmark disclosure, dated access offer, and an archived single-run visual coding sample.