Prompt specification
Build or customize the Three.js 3D scene "Kitchen Action Sequence Without Dialogue" 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: Kitchen Action Sequence Without Dialogue
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/kitchen-action-sequence-without-dialogue-x3435
Scene Description Prompt:
Build a small kitchen scene showing placing, pouring, and covering with consistent objects. Display each action's before and after states while avoiding impossible liquid disappearance. Use Three.js from cdnjs in a single HTML file, with visible voxel blocks.
Working Three.js Starter (kitchen-action-sequence-without-dialogue-x3435):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voxel Kitchen — Before & After Actions</title>
<style>
:root {
color-scheme: dark;
--bg: #101714;
--panel: #17211d;
--panel-2: #1d2a24;
--line: rgba(229, 239, 225, 0.12);
--text: #edf3e8;
--muted: #9eafa4;
--green: #8fd09a;
--orange: #f1a166;
--amber: #ffc15a;
--blue: #75b7d8;
}
* {
box-sizing: border-box;
}
[hidden] {
display: none !important;
}
html,
body {
margin: 0;
min-height: 100%;
background:
radial-gradient(circle at 70% 0%, #25352c 0, transparent 35rem),
var(--bg);
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
.app {
width: min(1600px, 100%);
margin: 0 auto;
padding: 24px;
}
header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
margin-bottom: 20px;
}
.brand {
display: flex;
align-items: center;
gap: 14px;
}
.brand-mark {
display: grid;
grid-template-columns: repeat(2, 9px);
grid-template-rows: repeat(2, 9px);
gap: 3px;
transform: rotate(-7deg);
}
.brand-mark i {
display: block;
background: var(--green);
border-radius: 1px;
}
.brand-mark i:nth-child(2) {
background: var(--orange);
}
.brand-mark i:nth-child(3) {
background: var(--amber);
}
.brand h1 {
margin: 0;
font-size: clamp(18px, 2vw, 25px);
letter-spacing: -0.035em;
}
.brand p {
margin: 3px 0 0;
color: var(--muted);
font-size: 12px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.header-badge {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 9px 12px;
border: 1px solid var(--line);
border-radius: 999px;
color: #c5d4c8;
background: rgba(255, 255, 255, 0.025);
font-size: 12px;
white-space: nowrap;
}
.header-badge::before {
content: "";
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--green);
box-shadow: 0 0 12px rgba(143, 208, 154, 0.8);
}
.workspace {
display: grid;
grid-template-columns: 250px minmax(440px, 1fr) 300px;
gap: 16px;
align-items: stretch;
}
.panel {
border: 1px solid var(--line);
border-radius: 18px;
background: rgba(23, 33, 29, 0.9);
box-shadow: 0 18px 45px rgba(0, 0, 0, 0.2);
overflow: hidden;
}
.panel-heading {
padding: 16px 17px 13px;
border-bottom: 1px solid var(--line);
}
.eyebrow {
color: var(--muted);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.actions {
padding: 10px;
display: grid;
gap: 8px;
}
.action-card {
width: 100%;
padding: 13px;
display: grid;
grid-template-columns: 35px 1fr;
gap: 10px;
text-align: left;
border: 1px solid transparent;
border-radius: 13px;
background: transparent;
cursor: pointer;
transition: 160ms ease;
}
.action-card:hover {
background: rgba(255, 255, 255, 0.035);
}
.action-card.active {
border-color: rgba(143, 208, 154, 0.35);
background: rgba(143, 208, 154, 0.08);
}
.action-index {
width: 34px;
height: 34px;
display: grid;
place-items: center;
border-radius: 9px;
color: #17211d;
background: var(--green);
font-size: 12px;
font-weight: 800;
}
.action-card:nth-child(2) .action-index {
background: var(--orange);
}
.action-card:nth-child(3) .action-index {
background: var(--amber);
}
.action-name {
display: block;
margin: 1px 0 5px;
font-size: 14px;
font-weight: 750;
}
.action-flow {
display: flex;
align-items: center;
gap: 6px;
color: var(--muted);
font-size: 10px;
}
.action-flow b {
color: #dce7dc;
font-weight: 650;
}
.nav-note {
margin: 8px 17px 17px;
padding-top: 14px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 11px;
line-height: 1.55;
}
.nav-note strong {
color: var(--text);
}
.stage-panel {
min-width: 0;
}
.stage-toolbar {
min-height: 60px;
padding: 10px 13px 10px 17px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 14px;
border-bottom: 1px solid var(--line);
}
.stage-title strong {
display: block;
font-size: 13px;
}
.stage-title span {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 10px;
}
.mode-switch {
display: flex;
padding: 3px;
gap: 2px;
border: 1px solid var(--line);
border-radius: 10px;
background: #101915;
}
.mode-switch button {
padding: 6px 9px;
border: 0;
border-radius: 7px;
background: transparent;
color: var(--muted);
cursor: pointer;
font-size: 10px;
font-weight: 750;
}
.mode-switch button.active {
color: #142019;
background: var(--green);
}
#stage {
position: relative;
height: 650px;
overflow: hidden;
background: #c8d3ca;
isolation: isolate;
}
#scene {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
cursor: grab;
}
#scene:active {
cursor: grabbing;
}
.view-label {
position: absolute;
z-index: 2;
top: 16px;
display: flex;
align-items: center;
gap: 8px;
padding: 7px 10px;
border: 1px solid rgba(255, 255, 255, 0.28);
border-radius: 999px;
color: #17211d;
background: rgba(249, 250, 243, 0.9);
box-shadow: 0 6px 18px rgba(22, 30, 26, 0.14);
pointer-events: none;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.view-label::before {
content: "";
width: 7px;
height: 7px;
border-radius: 2px;
background: var(--green);
}
.view-label.after {
left: calc(50% + 16px);
}
.view-label.after::before {
background: var(--orange);
}
.view-label::after {
content: attr(data-note);
color: #66756c;
font-weight: 600;
letter-spacing: 0;
text-transform: none;
}
body[data-mode="before"] .view-label.after,
body[data-mode="after"] .view-label.before {
display: none;
}
body[data-mode="before"] .view-label.before,
body[data-mode="after"] .view-label.after {
left: 16px;
}
.divider {
position: absolute;
z-index: 1;
top: 0;
bottom: 0;
left: 50%;
width: 2px;
background: rgba(30, 45, 37, 0.22);
pointer-events: none;
}
body:not([data-mode="compare"]) .divider {
display: none;
}
.scene-chip {
position: absolute;
z-index: 2;
left: 50%;
bottom: 15px;
transform: translateX(-50%);
padding: 7px 11px;
border-radius: 999px;
color: #eaf2e8;
background: rgba(18, 30, 24, 0.76);
backdrop-filter: blur(8px);
pointer-events: none;
font-size: 10px;
letter-spacing: 0.03em;
white-space: nowrap;
}
.stage-footer {
min-height: 44px;
padding: 9px 13px 9px 17px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
color: var(--muted);
font-size: 10px;
}
.stage-footer kbd {
padding: 2px 5px;
border: 1px solid var(--line);
border-radius: 4px;
color: #d9e6da;
background: rgba(255, 255, 255, 0.04);
font: inherit;
}
.reset-view {
border: 0;
color: var(--green);
background: transparent;
cursor: pointer;
font-size: 10px;
font-weight: 750;
}
.inspector {
padding-bottom: 14px;
}
.inspector-body {
padding: 17px;
}
.inspector h2 {
margin: 7px 0 8px;
font-size: 22px;
letter-spacing: -0.04em;
}
.description {
min-height: 52px;
margin: 0 0 17px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.section-label {
margin: 16px 0 8px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.ledger {
border-top: 1px solid var(--line);
}
.ledger-row {
display: grid;
grid-template-columns: 1fr 67px 67px;
gap: 7px;
align-items: center;
padding: 9px 0;
border-bottom: 1px solid var(--line);
font-size: 10px;
}
.ledger-head {
color: var(--muted);
font-size: 8px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.ledger-value {
text-align: right;
color: #dce7dc;
font-weight: 700;
}
.ledger-value.after {
color: var(--orange);
}
.conservation-card {
padding: 13px;
border: 1px solid rgba(143, 208, 154, 0.22);
border-radius: 13px;
background: rgba(143, 208, 154, 0.055);
}
.conservation-card.orange {
border-color: rgba(241, 161, 102, 0.25);
background: rgba(241, 161, 102, 0.055);
}
.conservation-title {
display: flex;
align-items: center;
gap: 7px;
color: var(--green);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.conservation-card.orange .conservation-title {
color: var(--orange);
}
.equation {
margin: 11px 0 8px;
color: #f2f6ef;
font-size: 17px;
font-weight: 800;
letter-spacing: 0.02em;
}
.equation .amber {
color: var(--amber);
}
.proof {
margin: 0;
color: var(--muted);
font-size: 10px;
line-height: 1.5;
}
.toggle-row {
margin-top: 14px;
padding: 11px 12px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
border: 1px solid var(--line);
border-radius: 11px;
background: rgba(255, 255, 255, 0.025);
cursor: pointer;
}
.toggle-copy strong {
display: block;
font-size: 11px;
}
.toggle-copy span {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 9px;
}
.toggle-row input {
width: 34px;
height: 18px;
appearance: none;
border-radius: 999px;
background: #46534b;
cursor: pointer;
transition: 150ms ease;
}
.toggle-row input::before {
content: "";
display: block;
width: 14px;
height: 14px;
margin: 2px;
border-radius: 50%;
background: white;
transition: 150ms ease;
}
.toggle-row input:checked {
background: var(--green);
}
.toggle-row input:checked::before {
transform: translateX(16px);
}
.identity {
margin-top: 14px;
padding: 12px;
display: flex;
align-items: center;
gap: 10px;
border: 1px solid var(--line);
border-radius: 11px;
}
.identity-swatch {
width: 27px;
height: 27px;
border-radius: 7px;
background: var(--blue);
box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.22);
}
.identity-swatch.orange {
background: var(--orange);
}
.identity strong {
display: block;
font-size: 10px;
}
.identity span {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 9px;
}
#loading {
position: absolute;
z-index: 5;
inset: 0;
display: grid;
place-items: center;
color: #26382e;
background: #c8d3ca;
font-size: 12px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
@media (max-width: 1180px) {
.workspace {
grid-template-columns: 220px minmax(440px, 1fr);
}
.inspector {
grid-column: 1 / -1;
}
.inspector-body {
display: grid;
grid-template-columns: 1fr 1.2fr;
gap: 0 24px;
}
.inspector-body > .section-label:first-child,
.inspector-body > h2,
.inspector-body > .description {
grid-column: 1;
}
.ledger,
.conservation-card,
.toggle-row,
.identity {
grid-column: 2;
}
.ledger {
grid-row: 1 / span 4;
}
}
@media (max-width: 760px) {
.app {
padding: 12px;
}
header {
align-items: flex-start;
}
.header-badge {
display: none;
}
.workspace {
grid-template-columns: 1fr;
}
.actions {
grid-template-columns: repeat(3, 1fr);
}
.action-card {
grid-template-columns: 1fr;
padding: 10px;
}
.action-flow {
display: none;
}
.nav-note {
display: none;
}
#stage {
height: 540px;
}
.inspector-body {
display: block;
}
}
@media (max-width: 480px) {
.view-label::after {
display: none;
}
.stage-toolbar {
align-items: flex-start;
flex-direction: column;
}
.mode-switch {
width: 100%;
}
.mode-switch button {
flex: 1;
}
}
</style>
</head>
<body data-mode="compare">
<div class="app">
<header>
<div class="brand">
<div class="brand-mark" aria-hidden="true">
<i></i><i></i><i></i><i></i>
</div>
<div>
<h1>Voxel Kitchen</h1>
<p>Action continuity study</p>
</div>
</div>
<div class="header-badge">Consistent assets · conserved contents</div>
</header>
<main class="workspace">
<nav class="panel" aria-label="Kitchen actions">
<div class="panel-heading eyebrow">Choose an action</div>
<div class="actions">
<button class="action-card active" data-action="place" type="button">
<span class="action-index">01</span>
<span>
<span class="action-name">Place</span>
<span class="action-flow"><b>Hover</b><span>→</span><b>Counter</b></span>
</span>
</button>
<button class="action-card" data-action="pour" type="button">
<span class="action-index">02</span>
<span>
<span class="action-name">Pour</span>
<span class="action-flow"><b>7 units</b><span>→</span><b>7 units</b></span>
</span>
</button>
<button class="action-card" data-action="cover" type="button">
<span class="action-index">03</span>
<span>
<span class="action-name">Cover</span>
<span class="action-flow"><b>Open</b><span>→</span><b>Sealed</b></span>
</span>
</button>
</div>
<p class="nav-note">
<strong>One scene, two states.</strong>
Drag to orbit, scroll to zoom, and use the numbered shortcuts to switch actions.
</p>
</nav>
<section class="panel stage-panel" aria-label="Before and after scene">
<div class="stage-toolbar">
<div class="stage-title">
<strong id="stageActionTitle">01 · Place the pitcher</strong>
<span id="stageActionSubtitle">Same object, before and after</span>
</div>
<div class="mode-switch" aria-label="View mode">
<button class="active" data-mode="compare" type="button">Split</button>
<button data-mode="before" type="button">Before</button>
<button data-mode="after" type="button">After</button>
</div>
</div>
<div id="stage">
<canvas id="scene" tabindex="0" aria-label="Interactive voxel kitchen"></canvas>
<div class="view-label before" data-note="hovering">Before</div>
<div class="view-label after" data-note="resting">After</div>
<div class="divider"></div>
<div class="scene-chip" id="sceneChip">Drag to orbit · scroll to zoom</div>
<div id="loading">Building voxel kitchen…</div>
</div>
<div class="stage-footer">
<span><kbd>1</kbd> <kbd>2</kbd> <kbd>3</kbd> actions · <kbd>C</kbd> compare</span>
<button class="reset-view" id="resetView" type="button">Reset view</button>
</div>
</section>
<aside class="panel inspector" aria-label="State inspector">
<div class="panel-heading eyebrow">State inspector</div>
<div class="inspector-body">
<div class="eyebrow" id="inspectorKicker">Action 01</div>
<h2 id="inspectorTitle">Place the pitcher</h2>
<p class="description" id="inspectorDescription"></p>
<div class="section-label">Object ledger</div>
<div class="ledger" id="ledger"></div>
<div class="section-label">Conservation proof</div>
<div class="conservation-card" id="conservationCard">
<div class="conservation-title">
<span>✓</span>
<span id="conservationLabel">Contents preserved</span>
</div>
<div class="equation" id="equation"></div>
<p class="proof" id="proof"></p>
</div>
<label class="toggle-row" id="xrayRow" hidden>
<span class="toggle-copy">
<strong>Inspection cutaway</strong>
<span>Reveal the retained contents under the lid.</span>
</span>
<input id="xray" type="checkbox" checked />
</label>
<div class="identity">
<span class="identity-swatch" id="identitySwatch"></span>
<span>
<strong id="identityTitle">Cobalt pitcher</strong>
<span id="identityText">The exact same asset appears in both states.</span>
</span>
</div>
</div>
</aside>
</main>
</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 canvas = document.querySelector("#scene");
const loading = document.querySelector("#loading");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xc8d3ca);
scene.fog = new THREE.Fog(0xc8d3ca, 12, 22);
const camera = new THREE.OrthographicCamera(-4, 4, 3, -3, 0.1, 50);
const orbit = {
theta: 0.48,
phi: 1.08,
radius: 11,
target: new THREE.Vector3(0, 1.28, 0)
};
const defaultOrbit = { ...orbit, target: orbit.target.clone() };
const SURFACE = 1.03;
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.76,
metalness: 0,
...options
});
const mats = {
wall: material(0xd7d4c3),
wallSide: material(0xc3c7b7),
floor: material(0x65786b),
counter: material(0xe6dcc3),
cabinet: material(0x315c50),
cabinetLight: material(0x477363),
cabinetDark: material(0x24483f),
wood: material(0xc79258),
woodDark: material(0x98693f),
brass: material(0xd7ae55, { metalness: 0.55, roughness: 0.38 }),
dark: material(0x26332e),
black: material(0x17211d),
blue: material(0x4e9fc4),
blueLight: material(0x74bdd9),
blueDark: material(0x327b9f),
coral: material(0xdb7958),
cream: material(0xf0dfb6),
amber: material(0xffb832, {
roughness: 0.38,
emissive: 0x7a3900,
emissiveIntensity: 0.28
}),
green: material(0x6c9f64),
greenLight: material(0x91b978),
terracotta: material(0xae5f45),
glass: material(0x83b8bd, {
roughness: 0.2,
transparent: true,
opacity: 0.72
})
};
const edgeMaterial = new THREE.LineBasicMaterial({
color: 0x18231e,
transparent: true,
opacity: 0.56
});
const geometryCache = new Map();
function getGeometry(w, h, d) {
const key = `${w}/${h}/${d}`;
if (!geometryCache.has(key)) {
geometryCache.set(key, new THREE.BoxGeometry(w, h, d));
}
return geometryCache.get(key);
}
function addBlock(parent, size, position, mat, outlined = true) {
const geometry = getGeometry(...size);
const mesh = new THREE.Mesh(geometry, mat);
mesh.position.set(...position);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
if (outlined) {
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(geometry, 20),
edgeMaterial
);
mesh.add(edges);
}
return mesh;
}
function addCubeRow(parent, count, spacing, position, mat, size = 0.14) {
for (let i = 0; i < count; i++) {
addBlock(
parent,
[size, size, size],
[position[0] + (i - (count - 1) / 2) * spacing, position[1], position[2]],
mat
);
}
}
// Lighting
scene.add(new THREE.HemisphereLight(0xfff5dc, 0x3d5a4d, 2.2));
const keyLight = new THREE.DirectionalLight(0xfff5e4, 3.1);
keyLight.position.set(-3.5, 7, 5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -6;
keyLight.shadow.camera.right = 6;
keyLight.shadow.camera.top = 6;
keyLight.shadow.camera.bottom = -6;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 18;
keyLight.shadow.bias = -0.00035;
scene.add(keyLight);
const warmLight = new THREE.PointLight(0xffc268, 18, 8, 2);
warmLight.position.set(-1.5, 3.1, -0.7);
scene.add(warmLight);
// Static kitchen
const kitchen = new THREE.Group();
scene.add(kitchen);
addBlock(kitchen, [10, 0.2, 8], [0, -1.2, 0.3], mats.floor);
addBlock(kitchen, [8.4, 5.5, 0.22], [0, 1.42, -1.58], mats.wall);
addBlock(kitchen, [0.18, 5.5, 3.8], [-4.15, 1.42, 0.35], mats.wallSide);
// Counter carcass and top
addBlock(kitchen, [6.6, 1.8, 2.45], [0, -0.03, -0.05], mats.cabinetDark);
addBlock(kitchen, [6.82, 0.16, 2.72], [0, 0.94, -0.05], mats.counter);
for (const x of [-2.18, 0, 2.18]) {
addBlock(kitchen, [2.02, 1.45, 0.07], [x, -0.02, 1.205], mats.cabinet);
addBlock(kitchen, [1.85, 0.07, 0.05], [x, 0.64, 1.255], mats.cabinetLight);
addBlock(kitchen, [0.25, 0.08, 0.1], [x, 0.29, 1.28], mats.brass);
}
// Backsplash tiles
const tileMats = [
material(0xe6dfca),
material(0xd9d7c1),
material(0xefe5cf),
material(0xcfd5c3)
];
for (let row = 0; row < 4; row++) {
for (let col = 0; col < 14; col++) {
const tileMat = tileMats[(row + col * 3) % tileMats.length];
addBlock(
kitchen,
[0.45, 0.35, 0.045],
[-2.925 + col * 0.45, 1.22 + row * 0.37, -1.435],
tileMat
);
}
}
// Window
addBlock(kitchen, [1.82, 1.48, 0.07], [1.35, 2.46, -1.42], mats.glass, false);
addBlock(kitchen, [1.98, 0.10, 0.12], [1.35, 3.24, -1.36], mats.woodDark);
addBlock(kitchen, [1.98, 0.10, 0.12], [1.35, 1.68, -1.36], mats.woodDark);
addBlock(kitchen, [0.10, 1.62, 0.12], [0.40, 2.46, -1.36], mats.woodDark);
addBlock(kitchen, [0.10, 1.62, 0.12], [2.30, 2.46, -1.36], mats.woodDark);
addBlock(kitchen, [0.07, 1.48, 0.10], [1.35, 2.46, -1.34], mats.woodDark);
// Shelf and jars
addBlock(kitchen, [2.15, 0.12, 0.52], [-1.65, 2.75, -1.14], mats.wood);
for (const x of [-2.4, -1.9]) {
addBlock(kitchen, [0.12, 0.28, 0.12], [x, 2.58, -1.25], mats.woodDark);
}
addBlock(kitchen, [0.38, 0.42, 0.34], [-2.33, 3.02, -1.13], mats.coral);
addBlock(kitchen, [0.34, 0.35, 0.32], [-1.79, 2.985, -1.12], mats.cream);
addBlock(kitchen, [0.22, 0.12, 0.22], [-1.79, 3.22, -1.12], mats.woodDark);
// Hanging rail and utensils
addBlock(kitchen, [1.48, 0.07, 0.09], [-0.58, 2.64, -1.26], mats.brass);
for (const x of [-1.12, -0.74, -0.39]) {
addBlock(kitchen, [0.035, 0.34, 0.04], [x, 2.43, -1.22], mats.dark);
addBlock(kitchen, [0.18, 0.18, 0.06], [x, 2.22, -1.22], mats.cream);
}
// Sink
addBlock(kitchen, [1.05, 0.055, 0.72], [-2.35, 1.045, -0.18], mats.dark);
addBlock(kitchen, [0.12, 0.44, 0.12], [-2.35, 1.25, -0.72], mats.brass);
addBlock(kitchen, [0.12, 0.12, 0.42], [-2.35, 1.46, -0.53], mats.brass);
addBlock(kitchen, [0.12, 0.30, 0.12], [-2.35, 1.33, -0.33], mats.brass);
// Plant
addBlock(kitchen, [0.52, 0.46, 0.52], [2.65, 1.27, -0.34], mats.terracotta);
addBlock(kitchen, [0.44, 0.06, 0.44], [2.65, 1.53, -0.34], mats.woodDark);
addBlock(kitchen, [0.18, 0.65, 0.18], [2.65, 1.82, -0.34], mats.green);
addBlock(kitchen, [0.42, 0.18, 0.18], [2.54, 2.00, -0.34], mats.greenLight);
addBlock(kitchen, [0.18, 0.42, 0.18], [2.78, 1.91, -0.25], mats.green);
addBlock(kitchen, [0.38, 0.18, 0.18], [2.58, 2.16, -0.36], mats.greenLight);
// Shared action assets
function buildJug() {
const group = new THREE.Group();
// Voxel base and hollow body.
for (const x of [-0.16, 0, 0.16]) {
for (const z of [-0.16, 0, 0.16]) {
addBlock(group, [0.15, 0.15, 0.15], [x, -0.32, z], mats.blueDark);
}
}
for (const y of [-0.15, 0.05]) {
for (const x of [-0.16, 0, 0.16]) {
addBlock(group, [0.15, 0.15, 0.15], [x, y, -0.16], mats.blue);
addBlock(group, [0.15, 0.15, 0.15], [-0.16, y, 0], mats.blue);
addBlock(group, [0.15, 0.15, 0.15], [0.16, y, 0], mats.blue);
}
}
addBlock(group, [0.16, 0.16, 0.16], [-0.16, 0.22, -0.16], mats.blueLight);
addBlock(group, [0.16, 0.16, 0.16], [0, 0.22, -0.16], mats.blueLight);
addBlock(group, [0.16, 0.16, 0.16], [0.16, 0.19, -0.14], mats.blueLight);
// Spout
addBlock(group, [0.15, 0.15, 0.15], [0.27, 0.12, -0.12], mats.blueLight);
addBlock(group, [0.15, 0.15, 0.15], [0.36, 0.04, -0.10], mats.blueLight);
// Handle
addBlock(group, [0.14, 0.14, 0.14], [-0.31, -0.16, -0.13], mats.blueDark);
addBlock(group, [0.14, 0.14, 0.14], [-0.34, 0.02, -0.13], mats.blueDark);
addBlock(group, [0.14, 0.14, 0.14], [-0.28, 0.16, -0.13], mats.blueDark);
addBlock(group, [0.14, 0.14, 0.14], [-0.18, 0.16, -0.13], mats.blue);
const liquidGroup = new THREE.Group();
const liquidPositions = [
[-0.12, -0.26, 0.00],
[0.00, -0.26, 0.00],
[0.12, -0.26, 0.00],
[-0.12, -0.09, -0.02],
[0.00, -0.09, -0.02],
[0.12, -0.09, -0.02],
[0.00, 0.08, -0.03]
];
for (const p of liquidPositions) {
addBlock(liquidGroup, [0.115, 0.115, 0.115], p, mats.amber);
}
group.add(liquidGroup);
group.userData.liquid = liquidGroup;
return group;
}
function buildBowl() {
const group = new THREE.Group();
for (const x of [-0.16, 0, 0.16]) {
for (const z of [-0.16, 0, 0.16]) {
addBlock(group, [0.15, 0.15, 0.15], [x, -0.08, z], mats.cream);
}
}
for (const x of [-0.16, 0, 0.16]) {
addBlock(group, [0.15, 0.15, 0.15], [x, 0.07, -0.16], mats.coral);
}
for (const z of [-0.16, 0, 0.16]) {
addBlock(group, [0.15, 0.15, 0.15], [-0.16, 0.07, z], mats.coral);
addBlock(group, [0.15, 0.15, 0.15], [0.16, 0.07, z], mats.coral);
}
const liquidGroup = new THREE.Group();
const positions = [
[-0.10, 0.015, -0.08],
[0.10, 0.015, -0.08],
[-0.10, 0.015, 0.08],
[0.10, 0.015, 0.08]
];
for (const p of positions) {
addBlock(liquidGroup, [0.125, 0.125, 0.125], p, mats.amber);
}
group.add(liquidGroup);
group.userData.liquid = liquidGroup;
return group;
}
function buildPot() {
const group = new THREE.Group();
const frontMaterial = material(0xb7684d, {
transparent: true,
opacity: 1
});
const positions = [-0.32, -0.16, 0, 0.16, 0.32];
for (const x of positions) {
for (const z of positions) {
addBlock(group, [0.15, 0.15, 0.15], [x, 0.08, z], mats.terracotta);
}
}
for (const y of [0.24, 0.40, 0.56]) {
for (const x of positions) {
addBlock(group, [0.15, 0.15, 0.15], [x, y, -0.32], mats.terracotta);
if (Math.abs(x) === 0.32) {
addBlock(group, [0.15, 0.15, 0.15], [x, y, 0.32], frontMaterial);
} else {
addBlock(group, [0.15, 0.15, 0.15], [x, y, 0.32], mats.terracotta);
}
addBlock(group, [0.15, 0.15, 0.15], [-0.32, y, x], mats.terracotta);
addBlock(group, [0.15, 0.15, 0.15], [0.32, y, x], mats.terracotta);
}
}
// Block handles
addBlock(group, [0.22, 0.16, 0.16], [-0.50, 0.40, -0.16], mats.terracotta);
addBlock(group, [0.22, 0.16, 0.16], [-0.50, 0.40, 0.16], mats.terracotta);
addBlock(group, [0.22, 0.16, 0.16], [0.50, 0.40, -0.16], mats.terracotta);
addBlock(group, [0.22, 0.16, 0.16], [0.50, 0.40, 0.16], mats.terracotta);
const liquidGroup = new THREE.Group();
const liquidPositions = [
[-0.15, 0.22, -0.10],
[0.15, 0.22, -0.10],
[-0.15, 0.22, 0.12],
[0.15, 0.22, 0.12],
[0.00, 0.39, 0.00]
];
for (const p of liquidPositions) {
addBlock(liquidGroup, [0.13, 0.13, 0.13], p, mats.amber);
}
group.add(liquidGroup);
group.userData.liquid = liquidGroup;
group.userData.frontMaterial = frontMaterial;
return group;
}
function buildLid() {
const group = new THREE.Group();
const lidMaterial = material(0xe2c989, {
transparent: true,
opacity: 1
});
const positions = [-0.32, -0.16, 0, 0.16, 0.32];
for (const x of positions) {
for (const z of positions) {
addBlock(group, [0.15, 0.14, 0.15], [x, 0, z], lidMaterial);
}
}
addBlock(group, [0.16, 0.14, 0.16], [0, 0.15, 0], lidMaterial);
addBlock(group, [0.34, 0.12, 0.16], [0, 0.27, 0], lidMaterial);
group.userData.material = lidMaterial;
return group;
}
function buildMat(width = 0.95, depth = 0.66) {
const group = new THREE.Group();
addBlock(group, [width, 0.04, depth], [0, 0, 0], mats.woodDark);
addBlock(group, [width - 0.10, 0.025, depth - 0.10], [0, 0.025, 0], mats.wood);
return group;
}
function buildArrow() {
const group = new THREE.Group();
const yellow = material(0xf6c75b, {
emissive: 0x6c4700,
emissiveIntensity: 0.22
});
addBlock(group, [0.10, 0.10, 0.10], [0, 0.17, 0], yellow);
addBlock(group, [0.10, 0.10, 0.10], [0, 0.04, 0], yellow);
addBlock(group, [0.10, 0.10, 0.10], [-0.10, -0.08, 0], yellow);
addBlock(group, [0.10, 0.10, 0.10], [0, -0.08, 0], yellow);
addBlock(group, [0.10, 0.10, 0.10], [0.10, -0.08, 0], yellow);
return group;
}
const jug = buildJug();
const bowl = buildBowl();
const pot = buildPot();
const lid = buildLid();
const placeMat = buildMat();
const pourMat = buildMat(1.0, 0.66);
const coverMat = buildMat(1.2, 0.76);
const stream = new THREE.Group();
addBlock(stream, [0.13, 0.13, 0.13], [0, 0, 0], mats.amber);
const placeArrow = buildArrow();
const coverArrow = buildArrow();
scene.add(jug, bowl, pot, lid, placeMat, pourMat, coverMat, stream, placeArrow, coverArrow);
const propGroups = [
jug,
bowl,
pot,
lid,
placeMat,
pourMat,
coverMat,
stream,
placeArrow,
coverArrow
];
let selectedAction = "place";
let viewMode = "compare";
let xrayEnabled = true;
const scenarioInfo = {
place: {
number: "01",
title: "Place the pitcher",
subtitle: "Same cobalt pitcher, from hover to rest",
description:
"The pitcher descends onto its wooden mat. Its seven amber content units remain inside throughout the placement.",
labels: {
before: "hovering",
after: "resting"
},
ledger: [
["Pitcher position", "0.50 u above", "On mat"],
["Pitcher contents", "7 units", "7 units"],
["Other contents", "0 units", "0 units"]
],
equation: '<span class="amber">7</span> = <span class="amber">7</span>',
proof: "Placement changes only location. No content is added, removed, or hidden.",
label: "Contents preserved",
identity: "Cobalt pitcher",
identityText: "The same blue asset and seven amber cubes appear in both states.",
swatch: "blue"
},
pour: {
number: "02",
title: "Pour into the bowl",
subtitle: "Seven voxel units remain visible across the system",
description:
"The pitcher tips toward the bowl. Two units remain in the pitcher, four occupy the bowl, and one is in transit.",
labels: {
before: "7 in pitcher",
after: "7 total"
},
ledger: [
["In pitcher", "7 units", "2 units"],
["In bowl", "0 units", "4 units"],
["In transit", "0 units", "1 unit"],
["Total", "7 units", "7 units"]
],
equation:
'<span class="amber">7</span> = 2 + 4 + <span class="amber">1</span>',
proof:
"Every one of the seven original amber cubes is accounted for: in the pitcher, in the bowl, or between them.",
label: "Volume conserved",
identity: "Cobalt pitcher + coral bowl",
identityText: "The pitcher from action 01 is reused, together with the same bowl.",
swatch: "orange"
},
cover: {
number: "03",
title: "Cover the pot",
subtitle: "Five retained units under the matching lid",
description:
"The voxel lid moves from the worktop onto the pot. The five amber units remain inside the pot throughout.",
labels: {
before: "lid beside pot",
after: "lid seated"
},
ledger: [
["Lid position", "On worktop", "Seated on pot"],
["Pot contents", "5 units", "5 units"],
["Total", "5 units", "5 units"]
],
equation: '<span class="amber">5</span> = <span class="amber">5</span>',
proof:
"Covering hides the contents from an exterior view, but does not delete them. Use the cutaway to inspect all five.",
label: "Nothing hidden is removed",
identity: "Terracotta pot + cream lid",
identityText: "The same pot and lid are used for both states.",
swatch: "orange"
}
};
function showLiquid(group, count) {
group.children.forEach((cube, index) => {
cube.visible = index < count;
});
}
function resetProps() {
propGroups.forEach((group) => {
group.visible = false;
});
showLiquid(jug.userData.liquid, 7);
showLiquid(bowl.userData.liquid, 4);
showLiquid(pot.userData.liquid, 5);
}
function applyState(action, phase) {
resetProps();
if (action === "place") {
placeMat.visible = true;
placeMat.position.set(-0.78, SURFACE + 0.02, 0.13);
jug.visible = true;
jug.position.set(-0.78, SURFACE + 0.90, 0.13);
jug.rotation.set(0, 0, phase === "before" ? -0.035 : 0);
if (phase === "before") {
placeArrow.visible = true;
placeArrow.position.set(-0.78, SURFACE + 0.66, 0.62);
}
}
if (action === "pour") {
pourMat.visible = true;
pourMat.position.set(0.48, SURFACE + 0.02, 0.13);
bowl.visible = true;
bowl.position.set(0.78, SURFACE + 0.15, 0.13);
bowl.rotation.set(0, 0, 0);
jug.visible = true;
if (phase === "before") {
jug.position.set(-0.78, SURFACE + 0.40, 0.13);
jug.rotation.set(0, 0, 0);
showLiquid(jug.userData.liquid, 7);
showLiquid(bowl.userData.liquid, 0);
stream.visible = false;
} else {
jug.position.set(0.18, SURFACE + 1.03, 0.13);
jug.rotation.set(0, 0, -1.05);
showLiquid(jug.userData.liquid, 2);
showLiquid(bowl.userData.liquid, 4);
stream.visible = true;
stream.position.set(0.52, SURFACE + 0.76, 0.13);
stream.rotation.set(0, 0, -0.25);
}
}
if (action === "cover") {
coverMat.visible = true;
coverMat.position.set(0.30, SURFACE + 0.02, 0.13);
pot.visible = true;
pot.position.set(0.18, SURFACE, 0.13);
pot.rotation.set(0, 0, 0);
lid.visible = true;
if (phase === "before") {
lid.position.set(1.47, SURFACE + 0.075, 0.20);
lid.rotation.set(0, 0.13, 0);
coverArrow.visible = true;
coverArrow.position.set(1.47, SURFACE + 0.49, 0.68);
} else {
lid.position.set(0.18, SURFACE + 0.69, 0.13);
lid.rotation.set(0, 0, 0);
}
}
const cutaway = action === "cover" && xrayEnabled;
const frontMaterial = pot.userData.frontMaterial;
const lidMaterial = lid.userData.material;
frontMaterial.opacity = cutaway ? 0.16 : 1;
frontMaterial.depthWrite = !cutaway;
lidMaterial.opacity = cutaway ? 0.28 : 1;
lidMaterial.depthWrite = !cutaway;
}
function updateCamera(width, height) {
const aspect = width / Math.max(height, 1);
const frustumHeight = 5.45;
camera.left = (-frustumHeight * aspect) / 2;
camera.right = (frustumHeight * aspect) / 2;
camera.top = frustumHeight / 2;
camera.bottom = -frustumHeight / 2;
camera.updateProjectionMatrix();
const { theta, phi, radius, target } = orbit;
camera.position.set(
target.x + radius * Math.sin(phi) * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + radius * Math.sin(phi) * Math.cos(theta)
);
camera.lookAt(target);
}
function renderViewport(rect, action, phase) {
applyState(action, phase);
updateCamera(rect.width, rect.height);
renderer.setViewport(rect.x, rect.y, rect.width, rect.height);
renderer.setScissor(rect.x, rect.y, rect.width, rect.height);
renderer.render(scene, camera);
}
function render() {
const width = Math.max(stage.clientWidth, 1);
const height = Math.max(stage.clientHeight, 1);
renderer.setScissorTest(false);
renderer.setViewport(0, 0, width, height);
renderer.clear();
renderer.setScissorTest(true);
if (viewMode === "compare") {
const half = Math.floor(width / 2);
renderViewport(
{ x: 0, y: 0, width: half, height },
selectedAction,
"before"
);
renderViewport(
{ x: half + 1, y: 0, width: width - half - 1, height },
selectedAction,
"after"
);
} else {
renderViewport(
{ x: 0, y: 0, width, height },
selectedAction,
viewMode
);
}
renderer.setScissorTest(false);
}
function updateInspector() {
const info = scenarioInfo[selectedAction];
document.querySelector("#inspectorKicker").textContent =
`Action ${info.number}`;
document.querySelector("#inspectorTitle").textContent = info.title;
document.querySelector("#inspectorDescription").textContent = info.description;
document.querySelector("#stageActionTitle").textContent =
`${info.number} · ${info.title}`;
document.querySelector("#stageActionSubtitle").textContent = info.subtitle;
const beforeLabel = document.querySelector(".view-label.before");
const afterLabel = document.querySelector(".view-label.after");
beforeLabel.dataset.note = info.labels.before;
afterLabel.dataset.note = info.labels.after;
document.querySelector("#ledger").innerHTML = `
<div class="ledger-row ledger-head">
<span>State detail</span>
<span class="ledger-value">Before</span>
<span class="ledger-value after">After</span>
</div>
${info.ledger
.map(
([label, before, after]) => `
<div class="ledger-row">
<span>${label}</span>
<span class="ledger-value">${before}</span>
<span class="ledger-value after">${after}</span>
</div>
`
)
.join("")}
`;
document.querySelector("#equation").innerHTML = info.equation;
document.querySelector("#proof").textContent = info.proof;
document.querySelector("#conservationLabel").textContent = info.label;
document.querySelector("#conservationCard").classList.toggle(
"orange",
selectedAction === "pour"
);
document.querySelector("#identityTitle").textContent = info.identity;
document.querySelector("#identityText").textContent = info.identityText;
document.querySelector("#identitySwatch").classList.toggle(
"orange",
info.swatch === "orange"
);
document.querySelector("#xrayRow").hidden = selectedAction !== "cover";
document.querySelector("#sceneChip").textContent =
selectedAction === "cover"
? "Drag to orbit · cutaway reveals retained contents"
: "Drag to orbit · scroll to zoom";
}
function selectAction(action) {
selectedAction = action;
document.querySelectorAll(".action-card").forEach((button) => {
button.classList.toggle("active", button.dataset.action === action);
});
updateInspector();
}
function setViewMode(mode) {
viewMode = mode;
document.body.dataset.mode = mode;
document.querySelectorAll(".mode-switch button").forEach((button) => {
button.classList.toggle("active", button.dataset.mode === mode);
});
}
document.querySelectorAll(".action-card").forEach((button) => {
button.addEventListener("click", () => selectAction(button.dataset.action));
});
document.querySelectorAll(".mode-switch button").forEach((button) => {
button.addEventListener("click", () => setViewMode(button.dataset.mode));
});
document.querySelector("#xray").addEventListener("change", (event) => {
xrayEnabled = event.target.checked;
});
// Camera controls implemented directly, without Three.js addons.
let dragging = false;
let pointerX = 0;
let pointerY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
orbit.theta -= dx * 0.006;
orbit.phi = THREE.MathUtils.clamp(orbit.phi + dy * 0.005, 0.52, 1.38);
pointerX = event.clientX;
pointerY = event.clientY;
});
function stopDragging(event) {
dragging = false;
if (event.pointerId !== undefined && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius + event.deltaY * 0.008,
6.5,
15
);
},
{ passive: false }
);
document.querySelector("#resetView").addEventListener("click", () => {
orbit.theta = defaultOrbit.theta;
orbit.phi = defaultOrbit.phi;
orbit.radius = defaultOrbit.radius;
orbit.target.copy(defaultOrbit.target);
});
window.addEventListener("keydown", (event) => {
if (event.target instanceof HTMLInputElement) return;
if (event.key === "1") selectAction("place");
if (event.key === "2") selectAction("pour");
if (event.key === "3") selectAction("cover");
if (event.key.toLowerCase() === "b") setViewMode("before");
if (event.key.toLowerCase() === "a") setViewMode("after");
if (event.key.toLowerCase() === "c") setViewMode("compare");
const step = 0.08;
if (event.key === "ArrowLeft") orbit.theta -= step;
if (event.key === "ArrowRight") orbit.theta += step;
if (event.key === "ArrowUp") orbit.phi = Math.max(0.52, orbit.phi - step);
if (event.key === "ArrowDown") orbit.phi = Math.min(1.38, orbit.phi + step);
});
const resizeObserver = new ResizeObserver(() => {
const width = Math.max(stage.clientWidth, 1);
const height = Math.max(stage.clientHeight, 1);
renderer.setSize(width, height, false);
render();
});
resizeObserver.observe(stage);
updateInspector();
renderer.setSize(stage.clientWidth, stage.clientHeight, false);
render();
loading.hidden = true;
function animate() {
requestAnimationFrame(animate);
render();
}
animate();
</script>
</body>
</html>
```