Prompt specification
Build or customize the Three.js 3D scene "Equal power different voltage-current pairs" 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: Equal power different voltage-current pairs
Category: Science & Physics · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/equal-power-different-voltage-current-pairs-x1630
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows two stylized solid electrical teaching stands. Each stand contains a virtual supply, a load, voltage and current indicators, and a transparent energy counter. Use one illustrative voltage-current pair on the left and a different pair on the right whose products are equal. Start both loads together and let their accumulated energy columns rise at the same rate. Keep voltage, current, power, and energy visibly separate, including their units. A shared timer should make it easy to compare equal elapsed intervals, and changing one pair should update its power and subsequent energy accumulation without rewriting the other stand's history.
Working Three.js Starter (equal-power-different-voltage-current-pairs-x1630):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Electrical Teaching Stands — Three.js</title>
<style>
:root {
color-scheme: dark;
--bg: #061014;
--panel: rgba(12, 28, 34, 0.88);
--panel-strong: rgba(15, 34, 41, 0.96);
--line: rgba(177, 225, 224, 0.15);
--text: #e9f5f4;
--muted: #91aaa9;
--cyan: #4ce2c7;
--amber: #ffb65c;
}
* {
box-sizing: border-box;
}
html, body {
margin: 0;
min-height: 100%;
background:
radial-gradient(circle at 18% 18%, rgba(28, 105, 103, 0.20), transparent 35%),
radial-gradient(circle at 82% 15%, rgba(132, 78, 30, 0.16), transparent 32%),
var(--bg);
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
body {
min-height: 100svh;
display: grid;
grid-template-rows: auto minmax(430px, 1fr) auto;
overflow: hidden;
}
button, select, input {
font: inherit;
}
button, select {
color: var(--text);
}
.topbar {
position: relative;
z-index: 10;
min-height: 88px;
padding: 15px 24px;
display: grid;
grid-template-columns: minmax(240px, 1fr) auto minmax(300px, 1fr);
gap: 22px;
align-items: center;
border-bottom: 1px solid var(--line);
background: rgba(6, 16, 20, 0.82);
backdrop-filter: blur(18px);
}
.brand {
display: flex;
align-items: center;
gap: 14px;
min-width: 0;
}
.brand-mark {
width: 42px;
height: 42px;
border: 1px solid rgba(76, 226, 199, 0.45);
border-radius: 13px;
display: grid;
place-items: center;
color: var(--cyan);
font-weight: 900;
font-size: 21px;
background: rgba(76, 226, 199, 0.08);
box-shadow: inset 0 0 20px rgba(76, 226, 199, 0.05);
flex: 0 0 auto;
}
.eyebrow {
display: block;
margin-bottom: 4px;
color: var(--muted);
font-size: 10px;
line-height: 1;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(17px, 2vw, 25px);
line-height: 1.05;
font-weight: 760;
letter-spacing: -0.03em;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.timer-block {
min-width: 166px;
text-align: center;
padding: 9px 18px 10px;
border: 1px solid rgba(76, 226, 199, 0.22);
border-radius: 15px;
background: rgba(76, 226, 199, 0.045);
}
#timer {
display: block;
margin-top: 4px;
font-variant-numeric: tabular-nums;
font-size: 27px;
line-height: 1;
letter-spacing: 0.04em;
color: #f2fffd;
}
.top-actions {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 9px;
flex-wrap: wrap;
}
.button, .speed-control {
min-height: 39px;
border: 1px solid var(--line);
border-radius: 11px;
background: rgba(255, 255, 255, 0.045);
}
.button {
padding: 0 14px;
cursor: pointer;
font-weight: 750;
font-size: 12px;
transition: border-color 150ms, background 150ms, transform 150ms;
}
.button:hover {
border-color: rgba(76, 226, 199, 0.5);
background: rgba(76, 226, 199, 0.09);
}
.button:active {
transform: translateY(1px);
}
.button.primary {
border-color: rgba(76, 226, 199, 0.45);
color: #06231f;
background: var(--cyan);
}
.button.primary:hover {
background: #75eed8;
}
.speed-control {
display: flex;
align-items: center;
gap: 7px;
padding: 0 9px 0 12px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.speed-control select {
border: 0;
outline: 0;
background: transparent;
font-weight: 800;
font-size: 12px;
cursor: pointer;
}
.speed-control option {
color: var(--text);
background: #102229;
}
#stage {
position: relative;
min-height: 430px;
overflow: hidden;
isolation: isolate;
}
#stage canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
cursor: grab;
}
#stage canvas:active {
cursor: grabbing;
}
.stage-overlay {
position: absolute;
z-index: 3;
pointer-events: none;
}
.stage-overlay.top-left {
top: 18px;
left: 22px;
}
.stage-overlay.bottom-right {
right: 22px;
bottom: 18px;
}
.stage-chip {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 8px 11px;
border: 1px solid var(--line);
border-radius: 999px;
background: rgba(5, 16, 20, 0.65);
backdrop-filter: blur(10px);
color: #b6cccc;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.chip-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--cyan);
box-shadow: 0 0 12px var(--cyan);
}
#equalBadge {
transition: color 180ms, border-color 180ms, background 180ms;
}
#equalBadge.different {
color: #ffd19a;
border-color: rgba(255, 182, 92, 0.35);
background: rgba(255, 182, 92, 0.07);
}
#loading {
position: absolute;
inset: 0;
z-index: 5;
display: grid;
place-items: center;
color: var(--muted);
font-size: 12px;
letter-spacing: 0.12em;
text-transform: uppercase;
background: #061014;
transition: opacity 300ms;
}
.controls {
position: relative;
z-index: 10;
padding: 0 18px 18px;
border-top: 1px solid var(--line);
background: rgba(6, 16, 20, 0.94);
backdrop-filter: blur(18px);
}
.lab-note {
min-height: 34px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 18px;
padding: 0 4px;
color: var(--muted);
font-size: 11px;
}
.lab-note strong {
color: #cce2df;
letter-spacing: 0.08em;
text-transform: uppercase;
font-size: 10px;
}
.control-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 14px;
}
.stand-card {
--accent: var(--cyan);
--accent-soft: rgba(76, 226, 199, 0.13);
position: relative;
overflow: hidden;
padding: 15px 16px 13px;
border: 1px solid var(--line);
border-radius: 17px;
background:
linear-gradient(125deg, var(--accent-soft), transparent 36%),
var(--panel-strong);
box-shadow: 0 14px 35px rgba(0, 0, 0, 0.16);
}
.stand-card.right {
--accent: var(--amber);
--accent-soft: rgba(255, 182, 92, 0.12);
}
.stand-card::before {
content: "";
position: absolute;
inset: 0 auto 0 0;
width: 3px;
background: var(--accent);
box-shadow: 0 0 18px var(--accent);
}
.card-heading {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 11px;
}
.card-heading h2 {
margin: 0;
font-size: 14px;
letter-spacing: 0.02em;
}
.card-heading h2 span {
color: var(--accent);
}
.initial-pair {
color: var(--muted);
font-size: 10px;
font-variant-numeric: tabular-nums;
}
.stats {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 7px;
}
.stat {
min-width: 0;
padding: 9px 10px 8px;
border: 1px solid rgba(255, 255, 255, 0.07);
border-radius: 10px;
background: rgba(0, 0, 0, 0.15);
}
.stat-label {
display: block;
margin-bottom: 4px;
color: var(--muted);
font-size: 8px;
font-weight: 850;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.stat-value {
display: flex;
align-items: baseline;
gap: 5px;
white-space: nowrap;
font-variant-numeric: tabular-nums;
}
.stat-value strong {
overflow: hidden;
text-overflow: ellipsis;
font-size: clamp(14px, 1.6vw, 20px);
line-height: 1;
letter-spacing: -0.035em;
}
.stat-value small {
color: var(--accent);
font-size: 9px;
font-weight: 850;
text-transform: uppercase;
}
.pair-controls {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 18px;
margin-top: 12px;
}
.range-label {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
margin-bottom: 5px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.range-label output {
color: var(--text);
font-size: 10px;
font-variant-numeric: tabular-nums;
letter-spacing: 0;
}
input[type="range"] {
width: 100%;
height: 4px;
margin: 7px 0 3px;
display: block;
accent-color: var(--accent);
cursor: pointer;
}
.trace-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin: 10px 0 4px;
color: var(--muted);
font-size: 8px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
}
#leftEvent, #rightEvent {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 8px;
letter-spacing: 0.02em;
text-transform: none;
}
.trace {
width: 100%;
height: 52px;
display: block;
border-radius: 8px;
background: rgba(0, 0, 0, 0.14);
}
@media (max-width: 900px) {
body {
overflow: auto;
}
.topbar {
grid-template-columns: 1fr auto;
padding: 13px 16px;
}
.timer-block {
grid-column: 2;
grid-row: 1;
}
.top-actions {
grid-column: 1 / -1;
justify-content: flex-start;
}
.control-grid {
grid-template-columns: 1fr;
}
}
@media (max-width: 560px) {
body {
grid-template-rows: auto 460px auto;
}
.topbar {
gap: 12px;
}
.brand-mark {
width: 36px;
height: 36px;
}
.timer-block {
min-width: 132px;
padding-inline: 10px;
}
#timer {
font-size: 22px;
}
.stage-overlay.top-left {
top: 12px;
left: 12px;
}
.stage-overlay.bottom-right {
right: 12px;
bottom: 12px;
}
.controls {
padding: 0 10px 12px;
}
.lab-note {
align-items: flex-start;
flex-direction: column;
gap: 3px;
padding: 9px 4px;
}
.stats {
grid-template-columns: 1fr 1fr;
}
.pair-controls {
gap: 11px;
}
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
scroll-behavior: auto !important;
transition-duration: 0.01ms !important;
}
}
</style>
</head>
<body>
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true">Ω</div>
<div>
<span class="eyebrow">Interactive electrical lab / 02</span>
<h1>Power, clearly separated.</h1>
</div>
</div>
<div class="timer-block" aria-label="Shared simulated elapsed timer">
<span class="eyebrow">Shared timer · simulated</span>
<strong id="timer">00:00.0</strong>
</div>
<div class="top-actions">
<label class="speed-control">
Speed
<select id="speed" aria-label="Simulation speed">
<option value="1">1×</option>
<option value="60" selected>60×</option>
</select>
</label>
<button id="runButton" class="button primary" type="button" aria-pressed="false">
Start both loads
</button>
<button id="resetButton" class="button" type="button" title="Clear the shared timer and both energy histories">
Reset run
</button>
</div>
</header>
<main id="stage">
<div id="loading">Building electrical stands…</div>
<div class="stage-overlay top-left">
<div class="stage-chip">
<span class="chip-dot"></span>
Virtual DC teaching circuits
</div>
</div>
<div class="stage-overlay bottom-right">
<div id="equalBadge" class="stage-chip">Equal live power · 240 W</div>
</div>
<div class="stage-overlay bottom-right" style="bottom: 58px;">
<div class="stage-chip">Drag to orbit · Wheel/pinch to zoom · Double-click to reset view</div>
</div>
</main>
<section class="controls" aria-label="Stand controls and measurements">
<div class="lab-note">
<strong>One clock · two independent, append-only energy histories</strong>
<span>
Pair edits affect only that stand’s future intervals. Past accumulated kWh is never recalculated.
</span>
</div>
<div class="control-grid">
<article class="stand-card left" id="leftCard">
<div class="card-heading">
<h2><span>●</span> Stand A / Left</h2>
<span class="initial-pair">Initial: 120 V × 2.0 A = 240 W</span>
</div>
<div class="stats">
<div class="stat">
<span class="stat-label">Voltage</span>
<div class="stat-value"><strong id="leftVoltageStat">120</strong><small>V</small></div>
</div>
<div class="stat">
<span class="stat-label">Current</span>
<div class="stat-value"><strong id="leftCurrentStat">2.00</strong><small>A</small></div>
</div>
<div class="stat">
<span class="stat-label">Power</span>
<div class="stat-value"><strong id="leftPowerStat">240</strong><small>W</small></div>
</div>
<div class="stat">
<span class="stat-label">Energy</span>
<div class="stat-value"><strong id="leftEnergyStat">0.0000</strong><small>kWh</small></div>
</div>
</div>
<div class="pair-controls">
<label>
<span class="range-label">
Voltage
<output id="leftVoltageOutput">120 V</output>
</span>
<input id="leftVoltage" type="range" min="24" max="480" step="1" value="120">
</label>
<label>
<span class="range-label">
Current
<output id="leftCurrentOutput">2.0 A</output>
</span>
<input id="leftCurrent" type="range" min="0.1" max="10" step="0.1" value="2">
</label>
</div>
<div class="trace-header">
<span>Stored energy history · kWh</span>
<span id="leftEvent">Initial pair at 00:00.0</span>
</div>
<canvas id="leftTrace" class="trace" aria-label="Stand A accumulated energy history"></canvas>
</article>
<article class="stand-card right" id="rightCard">
<div class="card-heading">
<h2><span>●</span> Stand B / Right</h2>
<span class="initial-pair">Initial: 240 V × 1.0 A = 240 W</span>
</div>
<div class="stats">
<div class="stat">
<span class="stat-label">Voltage</span>
<div class="stat-value"><strong id="rightVoltageStat">240</strong><small>V</small></div>
</div>
<div class="stat">
<span class="stat-label">Current</span>
<div class="stat-value"><strong id="rightCurrentStat">1.00</strong><small>A</small></div>
</div>
<div class="stat">
<span class="stat-label">Power</span>
<div class="stat-value"><strong id="rightPowerStat">240</strong><small>W</small></div>
</div>
<div class="stat">
<span class="stat-label">Energy</span>
<div class="stat-value"><strong id="rightEnergyStat">0.0000</strong><small>kWh</small></div>
</div>
</div>
<div class="pair-controls">
<label>
<span class="range-label">
Voltage
<output id="rightVoltageOutput">240 V</output>
</span>
<input id="rightVoltage" type="range" min="24" max="480" step="1" value="240">
</label>
<label>
<span class="range-label">
Current
<output id="rightCurrentOutput">1.0 A</output>
</span>
<input id="rightCurrent" type="range" min="0.1" max="10" step="0.1" value="1">
</label>
</div>
<div class="trace-header">
<span>Stored energy history · kWh</span>
<span id="rightEvent">Initial pair at 00:00.0</span>
</div>
<canvas id="rightTrace" class="trace" aria-label="Stand B accumulated energy history"></canvas>
</article>
</div>
</section>
<noscript>This demonstration requires JavaScript and WebGL.</noscript>
<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 stage = $("stage");
const timerElement = $("timer");
const runButton = $("runButton");
const resetButton = $("resetButton");
const speedSelect = $("speed");
const equalBadge = $("equalBadge");
const MAX_COLUMN_KWH = 0.12;
const CYAN = 0x4ce2c7;
const AMBER = 0xffb65c;
const state = {
running: false,
elapsed: 0,
speed: 60,
lastRealTime: performance.now(),
sampleAccumulator: 0,
lastUIUpdate: 0,
lastTraceUpdate: 0
};
// Renderer and scene -----------------------------------------------------
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.setClearColor(0x061014, 0);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.15;
stage.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0x061014, 14, 31);
const camera = new THREE.PerspectiveCamera(42, 1, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, 2.35, 0);
const cameraOrbit = {
theta: 0.02,
phi: 1.18,
radius: 14.2,
fitScale: 1
};
const hemisphere = new THREE.HemisphereLight(0xc8f6f2, 0x152027, 1.55);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xe9ffff, 3.2);
keyLight.position.set(4, 10, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -12;
keyLight.shadow.camera.right = 12;
keyLight.shadow.camera.top = 12;
keyLight.shadow.camera.bottom = -8;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 30;
scene.add(keyLight);
const cyanLight = new THREE.PointLight(CYAN, 18, 12, 2);
cyanLight.position.set(-5, 4.5, 4);
scene.add(cyanLight);
const amberLight = new THREE.PointLight(AMBER, 18, 12, 2);
amberLight.position.set(5, 4.5, 4);
scene.add(amberLight);
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(40, 24),
new THREE.MeshStandardMaterial({
color: 0x071216,
roughness: 0.92,
metalness: 0.08
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.07;
ground.receiveShadow = true;
scene.add(ground);
const grid = new THREE.GridHelper(32, 32, 0x225157, 0x102a2f);
grid.position.y = -0.055;
grid.material.transparent = true;
grid.material.opacity = 0.35;
scene.add(grid);
const backRail = new THREE.Mesh(
new THREE.BoxGeometry(18, 0.035, 0.05),
new THREE.MeshBasicMaterial({ color: 0x1d575b })
);
backRail.position.set(0, 0.02, -3.3);
scene.add(backRail);
// Geometry helpers ------------------------------------------------------
function roundedBoxGeometry(width, height, depth, radius = 0.1) {
const r = Math.min(radius, width / 2, height / 2);
const x = -width / 2;
const y = -height / 2;
const shape = new THREE.Shape();
shape.moveTo(x + r, y);
shape.lineTo(x + width - r, y);
shape.quadraticCurveTo(x + width, y, x + width, y + r);
shape.lineTo(x + width, y + height - r);
shape.quadraticCurveTo(x + width, y + height, x + width - r, y + height);
shape.lineTo(x + r, y + height);
shape.quadraticCurveTo(x, y + height, x, y + height - r);
shape.lineTo(x, y + r);
shape.quadraticCurveTo(x, y, x + r, y);
const geometry = new THREE.ExtrudeGeometry(shape, {
depth,
steps: 1,
bevelEnabled: true,
bevelSegments: 2,
bevelSize: 0.025,
bevelThickness: 0.025,
curveSegments: 5
});
geometry.translate(0, 0, -depth / 2);
geometry.computeVertexNormals();
return geometry;
}
function roundedRectPath(ctx, x, y, width, height, radius) {
const r = Math.min(radius, width / 2, height / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + width - r, y);
ctx.quadraticCurveTo(x + width, y, x + width, y + r);
ctx.lineTo(x + width, y + height - r);
ctx.quadraticCurveTo(x + width, y + height, x + width - r, y + height);
ctx.lineTo(x + r, y + height);
ctx.quadraticCurveTo(x, y + height, x, y + height - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
}
function makeLabel(text, accentHex, width = 1.65) {
const canvas = document.createElement("canvas");
canvas.width = 640;
canvas.height = 144;
const ctx = canvas.getContext("2d");
const accent = `#${accentHex.toString(16).padStart(6, "0")}`;
roundedRectPath(ctx, 8, 8, 624, 128, 25);
ctx.fillStyle = "rgba(5, 17, 21, 0.92)";
ctx.fill();
ctx.lineWidth = 3;
ctx.strokeStyle = accent;
ctx.stroke();
ctx.fillStyle = accent;
ctx.font = "800 31px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 320, 72);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false,
depthTest: false,
toneMapped: false
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(width, width * 144 / 640, 1);
sprite.renderOrder = 20;
return sprite;
}
function addEdges(mesh, color = 0x4b6d70, opacity = 0.45) {
const edges = new THREE.EdgesGeometry(mesh.geometry, 28);
const line = new THREE.LineSegments(
edges,
new THREE.LineBasicMaterial({
color,
transparent: true,
opacity
})
);
mesh.add(line);
return line;
}
function createDisplayTexture() {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 512;
const context = canvas.getContext("2d");
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
return { canvas, context, texture };
}
function drawStandDisplay(stand) {
const ctx = stand.display.context;
const accent = `#${stand.accent.toString(16).padStart(6, "0")}`;
ctx.clearRect(0, 0, 1024, 512);
ctx.fillStyle = "#08191e";
ctx.fillRect(0, 0, 1024, 512);
ctx.fillStyle = accent;
ctx.fillRect(0, 0, 1024, 10);
ctx.fillRect(30, 30, 8, 52);
ctx.fillStyle = "#e8f7f5";
ctx.font = "800 39px system-ui, sans-serif";
ctx.textBaseline = "middle";
ctx.fillText(`STAND ${stand.id}`, 58, 56);
ctx.fillStyle = "#7fa19f";
ctx.font = "700 19px system-ui, sans-serif";
ctx.textAlign = "right";
ctx.fillText(state.running ? "LOADS ACTIVE" : "LOADS READY", 985, 57);
ctx.textAlign = "left";
const values = [
["VOLTAGE", stand.voltage.toFixed(0), "V"],
["CURRENT", stand.current.toFixed(2), "A"],
["POWER", stand.power.toFixed(0), "W"],
["ENERGY", stand.energyKwh.toFixed(4), "kWh"]
];
const startX = 30;
const boxWidth = 232;
const gap = 12;
values.forEach(([label, value, unit], index) => {
const x = startX + index * (boxWidth + gap);
const y = 112;
const height = 352;
roundedRectPath(ctx, x, y, boxWidth, height, 20);
ctx.fillStyle = index === 3 ? `${accent}12` : "rgba(255,255,255,0.035)";
ctx.fill();
ctx.strokeStyle = index === 3 ? `${accent}90` : "rgba(160,210,210,0.14)";
ctx.lineWidth = 2;
ctx.stroke();
ctx.fillStyle = "#829f9e";
ctx.font = "800 18px system-ui, sans-serif";
ctx.fillText(label, x + 18, y + 34);
ctx.fillStyle = "#f0fffc";
ctx.font = `800 ${value.length > 6 ? 43 : 55}px system-ui, sans-serif`;
ctx.fillText(value, x + 18, y + 113);
ctx.fillStyle = accent;
ctx.font = "800 22px system-ui, sans-serif";
ctx.fillText(unit, x + 18, y + 165);
ctx.fillStyle = "rgba(255,255,255,0.07)";
ctx.fillRect(x + 18, y + 210, boxWidth - 36, 3);
if (index < 3) {
ctx.fillStyle = "rgba(255,255,255,0.28)";
ctx.font = "700 15px system-ui, sans-serif";
ctx.fillText(index === 2 ? "P = V × I" : "MEASURED", x + 18, y + 248);
} else {
ctx.fillStyle = "rgba(255,255,255,0.28)";
ctx.font = "700 15px system-ui, sans-serif";
ctx.fillText("∫ P(t) dt", x + 18, y + 248);
}
});
stand.display.texture.needsUpdate = true;
}
// Stand construction ----------------------------------------------------
function createStand(id, xPosition, accent, voltage, current) {
const group = new THREE.Group();
group.position.x = xPosition;
scene.add(group);
const accentCSS = `#${accent.toString(16).padStart(6, "0")}`;
const darkMetal = new THREE.MeshStandardMaterial({
color: 0x10272d,
roughness: 0.45,
metalness: 0.72
});
const accentMaterial = new THREE.MeshStandardMaterial({
color: accent,
emissive: accent,
emissiveIntensity: 0.18,
roughness: 0.3,
metalness: 0.45
});
const base = new THREE.Mesh(
roundedBoxGeometry(4.15, 0.3, 2.15, 0.12),
new THREE.MeshStandardMaterial({
color: 0x0b1b20,
roughness: 0.58,
metalness: 0.58
})
);
base.position.y = 0.12;
base.castShadow = true;
base.receiveShadow = true;
group.add(base);
addEdges(base, 0x315258, 0.45);
const baseInset = new THREE.Mesh(
new THREE.BoxGeometry(3.83, 0.025, 1.84),
new THREE.MeshBasicMaterial({ color: accent, transparent: true, opacity: 0.12 })
);
baseInset.position.y = 0.281;
group.add(baseInset);
const postGeometry = roundedBoxGeometry(0.12, 4.4, 0.14, 0.045);
for (const x of [-1.32, 1.32]) {
const post = new THREE.Mesh(postGeometry, darkMetal);
post.position.set(x, 2.42, -0.34);
post.castShadow = true;
group.add(post);
}
const topBar = new THREE.Mesh(
roundedBoxGeometry(2.76, 0.12, 0.14, 0.045),
darkMetal
);
topBar.position.set(0, 4.56, -0.34);
topBar.castShadow = true;
group.add(topBar);
const board = new THREE.Mesh(
roundedBoxGeometry(2.55, 1.46, 0.15, 0.12),
new THREE.MeshStandardMaterial({
color: 0x07171c,
roughness: 0.6,
metalness: 0.25
})
);
board.position.set(0, 2.72, -0.22);
board.castShadow = true;
group.add(board);
addEdges(board, accent, 0.35);
const display = createDisplayTexture();
const displayMesh = new THREE.Mesh(
new THREE.PlaneGeometry(2.36, 1.18),
new THREE.MeshBasicMaterial({
map: display.texture,
toneMapped: false
})
);
displayMesh.position.set(0, 2.72, -0.135);
group.add(displayMesh);
const supply = new THREE.Mesh(
roundedBoxGeometry(1.18, 1.05, 0.9, 0.13),
new THREE.MeshStandardMaterial({
color: 0x13313b,
emissive: accent,
emissiveIntensity: 0.045,
roughness: 0.35,
metalness: 0.5
})
);
supply.position.set(-0.9, 3.83, 0.02);
supply.castShadow = true;
group.add(supply);
addEdges(supply, accent, 0.72);
const supplyFace = new THREE.Mesh(
roundedBoxGeometry(0.86, 0.65, 0.055, 0.06),
new THREE.MeshStandardMaterial({
color: 0x07171c,
roughness: 0.5,
metalness: 0.25
})
);
supplyFace.position.set(-0.9, 3.83, 0.493);
group.add(supplyFace);
const supplyLed = new THREE.Mesh(
new THREE.SphereGeometry(0.095, 20, 12),
new THREE.MeshStandardMaterial({
color: accent,
emissive: accent,
emissiveIntensity: 1.4,
roughness: 0.2
})
);
supplyLed.position.set(-1.18, 3.98, 0.56);
group.add(supplyLed);
const load = new THREE.Mesh(
roundedBoxGeometry(1.18, 1.02, 0.9, 0.13),
new THREE.MeshStandardMaterial({
color: 0x26302c,
emissive: accent,
emissiveIntensity: 0.035,
roughness: 0.5,
metalness: 0.42
})
);
load.position.set(0.9, 1.26, 0.02);
load.castShadow = true;
group.add(load);
addEdges(load, accent, 0.72);
const loadFace = new THREE.Mesh(
roundedBoxGeometry(0.86, 0.63, 0.055, 0.06),
new THREE.MeshStandardMaterial({
color: 0x111b19,
roughness: 0.55,
metalness: 0.25
})
);
loadFace.position.set(0.9, 1.26, 0.493);
group.add(loadFace);
for (let i = 0; i < 4; i++) {
const vent = new THREE.Mesh(
new THREE.BoxGeometry(0.54, 0.035, 0.025),
new THREE.MeshBasicMaterial({ color: accent, transparent: true, opacity: 0.65 })
);
vent.position.set(0.9, 1.08 + i * 0.12, 0.532);
group.add(vent);
}
const loadLed = new THREE.Mesh(
new THREE.SphereGeometry(0.105, 20, 12),
new THREE.MeshStandardMaterial({
color: accent,
emissive: accent,
emissiveIntensity: 0.3,
roughness: 0.2
})
);
loadLed.position.set(1.18, 1.47, 0.56);
group.add(loadLed);
const cablePoints = [
new THREE.Vector3(-0.9, 4.34, 0.24),
new THREE.Vector3(-0.9, 4.67, 0.24),
new THREE.Vector3(0.9, 4.67, 0.24),
new THREE.Vector3(0.9, 1.83, 0.24),
new THREE.Vector3(0.9, 0.75, 0.24),
new THREE.Vector3(-0.9, 0.75, 0.24),
new THREE.Vector3(-0.9, 3.32, 0.24)
];
const cableCurve = new THREE.CatmullRomCurve3(
cablePoints,
true,
"catmullrom",
0.12
);
const cableMaterial = new THREE.MeshStandardMaterial({
color: 0x164249,
emissive: accent,
emissiveIntensity: 0.12,
roughness: 0.32,
metalness: 0.5
});
const cable = new THREE.Mesh(
new THREE.TubeGeometry(cableCurve, 120, 0.043, 8, true),
cableMaterial
);
cable.castShadow = true;
group.add(cable);
const particles = [];
const particleGeometry = new THREE.SphereGeometry(0.067, 12, 8);
const particleMaterial = new THREE.MeshBasicMaterial({
color: 0xdffffb,
toneMapped: false
});
for (let i = 0; i < 7; i++) {
const particle = new THREE.Mesh(particleGeometry, particleMaterial);
particle.position.copy(cableCurve.getPointAt(i / 7));
group.add(particle);
particles.push(particle);
}
const towerX = id === "A" ? -1.78 : 1.78;
const towerBottom = 0.3;
const towerHeight = 2.55;
const towerShell = new THREE.Mesh(
new THREE.CylinderGeometry(0.31, 0.31, towerHeight, 32, 1, true),
new THREE.MeshPhysicalMaterial({
color: accent,
transparent: true,
opacity: 0.13,
roughness: 0.12,
metalness: 0,
side: THREE.DoubleSide,
depthWrite: false
})
);
towerShell.position.set(towerX, towerBottom + towerHeight / 2, 0.06);
group.add(towerShell);
const towerFill = new THREE.Mesh(
new THREE.CylinderGeometry(0.22, 0.22, 1, 32),
new THREE.MeshStandardMaterial({
color: accent,
emissive: accent,
emissiveIntensity: 0.45,
transparent: true,
opacity: 0.78,
roughness: 0.25
})
);
towerFill.position.set(towerX, towerBottom, 0.06);
towerFill.scale.y = 0.001;
group.add(towerFill);
for (let i = 0; i <= 4; i++) {
const tick = new THREE.Mesh(
new THREE.BoxGeometry(0.2, 0.018, 0.018),
new THREE.MeshBasicMaterial({
color: 0x88aaa8,
transparent: true,
opacity: 0.7
})
);
tick.position.set(
towerX + (id === "A" ? -0.3 : 0.3),
towerBottom + i * towerHeight / 4,
0.12
);
group.add(tick);
}
const towerCap = new THREE.Mesh(
new THREE.TorusGeometry(0.31, 0.027, 10, 40),
new THREE.MeshStandardMaterial({
color: accent,
emissive: accent,
emissiveIntensity: 0.3,
roughness: 0.25,
metalness: 0.5
})
);
towerCap.rotation.x = Math.PI / 2;
towerCap.position.set(towerX, towerBottom + towerHeight, 0.06);
group.add(towerCap);
const supplyLabel = makeLabel(`VIRTUAL SUPPLY ${id}`, accent, 1.9);
supplyLabel.position.set(-0.9, 4.92, 0.2);
group.add(supplyLabel);
const loadLabel = makeLabel(`LOAD ${id}`, accent, 1.25);
loadLabel.position.set(0.9, 2.05, 0.42);
group.add(loadLabel);
const energyLabel = makeLabel(`ENERGY · kWh`, accent, 1.55);
energyLabel.position.set(towerX, 3.14, 0.12);
group.add(energyLabel);
const scaleLabel = makeLabel("0.12 kWh FULL", accent, 1.35);
scaleLabel.position.set(towerX, 0.54, 0.15);
group.add(scaleLabel);
const stand = {
id,
accent,
accentCSS,
group,
voltage,
current,
power: voltage * current,
energyKwh: 0,
trace: [],
events: [],
cableCurve,
particles,
cableMaterial,
loadLed,
supplyLed,
towerFill,
towerBottom,
towerHeight: 2.42,
display,
phase: Math.random() * 0.2
};
stand.trace.push({ t: 0, energy: 0 });
stand.events.push({ t: 0, power: stand.power, energy: 0 });
drawStandDisplay(stand);
return stand;
}
const leftStand = createStand("A", -2.75, CYAN, 120, 2);
const rightStand = createStand("B", 2.75, AMBER, 240, 1);
const stands = [leftStand, rightStand];
// Simulation ------------------------------------------------------------
function formatTime(seconds) {
const tenths = Math.floor(Math.max(0, seconds) * 10 + 1e-6);
const minutes = Math.floor(tenths / 600);
const remainingSeconds = Math.floor((tenths % 600) / 10);
const tenth = tenths % 10;
return `${String(minutes).padStart(2, "0")}:${String(remainingSeconds).padStart(2, "0")}.${tenth}`;
}
function integrateTo(now) {
if (!state.running) {
state.lastRealTime = now;
return;
}
const rawDelta = Math.max(0, (now - state.lastRealTime) / 1000);
state.lastRealTime = now;
// Very long stalls are ignored to avoid a sudden visual jump.
const realDelta = Math.min(rawDelta, 0.25);
const simulatedDelta = realDelta * state.speed;
if (simulatedDelta <= 0) return;
state.elapsed += simulatedDelta;
for (const stand of stands) {
// W × seconds → Wh → kWh.
// Existing accumulated energy is preserved; only future energy is added.
stand.energyKwh += stand.power * simulatedDelta / 3_600_000;
}
state.sampleAccumulator += simulatedDelta;
if (state.sampleAccumulator >= 15) {
state.sampleAccumulator %= 15;
for (const stand of stands) {
stand.trace.push({
t: state.elapsed,
energy: stand.energyKwh
});
}
}
}
function setRunning(running) {
if (running) {
state.running = true;
state.lastRealTime = performance.now();
} else {
integrateTo(performance.now());
state.running = false;
state.lastRealTime = performance.now();
}
updateRunButton();
updateUI();
drawTraces();
}
function updateRunButton() {
runButton.textContent = state.running
? "Pause both"
: state.elapsed > 0
? "Resume both loads"
: "Start both loads";
runButton.setAttribute("aria-pressed", String(state.running));
}
function resetRun() {
state.running = false;
state.elapsed = 0;
state.sampleAccumulator = 0;
state.lastRealTime = performance.now();
for (const stand of stands) {
stand.energyKwh = 0;
stand.trace = [{ t: 0, energy: 0 }];
stand.events = [{ t: 0, power: stand.power, energy: 0 }];
stand.phase = 0;
$("leftEvent").textContent = "Initial pair at 00:00.0";
$("rightEvent").textContent = "Initial pair at 00:00.0";
}
updateRunButton();
updateUI();
drawTraces();
}
runButton.addEventListener("click", () => {
setRunning(!state.running);
});
resetButton.addEventListener("click", resetRun);
speedSelect.addEventListener("change", () => {
// The speed change affects only future intervals.
state.speed = Number(speedSelect.value);
state.lastRealTime = performance.now();
});
document.addEventListener("visibilitychange", () => {
if (document.hidden && state.running) {
integrateTo(performance.now());
state.running = false;
state.lastRealTime = performance.now();
updateRunButton();
updateUI();
}
});
// Pair editing -----------------------------------------------------------
function bindPairControls(side, stand) {
const voltageInput = $(`${side}Voltage`);
const currentInput = $(`${side}Current`);
const change = (input, key) => {
// Integrate the previous pair up to the edit boundary.
integrateTo(performance.now());
const value = Number(input.value);
stand[key] = value;
stand.power = stand.voltage * stand.current;
stand.events.push({
t: state.elapsed,
power: stand.power,
energy: stand.energyKwh
});
stand.trace.push({
t: state.elapsed,
energy: stand.energyKwh
});
const eventElement = $(`${side}Event`);
eventElement.textContent =
`${formatTime(state.elapsed)} · ${stand.voltage.toFixed(0)} V / ${stand.current.toFixed(1)} A`;
updateUI();
drawTraces();
};
voltageInput.addEventListener("input", () => change(voltageInput, "voltage"));
currentInput.addEventListener("input", () => change(currentInput, "current"));
}
bindPairControls("left", leftStand);
bindPairControls("right", rightStand);
// UI and history charts --------------------------------------------------
function updateUI() {
timerElement.textContent = formatTime(state.elapsed);
updateStandUI(leftStand, "left");
updateStandUI(rightStand, "right");
const equal = Math.abs(leftStand.power - rightStand.power) < 0.05;
equalBadge.classList.toggle("different", !equal);
if (equal) {
equalBadge.textContent = `Equal live power · ${leftStand.power.toFixed(0)} W`;
} else {
equalBadge.textContent =
`Live power differs · ${leftStand.power.toFixed(0)} W / ${rightStand.power.toFixed(0)} W`;
}
}
function updateStandUI(stand, side) {
$(`${side}VoltageStat`).textContent = stand.voltage.toFixed(0);
$(`${side}CurrentStat`).textContent = stand.current.toFixed(2);
$(`${side}PowerStat`).textContent = stand.power.toFixed(0);
$(`${side}EnergyStat`).textContent = stand.energyKwh.toFixed(4);
$(`${side}VoltageOutput`).textContent = `${stand.voltage.toFixed(0)} V`;
$(`${side}CurrentOutput`).textContent = `${stand.current.toFixed(1)} A`;
drawStandDisplay(stand);
}
function prepareTraceCanvas(canvas) {
const rect = canvas.getBoundingClientRect();
const dpr = Math.min(window.devicePixelRatio || 1, 2);
const pixelWidth = Math.max(1, Math.round(rect.width * dpr));
const pixelHeight = Math.max(1, Math.round(rect.height * dpr));
if (canvas.width !== pixelWidth || canvas.height !== pixelHeight) {
canvas.width = pixelWidth;
canvas.height = pixelHeight;
}
const ctx = canvas.getContext("2d");
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
ctx.clearRect(0, 0, rect.width, rect.height);
return { ctx, width: rect.width, height: rect.height };
}
function drawTrace(stand, side) {
const canvas = $(`${side}Trace`);
const { ctx, width, height } = prepareTraceCanvas(canvas);
const left = 7;
const right = width - 7;
const top = 7;
const bottom = height - 7;
const xMax = Math.max(60, state.elapsed);
let yMax = 0.01;
for (const item of stands) {
yMax = Math.max(yMax, item.energyKwh);
for (const point of item.trace) {
yMax = Math.max(yMax, point.energy);
}
}
yMax *= 1.12;
const xFor = (time) => left + (time / xMax) * (right - left);
const yFor = (energy) => bottom - (energy / yMax) * (bottom - top);
ctx.strokeStyle = "rgba(175,215,213,0.10)";
ctx.lineWidth = 1;
for (let i = 1; i < 4; i++) {
const y = top + (bottom - top) * i / 4;
ctx.beginPath();
ctx.moveTo(left, y);
ctx.lineTo(right, y);
ctx.stroke();
}
for (let i = 1; i < 5; i++) {
const x = left + (right - left) * i / 5;
ctx.beginPath();
ctx.moveTo(x, top);
ctx.lineTo(x, bottom);
ctx.stroke();
}
for (const event of stand.events) {
const x = xFor(event.t);
ctx.save();
ctx.setLineDash([3, 4]);
ctx.strokeStyle = `${stand.accentCSS}88`;
ctx.beginPath();
ctx.moveTo(x, top);
ctx.lineTo(x, bottom);
ctx.stroke();
ctx.restore();
}
if (stand.trace.length > 1) {
const gradient = ctx.createLinearGradient(0, top, 0, bottom);
gradient.addColorStop(0, `${stand.accentCSS}cc`);
gradient.addColorStop(1, `${stand.accentCSS}44`);
ctx.strokeStyle = gradient;
ctx.lineWidth = 2.2;
ctx.lineJoin = "round";
ctx.beginPath();
stand.trace.forEach((point, index) => {
const x = xFor(point.t);
const y = yFor(point.energy);
if (index === 0) ctx.moveTo(x, y);
else ctx.lineTo(x, y);
});
ctx.stroke();
const last = stand.trace[stand.trace.length - 1];
ctx.fillStyle = stand.accentCSS;
ctx.beginPath();
ctx.arc(xFor(last.t), yFor(last.energy), 2.7, 0, Math.PI * 2);
ctx.fill();
}
ctx.fillStyle = "rgba(181,211,209,0.52)";
ctx.font = "700 8px system-ui, sans-serif";
ctx.textBaseline = "bottom";
ctx.fillText("0", left, height - 1);
ctx.textAlign = "right";
ctx.fillText(formatTime(xMax), right, height - 1);
ctx.textAlign = "left";
}
function drawTraces() {
drawTrace(leftStand, "left");
drawTrace(rightStand, "right");
}
// 3D visual updates ------------------------------------------------------
function updateStandVisual(stand, realDelta) {
const fillHeight = Math.max(
0.001,
Math.min(1, stand.energyKwh / MAX_COLUMN_KWH) * stand.towerHeight
);
stand.towerFill.scale.y = fillHeight;
stand.towerFill.position.y = stand.towerBottom + fillHeight / 2;
stand.towerFill.visible = stand.energyKwh > 0.000001;
const animatedDelta = state.running ? realDelta : 0;
stand.phase = (
stand.phase +
animatedDelta * Math.min(2.6, 0.24 + stand.current * 0.48)
) % 1;
stand.particles.forEach((particle, index) => {
const position = (stand.phase + index / stand.particles.length) % 1;
particle.position.copy(stand.cableCurve.getPointAt(position));
});
stand.cableMaterial.emissiveIntensity = state.running
? 0.16 + Math.min(0.7, stand.current * 0.17)
: 0.07;
const powerGlow = state.running
? 0.65 + Math.min(2.2, stand.power / 650)
: 0.18;
stand.loadLed.material.emissiveIntensity = powerGlow;
stand.supplyLed.material.emissiveIntensity = state.running ? 1.8 : 0.7;
}
// Direct camera controls, implemented without addons ---------------------
const pointers = new Map();
let previousPinchDistance = 0;
function updateCamera() {
const fit = cameraOrbit.fitScale;
const radius = cameraOrbit.radius * fit;
const sinPhi = Math.sin(cameraOrbit.phi);
camera.position.set(
cameraTarget.x + radius * sinPhi * Math.sin(cameraOrbit.theta),
cameraTarget.y + radius * Math.cos(cameraOrbit.phi),
cameraTarget.z + radius * sinPhi * Math.cos(cameraOrbit.theta)
);
camera.lookAt(cameraTarget);
}
function resetCamera() {
cameraOrbit.theta = 0.02;
cameraOrbit.phi = 1.18;
cameraOrbit.radius = 14.2;
updateCamera();
}
function pointerDistance() {
const points = [...pointers.values()];
if (points.length < 2) return 0;
return Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
}
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
previousPinchDistance = pointerDistance();
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 1) {
cameraOrbit.theta -= dx * 0.006;
cameraOrbit.phi = THREE.MathUtils.clamp(
cameraOrbit.phi - dy * 0.005,
0.58,
1.48
);
} else if (pointers.size === 2) {
const distance = pointerDistance();
if (previousPinchDistance > 0 && distance > 0) {
cameraOrbit.radius = THREE.MathUtils.clamp(
cameraOrbit.radius * (previousPinchDistance / distance),
8.5,
23
);
}
previousPinchDistance = distance;
}
updateCamera();
});
function releasePointer(event) {
pointers.delete(event.pointerId);
previousPinchDistance = pointerDistance();
}
renderer.domElement.addEventListener("pointerup", releasePointer);
renderer.domElement.addEventListener("pointercancel", releasePointer);
renderer.domElement.addEventListener("lostpointercapture", releasePointer);
renderer.domElement.addEventListener("wheel", (event) => {
event.preventDefault();
cameraOrbit.radius = THREE.MathUtils.clamp(
cameraOrbit.radius * Math.exp(event.deltaY * 0.001),
8.5,
23
);
updateCamera();
}, { passive: false });
renderer.domElement.addEventListener("dblclick", resetCamera);
// Resize -----------------------------------------------------------------
function resize() {
const width = Math.max(1, stage.clientWidth);
const height = Math.max(1, stage.clientHeight);
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
cameraOrbit.fitScale = Math.max(1, 1.18 / camera.aspect);
updateCamera();
drawTraces();
}
new ResizeObserver(resize).observe(stage);
window.addEventListener("resize", resize);
// Main loop --------------------------------------------------------------
function animate(now) {
requestAnimationFrame(animate);
integrateTo(now);
updateCamera();
for (const stand of stands) {
updateStandVisual(stand, 1 / 60);
}
if (now - state.lastUIUpdate > 90) {
state.lastUIUpdate = now;
updateUI();
}
if (now - state.lastTraceUpdate > 180) {
state.lastTraceUpdate = now;
drawTraces();
}
renderer.render(scene, camera);
}
resize();
updateRunButton();
updateUI();
drawTraces();
requestAnimationFrame(animate);
requestAnimationFrame(() => {
const loading = $("loading");
loading.style.opacity = "0";
setTimeout(() => loading.remove(), 320);
});
</script>
</body>
</html>
```