Prompt specification
Build or customize the Three.js 3D scene "Kettle Timer and Toast Overlap" 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: Kettle Timer and Toast Overlap
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/kettle-timer-and-toast-overlap-x3426
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring temporal order and overlapping events. Show two household tasks on parallel visible timelines. Let users change start times and distinguish simultaneous intervals from events that merely happen consecutively. Stylized solid forms.
Working Three.js Starter (kettle-timer-and-toast-overlap-x3426):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Temporal Household Timeline</title>
<style>
:root {
color-scheme: light;
--ink: #193044;
--muted: #667982;
--paper: #f7f6ef;
--line: #d8dfdb;
--laundry: #4d7cf6;
--dishes: #ef8068;
--overlap: #efb642;
--consecutive: #45b889;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
}
body {
background:
radial-gradient(circle at 35% 30%, #faf8ef 0%, #e9ede8 58%, #dce4df 100%);
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
#stage,
#world-labels {
position: fixed;
inset: 0;
}
#stage canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
}
#world-labels {
z-index: 4;
pointer-events: none;
overflow: hidden;
}
.intro {
position: fixed;
z-index: 8;
top: 30px;
left: 34px;
max-width: 510px;
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 12px;
color: #667b75;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
width: 28px;
height: 3px;
border-radius: 999px;
background: var(--overlap);
content: "";
}
h1 {
max-width: 470px;
margin: 0;
font-size: clamp(34px, 4vw, 58px);
font-weight: 780;
letter-spacing: -0.055em;
line-height: 0.98;
}
.intro p {
max-width: 420px;
margin: 15px 0 0;
color: #61727b;
font-size: 14px;
line-height: 1.6;
}
.panel {
position: fixed;
z-index: 12;
top: 24px;
right: 24px;
width: 350px;
max-height: calc(100vh - 48px);
overflow: auto;
padding: 20px;
border: 1px solid rgba(255, 255, 255, 0.75);
border-radius: 24px;
background: rgba(250, 249, 243, 0.9);
box-shadow:
0 24px 70px rgba(30, 55, 55, 0.14),
inset 0 0 0 1px rgba(27, 55, 62, 0.04);
backdrop-filter: blur(18px);
scrollbar-width: thin;
}
.panel-head {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 17px;
}
.panel-title {
margin: 0;
font-size: 15px;
font-weight: 800;
letter-spacing: -0.02em;
}
.reset-view {
padding: 7px 10px;
border: 1px solid #d6ded9;
border-radius: 10px;
background: transparent;
color: #61737b;
cursor: pointer;
font-size: 11px;
font-weight: 750;
}
.reset-view:hover {
border-color: #aabbb4;
background: #fff;
color: var(--ink);
}
.section-label {
margin: 0 0 9px;
color: #7b8a8f;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.presets {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 7px;
margin-bottom: 18px;
}
.preset {
min-height: 49px;
padding: 8px 5px;
border: 1px solid #d8dfda;
border-radius: 13px;
background: rgba(255, 255, 255, 0.62);
color: #50636c;
cursor: pointer;
font-size: 11px;
font-weight: 800;
line-height: 1.2;
transition: 160ms ease;
}
.preset span {
display: block;
margin-top: 4px;
color: #8b999c;
font-size: 9px;
font-weight: 650;
}
.preset:hover,
.preset.active {
transform: translateY(-1px);
border-color: #98aaa3;
background: #fff;
color: var(--ink);
box-shadow: 0 6px 18px rgba(41, 65, 69, 0.08);
}
.preset.active {
border-color: #78948a;
box-shadow:
0 0 0 2px rgba(67, 119, 102, 0.1),
0 6px 18px rgba(41, 65, 69, 0.08);
}
.task-control {
--task: var(--laundry);
margin-top: 10px;
padding: 13px 14px 12px;
border: 1px solid #dde2dd;
border-radius: 17px;
background: rgba(255, 255, 255, 0.68);
}
.task-control.dishes {
--task: var(--dishes);
}
.task-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
}
.task-name {
display: flex;
align-items: center;
gap: 9px;
font-size: 13px;
font-weight: 820;
}
.task-dot {
width: 10px;
height: 10px;
border-radius: 4px;
background: var(--task);
box-shadow: 0 0 0 4px color-mix(in srgb, var(--task) 14%, transparent);
}
.task-time {
color: var(--ink);
font-variant-numeric: tabular-nums;
font-size: 13px;
font-weight: 850;
}
.range-row {
display: grid;
grid-template-columns: 1fr auto;
align-items: center;
gap: 10px;
margin-top: 11px;
}
.range-row label {
color: #7b898e;
font-size: 10px;
font-weight: 700;
}
.duration {
color: #8b9799;
font-size: 10px;
font-weight: 650;
}
input[type="range"] {
grid-column: 1 / -1;
width: 100%;
height: 5px;
margin: 2px 0 4px;
border-radius: 99px;
accent-color: var(--task);
cursor: pointer;
}
.range-labels {
grid-column: 1 / -1;
display: flex;
justify-content: space-between;
color: #9aa4a3;
font-size: 9px;
font-weight: 650;
}
.relation-card {
--rel: var(--overlap);
--rel-soft: #fff4d7;
margin-top: 17px;
padding: 16px;
border: 1px solid color-mix(in srgb, var(--rel) 32%, white);
border-radius: 19px;
background: var(--rel-soft);
transition: 180ms ease;
}
.relation-card.consecutive {
--rel: var(--consecutive);
--rel-soft: #e8f7ef;
}
.relation-card.separated {
--rel: #849397;
--rel-soft: #edf1ef;
}
.status-row {
display: flex;
align-items: center;
gap: 8px;
}
.status-pill {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 6px 8px;
border-radius: 999px;
background: var(--rel);
color: white;
font-size: 9px;
font-weight: 900;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.status-pill::before {
width: 6px;
height: 6px;
border-radius: 50%;
background: white;
content: "";
}
.relation-title {
margin: 12px 0 5px;
font-size: 17px;
font-weight: 850;
letter-spacing: -0.025em;
}
.relation-description {
min-height: 38px;
margin: 0;
color: #61727a;
font-size: 11px;
line-height: 1.55;
}
.relation-stats {
display: grid;
grid-template-columns: 1.2fr 0.8fr;
gap: 9px;
margin-top: 13px;
}
.stat {
padding: 10px;
border: 1px solid rgba(38, 64, 67, 0.08);
border-radius: 12px;
background: rgba(255, 255, 255, 0.55);
}
.stat span {
display: block;
color: #819094;
font-size: 8px;
font-weight: 800;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.stat strong {
display: block;
margin-top: 5px;
color: var(--ink);
font-size: 12px;
font-weight: 850;
font-variant-numeric: tabular-nums;
}
.order-list {
display: grid;
gap: 7px;
margin: 13px 0 0;
padding: 0;
list-style: none;
}
.order-list li {
display: flex;
align-items: center;
gap: 9px;
color: #4e626b;
font-size: 10px;
line-height: 1.35;
}
.order-number {
display: grid;
flex: 0 0 auto;
width: 21px;
height: 21px;
place-items: center;
border: 1px solid rgba(42, 66, 68, 0.14);
border-radius: 7px;
background: rgba(255, 255, 255, 0.62);
color: var(--ink);
font-size: 9px;
font-weight: 850;
}
.order-list b {
color: var(--ink);
font-weight: 800;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 13px;
margin-top: 16px;
padding-top: 14px;
border-top: 1px solid #dfe4df;
}
.legend-item {
display: flex;
align-items: center;
gap: 6px;
color: #718087;
font-size: 9px;
font-weight: 720;
}
.legend-swatch {
width: 15px;
height: 7px;
border-radius: 3px;
}
.controls-hint {
margin: 13px 0 0;
color: #8a9698;
font-size: 9px;
line-height: 1.55;
}
.world-label {
position: absolute;
z-index: 5;
transform: translate(-50%, -100%);
white-space: nowrap;
pointer-events: none;
will-change: left, top;
}
.task-label {
padding: 7px 10px;
border: 1px solid rgba(255, 255, 255, 0.85);
border-radius: 11px;
background: rgba(250, 249, 243, 0.88);
box-shadow: 0 8px 22px rgba(38, 57, 60, 0.12);
backdrop-filter: blur(8px);
text-align: center;
}
.task-label::before {
display: block;
width: 7px;
height: 7px;
margin: 0 auto 4px;
border-radius: 3px;
background: var(--task-color);
content: "";
}
.task-label strong {
display: block;
color: var(--ink);
font-size: 11px;
font-weight: 850;
}
.task-label span {
display: block;
margin-top: 2px;
color: #738287;
font-size: 9px;
font-weight: 700;
font-variant-numeric: tabular-nums;
}
.lane-label {
transform: translate(-100%, -50%);
color: #53666d;
font-size: 9px;
font-weight: 900;
letter-spacing: 0.14em;
text-transform: uppercase;
text-shadow: 0 1px 8px rgba(255, 255, 255, 0.9);
}
.axis-label {
transform: translate(-50%, -50%);
color: #75868a;
font-size: 9px;
font-weight: 750;
font-variant-numeric: tabular-nums;
}
.relation-label {
padding: 7px 11px;
border: 1px solid rgba(255, 255, 255, 0.8);
border-radius: 10px;
background: rgba(255, 247, 222, 0.94);
box-shadow: 0 8px 24px rgba(68, 55, 25, 0.12);
color: #8d6415;
font-size: 9px;
font-weight: 900;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.relation-label.consecutive {
background: rgba(233, 248, 240, 0.95);
color: #287d5d;
}
.relation-label.separated {
background: rgba(240, 243, 241, 0.95);
color: #67777a;
}
#loading {
position: fixed;
z-index: 50;
inset: 0;
display: grid;
place-items: center;
background: #e8ece6;
color: #667b75;
font-size: 12px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
transition: opacity 300ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 900px) {
.intro {
top: 18px;
left: 20px;
max-width: 390px;
}
h1 {
font-size: 38px;
}
.intro p {
max-width: 330px;
font-size: 12px;
}
.panel {
top: auto;
right: 14px;
bottom: 14px;
left: 14px;
width: auto;
max-height: 43vh;
padding: 16px;
border-radius: 20px;
}
.presets {
grid-template-columns: repeat(3, 1fr);
}
}
@media (max-width: 560px) {
.intro {
top: 14px;
left: 16px;
}
h1 {
max-width: 320px;
font-size: 32px;
}
.intro p {
display: none;
}
.eyebrow {
margin-bottom: 8px;
font-size: 9px;
}
.panel {
max-height: 48vh;
}
.task-label {
padding: 5px 7px;
}
.task-label span {
display: none;
}
}
</style>
</head>
<body>
<div id="stage"></div>
<div id="world-labels"></div>
<header class="intro">
<div class="eyebrow">Temporal planning / household routines</div>
<h1>Two tasks.<br>One shared window.</h1>
<p>
Drag the solid task blocks along their parallel timelines, or use the
controls to reveal the difference between overlapping work and a clean handoff.
</p>
</header>
<aside class="panel" aria-label="Timeline controls">
<div class="panel-head">
<h2 class="panel-title">Timeline controls</h2>
<button class="reset-view" id="reset-view" type="button">Reset view</button>
</div>
<p class="section-label">Try a scenario</p>
<div class="presets">
<button class="preset" type="button" data-preset="overlap">
Overlap<span>shared minutes</span>
</button>
<button class="preset" type="button" data-preset="consecutive">
Consecutive<span>end → start</span>
</button>
<button class="preset" type="button" data-preset="dishes-first">
Dishes first<span>reverse order</span>
</button>
</div>
<p class="section-label">Start times</p>
<div class="task-control" style="--task: var(--laundry)">
<div class="task-top">
<div class="task-name">
<span class="task-dot"></span>
Fold laundry
</div>
<output class="task-time" id="laundry-output" for="laundry-start">09:08</output>
</div>
<div class="range-row">
<label for="laundry-start">Starts at</label>
<span class="duration">24 min duration</span>
<input
id="laundry-start"
type="range"
min="0"
max="36"
step="1"
value="8"
aria-label="Fold laundry start time"
>
<div class="range-labels">
<span>09:00</span>
<span>09:36</span>
</div>
</div>
</div>
<div class="task-control dishes" style="--task: var(--dishes)">
<div class="task-top">
<div class="task-name">
<span class="task-dot"></span>
Load dishwasher
</div>
<output class="task-time" id="dishes-output" for="dishes-start">09:24</output>
</div>
<div class="range-row">
<label for="dishes-start">Starts at</label>
<span class="duration">16 min duration</span>
<input
id="dishes-start"
type="range"
min="0"
max="44"
step="1"
value="24"
aria-label="Load dishwasher start time"
>
<div class="range-labels">
<span>09:00</span>
<span>09:44</span>
</div>
</div>
</div>
<section
class="relation-card simultaneous"
id="relation-card"
aria-live="polite"
aria-atomic="true"
>
<div class="status-row">
<span class="status-pill" id="status-pill">Simultaneous</span>
</div>
<h3 class="relation-title" id="relation-title">Tasks run at the same time</h3>
<p class="relation-description" id="relation-description"></p>
<div class="relation-stats">
<div class="stat">
<span id="window-label">Shared window</span>
<strong id="shared-window">09:24 — 09:32</strong>
</div>
<div class="stat">
<span id="amount-label">Overlap</span>
<strong id="shared-amount">8 shared min</strong>
</div>
</div>
<ol class="order-list" id="order-list"></ol>
</section>
<div class="legend" aria-label="Visual legend">
<div class="legend-item">
<span class="legend-swatch" style="background: var(--overlap)"></span>
simultaneous interval
</div>
<div class="legend-item">
<span class="legend-swatch" style="background: var(--consecutive)"></span>
exact handoff
</div>
</div>
<p class="controls-hint">
Drag empty space to orbit · Shift-drag to pan · Scroll to zoom ·
Drag a colored task block to retime it.
</p>
</aside>
<div id="loading">Building timeline…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stage = document.querySelector("#stage");
const worldLabels = document.querySelector("#world-labels");
const loading = document.querySelector("#loading");
const TIME_MIN = 0;
const TIME_MAX = 60;
const TIME_X0 = -11.6;
const TIME_X1 = 11.6;
const BASE_CLOCK_MINUTES = 9 * 60;
const COLORS = {
laundry: 0x4d7cf6,
dishes: 0xef8068,
overlap: 0xefb642,
consecutive: 0x45b889,
separated: 0x849397
};
const state = {
laundry: {
id: "laundry",
name: "Fold laundry",
shortName: "Laundry",
duration: 24,
start: 8,
color: COLORS.laundry,
z: 2.15
},
dishes: {
id: "dishes",
name: "Load dishwasher",
shortName: "Dishes",
duration: 16,
start: 24,
color: COLORS.dishes,
z: -2.15
}
};
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe8ece6);
scene.fog = new THREE.Fog(0xe8ece6, 31, 65);
const camera = new THREE.PerspectiveCamera(
40,
innerWidth / innerHeight,
0.1,
120
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
stage.appendChild(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xffffff, 0x718078, 2.1);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff4dc, 3.2);
keyLight.position.set(-7, 16, 11);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -22;
keyLight.shadow.camera.right = 22;
keyLight.shadow.camera.top = 18;
keyLight.shadow.camera.bottom = -18;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 48;
keyLight.shadow.bias = -0.0002;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xbcd9ff, 1.15);
fillLight.position.set(12, 7, -10);
scene.add(fillLight);
const cameraControl = {
target: new THREE.Vector3(-1.4, 0.65, 0),
desiredTarget: new THREE.Vector3(-1.4, 0.65, 0),
theta: 0.43,
desiredTheta: 0.43,
phi: 0.96,
desiredPhi: 0.96,
radius: 23,
desiredRadius: 23
};
function clamp(value, min, max) {
return Math.max(min, Math.min(max, value));
}
function lerp(a, b, amount) {
return a + (b - a) * amount;
}
function timeToX(time) {
return lerp(
TIME_X0,
TIME_X1,
(time - TIME_MIN) / (TIME_MAX - TIME_MIN)
);
}
function xToTime(x) {
return clamp(
TIME_MIN +
((x - TIME_X0) / (TIME_X1 - TIME_X0)) *
(TIME_MAX - TIME_MIN),
TIME_MIN,
TIME_MAX
);
}
function minutesToWorldLength(minutes) {
return timeToX(minutes) - timeToX(0);
}
function formatClock(minutes) {
const total = BASE_CLOCK_MINUTES + Math.round(minutes);
const hours = Math.floor(total / 60);
const mins = total % 60;
return `${String(hours).padStart(2, "0")}:${String(mins).padStart(2, "0")}`;
}
function standardMaterial(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.68,
metalness: 0.02,
...options
});
}
function roundedPrism(width, height, depth, radius, material) {
const shape = new THREE.Shape();
const x = -width / 2;
const y = -depth / 2;
shape.moveTo(x + radius, y);
shape.lineTo(x + width - radius, y);
shape.quadraticCurveTo(x + width, y, x + width, y + radius);
shape.lineTo(x + width, y + depth - radius);
shape.quadraticCurveTo(
x + width,
y + depth,
x + width - radius,
y + depth
);
shape.lineTo(x + radius, y + depth);
shape.quadraticCurveTo(x, y + depth, x, y + depth - radius);
shape.lineTo(x, y + radius);
shape.quadraticCurveTo(x, y, x + radius, y);
const geometry = new THREE.ExtrudeGeometry(shape, {
depth: height,
bevelEnabled: true,
bevelSegments: 2,
steps: 1,
bevelSize: 0.055,
bevelThickness: 0.055,
curveSegments: 8
});
geometry.rotateX(-Math.PI / 2);
geometry.translate(0, -height / 2, 0);
geometry.computeVertexNormals();
return new THREE.Mesh(geometry, material);
}
function addBox(parent, size, position, material, castsShadow = true) {
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 = castsShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(100, 100),
standardMaterial(0xe4e9e2, { roughness: 0.95 })
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.56;
ground.receiveShadow = true;
scene.add(ground);
const board = new THREE.Group();
scene.add(board);
addBox(
board,
[26.2, 0.48, 8.7],
[0, -0.12, 0],
standardMaterial(0xcdd6d1),
false
);
addBox(
board,
[25.3, 0.16, 7.9],
[0, 0.15, 0],
standardMaterial(0xe6e9e3),
false
);
for (const task of Object.values(state)) {
addBox(
board,
[24.8, 0.17, 2.25],
[0, 0.34, task.z],
standardMaterial(0xf3f1e9),
false
);
}
for (let minute = 0; minute <= 60; minute += 5) {
const major = minute % 15 === 0;
addBox(
board,
[
major ? 0.045 : 0.022,
0.018,
major ? 7.55 : 7.25
],
[timeToX(minute), 0.48, 0],
standardMaterial(
major ? 0xa9b7b1 : 0xc1cbc5,
{ transparent: true, opacity: major ? 0.8 : 0.58 }
),
false
);
}
const taskGroups = {};
function makeLaundryIcon(group) {
const cream = standardMaterial(0xf6f0df);
const blue = standardMaterial(0x4d7cf6);
const paleBlue = standardMaterial(0x91adff);
const coral = standardMaterial(0xef8068);
const basket = roundedPrism(1.48, 0.56, 1.0, 0.13, cream);
basket.position.y = 1.73;
group.add(basket);
const rim = roundedPrism(1.68, 0.13, 1.17, 0.08, blue);
rim.position.y = 2.04;
group.add(rim);
const cloth1 = roundedPrism(0.68, 0.18, 0.72, 0.08, paleBlue);
cloth1.position.set(-0.32, 2.17, 0);
group.add(cloth1);
const cloth2 = roundedPrism(0.58, 0.17, 0.64, 0.08, coral);
cloth2.position.set(0.28, 2.18, 0.02);
group.add(cloth2);
}
function makeDishesIcon(group) {
const plate = standardMaterial(0xf5eee0);
const rim = standardMaterial(0xef8068);
const dark = standardMaterial(0x344b59);
for (let i = 0; i < 3; i++) {
const cylinder = new THREE.Mesh(
new THREE.CylinderGeometry(0.57 - i * 0.035, 0.55 - i * 0.035, 0.13, 32),
i === 2 ? rim : plate
);
cylinder.position.y = 1.55 + i * 0.16;
cylinder.castShadow = true;
cylinder.receiveShadow = true;
group.add(cylinder);
}
const cup = new THREE.Mesh(
new THREE.CylinderGeometry(0.25, 0.22, 0.48, 24),
dark
);
cup.position.set(0.65, 1.82, 0.05);
cup.castShadow = true;
group.add(cup);
}
for (const task of Object.values(state)) {
const group = new THREE.Group();
group.position.z = task.z;
group.userData.taskId = task.id;
const width = minutesToWorldLength(task.duration);
const base = roundedPrism(
width,
0.82,
1.5,
0.17,
standardMaterial(task.color, { roughness: 0.55 })
);
base.position.y = 0.98;
base.castShadow = true;
base.receiveShadow = true;
group.add(base);
const topStrip = roundedPrism(
width - 0.36,
0.055,
0.16,
0.045,
standardMaterial(task.color, {
roughness: 0.42,
emissive: task.color,
emissiveIntensity: 0.08
})
);
topStrip.position.set(0, 1.405, 0.54);
group.add(topStrip);
if (task.id === "laundry") {
makeLaundryIcon(group);
} else {
makeDishesIcon(group);
}
board.add(group);
taskGroups[task.id] = group;
task.group = group;
task.base = base;
}
const overlapRibbon = new THREE.Mesh(
new THREE.BoxGeometry(1, 0.11, 5.2),
new THREE.MeshStandardMaterial({
color: COLORS.overlap,
transparent: true,
opacity: 0.72,
roughness: 0.55,
depthWrite: false
})
);
overlapRibbon.position.y = 0.66;
overlapRibbon.renderOrder = 2;
board.add(overlapRibbon);
const overlapCapA = new THREE.Mesh(
new THREE.BoxGeometry(0.07, 0.07, 5.25),
standardMaterial(0xf5c85e)
);
const overlapCapB = overlapCapA.clone();
overlapCapA.position.y = 1.47;
overlapCapB.position.y = 1.47;
board.add(overlapCapA, overlapCapB);
const handoffMarker = new THREE.Mesh(
new THREE.BoxGeometry(0.085, 0.11, 5.25),
standardMaterial(COLORS.consecutive)
);
handoffMarker.position.y = 0.68;
board.add(handoffMarker);
const gapMarker = new THREE.Mesh(
new THREE.BoxGeometry(1, 0.08, 2.1),
new THREE.MeshStandardMaterial({
color: COLORS.separated,
transparent: true,
opacity: 0.55,
roughness: 0.7
})
);
gapMarker.position.y = 0.59;
board.add(gapMarker);
function createWorldLabel(className, html = "") {
const element = document.createElement("div");
element.className = `world-label ${className}`;
element.innerHTML = html;
worldLabels.appendChild(element);
return element;
}
for (const task of Object.values(state)) {
task.label = createWorldLabel(
"task-label",
`
<strong>${task.name}</strong>
<span></span>
`
);
task.label.style.setProperty(
"--task-color",
`#${task.color.toString(16).padStart(6, "0")}`
);
}
const axisLabels = [];
for (let minute = 0; minute <= 60; minute += 15) {
axisLabels.push({
minute,
element: createWorldLabel("axis-label", formatClock(minute))
});
}
const laundryLaneLabel = createWorldLabel("lane-label", "Laundry");
const dishesLaneLabel = createWorldLabel("lane-label", "Dishes");
const relationWorldLabel = createWorldLabel("relation-label");
function analyzeRelation() {
const a = state.laundry;
const b = state.dishes;
const aEnd = a.start + a.duration;
const bEnd = b.start + b.duration;
const overlapStart = Math.max(a.start, b.start);
const overlapEnd = Math.min(aEnd, bEnd);
const overlap = Math.max(0, overlapEnd - overlapStart);
let kind = "separated";
let earlier = null;
let later = null;
let gap = 0;
let boundary = null;
if (overlap > 0) {
kind = "simultaneous";
} else if (aEnd === b.start || bEnd === a.start) {
kind = "consecutive";
earlier = aEnd === b.start ? a : b;
later = aEnd === b.start ? b : a;
boundary = earlier.start + earlier.duration;
} else {
if (aEnd < b.start) {
earlier = a;
later = b;
gap = b.start - aEnd;
} else {
earlier = b;
later = a;
gap = a.start - bEnd;
}
}
return {
kind,
overlap,
overlapStart,
overlapEnd,
earlier,
later,
gap,
boundary,
aEnd,
bEnd
};
}
function updateWorldLabelContent() {
for (const task of Object.values(state)) {
task.label.querySelector("span").textContent =
`${formatClock(task.start)} — ${formatClock(task.start + task.duration)}`;
}
}
function updateScene() {
for (const task of Object.values(state)) {
task.group.position.x = timeToX(task.start + task.duration / 2);
}
const relation = analyzeRelation();
overlapRibbon.visible = relation.kind === "simultaneous";
overlapCapA.visible = relation.kind === "simultaneous";
overlapCapB.visible = relation.kind === "simultaneous";
handoffMarker.visible = relation.kind === "consecutive";
gapMarker.visible = relation.kind === "separated";
if (relation.kind === "simultaneous") {
const width =
timeToX(relation.overlapEnd) - timeToX(relation.overlapStart);
const center = timeToX((relation.overlapStart + relation.overlapEnd) / 2);
overlapRibbon.position.x = center;
overlapRibbon.scale.x = Math.max(0.01, width);
overlapCapA.position.x = timeToX(relation.overlapStart);
overlapCapB.position.x = timeToX(relation.overlapEnd);
relationWorldLabel.className = "world-label relation-label";
relationWorldLabel.textContent =
`${relation.overlap} min simultaneous`;
} else if (relation.kind === "consecutive") {
handoffMarker.position.x = timeToX(relation.boundary);
relationWorldLabel.className = "world-label relation-label consecutive";
relationWorldLabel.textContent = "Consecutive · no shared min";
} else {
const earlierEnd =
relation.earlier.id === "laundry" ? relation.aEnd : relation.bEnd;
const laterStart =
relation.later.id === "laundry" ? state.laundry.start : state.dishes.start;
const width = timeToX(laterStart) - timeToX(earlierEnd);
gapMarker.position.x = timeToX((earlierEnd + laterStart) / 2);
gapMarker.scale.x = Math.max(0.01, width);
relationWorldLabel.className = "world-label relation-label separated";
relationWorldLabel.textContent = `${relation.gap} min gap`;
}
updateWorldLabelContent();
}
function orderDescription(first, second, firstStart, secondStart) {
if (firstStart === secondStart) {
return {
title: "Both tasks start together",
detail: `At ${formatClock(firstStart)}`
};
}
return {
title: `${first.shortName} starts first`,
detail: `${secondStart - firstStart} min before ${second.shortName.toLowerCase()}`
};
}
function updateUI() {
const relation = analyzeRelation();
const a = state.laundry;
const b = state.dishes;
const laundrySlider = document.querySelector("#laundry-start");
const dishesSlider = document.querySelector("#dishes-start");
laundrySlider.value = a.start;
dishesSlider.value = b.start;
laundrySlider.setAttribute(
"aria-valuetext",
`${formatClock(a.start)}, ${a.duration} minute duration`
);
dishesSlider.setAttribute(
"aria-valuetext",
`${formatClock(b.start)}, ${b.duration} minute duration`
);
document.querySelector("#laundry-output").textContent = formatClock(a.start);
document.querySelector("#dishes-output").textContent = formatClock(b.start);
const card = document.querySelector("#relation-card");
const statusPill = document.querySelector("#status-pill");
const title = document.querySelector("#relation-title");
const description = document.querySelector("#relation-description");
const windowLabel = document.querySelector("#window-label");
const sharedWindow = document.querySelector("#shared-window");
const amountLabel = document.querySelector("#amount-label");
const sharedAmount = document.querySelector("#shared-amount");
const orderList = document.querySelector("#order-list");
card.className = `relation-card ${relation.kind}`;
if (relation.kind === "simultaneous") {
statusPill.textContent = "Simultaneous";
title.textContent = "Tasks run at the same time";
description.textContent =
`Both tasks are active during the amber interval. Their event bars physically overlap.`;
windowLabel.textContent = "Shared window";
sharedWindow.textContent =
`${formatClock(relation.overlapStart)} — ${formatClock(relation.overlapEnd)}`;
amountLabel.textContent = "Overlap";
sharedAmount.textContent = `${relation.overlap} shared min`;
} else if (relation.kind === "consecutive") {
statusPill.textContent = "Consecutive";
title.textContent = "Tasks only happen consecutively";
description.textContent =
`${relation.earlier.name} ends exactly when ${relation.later.name} begins. The green line marks a handoff, not a shared interval.`;
windowLabel.textContent = "Shared window";
sharedWindow.textContent = "No shared minutes";
amountLabel.textContent = "Overlap";
sharedAmount.textContent = "0 shared min";
} else {
statusPill.textContent = "Separated";
title.textContent = "Tasks are separated by a gap";
description.textContent =
`${relation.earlier.name} finishes before ${relation.later.name} starts, leaving ${relation.gap} inactive minutes between them.`;
windowLabel.textContent = "Inactive gap";
sharedWindow.textContent = `${relation.gap} min gap`;
amountLabel.textContent = "Overlap";
sharedAmount.textContent = "0 shared min";
}
const startOrder = orderDescription(a, b, a.start, b.start);
const endOrder = orderDescription(a, b, a.start + a.duration, b.start + b.duration);
orderList.innerHTML = `
<li>
<span class="order-number">1</span>
<span><b>${startOrder.title}</b><br>${startOrder.detail}</span>
</li>
<li>
<span class="order-number">2</span>
<span><b>${endOrder.title}</b><br>${endOrder.detail}</span>
</li>
`;
const presetValues = {
overlap: { laundry: 8, dishes: 24 },
consecutive: { laundry: 8, dishes: 32 },
"dishes-first": { laundry: 24, dishes: 12 }
};
document.querySelectorAll("[data-preset]").forEach((button) => {
const preset = presetValues[button.dataset.preset];
const active = preset.laundry === a.start && preset.dishes === b.start;
button.classList.toggle("active", active);
button.setAttribute("aria-pressed", String(active));
});
}
function setStart(id, value) {
const task = state[id];
task.start = clamp(Math.round(value), 0, TIME_MAX - task.duration);
updateScene();
updateUI();
}
document.querySelector("#laundry-start").addEventListener("input", (event) => {
setStart("laundry", Number(event.target.value));
});
document.querySelector("#dishes-start").addEventListener("input", (event) => {
setStart("dishes", Number(event.target.value));
});
document.querySelectorAll("[data-preset]").forEach((button) => {
button.addEventListener("click", () => {
const values = {
overlap: { laundry: 8, dishes: 24 },
consecutive: { laundry: 8, dishes: 32 },
"dishes-first": { laundry: 24, dishes: 12 }
}[button.dataset.preset];
state.laundry.start = values.laundry;
state.dishes.start = values.dishes;
updateScene();
updateUI();
});
});
document.querySelector("#reset-view").addEventListener("click", () => {
cameraControl.desiredTheta = 0.43;
cameraControl.desiredPhi = 0.96;
cameraControl.desiredRadius = 23;
cameraControl.desiredTarget.set(-1.4, 0.65, 0);
});
function updateCamera() {
cameraControl.theta = lerp(
cameraControl.theta,
cameraControl.desiredTheta,
0.1
);
cameraControl.phi = lerp(
cameraControl.phi,
cameraControl.desiredPhi,
0.1
);
cameraControl.radius = lerp(
cameraControl.radius,
cameraControl.desiredRadius,
0.1
);
cameraControl.target.lerp(
cameraControl.desiredTarget,
0.1
);
const { radius, theta, phi, target } = cameraControl;
const sinPhi = Math.sin(phi);
camera.position.set(
target.x + radius * sinPhi * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + radius * sinPhi * Math.cos(theta)
);
camera.lookAt(target);
camera.updateMatrixWorld();
}
function placeLabel(element, worldPosition, align = "center") {
const projected = worldPosition.clone().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) * innerWidth;
const y = (-projected.y * 0.5 + 0.5) * innerHeight;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
if (align === "left") {
element.style.transform = "translate(-100%, -50%)";
} else if (align === "center-y") {
element.style.transform = "translate(-50%, -50%)";
} else {
element.style.transform = "translate(-50%, -100%)";
}
}
function updateWorldLabels() {
for (const task of Object.values(state)) {
placeLabel(
task.label,
new THREE.Vector3(
task.group.position.x,
2.62,
task.z
)
);
}
for (const item of axisLabels) {
placeLabel(
item.element,
new THREE.Vector3(timeToX(item.minute), 0.18, 4.48),
"center-y"
);
}
placeLabel(
laundryLaneLabel,
new THREE.Vector3(-12.7, 0.65, state.laundry.z),
"left"
);
placeLabel(
dishesLaneLabel,
new THREE.Vector3(-12.7, 0.65, state.dishes.z),
"left"
);
const relation = analyzeRelation();
if (relation.kind === "simultaneous") {
placeLabel(
relationWorldLabel,
new THREE.Vector3(
timeToX((relation.overlapStart + relation.overlapEnd) / 2),
0.98,
0
),
"center-y"
);
} else if (relation.kind === "consecutive") {
placeLabel(
relationWorldLabel,
new THREE.Vector3(timeToX(relation.boundary), 0.95, 0),
"center-y"
);
} else {
const earlierEnd =
relation.earlier.id === "laundry"
? relation.aEnd
: relation.bEnd;
const laterStart =
relation.later.id === "laundry"
? state.laundry.start
: state.dishes.start;
placeLabel(
relationWorldLabel,
new THREE.Vector3(
timeToX((earlierEnd + laterStart) / 2),
0.82,
0
),
"center-y"
);
}
}
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const dragPlane = new THREE.Plane(new THREE.Vector3(0, 1, 0), -0.98);
const planeHit = new THREE.Vector3();
let pointerControl = null;
let draggedTask = null;
let hoveredTask = null;
function setPointer(event) {
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;
}
function pickTask(event) {
setPointer(event);
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(Object.values(taskGroups), true);
for (const hit of hits) {
let object = hit.object;
while (object && !object.userData.taskId) {
object = object.parent;
}
if (object) {
return { object, hit };
}
}
return null;
}
function updateHover(event) {
if (draggedTask) return;
const picked = pickTask(event);
const id = picked ? picked.object.userData.taskId : null;
if (hoveredTask !== id) {
if (hoveredTask) {
state[hoveredTask].base.material.emissiveIntensity = 0;
}
hoveredTask = id;
if (hoveredTask) {
state[hoveredTask].base.material.emissive.setHex(state[hoveredTask].color);
state[hoveredTask].base.material.emissiveIntensity = 0.12;
}
}
renderer.domElement.style.cursor = hoveredTask ? "grab" : "default";
}
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
setPointer(event);
if (event.button === 0) {
const picked = pickTask(event);
if (picked) {
const task = state[picked.object.userData.taskId];
raycaster.ray.intersectPlane(dragPlane, planeHit);
draggedTask = {
id: task.id,
offset: task.group.position.x - planeHit.x
};
renderer.domElement.style.cursor = "grabbing";
return;
}
}
pointerControl = {
mode:
event.button === 2 || event.shiftKey ? "pan" : "orbit",
x: event.clientX,
y: event.clientY
};
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (draggedTask) {
setPointer(event);
raycaster.setFromCamera(pointer, camera);
if (raycaster.ray.intersectPlane(dragPlane, planeHit)) {
const task = state[draggedTask.id];
const centerTime = xToTime(planeHit.x + draggedTask.offset);
setStart(task.id, centerTime - task.duration / 2);
}
return;
}
if (!pointerControl) {
updateHover(event);
return;
}
const dx = event.clientX - pointerControl.x;
const dy = event.clientY - pointerControl.y;
pointerControl.x = event.clientX;
pointerControl.y = event.clientY;
if (pointerControl.mode === "orbit") {
cameraControl.desiredTheta -= dx * 0.006;
cameraControl.desiredPhi = clamp(
cameraControl.desiredPhi - dy * 0.005,
0.45,
1.35
);
} else {
cameraControl.desiredTarget.x -= dx * 0.014;
cameraControl.desiredTarget.z += dy * 0.012;
cameraControl.desiredTarget.x = clamp(
cameraControl.desiredTarget.x,
-10,
10
);
cameraControl.desiredTarget.z = clamp(
cameraControl.desiredTarget.z,
-7,
7
);
}
});
function endPointer(event) {
if (draggedTask) {
state[draggedTask.id].base.material.emissiveIntensity = 0;
draggedTask = null;
}
pointerControl = null;
renderer.domElement.style.cursor = hoveredTask ? "grab" : "default";
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraControl.desiredRadius = clamp(
cameraControl.desiredRadius * Math.exp(event.deltaY * 0.001),
15,
38
);
},
{ passive: false }
);
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
window.addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
});
updateScene();
updateUI();
updateCamera();
function animate() {
requestAnimationFrame(animate);
updateCamera();
renderer.render(scene, camera);
updateWorldLabels();
}
animate();
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 350);
</script>
</body>
</html>
```