Prompt specification
Build or customize the Three.js 3D scene "Appliance energy comparison miniature room" 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: Appliance energy comparison miniature room
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/appliance-energy-comparison-miniature-room-x1631
Scene Description Prompt:
I'd like to see this as a voxel Three.js scene: appliance energy comparison miniature room. Compose fictional appliances with explicitly synthetic power ratings and on-time controls; calculate total energy use without presenting invented ratings as real product specifications. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (appliance-energy-comparison-miniature-room-x1631):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Voxel Energy Lab — Synthetic Appliance Comparison</title>
<style>
:root {
--ink: #17251f;
--muted: #68746d;
--paper: #f7f7ef;
--stage: #e8eadf;
--line: #d9ded3;
--green: #236b50;
--green-soft: #dff1e5;
--orange: #d96b43;
--orange-soft: #f8e2d8;
--blue: #3c8290;
--shadow: 0 18px 45px rgba(35, 54, 44, 0.12);
}
* { box-sizing: border-box; }
html { color-scheme: light; }
body {
margin: 0;
min-height: 100vh;
color: var(--ink);
background:
radial-gradient(circle at 12% 8%, rgba(255,255,255,.92), transparent 30%),
linear-gradient(135deg, #f2f3e9 0%, #e8ebe0 100%);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button, input { font: inherit; }
button {
color: inherit;
cursor: pointer;
}
.topbar {
max-width: 1540px;
margin: 0 auto;
padding: 22px 24px 18px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
}
.brand {
display: flex;
align-items: center;
gap: 14px;
}
.brand-mark {
width: 44px;
height: 44px;
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: repeat(3, 1fr);
gap: 3px;
padding: 5px;
border-radius: 12px;
background: var(--ink);
box-shadow: 0 8px 20px rgba(23,37,31,.18);
}
.brand-mark i {
display: block;
border-radius: 2px;
background: #a6d6b7;
}
.brand-mark i:nth-child(2),
.brand-mark i:nth-child(6),
.brand-mark i:nth-child(8) { background: #f1b75d; }
.brand-mark i:nth-child(5) { background: #74b9c7; }
.eyebrow {
margin: 0 0 3px;
color: var(--green);
font-size: 11px;
font-weight: 800;
letter-spacing: .13em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(21px, 2.4vw, 31px);
line-height: 1.05;
letter-spacing: -.035em;
}
.top-meta {
display: flex;
align-items: center;
gap: 9px;
flex-wrap: wrap;
justify-content: flex-end;
}
.pill {
display: inline-flex;
align-items: center;
gap: 7px;
padding: 8px 11px;
border: 1px solid var(--line);
border-radius: 999px;
background: rgba(255,255,255,.65);
color: #536159;
font-size: 12px;
font-weight: 700;
}
.pill::before {
content: "";
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--green);
box-shadow: 0 0 0 4px var(--green-soft);
}
.layout {
max-width: 1540px;
margin: 0 auto;
padding: 0 24px 24px;
display: grid;
grid-template-columns: minmax(0, 1fr) 420px;
gap: 20px;
align-items: start;
}
.scene-card,
.dashboard {
border: 1px solid rgba(255,255,255,.85);
background: rgba(255,255,255,.78);
box-shadow: var(--shadow);
backdrop-filter: blur(10px);
}
.scene-card {
position: sticky;
top: 18px;
height: calc(100vh - 126px);
min-height: 650px;
overflow: hidden;
border-radius: 24px;
background: var(--stage);
}
#viewport {
position: absolute;
inset: 0;
}
#viewport canvas {
width: 100%;
height: 100%;
display: block;
touch-action: none;
cursor: grab;
}
#viewport canvas:active { cursor: grabbing; }
.scene-top {
position: absolute;
z-index: 4;
top: 18px;
left: 18px;
right: 18px;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
pointer-events: none;
}
.scene-kicker {
padding: 12px 14px;
border: 1px solid rgba(255,255,255,.75);
border-radius: 14px;
background: rgba(250,250,244,.84);
box-shadow: 0 8px 25px rgba(40,60,48,.08);
backdrop-filter: blur(10px);
}
.scene-kicker strong {
display: block;
font-size: 12px;
letter-spacing: .08em;
text-transform: uppercase;
}
.scene-kicker span {
display: block;
margin-top: 4px;
color: var(--muted);
font-size: 11px;
}
.view-button {
pointer-events: auto;
border: 1px solid rgba(255,255,255,.8);
border-radius: 12px;
padding: 10px 12px;
background: rgba(250,250,244,.9);
box-shadow: 0 8px 25px rgba(40,60,48,.08);
font-size: 12px;
font-weight: 800;
}
.view-button:hover { background: #fff; }
.scene-bottom {
position: absolute;
z-index: 4;
left: 18px;
right: 18px;
bottom: 17px;
display: flex;
justify-content: space-between;
align-items: flex-end;
gap: 14px;
pointer-events: none;
}
.legend {
display: flex;
align-items: center;
gap: 10px;
flex-wrap: wrap;
max-width: 75%;
padding: 10px 12px;
border-radius: 12px;
background: rgba(250,250,244,.84);
color: #526158;
font-size: 11px;
backdrop-filter: blur(8px);
}
.legend span {
display: inline-flex;
align-items: center;
gap: 6px;
}
.legend i {
width: 8px;
height: 8px;
border-radius: 2px;
background: #68bd83;
box-shadow: 0 0 0 3px rgba(104,189,131,.16);
}
.scene-hint {
padding: 9px 11px;
border-radius: 11px;
background: rgba(23,37,31,.78);
color: #eef4ed;
font-size: 10px;
font-weight: 700;
white-space: nowrap;
}
#loading {
position: absolute;
inset: 0;
z-index: 8;
display: grid;
place-items: center;
color: var(--muted);
font-size: 13px;
font-weight: 700;
background: var(--stage);
}
.dashboard {
height: calc(100vh - 126px);
min-height: 650px;
overflow: auto;
border-radius: 24px;
scrollbar-width: thin;
scrollbar-color: #bdc7bb transparent;
}
.panel-head {
padding: 22px 22px 17px;
border-bottom: 1px solid var(--line);
}
.panel-title-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.panel-head h2 {
margin: 0;
font-size: 20px;
letter-spacing: -.025em;
}
.live-chip {
padding: 6px 8px;
border-radius: 8px;
background: var(--green-soft);
color: var(--green);
font-size: 10px;
font-weight: 900;
letter-spacing: .08em;
}
.panel-head p {
margin: 8px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.5;
}
.metrics {
padding: 15px;
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
}
.metric {
min-height: 91px;
padding: 13px;
border: 1px solid var(--line);
border-radius: 15px;
background: #fbfbf6;
}
.metric-label {
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: .07em;
text-transform: uppercase;
}
.metric-value {
margin-top: 7px;
font-size: 25px;
font-weight: 850;
letter-spacing: -.04em;
line-height: 1;
}
.metric-value small {
margin-left: 3px;
color: var(--muted);
font-size: 11px;
font-weight: 750;
letter-spacing: 0;
}
.metric-sub {
margin-top: 6px;
color: var(--muted);
font-size: 10px;
}
.metric.delta.good { background: var(--green-soft); border-color: #c6e4d1; }
.metric.delta.bad { background: var(--orange-soft); border-color: #efcdbf; }
.metric.delta.good .metric-value { color: var(--green); }
.metric.delta.bad .metric-value { color: #b65332; }
.presets {
padding: 0 15px 15px;
display: flex;
align-items: center;
gap: 8px;
}
.presets > span {
margin-right: 2px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
text-transform: uppercase;
letter-spacing: .07em;
}
.preset {
border: 1px solid var(--line);
border-radius: 10px;
padding: 8px 10px;
background: #fff;
font-size: 11px;
font-weight: 800;
}
.preset:hover { border-color: #aebcaf; transform: translateY(-1px); }
.section-title {
padding: 17px 18px 10px;
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 12px;
}
.section-title h3 {
margin: 0;
font-size: 13px;
letter-spacing: -.01em;
}
.section-title span {
color: var(--muted);
font-size: 10px;
}
.controls {
padding: 0 12px;
display: grid;
gap: 9px;
}
.appliance {
padding: 12px;
border: 1px solid var(--line);
border-radius: 15px;
background: #fbfbf7;
transition: opacity .2s, border-color .2s, background .2s;
}
.appliance.off {
opacity: .62;
background: #f2f3ed;
}
.appliance-top {
display: grid;
grid-template-columns: auto 1fr auto;
align-items: center;
gap: 9px;
}
.device-icon {
width: 30px;
height: 30px;
display: grid;
place-items: center;
border-radius: 9px;
color: #fff;
font-size: 14px;
font-weight: 900;
box-shadow: inset 0 -5px 0 rgba(0,0,0,.08);
}
.device-name {
min-width: 0;
}
.device-name strong {
display: block;
font-size: 12px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.rating {
display: inline-flex;
align-items: center;
gap: 5px;
margin-top: 3px;
color: var(--muted);
font-size: 9px;
font-weight: 750;
}
.synthetic-tag {
padding: 2px 4px;
border-radius: 4px;
background: #e7ebe2;
color: #5a675f;
letter-spacing: .05em;
}
.switch {
width: 39px;
height: 23px;
padding: 3px;
border: 0;
border-radius: 999px;
background: #c7cec5;
transition: background .2s;
}
.switch span {
display: block;
width: 17px;
height: 17px;
border-radius: 50%;
background: #fff;
box-shadow: 0 2px 5px rgba(0,0,0,.2);
transition: transform .2s;
}
.switch[aria-checked="true"] { background: var(--green); }
.switch[aria-checked="true"] span { transform: translateX(16px); }
.slider-label {
margin-top: 11px;
display: flex;
justify-content: space-between;
gap: 10px;
color: var(--muted);
font-size: 10px;
font-weight: 750;
}
.slider-label output {
color: var(--ink);
font-weight: 850;
}
input[type="range"] {
--fill: 50%;
width: 100%;
height: 5px;
margin: 9px 0 7px;
display: block;
appearance: none;
border-radius: 999px;
outline: none;
background: linear-gradient(to right,
var(--device-color) 0 var(--fill),
#dfe3da var(--fill) 100%);
}
input[type="range"]::-webkit-slider-thumb {
width: 17px;
height: 17px;
appearance: none;
border: 3px solid #fff;
border-radius: 50%;
background: var(--device-color);
box-shadow: 0 1px 5px rgba(0,0,0,.25);
}
input[type="range"]::-moz-range-thumb {
width: 12px;
height: 12px;
border: 3px solid #fff;
border-radius: 50%;
background: var(--device-color);
box-shadow: 0 1px 5px rgba(0,0,0,.25);
}
.usage-line {
display: flex;
justify-content: space-between;
gap: 10px;
color: var(--muted);
font-size: 9px;
}
.usage-line b {
color: var(--ink);
font-size: 10px;
}
.comparison {
margin: 15px 12px 12px;
padding: 14px;
border: 1px solid var(--line);
border-radius: 16px;
background: #f7f8f2;
}
.comparison-head {
display: flex;
justify-content: space-between;
align-items: baseline;
gap: 10px;
margin-bottom: 13px;
}
.comparison-head strong { font-size: 12px; }
.comparison-head span { color: var(--muted); font-size: 9px; }
.compare-row {
display: grid;
grid-template-columns: 98px 1fr 66px;
align-items: center;
gap: 8px;
margin: 10px 0;
}
.compare-name {
color: #56635b;
font-size: 9px;
font-weight: 800;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.compare-track {
position: relative;
height: 9px;
border-radius: 999px;
background: #e1e5dc;
overflow: visible;
}
.compare-fill {
position: absolute;
inset: 0 auto 0 0;
width: 0;
border-radius: inherit;
background: var(--device-color);
transition: width .25s ease;
}
.baseline-marker {
position: absolute;
top: -3px;
width: 2px;
height: 15px;
border-radius: 2px;
background: #34423a;
opacity: .58;
}
.compare-value {
text-align: right;
color: var(--muted);
font-size: 9px;
font-variant-numeric: tabular-nums;
}
.compare-value b {
display: block;
color: var(--ink);
font-size: 10px;
}
.formula {
margin-top: 12px;
padding-top: 11px;
border-top: 1px dashed #cdd4ca;
color: var(--muted);
font-size: 9px;
line-height: 1.55;
}
.formula code {
color: #34443a;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 9px;
}
.panel-note {
margin: 0 12px 14px;
padding: 12px;
border-radius: 13px;
background: #fff4dc;
color: #755a2d;
font-size: 10px;
line-height: 1.5;
}
footer {
max-width: 1540px;
margin: 0 auto;
padding: 0 24px 25px;
color: #69756d;
font-size: 10px;
line-height: 1.5;
text-align: center;
}
@media (max-width: 1050px) {
.layout { grid-template-columns: 1fr; }
.scene-card {
position: relative;
top: 0;
height: 680px;
min-height: 0;
}
.dashboard {
height: auto;
min-height: 0;
overflow: visible;
}
}
@media (max-width: 620px) {
.topbar {
padding: 17px 14px 14px;
align-items: flex-start;
}
.top-meta { display: none; }
.layout { padding: 0 12px 16px; gap: 12px; }
.scene-card { height: 520px; border-radius: 18px; }
.dashboard { border-radius: 18px; }
.scene-hint { display: none; }
.scene-bottom { left: 12px; right: 12px; bottom: 12px; }
.legend { max-width: 100%; }
.compare-row { grid-template-columns: 82px 1fr 57px; }
footer { padding-inline: 15px; }
}
</style>
</head>
<body>
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true">
<i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i>
</div>
<div>
<p class="eyebrow">Voxel Energy Lab</p>
<h1>Miniature room, measurable choices.</h1>
</div>
</div>
<div class="top-meta">
<span class="pill">Synthetic scenario model</span>
<span class="pill">7-day energy horizon</span>
</div>
</header>
<main class="layout">
<section class="scene-card" aria-label="Interactive voxel appliance room">
<div id="viewport"></div>
<div id="loading">Building the miniature room…</div>
<div class="scene-top">
<div class="scene-kicker">
<strong>Room 05 / Synthetic loads</strong>
<span id="sceneStatus">5 of 5 devices enabled</span>
</div>
<button class="view-button" id="resetCamera" type="button">Reset view</button>
</div>
<div class="scene-bottom">
<div class="legend">
<span><i></i> Enabled load</span>
<span>LED pulse = simulated operation</span>
</div>
<div class="scene-hint">Drag to orbit · Scroll to zoom</div>
</div>
</section>
<aside class="dashboard" aria-label="Appliance controls and energy calculations">
<div class="panel-head">
<div class="panel-title-row">
<h2>On-time controls</h2>
<span class="live-chip">LIVE MODEL</span>
</div>
<p>
Adjust fictional daily operating hours. Every wattage below is invented
for this interactive model—not a product specification.
</p>
</div>
<div class="metrics" aria-live="polite">
<div class="metric">
<div class="metric-label">Daily energy</div>
<div class="metric-value"><span id="dailyEnergy">0.00</span><small>kWh</small></div>
<div class="metric-sub">Current synthetic scenario</div>
</div>
<div class="metric">
<div class="metric-label">7-day energy</div>
<div class="metric-value"><span id="weeklyEnergy">0.00</span><small>kWh</small></div>
<div class="metric-sub">Daily total × 7 days</div>
</div>
<div class="metric">
<div class="metric-label">Synthetic baseline</div>
<div class="metric-value"><span id="baselineEnergy">0.00</span><small>kWh</small></div>
<div class="metric-sub">Per day, fixed reference</div>
</div>
<div class="metric delta" id="deltaMetric">
<div class="metric-label">Vs. baseline</div>
<div class="metric-value"><span id="deltaEnergy">0.00</span><small>kWh/day</small></div>
<div class="metric-sub" id="deltaNote">At the synthetic baseline</div>
</div>
</div>
<div class="presets">
<span>Presets</span>
<button class="preset" id="baselinePreset" type="button">Baseline</button>
<button class="preset" id="lowUsePreset" type="button">Low-use demo</button>
</div>
<div class="section-title">
<h3>Fictional appliances</h3>
<span>Synthetic W · hours/day</span>
</div>
<div class="controls" id="controls"></div>
<div class="section-title">
<h3>Daily comparison</h3>
<span>Bar = current · tick = baseline</span>
</div>
<div class="comparison">
<div class="comparison-head">
<strong>Usage by device</strong>
<span>kWh/day</span>
</div>
<div id="comparisonRows"></div>
<div class="formula">
<code>kWh = (synthetic watts ÷ 1000) × on-time hours/day</code><br>
Weekly use uses a fixed seven-day horizon. Disabled appliances contribute zero.
</div>
</div>
<div class="panel-note">
<strong>Simulation disclaimer:</strong> appliance names, colors, wattages,
and operating schedules are fictional archetypes created for this room.
They should not be used to estimate the energy use or specifications of a real product.
</div>
</aside>
</main>
<footer>
All power ratings are explicitly synthetic values for demonstration purposes.
This model does not represent certified, measured, or real-world product data.
</footer>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const appliances = [
{
id: "cooling",
name: "Cooling unit",
glyph: "C",
watts: 85,
color: 0x4fa6b7,
css: "#4fa6b7",
baselineHours: 8,
hours: 8,
maxHours: 16,
enabled: true
},
{
id: "laundry",
name: "Laundry unit",
glyph: "L",
watts: 620,
color: 0x6e83b6,
css: "#6e83b6",
baselineHours: 2,
hours: 2,
maxHours: 4,
enabled: true
},
{
id: "screen",
name: "Screen unit",
glyph: "S",
watts: 110,
color: 0xdc8357,
css: "#dc8357",
baselineHours: 4,
hours: 4,
maxHours: 12,
enabled: true
},
{
id: "cook",
name: "Cook unit",
glyph: "K",
watts: 1450,
color: 0xd45d4e,
css: "#d45d4e",
baselineHours: 1.5,
hours: 1.5,
maxHours: 5,
enabled: true
},
{
id: "climate",
name: "Air handler",
glyph: "A",
watts: 430,
color: 0x8c6caf,
css: "#8c6caf",
baselineHours: 6,
hours: 6,
maxHours: 12,
enabled: true
}
];
const lowUseHours = {
cooling: 8,
laundry: 0.75,
screen: 2,
cook: 0.5,
climate: 4
};
const dailyUse = app => app.enabled ? (app.watts / 1000) * app.hours : 0;
const baselineDaily = appliances.reduce(
(sum, app) => sum + (app.watts / 1000) * app.baselineHours,
0
);
// ---------- Interface ----------
const controlsHost = document.getElementById("controls");
const comparisonHost = document.getElementById("comparisonRows");
const refs = {};
for (const app of appliances) {
const card = document.createElement("article");
card.className = "appliance";
card.style.setProperty("--device-color", app.css);
card.innerHTML = `
<div class="appliance-top">
<div class="device-icon" style="background:${app.css}">${app.glyph}</div>
<div class="device-name">
<strong>${app.name}</strong>
<span class="rating">
${app.watts.toLocaleString()} W
<span class="synthetic-tag">SYNTHETIC</span>
</span>
</div>
<button class="switch" type="button" role="switch"
aria-checked="true" aria-label="Enable ${app.name}">
<span></span>
</button>
</div>
<div class="slider-label">
<span>Synthetic on-time</span>
<output>${app.hours} h/day</output>
</div>
<input type="range" min="0" max="${app.maxHours}" step="0.25"
value="${app.hours}" aria-label="${app.name} synthetic hours per day" />
<div class="usage-line">
<span>Modeled energy</span>
<b class="usage">${dailyUse(app).toFixed(2)} kWh/day</b>
</div>
`;
controlsHost.appendChild(card);
const slider = card.querySelector("input");
const output = card.querySelector("output");
const toggle = card.querySelector(".switch");
const usage = card.querySelector(".usage");
slider.addEventListener("input", () => {
app.hours = Number(slider.value);
updateModel();
});
toggle.addEventListener("click", () => {
app.enabled = !app.enabled;
updateModel();
});
refs[app.id] = { card, slider, output, toggle, usage };
const row = document.createElement("div");
row.className = "compare-row";
row.style.setProperty("--device-color", app.css);
row.innerHTML = `
<div class="compare-name">${app.name}</div>
<div class="compare-track">
<div class="compare-fill"></div>
<div class="baseline-marker"></div>
</div>
<div class="compare-value">
<b>${dailyUse(app).toFixed(2)}</b>
${((app.watts / 1000) * app.baselineHours).toFixed(2)} ref
</div>
`;
comparisonHost.appendChild(row);
refs[app.id].compareFill = row.querySelector(".compare-fill");
refs[app.id].baselineMarker = row.querySelector(".baseline-marker");
refs[app.id].compareValue = row.querySelector(".compare-value b");
}
function updateModel() {
let total = 0;
let enabledCount = 0;
for (const app of appliances) {
const use = dailyUse(app);
const ref = refs[app.id];
total += use;
if (app.enabled) enabledCount++;
ref.card.classList.toggle("off", !app.enabled);
ref.toggle.setAttribute("aria-checked", String(app.enabled));
ref.output.textContent = `${app.hours} h/day`;
ref.usage.textContent = app.enabled
? `${use.toFixed(2)} kWh/day`
: "0.00 kWh/day · disabled";
const fill = app.maxHours ? (app.hours / app.maxHours) * 100 : 0;
ref.slider.style.setProperty("--fill", `${fill}%`);
const baselineUse = (app.watts / 1000) * app.baselineHours;
const maximum = Math.max(use, baselineUse, 0.001);
ref.compareFill.style.width = `${(use / maximum) * 100}%`;
ref.baselineMarker.style.left = `${(baselineUse / maximum) * 100}%`;
ref.compareValue.textContent = use.toFixed(2);
}
const weekly = total * 7;
const difference = total - baselineDaily;
document.getElementById("dailyEnergy").textContent = total.toFixed(2);
document.getElementById("weeklyEnergy").textContent = weekly.toFixed(2);
document.getElementById("baselineEnergy").textContent = baselineDaily.toFixed(2);
document.getElementById("deltaEnergy").textContent =
`${difference >= 0 ? "+" : "−"}${Math.abs(difference).toFixed(2)}`;
const deltaMetric = document.getElementById("deltaMetric");
deltaMetric.classList.toggle("good", difference <= 0);
deltaMetric.classList.toggle("bad", difference > 0);
const percentage = baselineDaily
? Math.round((Math.abs(difference) / baselineDaily) * 100)
: 0;
document.getElementById("deltaNote").textContent =
difference === 0
? "At the synthetic baseline"
: difference < 0
? `${percentage}% below synthetic baseline`
: `${percentage}% above synthetic baseline`;
document.getElementById("sceneStatus").textContent =
`${enabledCount} of ${appliances.length} devices enabled`;
updateVisuals();
}
document.getElementById("baselinePreset").addEventListener("click", () => {
for (const app of appliances) {
app.hours = app.baselineHours;
app.enabled = true;
}
updateModel();
});
document.getElementById("lowUsePreset").addEventListener("click", () => {
for (const app of appliances) {
app.hours = lowUseHours[app.id];
app.enabled = true;
}
updateModel();
});
// ---------- Three.js scene ----------
const host = document.getElementById("viewport");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe8eadf);
scene.fog = new THREE.Fog(0xe8eadf, 18, 32);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false });
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.domElement.setAttribute("aria-label", "Voxel room showing five fictional appliances");
host.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-7, 7, 5.4, -5.4, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, 1.2, -0.35);
const desired = {
azimuth: 0.72,
polar: 0.82,
zoom: 1
};
const current = {
azimuth: desired.azimuth,
polar: desired.polar,
zoom: desired.zoom
};
function updateCamera() {
const radius = 14;
const horizontal = Math.sin(current.polar) * radius;
camera.position.set(
cameraTarget.x + Math.sin(current.azimuth) * horizontal,
cameraTarget.y + Math.cos(current.polar) * radius,
cameraTarget.z + Math.cos(current.azimuth) * horizontal
);
camera.lookAt(cameraTarget);
camera.zoom = current.zoom;
camera.updateProjectionMatrix();
}
updateCamera();
const hemi = new THREE.HemisphereLight(0xffffff, 0x8d9d87, 2.2);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff1d7, 3.1);
sun.position.set(5, 10, 7);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -8;
sun.shadow.camera.right = 8;
sun.shadow.camera.top = 8;
sun.shadow.camera.bottom = -8;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 30;
sun.shadow.bias = -0.0005;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xbdd9e2, 1.1);
fill.position.set(-6, 5, -4);
scene.add(fill);
function box(parent, size, position, color, options = {}) {
const material = options.material || new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.78,
metalness: options.metalness ?? 0,
emissive: options.emissive ?? 0x000000,
emissiveIntensity: options.emissiveIntensity ?? 0
});
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 = options.castShadow ?? true;
mesh.receiveShadow = options.receiveShadow ?? true;
parent.add(mesh);
return mesh;
}
function group(position) {
const g = new THREE.Group();
g.position.set(position[0], position[1], position[2]);
scene.add(g);
return g;
}
// Room shell and tiled floor.
box(scene, [10.3, 0.18, 7.3], [0, -0.2, 0], 0xcbd2c4);
const floorColors = [0xe8e4d7, 0xeee9dc, 0xdfded1, 0xe4e3d7];
for (let row = 0; row < 7; row++) {
for (let col = 0; col < 10; col++) {
const color = floorColors[(row * 3 + col * 5) % floorColors.length];
box(
scene,
[0.97, 0.12, 0.97],
[-4.5 + col, -0.06, -3 + row],
color,
{ castShadow: false }
);
}
}
box(scene, [10.25, 4.2, 0.18], [0, 2.05, -3.58], 0xf2efe3);
box(scene, [0.18, 4.2, 7.15], [-5.02, 2.05, 0], 0xe9e6da);
box(scene, [10.05, 0.16, 0.12], [0, 0.13, -3.44], 0xc5cdbf);
box(scene, [0.12, 0.16, 6.95], [-4.88, 0.13, 0], 0xc5cdbf);
// Window and frame.
box(scene, [2.25, 1.38, 0.12], [-1.55, 2.82, -3.43], 0xb8c4b4);
box(scene, [2.02, 1.15, 0.14], [-1.55, 2.82, -3.34], 0x8fc2c7);
box(scene, [0.09, 1.16, 0.17], [-1.55, 2.82, -3.25], 0xf5f0e3);
box(scene, [2.02, 0.09, 0.17], [-1.55, 2.82, -3.25], 0xf5f0e3);
box(scene, [2.34, 0.12, 0.35], [-1.55, 2.08, -3.27], 0xe4dfcf);
// Simple wall art.
box(scene, [1.2, 0.9, 0.09], [0.65, 2.72, -3.42], 0x8a6f54);
box(scene, [1.02, 0.72, 0.12], [0.65, 2.72, -3.34], 0xd9b66e);
box(scene, [0.38, 0.48, 0.14], [0.48, 2.72, -3.25], 0x688f76);
// Rug.
box(scene, [3.15, 0.045, 1.65], [0.65, 0.04, 1.1], 0x9ab7a6, { castShadow: false });
box(scene, [2.85, 0.055, 1.35], [0.65, 0.055, 1.1], 0xc6d5c3, { castShadow: false });
box(scene, [2.25, 0.065, 0.08], [0.65, 0.07, 1.1], 0x668d79, { castShadow: false });
const visualById = new Map();
function roundedRect(ctx, x, y, width, height, radius) {
ctx.beginPath();
ctx.moveTo(x + radius, y);
ctx.arcTo(x + width, y, x + width, y + height, radius);
ctx.arcTo(x + width, y + height, x, y + height, radius);
ctx.arcTo(x, y + height, x, y, radius);
ctx.arcTo(x, y, x + width, y, radius);
ctx.closePath();
}
function createLabel(app, parent, y) {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 144;
const ctx = canvas.getContext("2d");
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
sprite.position.set(0, y, 0);
sprite.scale.set(2.7, 0.76, 1);
sprite.renderOrder = 20;
parent.add(sprite);
return { canvas, ctx, texture, sprite };
}
function drawLabel(app, label) {
const { ctx, canvas, texture } = label;
ctx.clearRect(0, 0, canvas.width, canvas.height);
roundedRect(ctx, 5, 5, 502, 134, 24);
ctx.fillStyle = "rgba(250,250,244,0.96)";
ctx.fill();
ctx.lineWidth = 7;
ctx.strokeStyle = app.enabled ? app.css : "#aeb7ad";
ctx.stroke();
roundedRect(ctx, 18, 18, 12, 108, 6);
ctx.fillStyle = app.enabled ? app.css : "#9fa89f";
ctx.fill();
ctx.fillStyle = "#17251f";
ctx.font = "800 35px system-ui, sans-serif";
ctx.fillText(app.name.toUpperCase(), 48, 59);
ctx.fillStyle = app.enabled ? app.css : "#7d887f";
ctx.font = "800 23px system-ui, sans-serif";
ctx.fillText(
`${app.enabled ? "ON" : "OFF"} • ${app.watts.toLocaleString()} W SYNTHETIC`,
48,
103
);
texture.needsUpdate = true;
}
function makeIndicator(parent, position, color) {
const material = new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: 1.4,
roughness: 0.35
});
const mesh = box(parent, [0.13, 0.13, 0.09], position, color, {
material,
emissive: color,
emissiveIntensity: 1.4
});
return mesh;
}
// Cooling unit.
{
const app = appliances[0];
const g = group([-3.65, 0, -2.05]);
box(g, [1.38, 2.18, 1.22], [0, 1.11, 0], 0xe9e6da);
box(g, [1.22, 1.88, 0.09], [0, 1.13, 0.66], 0x63aeb8);
box(g, [0.11, 0.7, 0.13], [0.43, 1.2, 0.75], 0xf3f0e6);
box(g, [0.92, 0.08, 0.09], [0, 0.19, 0.72], 0x4e6570);
box(g, [0.92, 0.08, 0.09], [0, 0.34, 0.72], 0x4e6570);
box(g, [0.16, 0.14, 0.16], [-0.5, 0.08, 0.43], 0x526057);
box(g, [0.16, 0.14, 0.16], [0.5, 0.08, 0.43], 0x526057);
const led = makeIndicator(g, [0.42, 1.91, 0.72], 0x8ce6a8);
const label = createLabel(app, g, 2.65);
visualById.set(app.id, { led, label });
drawLabel(app, label);
}
// Laundry unit.
{
const app = appliances[1];
const g = group([-1.65, 0, -2.05]);
box(g, [1.55, 1.48, 1.42], [0, 0.76, 0], 0xf0eee5);
box(g, [1.58, 0.14, 1.46], [0, 1.53, 0], 0xfaf8ef);
box(g, [1.18, 0.2, 0.08], [0, 1.31, 0.75], 0xc5cbc4);
// Pixelated washer door.
box(g, [1.03, 0.99, 0.1], [0, 0.74, 0.74], 0x3d4c54);
const rim = 0xb7c4c3;
box(g, [1.06, 0.13, 0.13], [0, 1.12, 0.81], rim);
box(g, [1.06, 0.13, 0.13], [0, 0.36, 0.81], rim);
box(g, [0.13, 0.63, 0.13], [-0.46, 0.74, 0.81], rim);
box(g, [0.13, 0.63, 0.13], [0.46, 0.74, 0.81], rim);
box(g, [0.19, 0.19, 0.13], [-0.4, 1.02, 0.81], rim);
box(g, [0.19, 0.19, 0.13], [0.4, 1.02, 0.81], rim);
box(g, [0.19, 0.19, 0.13], [-0.4, 0.46, 0.81], rim);
box(g, [0.19, 0.19, 0.13], [0.4, 0.46, 0.81], rim);
box(g, [0.63, 0.63, 0.1], [0, 0.74, 0.86], 0x536b78);
const led = makeIndicator(g, [0.55, 1.31, 0.82], 0x8ce6a8);
const label = createLabel(app, g, 2.12);
visualById.set(app.id, { led, label });
drawLabel(app, label);
}
// Cook unit.
{
const app = appliances[3];
const g = group([0.35, 0, -2.03]);
box(g, [1.7, 1.45, 1.42], [0, 0.75, 0], 0xe7e3d9);
box(g, [1.76, 0.13, 1.48], [0, 1.52, 0], 0x41494a);
box(g, [1.36, 0.75, 0.1], [0, 0.49, 0.75], 0x30393b);
box(g, [1.05, 0.09, 0.12], [0, 0.77, 0.83], 0xd8d8ce);
for (const x of [-0.43, 0.43]) {
for (const z of [-0.35, 0.35]) {
box(g, [0.36, 0.06, 0.36], [x, 1.61, z], 0x778080);
box(g, [0.22, 0.07, 0.22], [x, 1.63, z], 0x353d3d);
}
}
for (const x of [-0.48, 0, 0.48]) {
box(g, [0.12, 0.12, 0.12], [x, 1.27, 0.76], 0xd76a4e);
}
const led = makeIndicator(g, [0.68, 1.27, 0.83], 0x8ce6a8);
const label = createLabel(app, g, 2.1);
visualById.set(app.id, { led, label });
drawLabel(app, label);
}
// Screen unit and console.
{
const app = appliances[2];
const g = group([3.05, 0, -2.02]);
box(g, [1.82, 0.64, 0.82], [0, 0.34, 0], 0xb7825e);
box(g, [0.13, 0.34, 0.13], [-0.65, 0.05, 0.26], 0x4b514b);
box(g, [0.13, 0.34, 0.13], [0.65, 0.05, 0.26], 0x4b514b);
box(g, [1.92, 1.13, 0.14], [0, 1.42, -0.03], 0x30383a);
box(g, [1.68, 0.9, 0.08], [0, 1.42, 0.07], 0x243a43);
box(g, [0.55, 0.25, 0.04], [-0.37, 1.27, 0.13], 0xdf865d);
box(g, [0.58, 0.22, 0.04], [0.35, 1.22, 0.13], 0x6faea8);
box(g, [1.22, 0.19, 0.04], [0, 1.08, 0.13], 0x587d71);
box(g, [0.14, 0.32, 0.13], [0, 0.84, 0], 0x343c3c);
box(g, [0.54, 0.08, 0.25], [0, 0.71, 0], 0x343c3c);
const led = makeIndicator(g, [0.74, 0.34, 0.46], 0x8ce6a8);
const label = createLabel(app, g, 2.45);
visualById.set(app.id, { led, label });
drawLabel(app, label);
}
// Wall-mounted air handler.
{
const app = appliances[4];
const g = group([3.05, 2.62, -3.22]);
box(g, [2.16, 0.66, 0.46], [0, 0, 0], 0xeeeae0);
box(g, [1.87, 0.18, 0.1], [0, -0.12, 0.27], 0x5a6263);
for (let i = 0; i < 6; i++) {
box(g, [1.75, 0.025, 0.06], [0, -0.08 + i * 0.045, 0.34], 0x87908d);
}
const led = makeIndicator(g, [0.93, 0.2, 0.3], 0x8ce6a8);
const label = createLabel(app, g, 0.92);
visualById.set(app.id, { led, label });
drawLabel(app, label);
}
// Voxel plant.
{
const g = group([4.05, 0, 1.35]);
box(g, [0.72, 0.66, 0.72], [0, 0.34, 0], 0xc97956);
box(g, [0.78, 0.12, 0.78], [0, 0.69, 0], 0xd58a63);
box(g, [0.1, 0.9, 0.1], [0, 1.05, 0], 0x4e7451);
box(g, [0.62, 0.18, 0.22], [0.23, 1.2, 0], 0x6e9561);
box(g, [0.58, 0.18, 0.22], [-0.2, 1.48, 0], 0x7da46b);
box(g, [0.45, 0.16, 0.22], [0.15, 1.74, 0], 0x5f8959);
}
// Small floor energy meter.
const meterGroup = group([3.72, 0, 0.95]);
box(meterGroup, [0.82, 0.65, 0.55], [0, 0.34, 0], 0x43504b);
box(meterGroup, [0.65, 0.3, 0.08], [0, 0.43, 0.31], 0x24332e);
const meterBars = [];
for (let i = 0; i < 5; i++) {
const material = new THREE.MeshStandardMaterial({
color: 0x73c98b,
emissive: 0x73c98b,
emissiveIntensity: 0.8,
roughness: 0.35
});
const bar = box(
meterGroup,
[0.08, 0.14, 0.05],
[-0.22 + i * 0.11, 0.43, 0.37],
0x73c98b,
{ material }
);
meterBars.push(bar);
}
function updateVisuals() {
for (const app of appliances) {
const visual = visualById.get(app.id);
if (!visual) continue;
visual.led.material.color.set(app.enabled ? 0x8ce6a8 : 0x68736b);
visual.led.material.emissive.set(app.enabled ? 0x71db91 : 0x27372d);
visual.led.material.emissiveIntensity = app.enabled ? 1.5 : 0.08;
drawLabel(app, visual.label);
}
}
// ---------- Direct camera controls ----------
let dragging = false;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("pointerdown", event => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
desired.azimuth -= dx * 0.006;
desired.polar = THREE.MathUtils.clamp(desired.polar + dy * 0.004, 0.54, 1.12);
});
function stopDragging(event) {
dragging = false;
if (event.pointerId !== undefined && renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
desired.zoom = THREE.MathUtils.clamp(
desired.zoom * Math.exp(-event.deltaY * 0.001),
0.72,
1.65
);
}, { passive: false });
function resetCamera() {
desired.azimuth = 0.72;
desired.polar = 0.82;
desired.zoom = 1;
}
document.getElementById("resetCamera").addEventListener("click", resetCamera);
renderer.domElement.addEventListener("dblclick", resetCamera);
function resize() {
const width = Math.max(1, host.clientWidth);
const height = Math.max(1, host.clientHeight);
const aspect = width / height;
const halfHeight = 5.4;
camera.left = -halfHeight * aspect;
camera.right = halfHeight * aspect;
camera.top = halfHeight;
camera.bottom = -halfHeight;
camera.updateProjectionMatrix();
renderer.setSize(width, height, false);
}
new ResizeObserver(resize).observe(host);
resize();
// ---------- Animation ----------
const clock = new THREE.Clock();
let meterLevel = 5;
renderer.setAnimationLoop(() => {
const elapsed = clock.getElapsedTime();
current.azimuth += (desired.azimuth - current.azimuth) * 0.1;
current.polar += (desired.polar - current.polar) * 0.1;
current.zoom += (desired.zoom - current.zoom) * 0.1;
updateCamera();
let index = 0;
for (const app of appliances) {
const visual = visualById.get(app.id);
if (visual && app.enabled) {
visual.led.material.emissiveIntensity =
1.2 + Math.sin(elapsed * 4.2 + index * 1.7) * 0.45;
}
index++;
}
const total = appliances.reduce((sum, app) => sum + dailyUse(app), 0);
const meterRatio = baselineDaily ? total / baselineDaily : 0;
const targetLevel = Math.max(0, Math.min(5, Math.ceil(meterRatio * 5)));
meterLevel += (targetLevel - meterLevel) * 0.1;
for (let i = 0; i < meterBars.length; i++) {
const active = i < meterLevel;
const color = meterRatio > 1.001 ? 0xe9855e : 0x73c98b;
meterBars[i].material.color.set(active ? color : 0x4c5852);
meterBars[i].material.emissive.set(active ? color : 0x000000);
meterBars[i].material.emissiveIntensity = active ? 0.9 : 0;
}
renderer.render(scene, camera);
});
updateModel();
document.getElementById("loading").remove();
</script>
</body>
</html>
```