Prompt specification
Build or customize the Three.js 3D scene "Expedition With a Finite Event Deck" inside the active workspace.
Engineering Constraints:
1. Runtime & Orbit: Use Three.js r160 with OrbitControls (damping enabled) and ACESFilmicToneMapping.
2. Frame Timing: Drive all motion strictly with clock.getDelta() so animation speed is FPS-independent.
3. Viewport Hygiene: Handle window resize cleanly, cap DPR at Math.min(window.devicePixelRatio, 2), and dispose geometries/materials/renderer on unmount.
Scene Metadata:
Scene: Expedition With a Finite Event Deck
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/expedition-with-a-finite-event-deck-x3531
Scene Description Prompt:
I'd like to see this as a voxel Three.js scene: expedition with a finite event deck. Build an original exploration board where a known deck controls weather events. Display discarded cards and allow planning based on changing conditional probabilities. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (expedition-with-a-finite-event-deck-x3531):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Frostline — Voxel Expedition</title>
<style>
:root {
color-scheme: dark;
--bg: #071117;
--panel: rgba(10, 24, 31, 0.93);
--panel-2: rgba(15, 34, 42, 0.82);
--line: rgba(132, 190, 191, 0.18);
--line-strong: rgba(132, 205, 202, 0.34);
--text: #e8f2ed;
--muted: #87a5a5;
--dim: #557274;
--cyan: #62d6d0;
--yellow: #f2b85b;
--red: #ff716c;
--green: #78d6a3;
--purple: #af8bff;
--blue: #65bde0;
--snow: #d9f4f1;
--wind: #7de0bd;
--clear: #f2ca67;
--rain: #65bde0;
--storm: #af8bff;
--mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
--sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body {
margin: 0;
min-height: 100%;
background: var(--bg);
color: var(--text);
font-family: var(--sans);
}
body {
overflow: hidden;
background:
radial-gradient(circle at 48% 18%, rgba(34, 86, 91, 0.22), transparent 35%),
radial-gradient(circle at 85% 70%, rgba(85, 63, 108, 0.14), transparent 30%),
#071117;
}
button { font: inherit; }
button:focus-visible {
outline: 2px solid var(--cyan);
outline-offset: 2px;
}
#app {
height: 100vh;
min-height: 620px;
display: grid;
grid-template-rows: 70px 1fr;
}
header {
z-index: 20;
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
padding: 0 20px;
border-bottom: 1px solid var(--line);
background: rgba(6, 17, 23, 0.91);
backdrop-filter: blur(18px);
}
.brand {
display: flex;
align-items: center;
gap: 13px;
min-width: 0;
}
.brand-mark {
position: relative;
width: 34px;
height: 34px;
flex: 0 0 auto;
transform: rotate(30deg) skewY(-4deg);
border: 2px solid var(--yellow);
background: linear-gradient(135deg, rgba(242,184,91,.24), transparent);
box-shadow: 7px 7px 0 -4px var(--cyan);
}
.brand-mark::after {
content: "";
position: absolute;
inset: 7px;
border: 2px solid rgba(242,184,91,.45);
}
.brand h1 {
margin: 0;
font-size: 17px;
line-height: 1;
letter-spacing: .18em;
text-transform: uppercase;
}
.brand p {
margin: 6px 0 0;
color: var(--muted);
font: 10px/1 var(--mono);
letter-spacing: .08em;
text-transform: uppercase;
}
.header-center {
display: flex;
align-items: center;
justify-content: center;
gap: 9px;
flex: 1;
}
.header-chip {
display: inline-flex;
align-items: center;
gap: 7px;
padding: 8px 10px;
border: 1px solid var(--line);
background: rgba(255,255,255,.025);
color: var(--muted);
font: 10px/1 var(--mono);
letter-spacing: .06em;
text-transform: uppercase;
white-space: nowrap;
}
.header-chip b {
color: var(--text);
font-weight: 600;
}
.status-dot {
width: 6px;
height: 6px;
background: var(--cyan);
box-shadow: 0 0 10px var(--cyan);
}
.header-actions {
display: flex;
align-items: center;
gap: 8px;
}
.ghost-btn {
border: 1px solid var(--line-strong);
background: transparent;
color: var(--muted);
padding: 9px 12px;
cursor: pointer;
font: 10px/1 var(--mono);
letter-spacing: .06em;
text-transform: uppercase;
transition: .18s ease;
}
.ghost-btn:hover {
color: var(--text);
border-color: var(--cyan);
background: rgba(98,214,208,.06);
}
main {
min-height: 0;
display: grid;
grid-template-columns: 286px minmax(420px, 1fr) 340px;
grid-template-areas: "left scene right";
}
.panel {
min-height: 0;
overflow-y: auto;
scrollbar-width: thin;
scrollbar-color: #315058 transparent;
background: var(--panel);
backdrop-filter: blur(16px);
}
.panel::-webkit-scrollbar { width: 5px; }
.panel::-webkit-scrollbar-thumb { background: #315058; }
.left-panel {
grid-area: left;
border-right: 1px solid var(--line);
padding: 18px;
}
.right-panel {
grid-area: right;
border-left: 1px solid var(--line);
padding: 18px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 9px;
color: var(--cyan);
font: 10px/1 var(--mono);
letter-spacing: .14em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 15px;
height: 2px;
background: currentColor;
}
.mission-title {
margin: 0;
font-size: 26px;
line-height: 1.05;
letter-spacing: -.035em;
}
.mission-copy {
margin: 10px 0 17px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.location-card {
position: relative;
overflow: hidden;
padding: 14px;
border: 1px solid var(--line-strong);
background: linear-gradient(135deg, rgba(98,214,208,.08), rgba(255,255,255,.018));
}
.location-card::after {
content: "";
position: absolute;
width: 44px;
height: 44px;
right: -13px;
top: -13px;
border: 1px solid rgba(98,214,208,.22);
transform: rotate(45deg);
}
.small-label {
color: var(--dim);
font: 9px/1 var(--mono);
letter-spacing: .11em;
text-transform: uppercase;
}
.location-row {
display: flex;
justify-content: space-between;
align-items: flex-end;
gap: 10px;
margin-top: 8px;
}
.location-name {
font-size: 17px;
font-weight: 650;
}
.location-next {
margin-top: 5px;
color: var(--muted);
font-size: 11px;
}
.waypoint-code {
color: var(--yellow);
font: 12px/1 var(--mono);
}
.route-track {
position: relative;
margin: 16px 2px 20px;
display: grid;
grid-template-columns: repeat(7, 1fr);
}
.route-track::before {
content: "";
position: absolute;
left: 6%;
right: 6%;
top: 7px;
height: 1px;
background: var(--line-strong);
}
.route-node {
position: relative;
z-index: 1;
display: grid;
justify-items: center;
gap: 7px;
color: var(--dim);
font: 8px/1 var(--mono);
text-align: center;
}
.route-node i {
width: 9px;
height: 9px;
border: 2px solid #385359;
background: var(--panel);
transform: rotate(45deg);
}
.route-node.done { color: var(--muted); }
.route-node.done i { border-color: var(--green); background: var(--green); }
.route-node.current { color: var(--yellow); }
.route-node.current i {
border-color: var(--yellow);
background: var(--yellow);
box-shadow: 0 0 11px rgba(242,184,91,.55);
}
.route-node.next { color: var(--cyan); }
.route-node.next i { border-color: var(--cyan); }
.section-title {
display: flex;
align-items: center;
justify-content: space-between;
margin: 20px 0 10px;
color: var(--text);
font: 10px/1 var(--mono);
letter-spacing: .12em;
text-transform: uppercase;
}
.section-title span {
color: var(--dim);
font-size: 9px;
letter-spacing: .05em;
}
.stats-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
.stat {
padding: 11px;
border: 1px solid var(--line);
background: rgba(255,255,255,.018);
}
.stat.wide { grid-column: 1 / -1; }
.stat-head {
display: flex;
align-items: center;
justify-content: space-between;
color: var(--muted);
font: 9px/1 var(--mono);
text-transform: uppercase;
letter-spacing: .08em;
}
.stat-head b {
color: var(--text);
font-size: 11px;
}
.meter {
height: 4px;
margin-top: 9px;
background: rgba(255,255,255,.07);
overflow: hidden;
}
.meter > i {
display: block;
height: 100%;
width: 50%;
background: var(--cyan);
transition: width .35s ease, background .2s ease;
}
.plan-list {
display: grid;
gap: 7px;
}
.plan {
position: relative;
width: 100%;
padding: 12px 12px 11px 38px;
border: 1px solid var(--line);
background: rgba(255,255,255,.018);
color: var(--text);
text-align: left;
cursor: pointer;
transition: .18s ease;
}
.plan::before {
content: "";
position: absolute;
left: 13px;
top: 15px;
width: 11px;
height: 11px;
border: 1px solid #4f6c70;
transform: rotate(45deg);
}
.plan:hover:not(:disabled) {
border-color: var(--line-strong);
background: rgba(98,214,208,.035);
}
.plan.selected {
border-color: rgba(98,214,208,.72);
background: linear-gradient(90deg, rgba(98,214,208,.1), rgba(98,214,208,.02));
}
.plan.selected::before {
border-color: var(--cyan);
background: var(--cyan);
box-shadow: 0 0 10px rgba(98,214,208,.4);
}
.plan:disabled {
opacity: .37;
cursor: not-allowed;
}
.plan strong {
display: block;
font-size: 12px;
font-weight: 650;
}
.plan small {
display: block;
margin-top: 5px;
color: var(--muted);
font-size: 10px;
line-height: 1.35;
}
.plan .odds {
float: right;
color: var(--yellow);
font: 11px/1 var(--mono);
}
.odds-box {
display: grid;
grid-template-columns: 1fr auto;
gap: 8px;
align-items: center;
margin-top: 10px;
padding: 10px 11px;
border-left: 2px solid var(--yellow);
background: rgba(242,184,91,.055);
}
.odds-box span {
color: var(--muted);
font-size: 10px;
line-height: 1.35;
}
.odds-box b {
color: var(--yellow);
font: 18px/1 var(--mono);
}
.field-actions {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
}
.action-btn {
min-height: 55px;
padding: 9px;
border: 1px solid var(--line);
background: rgba(255,255,255,.022);
color: var(--text);
cursor: pointer;
font-size: 10px;
line-height: 1.3;
text-align: left;
}
.action-btn:hover:not(:disabled) {
border-color: var(--cyan);
background: rgba(98,214,208,.06);
}
.action-btn:disabled { opacity: .35; cursor: not-allowed; }
.action-btn b { display: block; margin-bottom: 3px; font-size: 11px; }
.action-btn span { color: var(--muted); font: 9px/1.3 var(--mono); }
.commit-btn {
width: 100%;
margin-top: 9px;
padding: 13px 12px;
border: 1px solid var(--yellow);
background: var(--yellow);
color: #182126;
cursor: pointer;
font: 700 11px/1 var(--mono);
letter-spacing: .06em;
text-transform: uppercase;
box-shadow: 4px 4px 0 rgba(242,184,91,.15);
transition: .18s ease;
}
.commit-btn:hover:not(:disabled) {
transform: translate(-1px,-1px);
box-shadow: 6px 6px 0 rgba(242,184,91,.18);
}
.commit-btn:disabled { opacity: .35; cursor: not-allowed; }
.outcome {
min-height: 66px;
margin-top: 16px;
padding: 10px;
border: 1px solid var(--line);
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.outcome b { color: var(--text); }
.scene {
position: relative;
grid-area: scene;
min-width: 0;
min-height: 0;
overflow: hidden;
background:
radial-gradient(circle at 50% 40%, #102833, #071117 75%);
}
#scene {
position: absolute;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene canvas:active { cursor: grabbing; }
.scene-top {
position: absolute;
z-index: 3;
top: 17px;
left: 18px;
right: 18px;
display: flex;
justify-content: space-between;
align-items: flex-start;
pointer-events: none;
}
.scene-id {
padding: 10px 12px;
border-left: 2px solid var(--cyan);
background: rgba(5,15,21,.72);
backdrop-filter: blur(10px);
}
.scene-id b {
display: block;
font: 11px/1 var(--mono);
letter-spacing: .09em;
}
.scene-id span {
display: block;
margin-top: 6px;
color: var(--muted);
font: 9px/1 var(--mono);
}
.scene-weather {
display: flex;
align-items: center;
gap: 8px;
padding: 9px 11px;
border: 1px solid var(--line);
background: rgba(5,15,21,.72);
color: var(--muted);
font: 9px/1 var(--mono);
text-transform: uppercase;
backdrop-filter: blur(10px);
}
.weather-glyph {
color: var(--cyan);
font-size: 16px;
}
.scene-bottom {
position: absolute;
z-index: 3;
left: 18px;
right: 18px;
bottom: 16px;
display: flex;
justify-content: space-between;
align-items: flex-end;
gap: 12px;
pointer-events: none;
}
.map-legend {
display: flex;
flex-wrap: wrap;
gap: 12px;
padding: 9px 11px;
background: rgba(5,15,21,.72);
border: 1px solid var(--line);
color: var(--muted);
font: 9px/1 var(--mono);
backdrop-filter: blur(10px);
}
.map-legend span { display: flex; align-items: center; gap: 6px; }
.map-legend i { width: 7px; height: 7px; display: inline-block; }
.map-legend .current-dot { background: var(--yellow); }
.map-legend .next-dot { background: var(--cyan); }
.map-legend .done-dot { background: var(--green); }
.camera-help {
color: rgba(203,224,221,.55);
font: 9px/1.4 var(--mono);
text-align: right;
text-transform: uppercase;
}
.scene-reset {
pointer-events: auto;
margin-top: 7px;
padding: 7px 9px;
border: 1px solid var(--line);
background: rgba(5,15,21,.72);
color: var(--muted);
cursor: pointer;
font: 9px/1 var(--mono);
text-transform: uppercase;
}
.scene-reset:hover { color: var(--text); border-color: var(--cyan); }
.weather-card {
--cat: var(--cyan);
position: relative;
overflow: hidden;
min-height: 146px;
padding: 17px;
border: 1px solid var(--line-strong);
background:
linear-gradient(135deg, color-mix(in srgb, var(--cat) 12%, transparent), transparent 65%),
rgba(255,255,255,.018);
}
.weather-card::after {
content: "";
position: absolute;
right: -25px;
bottom: -25px;
width: 85px;
height: 85px;
border: 1px solid color-mix(in srgb, var(--cat) 35%, transparent);
transform: rotate(45deg);
}
.weather-card-head {
display: flex;
align-items: center;
justify-content: space-between;
color: var(--muted);
font: 9px/1 var(--mono);
letter-spacing: .08em;
text-transform: uppercase;
}
.weather-card-icon {
width: 42px;
height: 42px;
display: grid;
place-items: center;
margin: 16px 0 11px;
border: 1px solid color-mix(in srgb, var(--cat) 50%, transparent);
color: var(--cat);
background: color-mix(in srgb, var(--cat) 8%, transparent);
font-size: 23px;
box-shadow: 5px 5px 0 color-mix(in srgb, var(--cat) 9%, transparent);
}
.weather-card h3 {
margin: 0;
font-size: 20px;
line-height: 1.05;
letter-spacing: -.025em;
}
.weather-card p {
margin: 7px 0 0;
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.basis-note {
margin: 10px 0 0;
color: var(--dim);
font: 9px/1.45 var(--mono);
}
.forecast-list {
display: grid;
gap: 8px;
margin-top: 14px;
}
.forecast-row {
display: grid;
grid-template-columns: 70px 1fr 34px;
align-items: center;
gap: 8px;
color: var(--muted);
font: 9px/1 var(--mono);
}
.forecast-track {
height: 5px;
background: rgba(255,255,255,.055);
overflow: hidden;
}
.forecast-track i {
display: block;
height: 100%;
width: 0;
background: var(--cat);
transition: width .35s ease;
}
.forecast-row b {
color: var(--text);
text-align: right;
font-weight: 500;
}
details {
margin-top: 12px;
border: 1px solid var(--line);
background: rgba(255,255,255,.012);
}
summary {
padding: 11px 12px;
cursor: pointer;
color: var(--text);
font: 10px/1 var(--mono);
letter-spacing: .08em;
text-transform: uppercase;
list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::before { content: "+ "; color: var(--cyan); }
details[open] summary::before { content: "− "; }
.deck-note {
padding: 0 12px 10px;
color: var(--dim);
font-size: 9px;
line-height: 1.45;
}
.manifest-list {
border-top: 1px solid var(--line);
}
.manifest-row {
--cat: var(--cyan);
display: grid;
grid-template-columns: 23px 1fr auto;
gap: 8px;
align-items: center;
padding: 9px 11px;
border-bottom: 1px solid rgba(132,190,191,.08);
cursor: help;
}
.manifest-row:hover { background: rgba(255,255,255,.025); }
.manifest-row.zero { opacity: .33; }
.card-chip {
width: 22px;
height: 22px;
display: grid;
place-items: center;
border: 1px solid color-mix(in srgb, var(--cat) 48%, transparent);
color: var(--cat);
background: color-mix(in srgb, var(--cat) 7%, transparent);
font-size: 11px;
}
.manifest-name {
min-width: 0;
font-size: 10px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.manifest-meta {
color: var(--dim);
font: 8px/1.3 var(--mono);
text-align: right;
text-transform: uppercase;
}
.discard-list {
max-height: 220px;
overflow-y: auto;
border-top: 1px solid var(--line);
}
.discard-row {
--cat: var(--cyan);
display: grid;
grid-template-columns: 24px 1fr auto;
gap: 8px;
align-items: center;
padding: 9px 10px;
border-bottom: 1px solid rgba(132,190,191,.08);
}
.discard-row .card-chip { width: 23px; height: 23px; }
.discard-name { font-size: 10px; }
.discard-result {
margin-top: 3px;
color: var(--dim);
font: 8px/1 var(--mono);
text-transform: uppercase;
}
.discard-round { color: var(--dim); font: 8px/1 var(--mono); }
.empty {
padding: 18px 12px;
color: var(--dim);
text-align: center;
font: 9px/1.5 var(--mono);
}
.audit-strip {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 1px;
margin-top: 12px;
border: 1px solid var(--line);
background: var(--line);
}
.audit-strip div {
padding: 9px 5px;
text-align: center;
background: #0b1b22;
}
.audit-strip b {
display: block;
color: var(--text);
font: 12px/1 var(--mono);
}
.audit-strip span {
display: block;
margin-top: 5px;
color: var(--dim);
font: 7px/1 var(--mono);
letter-spacing: .06em;
text-transform: uppercase;
}
.toast {
position: fixed;
z-index: 100;
left: 50%;
bottom: 25px;
max-width: min(460px, calc(100vw - 30px));
transform: translate(-50%, 20px);
padding: 11px 15px;
border: 1px solid var(--line-strong);
background: rgba(8,23,29,.96);
color: var(--text);
font: 10px/1.45 var(--mono);
text-align: center;
opacity: 0;
pointer-events: none;
transition: .25s ease;
}
.toast.show {
transform: translate(-50%, 0);
opacity: 1;
}
.event-flash {
position: fixed;
z-index: 90;
inset: 0;
pointer-events: none;
opacity: 0;
background: radial-gradient(circle at 50% 45%, transparent 10%, rgba(101,189,224,.15));
}
.event-flash.fire { animation: flash .75s ease-out; }
@keyframes flash {
0% { opacity: 0; }
18% { opacity: 1; }
100% { opacity: 0; }
}
.end-overlay {
position: fixed;
z-index: 80;
inset: 0;
display: none;
place-items: center;
padding: 20px;
background: rgba(3,10,14,.78);
backdrop-filter: blur(12px);
}
.end-overlay.show { display: grid; }
.end-card {
width: min(460px, 100%);
padding: 30px;
border: 1px solid var(--line-strong);
background: #0b1b22;
box-shadow: 12px 12px 0 rgba(0,0,0,.25);
}
.end-card h2 {
margin: 0 0 12px;
font-size: 34px;
letter-spacing: -.04em;
}
.end-card p {
color: var(--muted);
font-size: 12px;
line-height: 1.65;
}
.end-card button {
margin-top: 12px;
width: 100%;
padding: 13px;
border: 1px solid var(--cyan);
background: rgba(98,214,208,.1);
color: var(--cyan);
cursor: pointer;
font: 10px/1 var(--mono);
letter-spacing: .08em;
text-transform: uppercase;
}
@media (max-width: 1160px) {
main { grid-template-columns: 254px minmax(360px, 1fr) 300px; }
.left-panel, .right-panel { padding: 14px; }
.header-center .header-chip:nth-child(2) { display: none; }
}
@media (max-width: 860px) {
body { overflow: auto; }
#app { height: auto; min-height: 100vh; grid-template-rows: 64px auto; }
header { padding: 0 13px; }
.header-center { display: none; }
.brand p { display: none; }
main {
grid-template-columns: 1fr;
grid-template-areas: "scene" "left" "right";
}
.scene { height: 58vh; min-height: 430px; }
.panel { overflow: visible; }
.left-panel { border-right: 0; border-top: 1px solid var(--line); }
.right-panel { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 520px) {
.brand h1 { font-size: 14px; }
.header-actions .ghost-btn:first-child { display: none; }
.scene { height: 52vh; min-height: 360px; }
.camera-help { display: none; }
.scene-top { left: 10px; right: 10px; top: 10px; }
.scene-bottom { left: 10px; right: 10px; bottom: 10px; }
.map-legend { gap: 8px; }
.mission-title { font-size: 23px; }
}
</style>
</head>
<body>
<div id="app">
<header>
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div>
<h1>Frostline</h1>
<p>Voxel expedition command</p>
</div>
</div>
<div class="header-center">
<div class="header-chip"><i class="status-dot"></i><b id="headerLocation">Base Camp</b></div>
<div class="header-chip">Known deck <b id="headerDeckCount">16 cards</b></div>
<div class="header-chip">Order <b>sealed</b></div>
</div>
<div class="header-actions">
<button class="ghost-btn" id="auditBtn">Audit deck</button>
<button class="ghost-btn" id="restartBtn">Restart</button>
</div>
</header>
<main>
<aside class="panel left-panel">
<div class="eyebrow">Expedition 07</div>
<h2 class="mission-title">The Whiteout<br />Relay</h2>
<p class="mission-copy">
Carry the signal across six exposed waypoints. Every forecast comes from a finite,
audited event deck—not procedural weather.
</p>
<div class="location-card">
<div class="small-label">Current position</div>
<div class="location-row">
<div>
<div class="location-name" id="currentName">Base Camp</div>
<div class="location-next" id="nextName">Next: Reed Ford</div>
</div>
<div class="waypoint-code" id="waypointCode">01 / 07</div>
</div>
</div>
<div class="route-track" id="routeTrack"></div>
<div class="section-title">Expedition state <span id="turnLabel">Turn 01</span></div>
<div class="stats-grid">
<div class="stat wide">
<div class="stat-head"><span>Vigor</span><b id="vigorValue">100</b></div>
<div class="meter"><i id="vigorBar"></i></div>
</div>
<div class="stat">
<div class="stat-head"><span>Supplies</span><b id="supplyValue">6</b></div>
</div>
<div class="stat">
<div class="stat-head"><span>Morale</span><b id="moraleValue">72</b></div>
<div class="meter"><i id="moraleBar"></i></div>
</div>
</div>
<div class="section-title">Route plan <span>Choose one</span></div>
<div class="plan-list">
<button class="plan" data-plan="shelter">
<span class="odds">HOLD</span>
<strong>Shelter in place</strong>
<small>No route progress. Weather exposure reduced to 45%.</small>
</button>
<button class="plan selected" data-plan="steady">
<span class="odds" id="steadyOdds">--%</span>
<strong>Measured crossing</strong>
<small>Advance one waypoint if the crossing check succeeds.</small>
</button>
<button class="plan" data-plan="run">
<span class="odds" id="runOdds">--%</span>
<strong>Storm run</strong>
<small>Faster morale, but harder crossings and heavier impact.</small>
</button>
</div>
<div class="odds-box">
<span id="oddsLabel">Forecasted crossing odds<br>from remaining deck</span>
<b id="crossingOdds">--%</b>
</div>
<div class="section-title">Field actions <span>Before resolving</span></div>
<div class="field-actions">
<button class="action-btn" id="campBtn">
<b>Make camp</b>
<span>−2 supply · +12 vigor</span>
</button>
<button class="action-btn" id="scoutBtn">
<b id="scoutTitle">Read the sky</b>
<span id="scoutCost">−1 supply · reveal top</span>
</button>
</div>
<button class="commit-btn" id="commitBtn">Resolve weather</button>
<div class="outcome" id="outcomeBox">
<b>Awaiting first decision.</b><br />The deck is sealed. Scout it or commit a route plan.
</div>
</aside>
<section class="scene" id="sceneStage">
<div id="scene"></div>
<div class="scene-top">
<div class="scene-id">
<b>WHITEOUT RANGE / SECTOR 4E</b>
<span>VOXEL SURVEY · ELEVATION 2,840 M</span>
</div>
<div class="scene-weather">
<span class="weather-glyph" id="weatherGlyph">◇</span>
<span id="weatherText">No front observed</span>
</div>
</div>
<div class="scene-bottom">
<div class="map-legend">
<span><i class="current-dot"></i> Expedition</span>
<span><i class="next-dot"></i> Next waypoint</span>
<span><i class="done-dot"></i> Surveyed</span>
</div>
<div>
<div class="camera-help">Drag to orbit · wheel to zoom<br />Select a marker for survey notes</div>
<button class="scene-reset" id="resetCameraBtn">Reset view</button>
</div>
</div>
</section>
<aside class="panel right-panel">
<div class="eyebrow">Finite event deck</div>
<h2 class="mission-title" style="font-size:22px">Weather Oracle</h2>
<p class="mission-copy" style="margin-bottom:13px">
All 16 event cards are known. Only their order is concealed. Discarding a card changes
the posterior forecast for the next turn.
</p>
<div class="weather-card" id="weatherCard">
<div class="weather-card-head">
<span id="weatherState">Order sealed</span>
<span id="weatherDeckRemaining">16 remain</span>
</div>
<div class="weather-card-icon" id="weatherIcon">?</div>
<h3 id="nextCardTitle">Unknown front</h3>
<p id="nextCardSub">Draw from the audited event deck.</p>
</div>
<p class="basis-note" id="basisNote">Posterior based only on the remaining card composition.</p>
<div class="section-title">Next-event distribution <span id="forecastBasis">Unconditioned</span></div>
<div class="forecast-list" id="forecastList"></div>
<details open>
<summary>Known deck manifest</summary>
<div class="deck-note">
Card names and quantities are fixed. Probabilities show the chance each event is next;
after scouting, the observed top card becomes certain.
</div>
<div class="manifest-list" id="manifestList"></div>
</details>
<details open>
<summary>Discard record <span id="discardCount">0 / 16</span></summary>
<div class="discard-list" id="discardList"></div>
</details>
<div class="audit-strip">
<div><b>16</b><span>Total cards</span></div>
<div><b id="remainingStat">16</b><span>Remaining</span></div>
<div><b id="discardStat">0</b><span>Discarded</span></div>
</div>
</aside>
</main>
</div>
<div class="toast" id="toast"></div>
<div class="event-flash" id="eventFlash"></div>
<div class="end-overlay" id="endOverlay">
<div class="end-card">
<div class="eyebrow">Expedition report</div>
<h2 id="endTitle">Signal relayed</h2>
<p id="endCopy"></p>
<button id="endRestartBtn">Begin another expedition</button>
</div>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const $ = id => document.getElementById(id);
const CATEGORY = {
Clear: { color: "#f2ca67", glyph: "☀", label: "CLEAR" },
Rain: { color: "#65bde0", glyph: "≈", label: "RAIN" },
Snow: { color: "#d9f4f1", glyph: "❄", label: "SNOW" },
Storm: { color: "#af8bff", glyph: "ϟ", label: "STORM" },
Wind: { color: "#7de0bd", glyph: "≋", label: "WIND" }
};
const DECK_SPEC = [
{ name: "Blue Morning", cat: "Clear", diff: 0, copies: 2 },
{ name: "Still Air", cat: "Clear", diff: 0, copies: 1 },
{ name: "Sun Break", cat: "Clear", diff: 0, copies: 1 },
{ name: "Valley Drizzle",cat: "Rain", diff: 1, copies: 2 },
{ name: "Cold Front", cat: "Rain", diff: 1, copies: 1 },
{ name: "Heavy Rain", cat: "Rain", diff: 2, copies: 1 },
{ name: "First Flurries",cat: "Snow", diff: 2, copies: 2 },
{ name: "Deep Snow", cat: "Snow", diff: 3, copies: 1 },
{ name: "Whiteout", cat: "Snow", diff: 3, copies: 1 },
{ name: "Thunderhead", cat: "Storm", diff: 3, copies: 1 },
{ name: "Black Squall", cat: "Storm", diff: 4, copies: 1 },
{ name: "Ridge Gale", cat: "Wind", diff: 3, copies: 1 },
{ name: "Crosswind", cat: "Wind", diff: 2, copies: 1 },
{ name: "Mistfall", cat: "Rain", diff: 1, copies: 1 },
{ name: "Silver Thaw", cat: "Clear", diff: 0, copies: 1 },
{ name: "Narrow Sun", cat: "Clear", diff: 0, copies: 1 }
];
const WAYPOINTS = [
{ name: "Base Camp", code: "01", x: -7.5, y: .62, z: 4.8, note: "Relay origin. Supply crates and the outbound radio mast." },
{ name: "Reed Ford", code: "02", x: -5.0, y: .86, z: 2.8, note: "A shallow meltwater crossing above the old survey road." },
{ name: "Pine Shelf", code: "03", x: -2.3, y: 1.15, z: 1.1, note: "Last reliable tree cover on the western approach." },
{ name: "Echo Pass", code: "04", x: .3, y: 1.72, z: -1.0, note: "Wind funnels through the notch and carries radio static." },
{ name: "Ice Shelf", code: "05", x: 3.0, y: 2.46, z: -2.7, note: "A fractured blue shelf with very little purchase." },
{ name: "Ridge Camp", code: "06", x: 5.2, y: 3.10, z: -.3, note: "An abandoned storm station with one working antenna." },
{ name: "Summit Relay", code: "07", x: 7.4, y: 3.82, z: -4.2, note: "The destination relay. Restore the signal and end the expedition." }
];
const PLAN = {
shelter: { label: "shelter in place", supply: 0, exposure: .45 },
steady: { label: "measured crossing", supply: 1, exposure: 1.00 },
run: { label: "storm run", supply: 2, exposure: 1.20 }
};
const state = {
deck: [],
discarded: [],
current: 0,
plan: "steady",
vigor: 100,
supplies: 6,
morale: 72,
revealed: false,
turn: 1,
over: false,
won: false,
sceneWeather: null
};
function makeDeck() {
const result = [];
let uid = 0;
DECK_SPEC.forEach(spec => {
for (let i = 0; i < spec.copies; i++) {
result.push({ uid: uid++, name: spec.name, cat: spec.cat, diff: spec.diff });
}
});
for (let i = result.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[result[i], result[j]] = [result[j], result[i]];
}
return result;
}
function topCard() {
return state.deck[0] || null;
}
function basePassChance(card) {
return {
0: .99,
1: .84,
2: .62,
3: .38,
4: .30
}[card.diff] ?? .5;
}
function passChanceForCard(card, plan = state.plan) {
if (plan === "shelter") return 0;
let chance = basePassChance(card);
if (plan === "steady") {
chance += Math.max(-.08, Math.min(.08, (state.vigor - 60) * .002 + (state.morale - 60) * .001));
} else if (plan === "run") {
chance -= card.diff === 0 ? .03 : .10;
}
return Math.max(.12, Math.min(.98, chance));
}
function forecastOdds(plan = state.plan) {
if (!state.deck.length || plan === "shelter") return 0;
if (state.revealed) {
const card = topCard();
return card ? passChanceForCard(card, plan) : 0;
}
const sum = state.deck.reduce((acc, card) => acc + passChanceForCard(card, plan), 0);
return sum / state.deck.length;
}
function categoryDistribution() {
const result = {};
Object.keys(CATEGORY).forEach(k => result[k] = 0);
if (!state.deck.length) return result;
if (state.revealed && topCard()) {
result[topCard().cat] = 1;
return result;
}
state.deck.forEach(card => result[card.cat]++);
Object.keys(result).forEach(k => result[k] /= state.deck.length);
return result;
}
function remainingGroups() {
const groups = new Map();
state.deck.forEach(card => {
const key = card.name + "|" + card.cat;
if (!groups.has(key)) groups.set(key, { name: card.name, cat: card.cat, diff: card.diff, count: 0 });
groups.get(key).count++;
});
return [...groups.values()];
}
function toast(message) {
$("toast").textContent = message;
$("toast").classList.add("show");
clearTimeout(toast.timer);
toast.timer = setTimeout(() => $("toast").classList.remove("show"), 2800);
}
function flashWeather(color) {
const el = $("eventFlash");
el.style.background = `radial-gradient(circle at 50% 45%, transparent 8%, ${color}28)`;
el.classList.remove("fire");
void el.offsetWidth;
el.classList.add("fire");
}
function renderRoute() {
$("routeTrack").innerHTML = WAYPOINTS.map((w, i) => {
const cls = i < state.current ? "done" : i === state.current ? "current" : i === state.current + 1 ? "next" : "";
return `<div class="route-node ${cls}"><i></i><span>${w.code}</span></div>`;
}).join("");
$("currentName").textContent = WAYPOINTS[state.current].name;
$("headerLocation").textContent = WAYPOINTS[state.current].name;
$("waypointCode").textContent = `${String(state.current + 1).padStart(2, "0")} / 07`;
$("nextName").textContent = state.current < WAYPOINTS.length - 1
? `Next: ${WAYPOINTS[state.current + 1].name}`
: "Destination reached";
$("turnLabel").textContent = `Turn ${String(state.turn).padStart(2, "0")}`;
}
function renderStats() {
$("vigorValue").textContent = Math.max(0, Math.round(state.vigor));
$("supplyValue").textContent = state.supplies;
$("moraleValue").textContent = Math.max(0, Math.round(state.morale));
$("vigorBar").style.width = `${Math.max(0, Math.min(100, state.vigor))}%`;
$("vigorBar").style.background = state.vigor < 30 ? "var(--red)" : "var(--cyan)";
$("moraleBar").style.width = `${Math.max(0, Math.min(100, state.morale))}%`;
$("moraleBar").style.background = state.morale < 30 ? "var(--red)" : "var(--green)";
}
function renderPlans() {
document.querySelectorAll(".plan").forEach(btn => {
const plan = btn.dataset.plan;
btn.classList.toggle("selected", state.plan === plan);
btn.disabled = state.over || (plan !== "shelter" && state.supplies < PLAN[plan].supply);
});
const steady = forecastOdds("steady");
const run = forecastOdds("run");
$("steadyOdds").textContent = state.current < WAYPOINTS.length - 1 ? `${Math.round(steady * 100)}%` : "DONE";
$("runOdds").textContent = state.current < WAYPOINTS.length - 1 ? `${Math.round(run * 100)}%` : "DONE";
$("crossingOdds").textContent = state.plan === "shelter" ? "HOLD" : `${Math.round(forecastOdds() * 100)}%`;
if (state.plan === "shelter") {
$("oddsLabel").innerHTML = "No route progress.<br />Weather exposure is reduced.";
} else {
$("oddsLabel").innerHTML = state.revealed
? "Conditioned on the<br />observed top card."
: `Weighted across ${state.deck.length}<br />remaining event cards.`;
}
$("commitBtn").disabled = state.over || !state.deck.length;
$("commitBtn").textContent = state.current === WAYPOINTS.length - 1
? "Expedition complete"
: `Resolve weather — ${PLAN[state.plan].label}`;
}
function renderForecast() {
const dist = categoryDistribution();
$("forecastList").innerHTML = Object.entries(CATEGORY).map(([name, meta]) => {
const pct = Math.round((dist[name] || 0) * 100);
return `
<div class="forecast-row" style="--cat:${meta.color}">
<span>${meta.label}</span>
<div class="forecast-track"><i style="width:${pct}%"></i></div>
<b>${pct}%</b>
</div>`;
}).join("");
$("forecastBasis").textContent = state.revealed ? "Observed" : "Unconditioned";
$("basisNote").textContent = state.revealed
? "The top card is known, so the next-event distribution is now certain."
: "Posterior based only on the remaining card composition.";
}
function renderManifest() {
const groups = remainingGroups();
const total = state.deck.length;
const observed = state.revealed ? topCard() : null;
$("manifestList").innerHTML = groups.length ? groups.map(group => {
const probability = observed
? (group.name === observed.name ? 1 : 0)
: group.count / Math.max(1, total);
const safe = Math.round(passChanceForCard(group, "steady") * 100);
return `
<div class="manifest-row ${probability === 0 ? "zero" : ""}" style="--cat:${CATEGORY[group.cat].color}"
title="${group.name}: ${group.count} remaining. Measured-crossing success if this event occurs: ${safe}%.">
<div class="card-chip">${CATEGORY[group.cat].glyph}</div>
<div class="manifest-name">${group.name}</div>
<div class="manifest-meta">${group.count} left<br />${Math.round(probability * 100)}% next</div>
</div>`;
}).join("") : `<div class="empty">The event deck is empty.</div>`;
}
function renderDiscard() {
const items = [...state.discarded].reverse();
$("discardCount").textContent = `${state.discarded.length} / ${DECK_SPEC.reduce((n,c) => n+c.copies,0)}`;
$("discardStat").textContent = state.discarded.length;
$("discardList").innerHTML = items.length ? items.map(card => `
<div class="discard-row" style="--cat:${CATEGORY[card.cat].color}">
<div class="card-chip">${CATEGORY[card.cat].glyph}</div>
<div>
<div class="discard-name">${card.name}</div>
<div class="discard-result">${card.outcome}</div>
</div>
<div class="discard-round">R${String(card.round).padStart(2,"0")}</div>
</div>`).join("") : `<div class="empty">No cards discarded.<br />The expedition history begins here.</div>`;
}
function renderWeatherCard() {
const card = topCard();
const remaining = state.deck.length;
$("weatherDeckRemaining").textContent = `${remaining} remain`;
$("weatherState").textContent = state.revealed ? "Signal acquired" : "Order sealed";
if (!card) {
$("weatherCard").style.setProperty("--cat", "#557274");
$("weatherIcon").textContent = "∅";
$("nextCardTitle").textContent = "No events remain";
$("nextCardSub").textContent = "The expedition can no longer resolve weather.";
return;
}
if (state.revealed) {
const meta = CATEGORY[card.cat];
$("weatherCard").style.setProperty("--cat", meta.color);
$("weatherIcon").textContent = meta.glyph;
$("nextCardTitle").textContent = card.name;
$("nextCardSub").textContent = `${meta.label} front · severity ${card.diff}/4 · crossing odds ${Math.round(passChanceForCard(card) * 100)}%.`;
} else {
$("weatherCard").style.setProperty("--cat", "#62d6d0");
$("weatherIcon").textContent = "?";
$("nextCardTitle").textContent = "Unknown front";
$("nextCardSub").textContent = `One of ${remaining} audited cards. Scout it to condition the forecast.`;
}
}
function renderActions() {
$("campBtn").disabled = state.over || state.supplies < 2;
$("scoutBtn").disabled = state.over || state.revealed || state.supplies < 1 || !state.deck.length;
$("scoutTitle").textContent = state.revealed ? "Signal acquired" : "Read the sky";
$("scoutCost").textContent = state.revealed ? "top card known" : "−1 supply · reveal top";
}
function renderUI() {
renderRoute();
renderStats();
renderPlans();
renderForecast();
renderManifest();
renderDiscard();
renderWeatherCard();
renderActions();
$("headerDeckCount").textContent = `${state.deck.length} cards`;
$("remainingStat").textContent = state.deck.length;
$("discardStat").textContent = state.discarded.length;
}
function selectPlan(plan) {
if (state.over) return;
if (plan !== "shelter" && state.supplies < PLAN[plan].supply) return;
state.plan = plan;
renderPlans();
}
function makeCamp() {
if (state.over || state.supplies < 2) return;
state.supplies -= 2;
state.vigor = Math.min(100, state.vigor + 12);
state.morale = Math.min(100, state.morale + 5);
$("outcomeBox").innerHTML = `<b>Camp established.</b><br />The team spent two supply crates and recovered 12 vigor. The event deck was not advanced.`;
toast("Camp established: +12 vigor, +5 morale.");
renderUI();
}
function scoutWeather() {
if (state.over || state.revealed || state.supplies < 1 || !state.deck.length) return;
state.supplies -= 1;
state.revealed = true;
const card = topCard();
setSceneWeather(card.cat);
$("outcomeBox").innerHTML = `<b>Observed: ${card.name}.</b><br />The top event is now certain. Remaining-card probabilities have been conditioned on this observation.`;
toast(`Weather signal acquired: ${card.name}.`);
renderUI();
}
function resolveWeather() {
if (state.over || !state.deck.length) return;
const plan = PLAN[state.plan];
if (state.supplies < plan.supply) return;
const card = topCard();
const chance = forecastOdds();
const crossing = state.plan !== "shelter";
const success = !crossing || Math.random() < chance;
state.supplies -= plan.supply;
const baseDamage = card.diff * 4 + (card.cat === "Storm" ? 5 : 0) + (card.cat === "Wind" ? 2 : 0);
let damage;
let movement = "held position";
let outcome;
if (!crossing) {
damage = Math.max(1, Math.round(baseDamage * plan.exposure));
state.vigor -= damage;
state.morale += card.cat === "Clear" ? 4 : card.cat === "Storm" ? -4 : -1;
outcome = `Held · ${damage} vigor impact`;
} else if (success) {
damage = Math.max(1, Math.round(baseDamage * plan.exposure));
state.vigor -= damage;
state.morale += state.plan === "run" ? 4 : card.cat === "Clear" ? 3 : -1;
state.current++;
movement = `advanced to ${WAYPOINTS[state.current].name}`;
outcome = `${movement} · ${damage} vigor impact`;
} else {
damage = Math.max(2, Math.round(baseDamage * plan.exposure * 1.45));
state.vigor -= damage;
state.morale -= 5;
outcome = `crossing failed · ${damage} vigor impact`;
}
state.vigor = Math.max(0, Math.min(100, state.vigor));
state.morale = Math.max(0, Math.min(100, state.morale));
card.outcome = outcome;
card.round = state.turn;
state.discarded.push(card);
state.deck.shift();
state.revealed = false;
state.turn++;
setSceneWeather(card.cat);
flashWeather(CATEGORY[card.cat].color);
updateSceneState();
$("outcomeBox").innerHTML = `<b>${card.name} discarded.</b><br />${outcome.charAt(0).toUpperCase() + outcome.slice(1)}. The remaining deck now gives a different next-event forecast.`;
if (state.current === WAYPOINTS.length - 1) {
finish(true, "The summit antenna catches the final carrier wave. The Whiteout Relay is restored, and the expedition turns home with the survey complete.");
} else if (state.vigor <= 0 || state.morale <= 0) {
finish(false, "The team can no longer continue safely. The expedition calls an emergency retreat before the next weather card can be resolved.");
} else if (!state.deck.length) {
finish(false, "The finite event deck has been exhausted before the relay was reached. With no forecast remaining, the expedition must withdraw.");
}
renderUI();
}
function finish(won, copy) {
state.over = true;
state.won = won;
$("endTitle").textContent = won ? "Signal relayed." : "Expedition recalled.";
$("endCopy").textContent = copy;
$("endOverlay").classList.add("show");
renderUI();
}
function restart() {
state.deck = makeDeck();
state.discarded = [];
state.current = 0;
state.plan = "steady";
state.vigor = 100;
state.supplies = 6;
state.morale = 72;
state.revealed = false;
state.turn = 1;
state.over = false;
state.won = false;
$("endOverlay").classList.remove("show");
$("outcomeBox").innerHTML = `<b>Awaiting first decision.</b><br />The deck is sealed. Scout it or commit a route plan.`;
setSceneWeather(null);
updateSceneState();
renderUI();
toast("New expedition initialized.");
}
// ---------- Three.js voxel scene ----------
const scene = new THREE.Scene();
scene.background = new THREE.Color("#08151d");
scene.fog = new THREE.Fog("#08151d", 20, 43);
const camera = new THREE.OrthographicCamera(-10, 10, 8, -8, .1, 100);
const renderer = new THREE.WebGLRenderer({ antialias: true, powerPreference: "high-performance" });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.18;
$("scene").appendChild(renderer.domElement);
const hemi = new THREE.HemisphereLight("#a9d8dd", "#172126", 1.55);
scene.add(hemi);
const sun = new THREE.DirectionalLight("#ffe3ae", 3.1);
sun.position.set(-8, 15, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -14;
sun.shadow.camera.right = 14;
sun.shadow.camera.top = 14;
sun.shadow.camera.bottom = -14;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 40;
sun.shadow.bias = -.0007;
scene.add(sun);
const rim = new THREE.DirectionalLight("#68d8dd", 1.4);
rim.position.set(10, 7, -10);
scene.add(rim);
const board = new THREE.Mesh(
new THREE.BoxGeometry(20.7, 1.1, 14.7),
new THREE.MeshStandardMaterial({ color: "#172b31", roughness: .92, metalness: .03 })
);
board.position.y = -.62;
board.receiveShadow = true;
board.castShadow = true;
scene.add(board);
const underBoard = new THREE.Mesh(
new THREE.BoxGeometry(21.3, .28, 15.3),
new THREE.MeshStandardMaterial({ color: "#071117", roughness: 1 })
);
underBoard.position.y = -1.22;
scene.add(underBoard);
function hash2(x, z) {
const n = Math.sin(x * 127.1 + z * 311.7) * 43758.5453;
return n - Math.floor(n);
}
function closestPath(x, z) {
let best = { dist: Infinity, y: 0 };
for (let i = 0; i < WAYPOINTS.length - 1; i++) {
const a = WAYPOINTS[i], b = WAYPOINTS[i + 1];
const dx = b.x - a.x, dz = b.z - a.z;
const t = Math.max(0, Math.min(1, ((x-a.x)*dx + (z-a.z)*dz) / (dx*dx + dz*dz)));
const px = a.x + dx*t, pz = a.z + dz*t;
const dist = Math.hypot(x-px, z-pz);
if (dist < best.dist) best = { dist, y: a.y + (b.y-a.y)*t };
}
return best;
}
const terrainData = [];
for (let ix = 0; ix < 20; ix++) {
for (let iz = 0; iz < 14; iz++) {
const x = ix - 9.5;
const z = iz - 6.5;
const path = closestPath(x, z);
const ridge = Math.max(0, (x + 4.5) * .18 + (-z - 1.0) * .13);
let height = Math.round(Math.max(0, ridge + (hash2(ix, iz) - .5) * 1.65));
if (path.dist < 1.18) height = Math.max(1, Math.round(path.y));
const isWater = x < -6.8 && z < 3.15;
terrainData.push({ x, z, height: isWater ? 0 : height, water: isWater, pathDist: path.dist });
}
}
const terrainMesh = new THREE.InstancedMesh(
new THREE.BoxGeometry(.98, 1, .98),
new THREE.MeshStandardMaterial({ roughness: .96, metalness: .01 }),
terrainData.length
);
terrainMesh.receiveShadow = true;
terrainMesh.castShadow = true;
const dummy = new THREE.Object3D();
const terrainColor = new THREE.Color();
terrainData.forEach((tile, i) => {
dummy.position.set(tile.x, tile.height / 2, tile.z);
dummy.scale.set(1, tile.height, 1);
dummy.rotation.set(0, 0, 0);
dummy.updateMatrix();
terrainMesh.setMatrixAt(i, dummy.matrix);
if (tile.water) terrainColor.set("#263c43");
else if (tile.height >= 3) terrainColor.set("#758c8e");
else if (tile.height === 2) terrainColor.set("#50686a");
else if (tile.pathDist < 1.3) terrainColor.set("#647878");
else terrainColor.set("#344d4e");
terrainColor.offsetHSL(0, 0, (hash2(i, 3)-.5)*.07);
terrainMesh.setColorAt(i, terrainColor);
});
terrainMesh.instanceMatrix.needsUpdate = true;
terrainMesh.instanceColor.needsUpdate = true;
scene.add(terrainMesh);
const snowCaps = terrainData.map((t,i) => ({...t, i})).filter(t => !t.water && t.height >= 3 && hash2(t.i, 8) > .35);
const capMesh = new THREE.InstancedMesh(
new THREE.BoxGeometry(1.01, .16, 1.01),
new THREE.MeshStandardMaterial({ color: "#d5e8e4", roughness: .9 }),
Math.max(1, snowCaps.length)
);
snowCaps.forEach((t, i) => {
dummy.position.set(t.x, t.height + .08, t.z);
dummy.scale.set(1,1,1);
dummy.updateMatrix();
capMesh.setMatrixAt(i, dummy.matrix);
});
capMesh.receiveShadow = true;
scene.add(capMesh);
const water = new THREE.Mesh(
new THREE.BoxGeometry(3.25, .16, 7.6),
new THREE.MeshStandardMaterial({ color: "#28586c", roughness: .28, metalness: .18, transparent: true, opacity: .88 })
);
water.position.set(-8.02, .12, -.22);
water.receiveShadow = true;
scene.add(water);
const pathTiles = [];
for (let i = 0; i < WAYPOINTS.length - 1; i++) {
const a = WAYPOINTS[i], b = WAYPOINTS[i+1];
const length = Math.hypot(b.x-a.x, b.z-a.z);
const count = Math.ceil(length / .36);
for (let j = 0; j < count; j++) {
const t = j / count;
pathTiles.push({
x: a.x + (b.x-a.x)*t,
y: a.y + (b.y-a.y)*t + .12,
z: a.z + (b.z-a.z)*t,
angle: Math.atan2(b.x-a.x, b.z-a.z)
});
}
}
const pathMesh = new THREE.InstancedMesh(
new THREE.BoxGeometry(.34, .12, .34),
new THREE.MeshStandardMaterial({ color: "#c4c7b6", roughness: .9 }),
pathTiles.length
);
pathTiles.forEach((p,i) => {
dummy.position.set(p.x,p.y,p.z);
dummy.rotation.set(0,p.angle,0);
dummy.scale.set(1,1,1);
dummy.updateMatrix();
pathMesh.setMatrixAt(i,dummy.matrix);
});
pathMesh.receiveShadow = true;
scene.add(pathMesh);
function addPeak(cx, cz, base, levels, color) {
for (let level = 0; level < levels; level++) {
const size = 3.5 - level * .43;
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size, .58, size),
new THREE.MeshStandardMaterial({ color, roughness: .95 })
);
mesh.position.set(cx + (level % 2 ? .14 : -.1), base + level * .53, cz - level * .12);
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
if (level > levels - 3) {
const snow = new THREE.Mesh(
new THREE.BoxGeometry(size * .88, .12, size * .88),
new THREE.MeshStandardMaterial({ color: "#dcece8", roughness: .9 })
);
snow.position.set(mesh.position.x, mesh.position.y + .35, mesh.position.z);
snow.castShadow = true;
scene.add(snow);
}
}
}
addPeak(8.0, -6.1, .4, 7, "#607779");
addPeak(-6.5, -6.0, .1, 6, "#526c70");
addPeak(3.7, -6.0, .3, 5, "#61777a");
addPeak(-9.0, 5.9, .2, 4, "#435e61");
const treeSpots = [
[-7,-1],[-6,1],[-4,4],[-3,4],[-1,4],[2,4],[4,2],[6,3],[-2,-3],[1,-5],[5,-4],[7,0],[-8,2]
];
function addTree(x, z, scale = 1) {
const path = closestPath(x,z);
if (path.dist < 1.6) return;
const h = hash2(x*3,z*5);
const base = Math.max(.5, Math.round((x+4)*.16 + h));
const group = new THREE.Group();
group.position.set(x, base, z);
const trunk = new THREE.Mesh(
new THREE.BoxGeometry(.22*scale, 1.2*scale, .22*scale),
new THREE.MeshStandardMaterial({ color: "#4d3c32", roughness: 1 })
);
trunk.position.y = .6*scale;
group.add(trunk);
for (let i=0; i<3; i++) {
const foliage = new THREE.Mesh(
new THREE.BoxGeometry((.9-i*.19)*scale, .55*scale, (.9-i*.19)*scale),
new THREE.MeshStandardMaterial({ color: i===2 ? "#729388" : "#345f58", roughness: 1 })
);
foliage.position.y = (1.1+i*.42)*scale;
foliage.castShadow = true;
group.add(foliage);
}
const cap = new THREE.Mesh(
new THREE.BoxGeometry(.53*scale,.1*scale,.53*scale),
new THREE.MeshStandardMaterial({ color:"#c9dfda", roughness:1 })
);
cap.position.y = 2.15*scale;
group.add(cap);
scene.add(group);
}
treeSpots.forEach((p,i) => addTree(p[0],p[1],.85+(i%3)*.13));
function labelSprite(text, color = "#d8ece8") {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 112;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "rgba(5,16,22,.84)";
ctx.fillRect(0,0,512,112);
ctx.strokeStyle = "rgba(119,174,177,.48)";
ctx.lineWidth = 3;
ctx.strokeRect(2,2,508,108);
ctx.fillStyle = color;
ctx.font = "600 31px monospace";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text.toUpperCase(),256,57);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(new THREE.SpriteMaterial({ map:texture, transparent:true, depthTest:false }));
sprite.scale.set(2.8,.61,1);
sprite.renderOrder = 8;
return sprite;
}
const nodeGroups = [];
const pickables = [];
WAYPOINTS.forEach((w,index) => {
const group = new THREE.Group();
group.position.set(w.x,w.y+.08,w.z);
const pedestal = new THREE.Mesh(
new THREE.BoxGeometry(.92,.18,.92),
new THREE.MeshStandardMaterial({ color:"#263f45", roughness:.9 })
);
pedestal.position.y = .02;
pedestal.castShadow = true;
group.add(pedestal);
const beaconMat = new THREE.MeshStandardMaterial({ color:"#557274", emissive:"#102328", roughness:.55 });
const beacon = new THREE.Mesh(new THREE.BoxGeometry(.31,.31,.31), beaconMat);
beacon.position.y = .34;
beacon.castShadow = true;
group.add(beacon);
const hit = new THREE.Mesh(
new THREE.BoxGeometry(1.1,1.1,1.1),
new THREE.MeshBasicMaterial({ transparent:true, opacity:0, depthWrite:false })
);
hit.position.y = .4;
hit.userData.waypoint = index;
group.add(hit);
pickables.push(hit);
const label = labelSprite(`${w.code} ${w.name}`);
label.position.y = 1.18;
group.add(label);
scene.add(group);
nodeGroups.push({group, beacon, beaconMat, label});
});
const marker = new THREE.Group();
const markerMat = new THREE.MeshBasicMaterial({ color:"#f2b85b", transparent:true, opacity:.9 });
[[-.48,-.48],[.48,-.48],[-.48,.48],[.48,.48]].forEach(([x,z]) => {
const m = new THREE.Mesh(new THREE.BoxGeometry(.28,.08,.28), markerMat);
m.position.set(x,.04,z);
marker.add(m);
});
scene.add(marker);
const expedition = new THREE.Group();
const orange = new THREE.MeshStandardMaterial({ color:"#e49a3f", roughness:.65, metalness:.12 });
const orangeDark = new THREE.MeshStandardMaterial({ color:"#b85f32", roughness:.75, metalness:.1 });
const dark = new THREE.MeshStandardMaterial({ color:"#172329", roughness:.85 });
const glass = new THREE.MeshStandardMaterial({ color:"#67cad1", roughness:.25, metalness:.35, emissive:"#143b42", emissiveIntensity:.5 });
const white = new THREE.MeshStandardMaterial({ color:"#d9e7df", roughness:.8 });
const rover = new THREE.Group();
const roverBody = new THREE.Mesh(new THREE.BoxGeometry(.72,.42,.88), orange);
roverBody.position.y = .43;
roverBody.castShadow = true;
rover.add(roverBody);
const cabin = new THREE.Mesh(new THREE.BoxGeometry(.58,.36,.48), glass);
cabin.position.set(0,.77,.08);
cabin.castShadow = true;
rover.add(cabin);
const cargo = new THREE.Mesh(new THREE.BoxGeometry(.5,.23,.29), orangeDark);
cargo.position.set(0,.69,-.29);
cargo.castShadow = true;
rover.add(cargo);
[-.37,.37].forEach(x => {
[-.28,.28].forEach(z => {
const wheel = new THREE.Mesh(new THREE.BoxGeometry(.16,.25,.25), dark);
wheel.position.set(x,.2,z);
wheel.castShadow = true;
rover.add(wheel);
});
});
const antenna = new THREE.Mesh(new THREE.BoxGeometry(.045,.78,.045), white);
antenna.position.set(.24,1.19,-.28);
rover.add(antenna);
const antennaTip = new THREE.Mesh(new THREE.BoxGeometry(.13,.13,.13), new THREE.MeshBasicMaterial({color:"#62d6d0"}));
antennaTip.position.set(.24,1.62,-.28);
rover.add(antennaTip);
expedition.add(rover);
function makePerson(color, offset) {
const p = new THREE.Group();
const body = new THREE.Mesh(new THREE.BoxGeometry(.18,.32,.16), new THREE.MeshStandardMaterial({ color, roughness:.85 }));
body.position.y = .33;
body.castShadow = true;
p.add(body);
const head = new THREE.Mesh(new THREE.BoxGeometry(.18,.18,.18), white);
head.position.y = .58;
head.castShadow = true;
p.add(head);
p.position.set(offset.x,0,offset.z);
return p;
}
expedition.add(makePerson("#62d6d0", {x:-.62,z:.18}));
expedition.add(makePerson("#d6e5dc", {x:-.68,z:-.2}));
scene.add(expedition);
const visualTarget = new THREE.Vector3(WAYPOINTS[0].x, WAYPOINTS[0].y+.15, WAYPOINTS[0].z);
expedition.position.copy(visualTarget);
function updateSceneState() {
nodeGroups.forEach((entry,index) => {
let color = "#557274";
let emissive = "#102328";
if (index < state.current) { color = "#78d6a3"; emissive = "#173a2b"; }
if (index === state.current) { color = "#f2b85b"; emissive = "#4a3212"; }
if (index === state.current + 1) { color = "#62d6d0"; emissive = "#123c3d"; }
entry.beaconMat.color.set(color);
entry.beaconMat.emissive.set(emissive);
});
const current = WAYPOINTS[state.current];
marker.position.set(current.x,current.y+.13,current.z);
visualTarget.set(current.x,current.y+.15,current.z);
}
// Voxel precipitation.
const PARTICLE_COUNT = 260;
const particleMesh = new THREE.InstancedMesh(
new THREE.BoxGeometry(.08,.25,.08),
new THREE.MeshBasicMaterial({ color:"#d9f4f1", transparent:true, opacity:.85 }),
PARTICLE_COUNT
);
particleMesh.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
particleMesh.frustumCulled = false;
scene.add(particleMesh);
const particles = Array.from({length:PARTICLE_COUNT}, () => ({
x: (Math.random()-.5)*22,
y: 2+Math.random()*12,
z: (Math.random()-.5)*16,
speed: 4+Math.random()*5,
drift: (Math.random()-.5)*1.4,
phase: Math.random()*Math.PI*2
}));
function setSceneWeather(category) {
state.sceneWeather = category;
if (!category) {
particleMesh.visible = false;
$("weatherGlyph").textContent = "◇";
$("weatherText").textContent = "No front observed";
scene.fog.color.set("#08151d");
return;
}
const meta = CATEGORY[category];
particleMesh.visible = category !== "Clear";
particleMesh.material.color.set(meta.color);
$("weatherGlyph").textContent = meta.glyph;
$("weatherText").textContent = category === "Clear" ? "Clear interval" : `${meta.label} front`;
scene.fog.color.set(category === "Storm" ? "#171627" : "#0a1920");
}
// Manual camera orbit controls, implemented without addons.
const controls = {
theta: .72,
phi: .76,
zoom: 1,
target: new THREE.Vector3(0,1.1,0)
};
function updateCamera() {
const radius = 30;
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x + radius * sinPhi * Math.sin(controls.theta),
controls.target.y + radius * Math.cos(controls.phi),
controls.target.z + radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
camera.zoom = controls.zoom;
camera.updateProjectionMatrix();
}
function resetCamera() {
controls.theta = .72;
controls.phi = .76;
controls.zoom = 1;
updateCamera();
}
function resize() {
const stage = $("sceneStage");
const w = stage.clientWidth;
const h = stage.clientHeight;
renderer.setSize(w,h,false);
const aspect = w / Math.max(1,h);
const viewHeight = 15.8;
camera.left = -viewHeight * aspect / 2;
camera.right = viewHeight * aspect / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
}
new ResizeObserver(resize).observe($("sceneStage"));
resize();
updateCamera();
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
let drag = null;
renderer.domElement.addEventListener("pointerdown", e => {
drag = { x:e.clientX, y:e.clientY, moved:false, id:e.pointerId };
renderer.domElement.setPointerCapture(e.pointerId);
});
renderer.domElement.addEventListener("pointermove", e => {
if (!drag || drag.id !== e.pointerId) return;
const dx = e.clientX-drag.x;
const dy = e.clientY-drag.y;
if (Math.abs(dx)+Math.abs(dy)>4) drag.moved = true;
if (drag.moved) {
controls.theta -= dx*.006;
controls.phi = Math.max(.42,Math.min(1.22,controls.phi+dy*.004));
updateCamera();
}
drag.x=e.clientX;
drag.y=e.clientY;
});
renderer.domElement.addEventListener("pointerup", e => {
if (!drag) return;
const wasDrag = drag.moved;
drag = null;
if (wasDrag) return;
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((e.clientX-rect.left)/rect.width)*2-1;
pointer.y = -((e.clientY-rect.top)/rect.height)*2+1;
raycaster.setFromCamera(pointer,camera);
const hits = raycaster.intersectObjects(pickables,false);
if (hits.length) {
const i = hits[0].object.userData.waypoint;
const w = WAYPOINTS[i];
toast(`${w.code} · ${w.name} — ${w.note}`);
}
});
renderer.domElement.addEventListener("wheel", e => {
e.preventDefault();
controls.zoom = Math.max(.72,Math.min(1.8,controls.zoom*Math.exp(-e.deltaY*.001)));
updateCamera();
}, { passive:false });
document.querySelectorAll(".plan").forEach(btn => {
btn.addEventListener("click", () => selectPlan(btn.dataset.plan));
});
$("campBtn").addEventListener("click", makeCamp);
$("scoutBtn").addEventListener("click", scoutWeather);
$("commitBtn").addEventListener("click", resolveWeather);
$("restartBtn").addEventListener("click", () => {
if (state.over || confirm("Abandon this expedition and rebuild the sealed deck?")) restart();
});
$("endRestartBtn").addEventListener("click", restart);
$("resetCameraBtn").addEventListener("click", resetCamera);
$("auditBtn").addEventListener("click", () => {
$("manifestList").scrollIntoView({behavior:"smooth", block:"center"});
toast("Deck audit: every card identity and quantity is visible. Only the shuffled order is hidden.");
});
const clock = new THREE.Clock();
renderer.setAnimationLoop(() => {
const dt = Math.min(.05, clock.getDelta());
const t = clock.elapsedTime;
expedition.position.lerp(visualTarget, 1-Math.exp(-dt*4.2));
const direction = visualTarget.clone().sub(expedition.position);
if (direction.lengthSq() > .0001) {
const targetAngle = Math.atan2(direction.x,direction.z);
let delta = targetAngle-expedition.rotation.y;
delta = Math.atan2(Math.sin(delta),Math.cos(delta));
expedition.rotation.y += delta*(1-Math.exp(-dt*7));
}
marker.rotation.y = t*.25;
marker.scale.setScalar(1+Math.sin(t*3)*.055);
if (particleMesh.visible && state.sceneWeather) {
const category = state.sceneWeather;
particles.forEach((p,i) => {
p.y -= p.speed*dt;
p.x += (category === "Wind" ? 3.8 : category === "Storm" ? 2.1 : .25)*dt;
p.z += (category === "Storm" ? 1.4 : .2)*dt;
if (p.y < -.2) { p.y = 11+Math.random()*3; p.x=(Math.random()-.5)*22; p.z=(Math.random()-.5)*16; }
if (p.x > 11) p.x=-11;
if (p.z > 8) p.z=-8;
dummy.position.set(p.x,p.y,p.z);
dummy.rotation.set(0,0,0);
if (category === "Wind") dummy.scale.set(3.8,.18,.18);
else if (category === "Snow") dummy.scale.set(.65,.65,.65);
else dummy.scale.set(.55,1.25,.55);
dummy.updateMatrix();
particleMesh.setMatrixAt(i,dummy.matrix);
});
particleMesh.instanceMatrix.needsUpdate = true;
}
renderer.render(scene,camera);
});
state.deck = makeDeck();
setSceneWeather(null);
updateSceneState();
renderUI();
</script>
</body>
</html>
```