Prompt specification
Build or customize the Three.js 3D scene "Ambiguous Package Delivery Note" 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: Ambiguous Package Delivery Note
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/ambiguous-package-delivery-note-x3363
Scene Description Prompt:
I'd like to see this as a voxel Three.js scene: ambiguous package delivery note. Build a hallway with two similar doors and an underspecified fictional delivery note. Highlight possible destinations and show which additional detail resolves the uncertainty. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (ambiguous-package-delivery-note-x3363):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Ambiguous Package Delivery — Voxel Three.js</title>
<style>
:root {
--ink: #24332f;
--muted: #6f7c77;
--paper: #fffdf4;
--panel: rgba(255, 253, 244, 0.94);
--line: rgba(36, 51, 47, 0.13);
--amber: #e8a83d;
--amber-soft: #fff0cf;
--green: #27856c;
--green-soft: #dff3e9;
--gray: #9aa6a1;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce6e1;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button { font: inherit; }
#app, #scene {
position: relative;
width: 100%;
height: 100%;
}
canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
}
.topbar {
position: absolute;
z-index: 5;
top: 22px;
left: 24px;
right: 24px;
display: grid;
grid-template-columns: 1fr auto 1fr;
align-items: center;
gap: 20px;
pointer-events: none;
}
.brand {
display: flex;
align-items: center;
gap: 11px;
font-size: 12px;
font-weight: 850;
letter-spacing: 0.15em;
}
.brand-mark {
width: 30px;
height: 30px;
border: 2px solid var(--ink);
border-radius: 7px;
position: relative;
background: rgba(255, 253, 244, 0.72);
box-shadow: 3px 3px 0 rgba(36, 51, 47, 0.13);
}
.brand-mark::before {
content: "";
position: absolute;
left: 5px;
top: 8px;
width: 16px;
height: 2px;
background: var(--ink);
box-shadow: 0 5px 0 var(--ink);
}
.case-title {
padding: 10px 15px;
border: 1px solid rgba(36, 51, 47, 0.14);
border-radius: 999px;
background: rgba(255, 253, 244, 0.77);
backdrop-filter: blur(12px);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
white-space: nowrap;
box-shadow: 0 7px 24px rgba(41, 62, 54, 0.07);
}
.case-title span {
color: var(--muted);
margin: 0 7px;
}
.badge {
justify-self: end;
display: flex;
align-items: center;
gap: 9px;
padding: 10px 14px;
border-radius: 999px;
border: 1px solid rgba(174, 121, 29, 0.22);
background: var(--amber-soft);
color: #8a5c13;
font-size: 11px;
font-weight: 850;
letter-spacing: 0.06em;
text-transform: uppercase;
box-shadow: 0 7px 24px rgba(41, 62, 54, 0.07);
transition: 220ms ease;
}
.badge::before {
content: "";
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--amber);
box-shadow: 0 0 0 4px rgba(232, 168, 61, 0.18);
}
.badge.resolved {
color: var(--green);
border-color: rgba(39, 133, 108, 0.22);
background: var(--green-soft);
}
.badge.resolved::before {
background: var(--green);
box-shadow: 0 0 0 4px rgba(39, 133, 108, 0.15);
}
.panel {
position: absolute;
z-index: 4;
border: 1px solid rgba(36, 51, 47, 0.13);
background: var(--panel);
backdrop-filter: blur(15px);
box-shadow: 0 18px 55px rgba(37, 57, 49, 0.13);
border-radius: 18px;
}
.note-panel {
top: 94px;
left: 24px;
width: 302px;
padding: 18px;
}
.panel-kicker,
.analysis-label {
color: var(--muted);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.note-paper {
position: relative;
min-height: 218px;
margin-top: 13px;
padding: 21px 22px 18px;
overflow: hidden;
color: #3d3b31;
background:
linear-gradient(rgba(112, 94, 56, 0.035) 1px, transparent 1px) 0 31px / 100% 31px,
#fff6cf;
border: 1px solid rgba(119, 93, 43, 0.16);
border-radius: 4px 4px 9px 4px;
box-shadow: 0 8px 18px rgba(75, 62, 35, 0.09);
transform: rotate(-0.7deg);
font-family: "Courier New", monospace;
}
.note-paper::before {
content: "";
position: absolute;
left: 50%;
top: -11px;
width: 74px;
height: 24px;
transform: translateX(-50%) rotate(1deg);
background: rgba(221, 207, 157, 0.72);
border-left: 1px dashed rgba(97, 78, 39, 0.12);
border-right: 1px dashed rgba(97, 78, 39, 0.12);
}
.note-to {
font-size: 10px;
font-weight: 700;
letter-spacing: 0.17em;
}
.note-address {
margin: 5px 0 13px;
font-size: 25px;
font-weight: 800;
letter-spacing: 0.02em;
}
.note-rule {
height: 1px;
margin: 0 0 14px;
background: rgba(78, 66, 39, 0.2);
}
.note-instruction {
font-size: 15px;
line-height: 1.45;
}
.note-signature {
margin-top: 22px;
text-align: right;
font-size: 13px;
}
.note-stamp {
position: absolute;
right: 14px;
bottom: 12px;
padding: 4px 7px;
border: 2px solid rgba(167, 67, 49, 0.55);
color: rgba(167, 67, 49, 0.72);
font-family: ui-sans-serif, system-ui, sans-serif;
font-size: 9px;
font-weight: 900;
letter-spacing: 0.11em;
transform: rotate(-5deg);
}
.note-explanation {
margin: 16px 2px 2px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.note-explanation b { color: var(--ink); }
.analysis-panel {
top: 94px;
right: 24px;
width: 330px;
padding: 19px;
}
.analysis-panel h1 {
margin: 5px 0 16px;
font-size: 21px;
line-height: 1.15;
letter-spacing: -0.035em;
}
.candidate-list {
display: grid;
gap: 9px;
}
.candidate {
width: 100%;
display: grid;
grid-template-columns: 12px 1fr auto;
align-items: center;
gap: 10px;
padding: 12px;
border: 1px solid rgba(232, 168, 61, 0.26);
border-radius: 11px;
background: var(--amber-soft);
color: var(--ink);
text-align: left;
cursor: pointer;
transition: transform 160ms ease, box-shadow 160ms ease, background 220ms ease;
}
.candidate:hover {
transform: translateY(-1px);
box-shadow: 0 7px 16px rgba(62, 73, 54, 0.08);
}
.candidate-dot {
width: 9px;
height: 9px;
border-radius: 50%;
background: var(--amber);
box-shadow: 0 0 0 4px rgba(232, 168, 61, 0.16);
}
.candidate-code {
display: block;
font-size: 14px;
font-weight: 850;
}
.candidate-copy {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 10px;
}
.candidate-state {
color: #9a6716;
font-size: 9px;
font-weight: 900;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.candidate.confirmed {
border-color: rgba(39, 133, 108, 0.25);
background: var(--green-soft);
}
.candidate.confirmed .candidate-dot {
background: var(--green);
box-shadow: 0 0 0 4px rgba(39, 133, 108, 0.15);
}
.candidate.confirmed .candidate-state { color: var(--green); }
.candidate.eliminated {
border-color: rgba(36, 51, 47, 0.11);
background: rgba(235, 237, 231, 0.78);
opacity: 0.66;
}
.candidate.eliminated .candidate-dot {
background: var(--gray);
box-shadow: none;
}
.candidate.eliminated .candidate-state { color: var(--muted); }
.missing-box,
.clarification {
margin-top: 14px;
padding: 13px 14px;
border-radius: 11px;
}
.missing-box {
border: 1px dashed rgba(36, 51, 47, 0.28);
background: rgba(245, 244, 237, 0.75);
}
.missing-box strong,
.clarification strong {
display: block;
margin-top: 5px;
font-size: 14px;
}
.missing-box p,
.clarification p {
margin: 5px 0 0;
color: var(--muted);
font-size: 11px;
line-height: 1.45;
}
.clarification {
border: 1px solid rgba(39, 133, 108, 0.24);
background: var(--green-soft);
animation: reveal 420ms ease both;
}
.clarification .analysis-label { color: var(--green); }
@keyframes reveal {
from { opacity: 0; transform: translateY(7px); }
to { opacity: 1; transform: translateY(0); }
}
.primary-button {
width: 100%;
margin-top: 14px;
padding: 12px 14px;
border: 0;
border-radius: 11px;
background: var(--ink);
color: #fffdf4;
font-size: 12px;
font-weight: 800;
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
transition: transform 160ms ease, background 160ms ease;
}
.primary-button:hover {
transform: translateY(-1px);
background: #172520;
}
.primary-button span {
font-size: 18px;
line-height: 0;
}
.legend {
position: absolute;
z-index: 3;
left: 24px;
bottom: 22px;
display: flex;
gap: 14px;
padding: 10px 13px;
border: 1px solid rgba(36, 51, 47, 0.12);
border-radius: 10px;
background: rgba(255, 253, 244, 0.78);
backdrop-filter: blur(10px);
font-size: 10px;
font-weight: 750;
color: var(--muted);
}
.legend span {
display: flex;
align-items: center;
gap: 6px;
}
.swatch {
width: 8px;
height: 8px;
border-radius: 2px;
background: var(--amber);
}
.swatch.green { background: var(--green); }
.swatch.gray { background: var(--gray); }
.camera-hint {
position: absolute;
z-index: 3;
right: 24px;
bottom: 24px;
color: rgba(36, 51, 47, 0.61);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.03em;
pointer-events: none;
}
.toast {
position: absolute;
z-index: 8;
left: 50%;
bottom: 25px;
max-width: min(460px, calc(100vw - 30px));
padding: 11px 15px;
border-radius: 10px;
background: rgba(31, 44, 40, 0.92);
color: #fffdf4;
font-size: 11px;
font-weight: 650;
line-height: 1.4;
text-align: center;
opacity: 0;
transform: translate(-50%, 12px);
pointer-events: none;
transition: 200ms ease;
}
.toast.show {
opacity: 1;
transform: translate(-50%, 0);
}
[hidden] { display: none !important; }
@media (max-width: 980px) {
.topbar {
grid-template-columns: 1fr auto;
}
.case-title { display: none; }
.note-panel {
top: 80px;
left: 16px;
width: 270px;
padding: 14px;
}
.note-paper {
min-height: 180px;
padding: 17px;
}
.note-address { font-size: 21px; }
.analysis-panel {
top: auto;
right: 16px;
bottom: 16px;
width: 305px;
}
.legend { display: none; }
.camera-hint { display: none; }
}
@media (max-width: 620px) {
.topbar {
top: 12px;
left: 12px;
right: 12px;
}
.brand { font-size: 10px; }
.badge { padding: 8px 10px; font-size: 9px; }
.note-panel {
top: 64px;
left: 12px;
width: 218px;
padding: 11px;
}
.note-paper {
min-height: 135px;
padding: 14px;
}
.note-address {
margin-bottom: 8px;
font-size: 18px;
}
.note-instruction { font-size: 12px; }
.note-signature { margin-top: 12px; }
.note-explanation { display: none; }
.analysis-panel {
left: 12px;
right: 12px;
bottom: 12px;
width: auto;
padding: 13px;
}
.analysis-panel h1 {
margin: 3px 0 10px;
font-size: 17px;
}
.candidate-list {
grid-template-columns: 1fr 1fr;
gap: 6px;
}
.candidate {
padding: 9px;
grid-template-columns: 9px 1fr;
}
.candidate-state { display: none; }
.missing-box, .clarification { margin-top: 9px; padding: 10px; }
.primary-button { margin-top: 9px; padding: 10px 12px; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
scroll-behavior: auto !important;
animation-duration: 0.001ms !important;
transition-duration: 0.001ms !important;
}
}
</style>
</head>
<body>
<main id="app">
<div id="scene"></div>
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<span>ROUTE / UNKNOWN</span>
</div>
<div class="case-title">
CASE 04 <span>—</span> AMBIGUOUS PACKAGE DELIVERY
</div>
<div id="statusBadge" class="badge ambiguous">
<span id="statusText">2 possible destinations</span>
</div>
</header>
<section class="panel note-panel" aria-label="Fictional delivery note">
<div class="panel-kicker">Delivery note · fictional</div>
<div class="note-paper">
<div class="note-to">TO</div>
<div class="note-address">APT. 12</div>
<div class="note-rule"></div>
<div class="note-instruction">Leave at the door.<br />Thanks, M.</div>
<div class="note-signature">— Mara</div>
<div class="note-stamp">INCOMPLETE</div>
</div>
<p class="note-explanation">
“12” matches both <b>12A</b> and <b>12B</b>. The note doesn’t identify
a unique door.
</p>
</section>
<section class="panel analysis-panel" aria-live="polite">
<div class="analysis-label">Destination analysis</div>
<h1>Which door is apartment 12?</h1>
<div class="candidate-list">
<button class="candidate" data-door="12A" type="button">
<span class="candidate-dot"></span>
<span>
<span class="candidate-code">Door 12A</span>
<span class="candidate-copy">Matches “12”</span>
</span>
<span class="candidate-state">Possible</span>
</button>
<button class="candidate" data-door="12B" type="button">
<span class="candidate-dot"></span>
<span>
<span class="candidate-code">Door 12B</span>
<span class="candidate-copy">Matches “12”</span>
</span>
<span class="candidate-state">Possible</span>
</button>
</div>
<div id="missingBox" class="missing-box">
<div class="analysis-label">Missing detail</div>
<strong>Exact unit suffix</strong>
<p>The A or B suffix is needed to distinguish the two doors.</p>
</div>
<div id="clarification" class="clarification" hidden>
<div class="analysis-label">Additional detail</div>
<strong>“Unit 12B”</strong>
<p>This exact unit identifier eliminates 12A and confirms 12B.</p>
</div>
<button id="revealButton" class="primary-button" type="button">
<span id="buttonLabel">Reveal clarifying detail</span>
<span aria-hidden="true">→</span>
</button>
</section>
<div class="legend" aria-label="Scene legend">
<span><i class="swatch"></i> Possible</span>
<span><i class="swatch green"></i> Confirmed</span>
<span><i class="swatch gray"></i> Eliminated</span>
</div>
<div class="camera-hint">Drag to orbit · Scroll to zoom · Click a door to inspect</div>
<div id="toast" class="toast" role="status"></div>
</main>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const sceneHost = document.querySelector("#scene");
const statusBadge = document.querySelector("#statusBadge");
const statusText = document.querySelector("#statusText");
const missingBox = document.querySelector("#missingBox");
const clarification = document.querySelector("#clarification");
const revealButton = document.querySelector("#revealButton");
const buttonLabel = document.querySelector("#buttonLabel");
const toast = document.querySelector("#toast");
const candidateButtons = [...document.querySelectorAll(".candidate")];
const state = {
resolved: false,
hovered: null
};
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce6e1);
scene.fog = new THREE.Fog(0xdce6e1, 22, 39);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
60
);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.8));
renderer.setSize(window.innerWidth, window.innerHeight);
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", "Interactive voxel hallway with doors 12A and 12B");
renderer.domElement.setAttribute("role", "img");
sceneHost.appendChild(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xfffbef, 0x6e8278, 2.1);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff3d8, 3.2);
sun.position.set(8, 13, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -12;
sun.shadow.camera.right = 12;
sun.shadow.camera.top = 12;
sun.shadow.camera.bottom = -12;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.bias = -0.0007;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb9d8dc, 0.9);
fill.position.set(-8, 7, 3);
scene.add(fill);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const pickTargets = [];
const doorVisuals = {};
function material(color, roughness = 0.82, metalness = 0) {
return new THREE.MeshStandardMaterial({ color, roughness, metalness });
}
function box(parent, w, h, d, color, x, y, z, options = {}) {
const mesh = new THREE.Mesh(
unitBox,
options.material || material(color, options.roughness ?? 0.82, options.metalness ?? 0)
);
mesh.scale.set(w, h, d);
mesh.position.set(x, y, z);
mesh.castShadow = options.castShadow ?? true;
mesh.receiveShadow = options.receiveShadow ?? true;
parent.add(mesh);
return mesh;
}
function canvasTexture(width, height, draw) {
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext("2d");
draw(ctx, width, height);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return texture;
}
function textPlane(text, width, height, options = {}) {
const texture = canvasTexture(1024, 256, (ctx, w, h) => {
if (options.background) {
ctx.fillStyle = options.background;
ctx.fillRect(0, 0, w, h);
} else {
ctx.clearRect(0, 0, w, h);
}
if (options.border) {
ctx.strokeStyle = options.border;
ctx.lineWidth = options.borderWidth || 10;
ctx.strokeRect(10, 10, w - 20, h - 20);
}
ctx.fillStyle = options.color || "#ffffff";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = `${options.weight || 800} ${options.fontSize || 110}px ${
options.font || "monospace"
}`;
ctx.fillText(text, w / 2, h / 2 + (options.offsetY || 0));
});
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({
map: texture,
transparent: !options.background,
depthWrite: !!options.background
})
);
return mesh;
}
// Hallway shell
box(scene, 11.1, 0.38, 12.2, 0x9baba4, 0, -0.21, 0);
const tileColors = [0xd9d4c7, 0xe3ded2, 0xd4d2c7, 0xded8ca];
for (let x = 0; x < 10; x++) {
for (let z = 0; z < 11; z++) {
const color = tileColors[(x * 3 + z * 2) % tileColors.length];
box(
scene,
1.015,
0.09,
1.015,
color,
-4.5 + x,
0.005,
-5 + z,
{ castShadow: false }
);
}
}
box(scene, 11.1, 4.35, 0.38, 0xe7e2d5, 0, 2.16, -5.22);
box(scene, 0.38, 4.35, 10.45, 0xd5ddd5, -5.35, 2.16, -0.02);
box(scene, 11.08, 0.22, 0.14, 0x73857d, 0, 0.19, -4.98);
box(scene, 0.14, 0.22, 10.2, 0x73857d, -5.12, 0.19, -0.02);
// Subtle wall blocks and trim
for (let i = 0; i < 8; i++) {
box(
scene,
0.018,
3.75,
0.06,
i % 2 ? 0xdfdacd : 0xe3ded1,
-4.9 + i * 1.37,
2.18,
-4.995,
{ castShadow: false }
);
}
// Hallway sign
const hallSign = textPlane("LEVEL 01 / RESIDENTIAL", 3.35, 0.43, {
background: "#344641",
border: "#73847e",
borderWidth: 7,
color: "#f8f2df",
fontSize: 64,
font: "Arial"
});
hallSign.position.set(0, 3.87, -4.985);
scene.add(hallSign);
function createDoor(code, x) {
const group = new THREE.Group();
group.position.x = x;
scene.add(group);
box(group, 2.12, 3.17, 0.2, 0x445752, 0, 1.71, -4.9);
box(group, 1.78, 2.86, 0.18, 0x617c79, 0, 1.67, -4.74);
// Identical inset panels keep the doors deliberately similar.
box(group, 1.39, 1.05, 0.055, 0x67837f, 0, 2.26, -4.625);
box(group, 1.39, 1.12, 0.055, 0x67837f, 0, 1.08, -4.625);
box(group, 0.12, 0.42, 0.12, 0xb99b57, 0.62, 1.55, -4.56, {
metalness: 0.5,
roughness: 0.35
});
box(group, 0.075, 0.075, 0.08, 0x343b35, 0.62, 1.55, -4.48);
box(group, 0.12, 0.27, 0.1, 0x8b9d95, -0.61, 1.52, -4.58);
box(group, 0.16, 0.025, 0.04, 0x455750, -0.61, 1.52, -4.51);
const plaque = textPlane(code, 0.82, 0.32, {
background: "#d8d1b8",
border: "#8e917e",
borderWidth: 5,
color: "#30413c",
fontSize: 98
});
plaque.position.set(0, 2.66, -4.605);
group.add(plaque);
// Highlight frame
const frameMaterial = material(0xe8a83d, 0.55);
frameMaterial.emissive = new THREE.Color(0xe8a83d);
frameMaterial.emissiveIntensity = 0.42;
box(group, 2.24, 0.09, 0.09, 0xffffff, 0, 3.35, -4.52, {
material: frameMaterial
});
box(group, 2.24, 0.09, 0.09, 0xffffff, 0, 0.08, -4.52, {
material: frameMaterial
});
box(group, 0.09, 3.36, 0.09, 0xffffff, -1.075, 1.715, -4.52, {
material: frameMaterial
});
box(group, 0.09, 3.36, 0.09, 0xffffff, 1.075, 1.715, -4.52, {
material: frameMaterial
});
// Doorway pool on the floor
const poolMaterial = new THREE.MeshBasicMaterial({
color: 0xe8a83d,
transparent: true,
opacity: 0.13,
depthWrite: false,
side: THREE.DoubleSide
});
const pool = new THREE.Mesh(new THREE.PlaneGeometry(2.75, 1.8), poolMaterial);
pool.rotation.x = -Math.PI / 2;
pool.position.set(0, 0.075, -3.55);
group.add(pool);
// Invisible, generous click target
const hit = new THREE.Mesh(
new THREE.BoxGeometry(1.85, 2.95, 0.3),
new THREE.MeshBasicMaterial({ transparent: true, opacity: 0, depthWrite: false })
);
hit.position.set(0, 1.66, -4.56);
hit.userData.doorCode = code;
group.add(hit);
pickTargets.push(hit);
doorVisuals[code] = {
group,
frameMaterial,
poolMaterial,
frameTarget: new THREE.Color(0xe8a83d),
poolTarget: new THREE.Color(0xe8a83d),
intensityTarget: 0.42,
opacityTarget: 0.13
};
}
createDoor("12A", -2.18);
createDoor("12B", 2.18);
// Package and its underspecified note
const parcel = new THREE.Group();
parcel.position.set(0, 0, 1.28);
scene.add(parcel);
box(parcel, 1.35, 0.92, 1.12, 0xb9884f, 0, 0.51, 0);
box(parcel, 0.17, 0.015, 1.13, 0xd9bc83, 0, 0.975, 0, {
castShadow: false
});
box(parcel, 1.36, 0.17, 0.02, 0xd9bc83, 0, 0.51, 0.566, {
castShadow: false
});
box(parcel, 0.16, 0.92, 0.025, 0xd9bc83, -0.38, 0.51, 0.566, {
castShadow: false
});
const packageNoteTexture = canvasTexture(512, 384, (ctx, w, h) => {
ctx.fillStyle = "#fff5cd";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = "#4d493a";
ctx.font = "700 35px monospace";
ctx.fillText("DELIVERY", 34, 58);
ctx.font = "800 68px monospace";
ctx.fillText("APT. 12", 34, 138);
ctx.fillRect(34, 176, 420, 4);
ctx.font = "700 29px monospace";
ctx.fillText("LEAVE AT DOOR", 34, 228);
ctx.font = "500 23px monospace";
ctx.fillText("note #M-17", 34, 322);
});
const packageNote = new THREE.Mesh(
new THREE.PlaneGeometry(1.08, 0.81),
new THREE.MeshBasicMaterial({ map: packageNoteTexture })
);
packageNote.position.set(0.12, 0.55, 0.585);
parcel.add(packageNote);
// Confirmed route, hidden until clarification appears
const route = new THREE.Group();
scene.add(route);
const routeMaterial = new THREE.MeshBasicMaterial({
color: 0x27856c,
transparent: true,
opacity: 0.76
});
for (let i = 0; i < 8; i++) {
box(route, 0.28, 0.055, 0.48, 0xffffff, 0, 0.11, 0.7 - i * 0.56, {
material: routeMaterial,
castShadow: false
});
}
for (let i = 0; i < 8; i++) {
box(route, 0.31, 0.055, 0.28, 0xffffff, 0.18 + i * 0.285, 0.11, -3.46, {
material: routeMaterial,
castShadow: false
});
}
route.visible = false;
// Voxel bench
const bench = new THREE.Group();
bench.position.set(-3.95, 0, 0.8);
scene.add(bench);
box(bench, 1.25, 0.18, 2.0, 0x80664a, 0, 0.7, 0);
box(bench, 1.25, 0.75, 0.16, 0x80664a, 0, 1.08, -0.86);
box(bench, 0.16, 0.62, 0.16, 0x45544e, -0.47, 0.33, -0.72);
box(bench, 0.16, 0.62, 0.16, 0x45544e, 0.47, 0.33, -0.72);
box(bench, 0.16, 0.62, 0.16, 0x45544e, -0.47, 0.33, 0.72);
box(bench, 0.16, 0.62, 0.16, 0x45544e, 0.47, 0.33, 0.72);
// Voxel plant
const plant = new THREE.Group();
plant.position.set(4.05, 0, -2.45);
scene.add(plant);
box(plant, 0.7, 0.68, 0.7, 0xa86f50, 0, 0.36, 0);
box(plant, 0.56, 0.08, 0.56, 0x76503e, 0, 0.69, 0);
box(plant, 0.12, 1.25, 0.12, 0x506b4f, 0, 1.16, 0);
box(plant, 0.68, 0.23, 0.28, 0x587957, -0.2, 1.25, 0);
box(plant, 0.28, 0.25, 0.7, 0x678961, 0.2, 1.55, 0);
box(plant, 0.56, 0.21, 0.25, 0x6f925f, 0, 1.85, 0);
// Wall sconces
for (const x of [-4.22, 4.22]) {
box(scene, 0.19, 0.55, 0.22, 0x40524d, x, 2.85, -4.81);
box(scene, 0.28, 0.29, 0.26, 0xffe0a0, x, 2.89, -4.65, {
roughness: 0.35
});
}
// Small voxel rug
box(scene, 3.5, 0.025, 4.5, 0x81958a, 0, 0.075, 0.05, {
castShadow: false
});
box(scene, 3.2, 0.03, 4.2, 0x9cad9f, 0, 0.082, 0.05, {
castShadow: false
});
// Custom orbit camera controls: no external controls addon.
const controls = {
yaw: 0.39,
pitch: 0.58,
radius: 18.2,
targetYaw: 0.39,
targetPitch: 0.58,
targetRadius: 18.2,
target: new THREE.Vector3(0, 1.35, -0.15)
};
function updateCamera() {
const cp = Math.cos(controls.pitch);
camera.position.set(
controls.target.x + controls.radius * Math.sin(controls.yaw) * cp,
controls.target.y + controls.radius * Math.sin(controls.pitch),
controls.target.z + controls.radius * Math.cos(controls.yaw) * cp
);
camera.lookAt(controls.target);
}
let dragging = false;
let dragMoved = 0;
let lastPointerX = 0;
let lastPointerY = 0;
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
function updatePointer(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 pickDoor(event) {
updatePointer(event);
raycaster.setFromCamera(pointer, camera);
const hit = raycaster.intersectObjects(pickTargets, false)[0];
return hit ? hit.object.userData.doorCode : null;
}
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
dragMoved = 0;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (dragging) {
const dx = event.clientX - lastPointerX;
const dy = event.clientY - lastPointerY;
dragMoved += Math.abs(dx) + Math.abs(dy);
controls.targetYaw -= dx * 0.006;
controls.targetPitch = THREE.MathUtils.clamp(
controls.targetPitch + dy * 0.005,
0.28,
1.02
);
lastPointerX = event.clientX;
lastPointerY = event.clientY;
renderer.domElement.style.cursor = "grabbing";
} else {
state.hovered = pickDoor(event);
renderer.domElement.style.cursor = state.hovered ? "pointer" : "grab";
}
});
renderer.domElement.addEventListener("pointerup", (event) => {
dragging = false;
renderer.domElement.style.cursor = "grab";
if (dragMoved < 6) {
const code = pickDoor(event);
if (code) inspectDoor(code);
}
});
renderer.domElement.addEventListener("pointercancel", () => {
dragging = false;
renderer.domElement.style.cursor = "grab";
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.targetRadius = THREE.MathUtils.clamp(
controls.targetRadius + event.deltaY * 0.012,
12,
25
);
},
{ passive: false }
);
renderer.domElement.style.cursor = "grab";
let toastTimer;
function showToast(message) {
clearTimeout(toastTimer);
toast.textContent = message;
toast.classList.add("show");
toastTimer = setTimeout(() => toast.classList.remove("show"), 2600);
}
function inspectDoor(code) {
if (!state.resolved) {
showToast(
`Door ${code} is possible — the note still omits the exact unit suffix.`
);
} else if (code === "12B") {
showToast("Door 12B confirmed — the additional detail specifies “Unit 12B”.");
} else {
showToast("Door 12A eliminated — the additional detail specifies “Unit 12B”.");
}
}
candidateButtons.forEach((button) => {
button.addEventListener("click", () => inspectDoor(button.dataset.door));
});
const amber = new THREE.Color(0xe8a83d);
const green = new THREE.Color(0x27856c);
const gray = new THREE.Color(0x9aa6a1);
function applyVisualTargets() {
for (const code of ["12A", "12B"]) {
const visual = doorVisuals[code];
if (!state.resolved) {
visual.frameTarget.copy(amber);
visual.poolTarget.copy(amber);
visual.intensityTarget = 0.42;
visual.opacityTarget = 0.13;
} else if (code === "12B") {
visual.frameTarget.copy(green);
visual.poolTarget.copy(green);
visual.intensityTarget = 0.68;
visual.opacityTarget = 0.23;
} else {
visual.frameTarget.copy(gray);
visual.poolTarget.copy(gray);
visual.intensityTarget = 0.03;
visual.opacityTarget = 0.045;
}
}
}
function updateUI() {
const doorA = candidateButtons.find((button) => button.dataset.door === "12A");
const doorB = candidateButtons.find((button) => button.dataset.door === "12B");
doorA.classList.remove("possible", "confirmed", "eliminated");
doorB.classList.remove("possible", "confirmed", "eliminated");
if (!state.resolved) {
statusBadge.className = "badge ambiguous";
statusText.textContent = "2 possible destinations";
missingBox.hidden = false;
clarification.hidden = true;
buttonLabel.textContent = "Reveal clarifying detail";
for (const button of candidateButtons) {
button.classList.add("possible");
button.querySelector(".candidate-copy").textContent = "Matches “12”";
button.querySelector(".candidate-state").textContent = "Possible";
}
} else {
statusBadge.className = "badge resolved";
statusText.textContent = "Destination resolved";
missingBox.hidden = true;
clarification.hidden = false;
buttonLabel.textContent = "Replay ambiguous note";
doorA.classList.add("eliminated");
doorA.querySelector(".candidate-copy").textContent = "Does not match “Unit 12B”";
doorA.querySelector(".candidate-state").textContent = "Eliminated";
doorB.classList.add("confirmed");
doorB.querySelector(".candidate-copy").textContent = "Exact unit confirmed";
doorB.querySelector(".candidate-state").textContent = "Confirmed";
}
applyVisualTargets();
}
revealButton.addEventListener("click", () => {
state.resolved = !state.resolved;
route.visible = state.resolved;
updateUI();
if (state.resolved) {
showToast("Additional detail received: “Unit 12B.” One destination is now confirmed.");
} else {
showToast("Note restored: both 12A and 12B remain possible.");
}
});
updateUI();
updateCamera();
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.8));
});
const clock = new THREE.Clock();
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
const easing = 1 - Math.pow(0.001, delta);
controls.yaw = THREE.MathUtils.lerp(controls.yaw, controls.targetYaw, easing);
controls.pitch = THREE.MathUtils.lerp(controls.pitch, controls.targetPitch, easing);
controls.radius = THREE.MathUtils.lerp(controls.radius, controls.targetRadius, easing);
updateCamera();
for (const code of ["12A", "12B"]) {
const visual = doorVisuals[code];
visual.frameMaterial.color.lerp(visual.frameTarget, easing);
visual.frameMaterial.emissive.lerp(visual.frameTarget, easing);
visual.frameMaterial.emissiveIntensity = THREE.MathUtils.lerp(
visual.frameMaterial.emissiveIntensity,
visual.intensityTarget,
easing
);
visual.poolMaterial.color.lerp(visual.poolTarget, easing);
visual.poolMaterial.opacity = THREE.MathUtils.lerp(
visual.poolMaterial.opacity,
visual.opacityTarget,
easing
);
}
if (route.visible) {
route.children.forEach((tile, index) => {
const phase = THREE.MathUtils.clamp((clock.elapsedTime * 1.8 - index * 0.045) % 1.2, 0, 1);
const pulse = 0.85 + Math.sin(phase * Math.PI) * 0.15;
tile.scale.x = pulse;
tile.scale.z = pulse;
});
}
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```