Prompt specification
Build or customize the Three.js 3D scene "Fleet reliability concept depot" 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: Fleet reliability concept depot
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/fleet-reliability-concept-depot-x1823
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring rare events across repeated opportunities. Compose fictional vehicles with explicitly synthetic independent component-event probabilities; compare one vehicle and a fleet while noting that real failures may be correlated. Voxel style.
Working Three.js Starter (fleet-reliability-concept-depot-x1823):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Aster-7 — Rare Event Laboratory</title>
<style>
:root {
color-scheme: dark;
--bg: #07121b;
--panel: rgba(9, 24, 34, 0.86);
--panel-border: rgba(140, 220, 230, 0.18);
--text: #e8f4f3;
--muted: #91a9ad;
--cyan: #58e0c2;
--amber: #ffc857;
--red: #ff5277;
--blue: #68b9ff;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button, select {
color: var(--text);
background: #102b37;
border: 1px solid rgba(116, 211, 211, 0.25);
border-radius: 7px;
}
button {
min-height: 36px;
padding: 8px 12px;
cursor: pointer;
transition: background 120ms ease, border-color 120ms ease;
}
button:hover {
background: #173b47;
border-color: rgba(116, 211, 211, 0.5);
}
button.primary {
color: #041512;
background: var(--cyan);
border-color: var(--cyan);
font-weight: 750;
}
button.primary:hover { background: #79efd5; }
#scene-wrap {
position: fixed;
inset: 0;
}
#scene-wrap canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene-wrap canvas:active { cursor: grabbing; }
.glass {
background: var(--panel);
border: 1px solid var(--panel-border);
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
}
.topbar {
position: fixed;
top: 18px;
left: 18px;
right: 18px;
z-index: 5;
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
pointer-events: none;
}
.brand {
padding: 13px 16px;
border-radius: 10px;
}
.eyebrow {
margin-bottom: 4px;
color: var(--cyan);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(18px, 2.2vw, 28px);
line-height: 1.1;
letter-spacing: -0.035em;
}
.subtitle {
margin-top: 5px;
color: var(--muted);
font-size: 12px;
}
.top-chip {
padding: 9px 12px;
border-radius: 999px;
color: var(--amber);
font-size: 11px;
font-weight: 750;
letter-spacing: 0.04em;
}
.panel {
position: fixed;
z-index: 4;
border-radius: 11px;
overflow: hidden;
}
.panel h2 {
margin: 0;
padding: 14px 15px 11px;
border-bottom: 1px solid rgba(139, 211, 213, 0.12);
font-size: 12px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.panel-content { padding: 13px 15px; }
.assumptions {
top: 110px;
left: 18px;
width: 316px;
}
.model-note {
margin: 0 0 12px;
color: #b9c9ca;
font-size: 12px;
line-height: 1.5;
}
.component-list {
display: grid;
gap: 7px;
margin: 11px 0 12px;
}
.component {
display: grid;
grid-template-columns: 9px 1fr auto;
align-items: center;
gap: 8px;
color: #dce8e7;
font-size: 12px;
}
.component .dot {
width: 8px;
height: 8px;
border-radius: 2px;
box-shadow: 0 0 9px currentColor;
}
.component .probability {
color: var(--muted);
font-variant-numeric: tabular-nums;
}
.formula {
padding: 9px 10px;
border: 1px solid rgba(91, 223, 195, 0.18);
border-radius: 6px;
color: #a9c6c4;
background: rgba(41, 129, 119, 0.08);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 11px;
line-height: 1.55;
}
.caveat {
margin-top: 11px;
padding-left: 10px;
border-left: 2px solid var(--amber);
color: #c7c5b6;
font-size: 11px;
line-height: 1.5;
}
.caveat strong { color: var(--amber); }
.stats {
top: 110px;
right: 18px;
width: 356px;
}
.model-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
.metric {
min-height: 88px;
padding: 10px;
border: 1px solid rgba(129, 202, 205, 0.12);
border-radius: 7px;
background: rgba(6, 19, 27, 0.56);
}
.metric-label {
display: block;
min-height: 28px;
color: var(--muted);
font-size: 10px;
line-height: 1.3;
text-transform: uppercase;
letter-spacing: 0.04em;
}
.metric strong {
display: block;
margin: 4px 0 2px;
color: var(--cyan);
font-size: 21px;
line-height: 1.1;
font-variant-numeric: tabular-nums;
}
.metric small {
color: #829b9d;
font-size: 10px;
}
.observed {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 7px;
margin-top: 10px;
padding-top: 10px;
border-top: 1px solid rgba(129, 202, 205, 0.12);
}
.observed div { min-width: 0; }
.observed span {
display: block;
color: var(--muted);
font-size: 9px;
line-height: 1.3;
text-transform: uppercase;
}
.observed strong {
display: block;
margin-top: 3px;
overflow: hidden;
color: #d9e7e6;
font-size: 12px;
text-overflow: ellipsis;
white-space: nowrap;
}
.feed-title {
margin: 13px 0 7px;
color: var(--muted);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.event-feed {
display: grid;
gap: 5px;
max-height: 138px;
overflow: auto;
}
.event-row {
display: grid;
grid-template-columns: 7px 1fr auto;
align-items: center;
gap: 8px;
padding: 6px 7px;
border-radius: 5px;
background: rgba(255, 255, 255, 0.035);
color: #c7d6d5;
font-size: 10px;
}
.event-row .event-dot {
width: 6px;
height: 6px;
border-radius: 1px;
}
.event-row .event-unit {
color: #748e90;
font-variant-numeric: tabular-nums;
}
.empty-feed {
padding: 11px 8px;
border: 1px dashed rgba(127, 199, 201, 0.18);
border-radius: 5px;
color: #70898b;
font-size: 11px;
text-align: center;
}
.transport {
bottom: 18px;
left: 50%;
width: min(820px, calc(100% - 36px));
transform: translateX(-50%);
padding: 12px 14px;
display: flex;
align-items: center;
gap: 10px;
flex-wrap: wrap;
}
.transport button { white-space: nowrap; }
.control-group {
display: flex;
align-items: center;
gap: 8px;
}
.control-label {
color: var(--muted);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
white-space: nowrap;
}
input[type="number"] {
width: 78px;
height: 36px;
padding: 6px 8px;
color: var(--text);
border: 1px solid rgba(116, 211, 211, 0.25);
border-radius: 7px;
background: #0b202a;
}
input[type="range"] {
width: 112px;
accent-color: var(--cyan);
}
select {
height: 36px;
padding: 5px 8px;
}
.range-value {
min-width: 53px;
color: #d9e8e6;
font-size: 11px;
font-variant-numeric: tabular-nums;
}
.camera-help {
margin-left: auto;
color: #718b8e;
font-size: 10px;
text-align: right;
line-height: 1.4;
}
.world-label {
position: fixed;
z-index: 3;
padding: 6px 8px;
border: 1px solid rgba(100, 220, 205, 0.3);
border-radius: 4px;
color: #c8eeea;
background: rgba(5, 18, 26, 0.78);
box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
letter-spacing: 0.04em;
pointer-events: none;
transform: translate(-50%, -50%);
white-space: nowrap;
}
#tooltip {
position: fixed;
z-index: 10;
display: none;
max-width: 220px;
padding: 8px 10px;
border: 1px solid rgba(100, 220, 205, 0.28);
border-radius: 5px;
color: #d9e8e7;
background: rgba(5, 18, 26, 0.94);
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
font-size: 11px;
pointer-events: none;
}
#tooltip strong { color: var(--cyan); }
@media (max-width: 850px) {
.assumptions {
top: 104px;
left: 10px;
width: 275px;
}
.stats {
top: 104px;
right: 10px;
width: 310px;
}
.camera-help { display: none; }
}
@media (max-width: 620px) {
.topbar {
top: 10px;
left: 10px;
right: 10px;
}
.brand { padding: 10px 12px; }
.subtitle { display: none; }
.top-chip { display: none; }
.assumptions { display: none; }
.stats {
top: 78px;
left: 10px;
right: 10px;
width: auto;
max-height: 43vh;
overflow: auto;
}
.stats h2 { padding: 10px 12px; }
.stats .panel-content { padding: 9px; }
.model-grid { grid-template-columns: 1fr 1fr; }
.metric { min-height: 76px; padding: 8px; }
.metric strong { font-size: 17px; }
.event-feed { max-height: 90px; }
.transport {
bottom: 10px;
width: calc(100% - 20px);
gap: 7px;
padding: 9px;
}
.transport button {
min-height: 34px;
padding: 7px 9px;
font-size: 12px;
}
.control-group { gap: 5px; }
input[type="range"] { width: 85px; }
}
</style>
</head>
<body>
<div id="scene-wrap" aria-label="Interactive voxel vehicle reliability scene"></div>
<header class="topbar">
<div class="brand glass">
<div class="eyebrow">Synthetic reliability laboratory</div>
<h1>Aster-7 / Rare-event field</h1>
<div class="subtitle">
One reference vehicle versus a fleet under repeated opportunities
</div>
</div>
<div class="top-chip glass">
FICTIONAL MODEL · NOT A RELIABILITY FORECAST
</div>
</header>
<section class="panel assumptions glass">
<h2>Explicit synthetic model</h2>
<div class="panel-content">
<p class="model-note">
Every Aster-7 component is assigned a fictional event probability for
each vehicle-round. Draws are independent within and across units.
Multiple component events can occur in the same round.
</p>
<div id="component-list" class="component-list"></div>
<div class="formula">
q = ∏(1 − pᵢ)<br>
one vehicle, N rounds: 1 − qᴺ<br>
fleet, N rounds: 1 − qᴹᴺ
</div>
<div class="caveat">
<strong>Correlation warning:</strong> real failures may be correlated
through shared designs, weather, maintenance, software defects, load,
or common-cause faults. This independent synthetic model can therefore
understate real fleet-wide tail risk.
</div>
</div>
</section>
<section class="panel stats glass">
<h2>Repeated-opportunity comparison</h2>
<div class="panel-content">
<div class="model-grid">
<div class="metric">
<span class="metric-label">Any event / vehicle-round</span>
<strong id="p-aggregate">—</strong>
<small id="p-aggregate-sub">aggregate of 4 components</small>
</div>
<div class="metric">
<span class="metric-label">Fleet event / one round</span>
<strong id="p-fleet-round">—</strong>
<small id="p-fleet-round-sub">across all fleet units</small>
</div>
<div class="metric">
<span class="metric-label">One vehicle: ≥1 over horizon</span>
<strong id="p-one-horizon">—</strong>
<small id="p-one-horizon-sub">N repeated opportunities</small>
</div>
<div class="metric">
<span class="metric-label">Fleet: ≥1 over horizon</span>
<strong id="p-fleet-horizon">—</strong>
<small id="p-fleet-horizon-sub">N rounds per fleet unit</small>
</div>
<div class="metric">
<span class="metric-label">Expected events / one vehicle</span>
<strong id="expected-one">—</strong>
<small>component events, not vehicles</small>
</div>
<div class="metric">
<span class="metric-label">Expected events / fleet</span>
<strong id="expected-fleet">—</strong>
<small id="expected-fleet-sub">N × M vehicle-rounds</small>
</div>
</div>
<div class="observed">
<div>
<span>Observed any-event rate</span>
<strong id="sim-rate">—</strong>
</div>
<div>
<span>Sampled events</span>
<strong id="sim-count">0</strong>
</div>
<div>
<span>Progress</span>
<strong id="sim-progress">0 / 500</strong>
</div>
</div>
<div class="feed-title">Latest sampled events</div>
<div id="event-feed" class="event-feed">
<div class="empty-feed">No sampled event yet.</div>
</div>
</div>
</section>
<footer class="panel transport glass">
<div class="control-group">
<button id="run-button" class="primary">▶ Run</button>
<button id="step-button">Step</button>
<button id="reset-button">Reset</button>
</div>
<div class="control-group">
<label class="control-label" for="horizon-input">Rounds</label>
<input
id="horizon-input"
type="number"
min="10"
max="5000"
step="10"
value="500"
aria-label="Opportunities per vehicle"
>
</div>
<div class="control-group">
<label class="control-label" for="fleet-input">Fleet</label>
<input
id="fleet-input"
type="range"
min="2"
max="24"
step="1"
value="12"
aria-label="Number of fleet vehicles"
>
<span id="fleet-value" class="range-value">12 units</span>
</div>
<div class="control-group">
<label class="control-label" for="speed-input">Speed</label>
<select id="speed-input">
<option value="1">1×</option>
<option value="4">4×</option>
<option value="12">12×</option>
</select>
</div>
<button id="view-button">Reset view</button>
<div class="camera-help">
Drag to orbit · wheel to zoom<br>
Double-click to reset the camera
</div>
</footer>
<div id="hero-label" class="world-label">A-01 / REFERENCE</div>
<div id="fleet-label" class="world-label">FLEET / 12 UNITS</div>
<div id="tooltip"></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);
// Fictional, synthetic component-event probabilities.
const COMPONENTS = [
{ id: "regulator", name: "Flux regulator", p: 0.0040, color: 0xff5277 },
{ id: "coupler", name: "Gear coupler", p: 0.0060, color: 0xffc857 },
{ id: "relay", name: "Thermal relay", p: 0.0030, color: 0x68b9ff },
{ id: "prism", name: "Signal prism", p: 0.0020, color: 0x91ef74 }
];
const state = {
horizon: 500,
fleetSize: 12,
speed: 1,
running: false,
tick: 0,
totalEvents: 0,
anyVehicleRounds: 0,
heroEvents: 0,
fleetEvents: 0,
heroAffected: false,
fleetAffected: new Set(),
componentCounts: Object.fromEntries(
COMPONENTS.map(component => [component.id, 0])
),
feed: []
};
// -------------------------------------------------------------------------
// Three.js scene
// -------------------------------------------------------------------------
const sceneWrap = $("scene-wrap");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07121b);
scene.fog = new THREE.Fog(0x07121b, 19, 43);
const camera = new THREE.PerspectiveCamera(
41,
window.innerWidth / window.innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.domElement.setAttribute(
"aria-label",
"Voxel Aster-7 reference vehicle and fleet simulation"
);
sceneWrap.appendChild(renderer.domElement);
const ambient = new THREE.HemisphereLight(0xa8e8ff, 0x071018, 2.2);
scene.add(ambient);
const keyLight = new THREE.DirectionalLight(0xfff2d0, 3.1);
keyLight.position.set(7, 14, 9);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -18;
keyLight.shadow.camera.right = 18;
keyLight.shadow.camera.top = 18;
keyLight.shadow.camera.bottom = -18;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 45;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x48d9ff, 1.4);
rimLight.position.set(-10, 7, -10);
scene.add(rimLight);
const materials = {
ground: new THREE.MeshStandardMaterial({
color: 0x081721, roughness: 0.98, metalness: 0.02
}),
platform: new THREE.MeshStandardMaterial({
color: 0x102630, roughness: 0.85, metalness: 0.12
}),
platformTop: new THREE.MeshStandardMaterial({
color: 0x0c2028, roughness: 0.92, metalness: 0.08
}),
body: new THREE.MeshStandardMaterial({
color: 0x3b6170, roughness: 0.72, metalness: 0.16
}),
bodyLight: new THREE.MeshStandardMaterial({
color: 0x5e8790, roughness: 0.68, metalness: 0.2
}),
accent: new THREE.MeshStandardMaterial({
color: 0x59dfc0,
emissive: 0x123c36,
emissiveIntensity: 0.55,
roughness: 0.5,
metalness: 0.12
}),
amber: new THREE.MeshStandardMaterial({
color: 0xffbd52,
emissive: 0x3a2100,
emissiveIntensity: 0.35,
roughness: 0.6
}),
dark: new THREE.MeshStandardMaterial({
color: 0x101b22, roughness: 0.84, metalness: 0.22
}),
tire: new THREE.MeshStandardMaterial({
color: 0x080d12, roughness: 0.96, metalness: 0
}),
glass: new THREE.MeshStandardMaterial({
color: 0x214f67,
emissive: 0x0b2634,
emissiveIntensity: 0.65,
roughness: 0.25,
metalness: 0.35
})
};
const ground = new THREE.Mesh(
new THREE.BoxGeometry(46, 0.3, 42),
materials.ground
);
ground.position.set(2, -0.31, 0);
ground.receiveShadow = true;
scene.add(ground);
const grid = new THREE.GridHelper(44, 44, 0x24505a, 0x15333c);
grid.position.set(2, -0.145, 0);
grid.material.transparent = true;
grid.material.opacity = 0.55;
scene.add(grid);
// Distant voxel data pylons.
const pylonGroup = new THREE.Group();
const pylonMaterial = new THREE.MeshStandardMaterial({
color: 0x173b45,
emissive: 0x0b3037,
emissiveIntensity: 0.5,
roughness: 0.85
});
for (let index = 0; index < 13; index++) {
const height = 0.5 + (index % 4) * 0.55;
const pylon = new THREE.Mesh(
new THREE.BoxGeometry(0.35, height, 0.35),
pylonMaterial
);
const side = index % 2 === 0 ? -1 : 1;
pylon.position.set(
2 + side * (12 + (index % 3) * 2),
height / 2 - 0.15,
-13 + index * 2.1
);
pylon.receiveShadow = true;
pylonGroup.add(pylon);
}
scene.add(pylonGroup);
function addBox(parent, size, position, material) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
material
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makePlatform(width, depth, centerX, centerZ, accentMaterial) {
const group = new THREE.Group();
addBox(
group,
[width, 0.18, depth],
[0, 0, 0],
materials.platform
);
addBox(
group,
[width - 0.24, 0.04, depth - 0.24],
[0, 0.10, 0],
materials.platformTop
);
const stripeCount = Math.max(3, Math.floor(width / 1.4));
for (let index = 0; index < stripeCount; index++) {
const x = -width / 2 + 0.7 + index * ((width - 1.4) / (stripeCount - 1));
addBox(
group,
[0.32, 0.045, 0.08],
[x, 0.14, depth / 2 - 0.13],
accentMaterial
);
}
group.position.set(centerX, 0, centerZ);
scene.add(group);
return group;
}
function makeVehicle(isHero = false) {
const group = new THREE.Group();
if (isHero) {
// Main chassis, belly frame, cabin, and cargo blocks.
addBox(group, [2.45, 0.46, 3.35], [0, 0.58, 0], materials.body);
addBox(group, [1.98, 0.24, 3.65], [0, 0.29, 0], materials.dark);
addBox(group, [1.82, 0.78, 1.35], [0, 1.18, -0.52], materials.bodyLight);
addBox(group, [1.48, 0.48, 0.08], [0, 1.27, 0.18], materials.glass);
addBox(group, [2.02, 0.30, 1.05], [0, 1.00, 1.03], materials.accent);
addBox(group, [1.72, 0.50, 0.66], [0, 1.02, -1.43], materials.body);
addBox(group, [1.88, 0.14, 0.62], [0, 1.32, -1.43], materials.amber);
// Four chunky voxel wheels.
for (const x of [-1.34, 1.34]) {
for (const z of [-1.10, 1.10]) {
addBox(group, [0.56, 0.68, 0.82], [x, 0.34, z], materials.tire);
addBox(
group,
[0.59, 0.25, 0.27],
[x, 0.34, z],
materials.bodyLight
);
}
}
// Bumpers, side rails, and voxel lights.
addBox(group, [2.60, 0.18, 0.18], [0, 0.52, 1.78], materials.amber);
addBox(group, [2.15, 0.18, 0.16], [0, 0.48, -1.78], materials.dark);
addBox(group, [0.10, 0.44, 2.40], [-1.28, 0.77, 0], materials.accent);
addBox(group, [0.10, 0.44, 2.40], [1.28, 0.77, 0], materials.accent);
addBox(group, [0.40, 0.18, 0.10], [-0.67, 0.86, 1.60], materials.amber);
addBox(group, [0.40, 0.18, 0.10], [0.67, 0.86, 1.60], materials.amber);
// Antenna and roof rack.
addBox(group, [0.08, 0.70, 0.08], [0.66, 1.92, -1.03], materials.dark);
addBox(group, [0.18, 0.18, 0.18], [0.66, 2.32, -1.03], materials.accent);
addBox(group, [1.55, 0.08, 0.08], [0, 1.65, -0.82], materials.dark);
} else {
addBox(group, [1.34, 0.34, 1.86], [0, 0.46, 0], materials.body);
addBox(group, [1.03, 0.48, 0.78], [0, 0.86, -0.34], materials.bodyLight);
addBox(group, [0.80, 0.23, 0.07], [0, 0.91, 0.08], materials.glass);
addBox(group, [1.12, 0.18, 0.62], [0, 0.74, 0.60], materials.accent);
for (const x of [-0.72, 0.72]) {
for (const z of [-0.59, 0.59]) {
addBox(group, [0.31, 0.48, 0.48], [x, 0.25, z], materials.tire);
}
}
addBox(group, [1.42, 0.10, 0.10], [0, 0.40, 0.97], materials.amber);
}
const beaconMaterial = new THREE.MeshStandardMaterial({
color: 0x4ce6bd,
emissive: 0x174d43,
emissiveIntensity: 0.65,
roughness: 0.35,
metalness: 0.12
});
beaconMaterial.userData.transient = true;
const beacon = addBox(
group,
isHero ? [0.18, 0.18, 0.18] : [0.13, 0.13, 0.13],
isHero ? [0, 2.55, -1.03] : [0, 1.27, -0.34],
beaconMaterial
);
const lamps = {};
if (isHero) {
const lampPositions = [
[-0.55, 1.66, -0.60],
[0.55, 1.66, -0.60],
[-0.55, 1.66, -0.18],
[0.55, 1.66, -0.18]
];
COMPONENTS.forEach((component, index) => {
const lampMaterial = new THREE.MeshStandardMaterial({
color: component.color,
emissive: component.color,
emissiveIntensity: 0.4,
roughness: 0.45
});
const lamp = addBox(
group,
[0.19, 0.13, 0.19],
lampPositions[index],
lampMaterial
);
lamps[component.id] = lamp.material;
});
}
const vehicle = {
group,
beacon,
lamps,
isHero,
id: isHero ? "A-01" : "",
alertUntil: 0,
lastComponent: null
};
group.userData.vehicleRef = vehicle;
return vehicle;
}
const hero = makeVehicle(true);
hero.group.position.set(-4.15, 0.12, 0.15);
scene.add(hero.group);
makePlatform(4.65, 5.25, -4.15, 0.15, materials.amber);
let fleetGroup = null;
let fleetVehicles = [];
let fleetLabelAnchor = new THREE.Vector3(4, 2, 0);
function disposeFleet() {
if (!fleetGroup) return;
fleetGroup.traverse(object => {
if (object.geometry) object.geometry.dispose();
if (
object.material &&
object.material.userData &&
object.material.userData.transient
) {
object.material.dispose();
}
});
scene.remove(fleetGroup);
}
function buildFleet() {
disposeFleet();
fleetVehicles = [];
fleetGroup = new THREE.Group();
scene.add(fleetGroup);
const count = state.fleetSize;
const columns = Math.ceil(Math.sqrt(count * 1.65));
const rows = Math.ceil(count / columns);
const gapX = 1.76;
const gapZ = 2.04;
const startX = 0.45;
const startZ = -((rows - 1) * gapZ) / 2;
const centerX = startX + ((columns - 1) * gapX) / 2;
for (let index = 0; index < count; index++) {
const row = Math.floor(index / columns);
const column = index % columns;
const vehicle = makeVehicle(false);
vehicle.id = `F-${String(index + 1).padStart(2, "0")}`;
vehicle.group.position.set(
startX + column * gapX,
0.12,
startZ + row * gapZ
);
fleetGroup.add(vehicle.group);
fleetVehicles.push(vehicle);
}
const platform = makePlatform(
columns * gapX + 0.85,
rows * gapZ + 0.75,
centerX,
0,
materials.accent
);
fleetGroup.add(platform);
const average = fleetVehicles.reduce(
(sum, vehicle) => sum.add(vehicle.group.position),
new THREE.Vector3()
).divideScalar(fleetVehicles.length);
fleetLabelAnchor.set(average.x, 2.15, average.z);
}
// -------------------------------------------------------------------------
// Event particles
// -------------------------------------------------------------------------
const particleGeometry = new THREE.BoxGeometry(0.11, 0.11, 0.11);
const particleMaterials = new Map(
COMPONENTS.map(component => [
component.color,
new THREE.MeshBasicMaterial({ color: component.color })
])
);
const particles = [];
function spawnBurst(position, color) {
const material =
particleMaterials.get(color) ||
new THREE.MeshBasicMaterial({ color });
for (let index = 0; index < 10; index++) {
const particle = new THREE.Mesh(particleGeometry, material);
particle.position.copy(position);
particle.userData.velocity = new THREE.Vector3(
(Math.random() - 0.5) * 2.7,
1.1 + Math.random() * 2.3,
(Math.random() - 0.5) * 2.7
);
particle.userData.life = 0.75 + Math.random() * 0.35;
scene.add(particle);
particles.push(particle);
}
}
function updateParticles(delta) {
for (let index = particles.length - 1; index >= 0; index--) {
const particle = particles[index];
particle.userData.life -= delta;
particle.userData.velocity.y -= 4.1 * delta;
particle.position.addScaledVector(particle.userData.velocity, delta);
particle.rotation.x += delta * 5;
particle.rotation.y += delta * 7;
particle.scale.setScalar(
Math.max(0.02, Math.min(1, particle.userData.life * 2))
);
if (particle.userData.life <= 0) {
scene.remove(particle);
particles.splice(index, 1);
}
}
}
function clearParticles() {
for (const particle of particles) scene.remove(particle);
particles.length = 0;
}
// -------------------------------------------------------------------------
// Probability model and simulation
// -------------------------------------------------------------------------
const noEventPerRound = COMPONENTS.reduce(
(product, component) => product * (1 - component.p),
1
);
const componentProbabilitySum = COMPONENTS.reduce(
(sum, component) => sum + component.p,
0
);
const aggregateProbability = 1 - noEventPerRound;
function formatProbability(probability) {
if (probability <= 0) return "0%";
if (probability > 0.9999999) return ">99.99999%";
const digits =
probability < 0.001 ? 4 :
probability < 0.01 ? 3 : 2;
return `${(probability * 100).toFixed(digits)}%`;
}
function updateModel() {
const n = state.horizon;
const m = state.fleetSize;
const oneVehicleHorizon = 1 - Math.pow(noEventPerRound, n);
const fleetHorizon = 1 - Math.pow(noEventPerRound, n * m);
const fleetOneRound = 1 - Math.pow(noEventPerRound, m);
const expectedOne = n * componentProbabilitySum;
const expectedFleet = n * m * componentProbabilitySum;
const expectedAffectedFleet = m * oneVehicleHorizon;
$("p-aggregate").textContent = formatProbability(aggregateProbability);
$("p-aggregate-sub").textContent =
`${COMPONENTS.length} independent component draws`;
$("p-fleet-round").textContent = formatProbability(fleetOneRound);
$("p-fleet-round-sub").textContent = `${m} units in one round`;
$("p-one-horizon").textContent = formatProbability(oneVehicleHorizon);
$("p-one-horizon-sub").textContent = `${n} repeated opportunities`;
$("p-fleet-horizon").textContent = formatProbability(fleetHorizon);
$("p-fleet-horizon-sub").textContent =
`${m} units × ${n} rounds`;
$("expected-one").textContent = expectedOne.toFixed(2);
$("expected-fleet").textContent = expectedFleet.toFixed(2);
$("expected-fleet-sub").textContent =
`${expectedAffectedFleet.toFixed(2)} affected units expected`;
$("sim-progress").textContent = `${state.tick} / ${n}`;
$("fleet-label").textContent = `FLEET / ${m} UNITS`;
}
function renderComponentList() {
const list = $("component-list");
list.replaceChildren();
for (const component of COMPONENTS) {
const row = document.createElement("div");
row.className = "component";
const dot = document.createElement("span");
dot.className = "dot";
dot.style.background = `#${component.color.toString(16).padStart(6, "0")}`;
dot.style.color = dot.style.background;
const name = document.createElement("span");
name.textContent = component.name;
const probability = document.createElement("span");
probability.className = "probability";
probability.textContent = `${(component.p * 100).toFixed(2)}%`;
row.append(dot, name, probability);
list.appendChild(row);
}
}
function updateObserved() {
const vehicleRounds =
state.tick * (state.fleetSize + 1);
const observedRate = vehicleRounds > 0
? state.anyVehicleRounds / vehicleRounds
: null;
$("sim-rate").textContent = observedRate === null
? "—"
: formatProbability(observedRate);
$("sim-count").textContent = state.totalEvents;
$("sim-progress").textContent =
`${state.tick} / ${state.horizon}`;
$("hero-label").textContent =
`A-01 / REFERENCE${state.heroAffected ? " · ALERT" : ""}`;
$("fleet-label").textContent =
`FLEET / ${state.fleetSize} UNITS` +
(state.fleetAffected.size
? ` · ${state.fleetAffected.size} AFFECTED`
: "");
}
function addFeedEntry(component, vehicle, round) {
state.feed.unshift({
component,
vehicle,
round
});
state.feed.length = Math.min(state.feed.length, 8);
renderFeed();
}
function addSystemFeed(message) {
state.feed.unshift({ system: true, message });
state.feed.length = Math.min(state.feed.length, 8);
renderFeed();
}
function renderFeed() {
const feed = $("event-feed");
feed.replaceChildren();
if (!state.feed.length) {
const empty = document.createElement("div");
empty.className = "empty-feed";
empty.textContent = "No sampled event yet.";
feed.appendChild(empty);
return;
}
for (const entry of state.feed) {
const row = document.createElement("div");
row.className = "event-row";
if (entry.system) {
const dot = document.createElement("span");
dot.className = "event-dot";
dot.style.background = "#58e0c2";
const text = document.createElement("span");
text.textContent = entry.message;
const unit = document.createElement("span");
unit.className = "event-unit";
unit.textContent = "SYSTEM";
row.append(dot, text, unit);
} else {
const dot = document.createElement("span");
dot.className = "event-dot";
dot.style.background =
`#${entry.component.color.toString(16).padStart(6, "0")}`;
const text = document.createElement("span");
text.textContent = entry.component.name;
const unit = document.createElement("span");
unit.className = "event-unit";
unit.textContent = `${entry.vehicle} · R${entry.round}`;
row.append(dot, text, unit);
}
feed.appendChild(row);
}
}
function registerEvent(vehicle, component) {
state.totalEvents++;
state.componentCounts[component.id]++;
if (vehicle.isHero) {
state.heroEvents++;
state.heroAffected = true;
} else {
state.fleetEvents++;
state.fleetAffected.add(vehicle.id);
}
vehicle.alertUntil = performance.now() + 1250;
vehicle.lastComponent = component.id;
const burstPosition = vehicle.group.position.clone();
burstPosition.y += vehicle.isHero ? 1.75 : 1.30;
spawnBurst(burstPosition, component.color);
addFeedEntry(
component,
vehicle.isHero ? "A-01" : vehicle.id,
state.tick
);
}
function sampleVehicle(vehicle) {
let anyEvent = false;
for (const component of COMPONENTS) {
// Independent Bernoulli draw for each component and vehicle-round.
if (Math.random() < component.p) {
anyEvent = true;
registerEvent(vehicle, component);
}
}
return anyEvent;
}
function stepOpportunity() {
if (state.tick >= state.horizon) return;
state.tick++;
if (sampleVehicle(hero)) {
state.anyVehicleRounds++;
}
for (const vehicle of fleetVehicles) {
if (sampleVehicle(vehicle)) {
state.anyVehicleRounds++;
}
}
updateObserved();
if (state.tick === state.horizon) {
state.running = false;
updateRunButton();
addSystemFeed("Horizon complete");
}
}
function resetSimulation() {
state.running = false;
state.tick = 0;
state.totalEvents = 0;
state.anyVehicleRounds = 0;
state.heroEvents = 0;
state.fleetEvents = 0;
state.heroAffected = false;
state.fleetAffected.clear();
for (const component of COMPONENTS) {
state.componentCounts[component.id] = 0;
}
state.feed.length = 0;
clearParticles();
for (const vehicle of [hero, ...fleetVehicles]) {
vehicle.alertUntil = 0;
vehicle.lastComponent = null;
}
renderFeed();
updateObserved();
updateRunButton();
}
function updateRunButton() {
$("run-button").textContent = state.running ? "Ⅱ Pause" : "▶ Run";
}
// -------------------------------------------------------------------------
// Direct camera controls — no Three.js add-ons
// -------------------------------------------------------------------------
const cameraState = {
target: new THREE.Vector3(1.2, 0.75, 0),
radius: 18,
theta: 0.35,
phi: 1.03
};
function applyCamera() {
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraState.target.x +
cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraState.target.y +
cameraState.radius * Math.cos(cameraState.phi),
cameraState.target.z +
cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraState.target);
}
function resetCamera() {
cameraState.target.set(1.2, 0.75, 0);
cameraState.radius = 18 + Math.max(0, state.fleetSize - 12) * 0.18;
cameraState.theta = 0.35;
cameraState.phi = 1.03;
applyCamera();
}
let dragging = false;
let lastPointerX = 0;
let lastPointerY = 0;
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
renderer.domElement.addEventListener("pointerdown", event => {
if (event.button !== 0) return;
dragging = true;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
$("tooltip").style.display = "none";
});
renderer.domElement.addEventListener("pointermove", event => {
if (dragging) {
const deltaX = event.clientX - lastPointerX;
const deltaY = event.clientY - lastPointerY;
cameraState.theta -= deltaX * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - deltaY * 0.005,
0.38,
1.43
);
lastPointerX = event.clientX;
lastPointerY = event.clientY;
applyCamera();
return;
}
const rect = renderer.domElement.getBoundingClientRect();
pointer.x =
((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y =
-((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(
fleetVehicles.map(vehicle => vehicle.group),
true
);
if (!hits.length) {
$("tooltip").style.display = "none";
renderer.domElement.style.cursor = "grab";
return;
}
let object = hits[0].object;
let vehicle = null;
while (object) {
if (object.userData.vehicleRef) {
vehicle = object.userData.vehicleRef;
break;
}
object = object.parent;
}
if (!vehicle) return;
renderer.domElement.style.cursor = "pointer";
const tooltip = $("tooltip");
tooltip.innerHTML =
`<strong>${vehicle.id}</strong><br>` +
`Aster-7 synthetic unit<br>` +
`Observed events: ${vehicle.alertUntil ? "recent alert" : "none"}`;
tooltip.style.left = `${event.clientX + 13}px`;
tooltip.style.top = `${event.clientY + 13}px`;
tooltip.style.display = "block";
});
function endDrag(event) {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("pointerleave", () => {
dragging = false;
$("tooltip").style.display = "none";
});
renderer.domElement.addEventListener(
"wheel",
event => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.012,
9,
32
);
applyCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
// -------------------------------------------------------------------------
// UI bindings
// -------------------------------------------------------------------------
$("run-button").addEventListener("click", () => {
if (state.tick >= state.horizon) resetSimulation();
state.running = !state.running;
updateRunButton();
});
$("step-button").addEventListener("click", () => {
state.running = false;
updateRunButton();
stepOpportunity();
});
$("reset-button").addEventListener("click", resetSimulation);
$("view-button").addEventListener("click", resetCamera);
$("horizon-input").addEventListener("change", event => {
const value = Number(event.target.value);
state.horizon = THREE.MathUtils.clamp(
Number.isFinite(value) ? value : 500,
10,
5000
);
event.target.value = state.horizon;
updateModel();
resetSimulation();
});
$("fleet-input").addEventListener("input", event => {
$("fleet-value").textContent = `${event.target.value} units`;
});
$("fleet-input").addEventListener("change", event => {
state.fleetSize = Number(event.target.value);
buildFleet();
updateModel();
resetSimulation();
resetCamera();
});
$("speed-input").addEventListener("change", event => {
state.speed = Number(event.target.value);
});
// -------------------------------------------------------------------------
// Rendering and animation
// -------------------------------------------------------------------------
function updateVehicleVisuals(now) {
const allVehicles = [hero, ...fleetVehicles];
const pulse = 0.5 + 0.5 * Math.sin(now * 0.018);
for (const vehicle of allVehicles) {
const alerting = now < vehicle.alertUntil;
vehicle.beacon.material.color.setHex(
alerting ? 0xff315c : 0x4ce6bd
);
vehicle.beacon.material.emissive.setHex(
alerting ? 0x7a1026 : 0x174d43
);
vehicle.beacon.material.emissiveIntensity =
alerting ? 1.4 + pulse : 0.55;
vehicle.beacon.scale.setScalar(
alerting ? 1 + pulse * 0.38 : 1
);
}
for (const component of COMPONENTS) {
const material = hero.lamps[component.id];
const active =
now < hero.alertUntil &&
hero.lastComponent === component.id;
material.color.setHex(active ? 0xff315c : component.color);
material.emissive.setHex(active ? 0xff315c : component.color);
material.emissiveIntensity = active
? 2.3
: 0.35 + pulse * 0.12;
}
}
const projected = new THREE.Vector3();
function positionLabel(element, worldPosition) {
projected.copy(worldPosition).project(camera);
const visible = projected.z > -1 && projected.z < 1;
element.style.display = visible ? "block" : "none";
if (!visible) return;
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height, false);
}
window.addEventListener("resize", resize);
const clock = new THREE.Clock();
let simulationAccumulator = 0;
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const now = performance.now();
if (state.running && state.tick < state.horizon) {
simulationAccumulator += delta * state.speed;
while (
simulationAccumulator >= 0.30 &&
state.tick < state.horizon
) {
simulationAccumulator -= 0.30;
stepOpportunity();
}
}
updateParticles(delta);
updateVehicleVisuals(now);
positionLabel(
$("hero-label"),
hero.group.position.clone().add(new THREE.Vector3(0, 2.95, 0))
);
positionLabel($("fleet-label"), fleetLabelAnchor);
renderer.render(scene, camera);
}
renderComponentList();
buildFleet();
updateModel();
resetSimulation();
resetCamera();
resize();
animate();
</script>
</body>
</html>
```