Prompt specification
Build or customize the Three.js 3D scene "Reference Repair Dialogue Board" 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: Reference Repair Dialogue Board
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/reference-repair-dialogue-board-x3412
Scene Description Prompt:
I'd like to see this as a low-poly Three.js scene: reference repair dialogue board. Create a scene where a robot asks for clarification when several objects satisfy an instruction. Update the selected target only after a distinguishing property is supplied. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (reference-repair-dialogue-board-x3412):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Reference Repair Dialogue Board</title>
<style>
:root {
color-scheme: dark;
--bg: #07101c;
--panel: #0c1727;
--panel-2: #111f32;
--line: rgba(150, 184, 216, 0.16);
--text: #edf6ff;
--muted: #8ea4ba;
--cyan: #63e6d8;
--amber: #ffc857;
--red: #ff6b78;
--blue: #69a9ff;
}
* { box-sizing: border-box; }
html, body {
margin: 0;
min-height: 100%;
background: var(--bg);
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body { overflow: hidden; }
button, input { font: inherit; }
button {
color: inherit;
cursor: pointer;
}
button:focus-visible,
input:focus-visible {
outline: 2px solid var(--cyan);
outline-offset: 2px;
}
[hidden] { display: none !important; }
#app {
height: 100vh;
height: 100dvh;
display: grid;
grid-template-rows: 72px minmax(0, 1fr);
}
header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
padding: 0 24px;
border-bottom: 1px solid var(--line);
background: rgba(7, 16, 28, 0.96);
z-index: 10;
}
.brand {
display: flex;
align-items: center;
gap: 14px;
min-width: 0;
}
.brand-mark {
width: 38px;
height: 38px;
border: 1px solid rgba(99, 230, 216, 0.45);
border-radius: 11px;
display: grid;
place-items: center;
background:
linear-gradient(135deg, rgba(99, 230, 216, 0.18), rgba(105, 169, 255, 0.08));
box-shadow: inset 0 0 20px rgba(99, 230, 216, 0.08);
flex: 0 0 auto;
}
.brand-mark::before {
content: "";
width: 15px;
height: 15px;
border: 3px solid var(--cyan);
border-radius: 4px;
transform: rotate(45deg);
}
.brand-copy { min-width: 0; }
.brand-copy strong {
display: block;
font-size: 14px;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.brand-copy span {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 12px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.header-status {
display: flex;
align-items: center;
gap: 9px;
color: var(--muted);
font-size: 11px;
letter-spacing: 0.1em;
text-transform: uppercase;
white-space: nowrap;
}
.status-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--cyan);
box-shadow: 0 0 12px var(--cyan);
}
main {
display: grid;
grid-template-columns: minmax(0, 1fr) 410px;
min-height: 0;
}
#viewport {
position: relative;
min-width: 0;
min-height: 0;
overflow: hidden;
background: #091522;
border-right: 1px solid var(--line);
}
#viewport canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
cursor: grab;
z-index: 0;
}
#viewport canvas:active { cursor: grabbing; }
.scene-overlay {
position: absolute;
z-index: 2;
pointer-events: none;
}
.scene-title {
top: 22px;
left: 22px;
padding: 12px 14px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(8, 20, 33, 0.76);
backdrop-filter: blur(12px);
box-shadow: 0 14px 40px rgba(0, 0, 0, 0.18);
}
.scene-title .eyebrow {
color: var(--muted);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.scene-title strong {
display: block;
margin-top: 5px;
font-size: 14px;
letter-spacing: 0.03em;
}
#scenePill {
display: inline-flex;
align-items: center;
gap: 7px;
margin-top: 9px;
padding: 5px 8px;
border-radius: 999px;
color: var(--cyan);
background: rgba(99, 230, 216, 0.09);
border: 1px solid rgba(99, 230, 216, 0.22);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
#scenePill.ambiguous {
color: var(--amber);
background: rgba(255, 200, 87, 0.1);
border-color: rgba(255, 200, 87, 0.3);
}
.scene-help {
left: 22px;
bottom: 20px;
color: rgba(204, 222, 238, 0.65);
font-size: 10px;
letter-spacing: 0.04em;
}
.scene-help kbd {
display: inline-block;
margin: 0 3px;
padding: 3px 6px;
border: 1px solid var(--line);
border-radius: 5px;
background: rgba(10, 25, 41, 0.75);
color: #c8d9e8;
font: inherit;
}
#loading {
position: absolute;
inset: 0;
z-index: 5;
display: grid;
place-items: center;
color: var(--muted);
background: #091522;
font-size: 12px;
letter-spacing: 0.14em;
text-transform: uppercase;
}
aside {
min-height: 0;
display: flex;
flex-direction: column;
background: linear-gradient(180deg, #0b1726 0%, #091421 100%);
}
.panel-head {
padding: 20px 20px 15px;
border-bottom: 1px solid var(--line);
}
.panel-head-row {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
}
.section-label {
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
h1 {
margin: 5px 0 0;
font-size: 19px;
font-weight: 680;
letter-spacing: -0.02em;
}
.lock-badge {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 6px 8px;
border-radius: 8px;
color: var(--amber);
background: rgba(255, 200, 87, 0.08);
border: 1px solid rgba(255, 200, 87, 0.22);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
white-space: nowrap;
}
.target-card {
margin-top: 16px;
padding: 13px 14px;
display: grid;
grid-template-columns: 34px minmax(0, 1fr) auto;
align-items: center;
gap: 11px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(17, 31, 50, 0.72);
}
.target-icon {
width: 34px;
height: 34px;
border-radius: 9px;
display: grid;
place-items: center;
background: rgba(142, 164, 186, 0.1);
border: 1px solid var(--line);
color: var(--muted);
font-size: 17px;
}
.target-card.confirmed .target-icon {
color: var(--cyan);
background: rgba(99, 230, 216, 0.1);
border-color: rgba(99, 230, 216, 0.28);
}
.target-card.pending .target-icon {
color: var(--amber);
background: rgba(255, 200, 87, 0.1);
border-color: rgba(255, 200, 87, 0.25);
}
.target-copy { min-width: 0; }
.target-copy small {
display: block;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
#targetName {
display: block;
margin-top: 3px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 14px;
font-weight: 650;
}
#targetMeta {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 10px;
line-height: 1.4;
}
#targetState {
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.target-card.confirmed #targetState { color: var(--cyan); }
.target-card.pending #targetState { color: var(--amber); }
#messages {
flex: 1;
min-height: 140px;
overflow-y: auto;
padding: 17px 20px;
scrollbar-width: thin;
scrollbar-color: #26384c transparent;
}
.message {
display: grid;
grid-template-columns: 28px minmax(0, 1fr);
gap: 9px;
margin-bottom: 15px;
animation: messageIn 180ms ease-out;
}
@keyframes messageIn {
from { opacity: 0; transform: translateY(5px); }
to { opacity: 1; transform: translateY(0); }
}
.avatar {
width: 28px;
height: 28px;
border-radius: 8px;
display: grid;
place-items: center;
font-size: 8px;
font-weight: 900;
letter-spacing: 0.05em;
}
.message.robot .avatar {
color: var(--cyan);
background: rgba(99, 230, 216, 0.1);
border: 1px solid rgba(99, 230, 216, 0.22);
}
.message.user .avatar {
color: var(--blue);
background: rgba(105, 169, 255, 0.1);
border: 1px solid rgba(105, 169, 255, 0.22);
}
.message-body {
padding-top: 1px;
color: #d8e5f1;
font-size: 12px;
line-height: 1.55;
}
.message.user .message-body { color: #b8d1ed; }
.message-body strong { color: #ffffff; }
.control-deck {
padding: 15px 20px 18px;
border-top: 1px solid var(--line);
background: rgba(7, 16, 28, 0.5);
}
.quick-row {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin: 8px 0 12px;
}
.quick-button {
padding: 7px 9px;
border: 1px solid var(--line);
border-radius: 8px;
background: rgba(17, 31, 50, 0.64);
color: #b9c9d9;
font-size: 10px;
transition: border-color 140ms, color 140ms, background 140ms;
}
.quick-button:hover,
.quick-button.active {
color: var(--text);
border-color: rgba(99, 230, 216, 0.42);
background: rgba(99, 230, 216, 0.08);
}
form {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
gap: 8px;
}
input {
min-width: 0;
height: 40px;
padding: 0 12px;
border: 1px solid var(--line);
border-radius: 9px;
background: #081321;
color: var(--text);
font-size: 12px;
}
input::placeholder { color: #60758a; }
.send-button {
height: 40px;
padding: 0 14px;
border: 0;
border-radius: 9px;
color: #06231f;
background: var(--cyan);
font-size: 11px;
font-weight: 850;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.send-button:hover { filter: brightness(1.08); }
#clarificationPanel {
margin-top: 14px;
padding: 13px;
border: 1px solid rgba(255, 200, 87, 0.26);
border-radius: 12px;
background: rgba(255, 200, 87, 0.055);
}
.clarification-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 10px;
}
.clarification-head strong {
display: block;
color: #ffe1a0;
font-size: 12px;
}
.clarification-head span {
display: block;
margin-top: 4px;
color: #a99a77;
font-size: 9px;
line-height: 1.4;
}
.locked {
padding: 4px 6px;
border-radius: 5px;
color: var(--amber);
background: rgba(255, 200, 87, 0.09);
font-size: 8px;
font-weight: 850;
letter-spacing: 0.08em;
text-transform: uppercase;
white-space: nowrap;
}
#candidateNames {
margin-top: 10px;
color: #ddcfae;
font-size: 10px;
line-height: 1.45;
}
.property-group {
display: grid;
grid-template-columns: 48px minmax(0, 1fr);
gap: 8px;
align-items: start;
margin-top: 10px;
}
.property-group > span {
padding-top: 7px;
color: #8f856e;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.property-buttons {
display: flex;
flex-wrap: wrap;
gap: 5px;
}
.property-button {
display: inline-flex;
align-items: center;
gap: 5px;
padding: 6px 7px;
border: 1px solid rgba(255, 200, 87, 0.2);
border-radius: 7px;
background: rgba(12, 23, 39, 0.75);
color: #e7d4a7;
font-size: 9px;
transition: border-color 130ms, transform 130ms, opacity 130ms;
}
.property-button:hover:not(:disabled) {
transform: translateY(-1px);
border-color: rgba(255, 200, 87, 0.65);
}
.property-button:disabled {
cursor: not-allowed;
opacity: 0.3;
}
.property-count {
color: #978d76;
font-size: 8px;
}
.tip {
margin: 11px 2px 0;
color: #687e92;
font-size: 9px;
line-height: 1.45;
}
@media (max-width: 900px) {
body { overflow: auto; }
#app {
height: auto;
min-height: 100vh;
grid-template-rows: 68px auto;
}
main {
grid-template-columns: 1fr;
}
#viewport {
height: 58vh;
min-height: 450px;
border-right: 0;
border-bottom: 1px solid var(--line);
}
aside {
min-height: 680px;
}
.header-status { display: none; }
}
@media (max-width: 520px) {
header { padding: 0 15px; }
.brand-copy span { display: none; }
.scene-title { top: 14px; left: 14px; }
.scene-help { left: 14px; bottom: 13px; }
#messages, .panel-head, .control-deck { padding-left: 15px; padding-right: 15px; }
}
</style>
</head>
<body>
<div id="app">
<header>
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div class="brand-copy">
<strong>Reference Repair</strong>
<span>Dialogue board for unambiguous scene selection</span>
</div>
</div>
<div class="header-status">
<span class="status-dot"></span>
Live ambiguity check
</div>
</header>
<main>
<section id="viewport" aria-label="Interactive low-poly robot and object scene">
<div class="scene-overlay scene-title">
<div class="eyebrow">Scene 04 / Repair Bay</div>
<strong>Four reference objects</strong>
<div id="scenePill">Awaiting instruction</div>
</div>
<div class="scene-overlay scene-help">
<kbd>Drag</kbd> orbit <kbd>Scroll</kbd> zoom
</div>
<div id="loading">Building low-poly scene…</div>
</section>
<aside>
<div class="panel-head">
<div class="panel-head-row">
<div>
<div class="section-label">Dialogue Board</div>
<h1>Resolve the reference</h1>
</div>
<div class="lock-badge">Target lock</div>
</div>
<div id="targetCard" class="target-card">
<div id="targetIcon" class="target-icon">◇</div>
<div class="target-copy">
<small>Selected target</small>
<span id="targetName">None yet</span>
<span id="targetMeta">A distinguishing property is required before selection.</span>
</div>
<span id="targetState">Locked</span>
</div>
</div>
<div id="messages" aria-live="polite"></div>
<div class="control-deck">
<div class="section-label">Repair prompts</div>
<div class="quick-row">
<button class="quick-button" data-instruction="Select an object on the platform">On platform</button>
<button class="quick-button" data-instruction="Choose a small object">Small object</button>
<button class="quick-button" data-instruction="Choose a round object">Round object</button>
<button class="quick-button" data-instruction="Choose a large object">Large object</button>
</div>
<form id="instructionForm">
<input
id="instructionInput"
type="text"
autocomplete="off"
placeholder="Try: select an object on the platform"
aria-label="Instruction or distinguishing property"
>
<button class="send-button" type="submit">Send</button>
</form>
<section id="clarificationPanel" hidden>
<div class="clarification-head">
<div>
<strong>Which property distinguishes the target?</strong>
<span>Only a property with exactly one matching object is selectable.</span>
</div>
<span class="locked">Locked</span>
</div>
<div id="candidateNames"></div>
<div class="property-group">
<span>Color</span>
<div class="property-buttons">
<button class="property-button" data-property="red">Red <span class="property-count"></span></button>
<button class="property-button" data-property="blue">Blue <span class="property-count"></span></button>
<button class="property-button" data-property="yellow">Yellow <span class="property-count"></span></button>
<button class="property-button" data-property="green">Green <span class="property-count"></span></button>
</div>
</div>
<div class="property-group">
<span>Shape</span>
<div class="property-buttons">
<button class="property-button" data-property="cube">Cube <span class="property-count"></span></button>
<button class="property-button" data-property="sphere">Sphere <span class="property-count"></span></button>
<button class="property-button" data-property="cone">Cone <span class="property-count"></span></button>
<button class="property-button" data-property="cylinder">Cylinder <span class="property-count"></span></button>
</div>
</div>
<div class="property-group">
<span>Size</span>
<div class="property-buttons">
<button class="property-button" data-property="small">Small <span class="property-count"></span></button>
<button class="property-button" data-property="large">Large <span class="property-count"></span></button>
</div>
</div>
</section>
<p class="tip">
Suggested path: choose “On platform,” then supply one distinguishing property such as BLUE or SPHERE.
</p>
</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 viewport = document.getElementById("viewport");
const loading = document.getElementById("loading");
const messages = document.getElementById("messages");
const instructionForm = document.getElementById("instructionForm");
const instructionInput = document.getElementById("instructionInput");
const clarificationPanel = document.getElementById("clarificationPanel");
const candidateNames = document.getElementById("candidateNames");
const targetCard = document.getElementById("targetCard");
const targetIcon = document.getElementById("targetIcon");
const targetName = document.getElementById("targetName");
const targetMeta = document.getElementById("targetMeta");
const targetState = document.getElementById("targetState");
const scenePill = document.getElementById("scenePill");
// -------------------------------------------------------------------------
// Scene
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x091522);
scene.fog = new THREE.Fog(0x091522, 15, 28);
const camera = new THREE.PerspectiveCamera(40, 1, 0.1, 100);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
viewport.prepend(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xb9dcff, 0x172033, 2.1);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff3db, 3.2);
keyLight.position.set(4, 9, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -9;
keyLight.shadow.camera.right = 9;
keyLight.shadow.camera.top = 9;
keyLight.shadow.camera.bottom = -9;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 25;
keyLight.shadow.bias = -0.0004;
scene.add(keyLight);
const cyanLight = new THREE.PointLight(0x54e5dc, 14, 12, 2);
cyanLight.position.set(-3, 3.5, 3);
scene.add(cyanLight);
const amberLight = new THREE.PointLight(0xffc857, 9, 10, 2);
amberLight.position.set(5, 2.8, -3);
scene.add(amberLight);
function standardMaterial(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.72,
metalness: 0.08,
flatShading: true,
...options
});
}
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(30, 30),
standardMaterial(0x0b1724, { roughness: 0.92, metalness: 0.02 })
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.025;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(30, 30, 0x355069, 0x1c2d40);
grid.position.y = -0.012;
grid.material.transparent = true;
grid.material.opacity = 0.28;
scene.add(grid);
const stageTop = 0.18;
const stage = new THREE.Mesh(
new THREE.CylinderGeometry(3.65, 3.85, 0.24, 48),
standardMaterial(0x16283a, { roughness: 0.78, metalness: 0.12 })
);
stage.position.set(0, 0.07, 0);
stage.receiveShadow = true;
scene.add(stage);
const stageInset = new THREE.Mesh(
new THREE.CylinderGeometry(3.47, 3.47, 0.035, 48),
standardMaterial(0x20354a, { roughness: 0.82 })
);
stageInset.position.y = 0.205;
stageInset.receiveShadow = true;
scene.add(stageInset);
const stageEdge = new THREE.Mesh(
new THREE.TorusGeometry(3.68, 0.035, 6, 80),
new THREE.MeshBasicMaterial({ color: 0x4f718c })
);
stageEdge.rotation.x = Math.PI / 2;
stageEdge.position.y = 0.12;
scene.add(stageEdge);
function roundedRect(ctx, x, y, w, h, r) {
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + w - r, y);
ctx.quadraticCurveTo(x + w, y, x + w, y + r);
ctx.lineTo(x + w, y + h - r);
ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
ctx.lineTo(x + r, y + h);
ctx.quadraticCurveTo(x, y + h, x, y + h - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
}
function makeTextSprite(text, accent = "#63e6d8", width = 1.8) {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 96;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
roundedRect(ctx, 8, 8, 496, 80, 18);
ctx.fillStyle = "rgba(8, 19, 32, 0.88)";
ctx.fill();
ctx.strokeStyle = accent;
ctx.globalAlpha = 0.48;
ctx.lineWidth = 2;
ctx.stroke();
ctx.globalAlpha = 1;
ctx.fillStyle = "#f1f7fc";
ctx.font = "700 30px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 256, 49);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false,
depthTest: false
})
);
sprite.scale.set(width, width * 96 / 512, 1);
sprite.renderOrder = 8;
return sprite;
}
const objectDefs = [
{
id: "cube",
name: "Red cube",
color: "red",
shape: "cube",
size: "small",
hex: 0xe75d65,
position: [-1.85, 0.83],
height: 0.9
},
{
id: "sphere",
name: "Blue sphere",
color: "blue",
shape: "sphere",
size: "small",
hex: 0x4f91e8,
position: [0.15, 1.02],
height: 1.18
},
{
id: "cone",
name: "Yellow cone",
color: "yellow",
shape: "cone",
size: "large",
hex: 0xf0bf4b,
position: [2.25, -0.62],
height: 1.5
},
{
id: "cylinder",
name: "Green cylinder",
color: "green",
shape: "cylinder",
size: "large",
hex: 0x55b98a,
position: [0.42, -1.82],
height: 1.22
}
];
const objects = [];
function createObject(def) {
const group = new THREE.Group();
group.position.set(def.position[0], stageTop + 0.025, def.position[1]);
let geometry;
if (def.shape === "cube") {
geometry = new THREE.BoxGeometry(0.9, 0.9, 0.9);
} else if (def.shape === "sphere") {
geometry = new THREE.IcosahedronGeometry(0.59, 1);
} else if (def.shape === "cone") {
geometry = new THREE.ConeGeometry(0.68, 1.45, 6);
} else {
geometry = new THREE.CylinderGeometry(0.5, 0.57, 1.18, 8);
}
const material = standardMaterial(def.hex, {
roughness: def.shape === "sphere" ? 0.52 : 0.68,
metalness: 0.06,
emissive: 0x000000,
emissiveIntensity: 0
});
const mesh = new THREE.Mesh(geometry, material);
mesh.position.y = def.height / 2;
mesh.rotation.y = def.shape === "cube" ? 0.25 : 0;
mesh.castShadow = true;
mesh.receiveShadow = true;
group.add(mesh);
const pedestal = new THREE.Mesh(
new THREE.CylinderGeometry(0.72, 0.76, 0.055, 12),
standardMaterial(0x101e2c, { roughness: 0.9 })
);
pedestal.position.y = 0.025;
pedestal.receiveShadow = true;
group.add(pedestal);
const candidateRing = new THREE.Mesh(
new THREE.TorusGeometry(0.86, 0.034, 6, 48),
new THREE.MeshBasicMaterial({
color: 0xffc857,
transparent: true,
opacity: 0.8,
depthWrite: false
})
);
candidateRing.rotation.x = Math.PI / 2;
candidateRing.position.y = 0.065;
candidateRing.visible = false;
candidateRing.renderOrder = 3;
group.add(candidateRing);
const selectedRing = new THREE.Mesh(
new THREE.TorusGeometry(0.73, 0.045, 6, 48),
new THREE.MeshBasicMaterial({
color: 0x63e6d8,
transparent: true,
opacity: 0.95,
depthWrite: false
})
);
selectedRing.rotation.x = Math.PI / 2;
selectedRing.position.y = 0.085;
selectedRing.visible = false;
selectedRing.renderOrder = 4;
group.add(selectedRing);
const label = makeTextSprite(
`${def.color.toUpperCase()} / ${def.shape.toUpperCase()}`,
`#${def.hex.toString(16).padStart(6, "0")}`,
1.75
);
label.position.set(0, def.height + 0.38, 0);
group.add(label);
const badge = makeTextSprite("CONFIRMED", "#63e6d8", 1.35);
badge.position.set(0, def.height + 0.86, 0);
badge.visible = false;
group.add(badge);
scene.add(group);
objects.push({
...def,
group,
mesh,
candidateRing,
selectedRing,
label,
badge
});
}
objectDefs.forEach(createObject);
// -------------------------------------------------------------------------
// Low-poly robot
// -------------------------------------------------------------------------
const robot = new THREE.Group();
robot.position.set(-4.25, 0, -1.45);
robot.rotation.y = 1.18;
scene.add(robot);
const robotWhite = standardMaterial(0xc9d9df, { roughness: 0.54, metalness: 0.16 });
const robotDark = standardMaterial(0x23384a, { roughness: 0.65, metalness: 0.2 });
const robotJoint = standardMaterial(0x4b6577, { roughness: 0.5, metalness: 0.35 });
const robotAccent = standardMaterial(0x4fc9c1, { roughness: 0.45, metalness: 0.22 });
function robotBox(width, height, depth, material, x, y, z) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(width, height, depth), material);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
robot.add(robotBox(1.08, 1.18, 0.72, robotWhite, 0, 1.2, 0));
robot.add(robotBox(0.72, 0.28, 0.78, robotDark, 0, 0.57, 0));
robot.add(robotBox(0.3, 0.72, 0.38, robotDark, -0.3, 0.24, 0));
robot.add(robotBox(0.3, 0.72, 0.38, robotDark, 0.3, 0.24, 0));
robot.add(robotBox(0.4, 0.15, 0.58, robotJoint, -0.3, -0.15, 0.09));
robot.add(robotBox(0.4, 0.15, 0.58, robotJoint, 0.3, -0.15, 0.09));
robot.add(robotBox(0.48, 0.12, 0.78, robotAccent, 0, 1.48, 0.03));
const robotHead = new THREE.Group();
robotHead.position.set(0, 2.18, 0);
robot.add(robotHead);
const headMesh = robotBox(1.22, 0.82, 0.82, robotWhite, 0, 0, 0);
robotHead.add(headMesh);
robotHead.add(robotBox(0.91, 0.5, 0.045, robotDark, 0, 0.02, 0.425));
const eyeMaterial = new THREE.MeshStandardMaterial({
color: 0x8ffff3,
emissive: 0x43eadc,
emissiveIntensity: 2.4,
roughness: 0.25
});
robotHead.add(robotBox(0.14, 0.14, 0.035, eyeMaterial, -0.22, 0.08, 0.455));
robotHead.add(robotBox(0.14, 0.14, 0.035, eyeMaterial, 0.22, 0.08, 0.455));
robotHead.add(robotBox(0.26, 0.035, 0.035, robotJoint, 0, -0.13, 0.455));
const antennaStem = new THREE.Mesh(
new THREE.CylinderGeometry(0.035, 0.045, 0.38, 8),
robotJoint
);
antennaStem.position.y = 0.61;
robotHead.add(antennaStem);
const antennaTip = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.11, 0),
new THREE.MeshStandardMaterial({
color: 0xffc857,
emissive: 0xff9f32,
emissiveIntensity: 1.2,
roughness: 0.4
})
);
antennaTip.position.y = 0.84;
robotHead.add(antennaTip);
const leftArm = new THREE.Group();
leftArm.position.set(-0.7, 1.65, 0);
leftArm.rotation.z = -0.18;
leftArm.add(robotBox(0.25, 0.9, 0.28, robotWhite, 0, -0.4, 0));
leftArm.add(robotBox(0.29, 0.25, 0.31, robotJoint, 0, -0.91, 0));
robot.add(leftArm);
const rightArm = new THREE.Group();
rightArm.position.set(0.7, 1.65, 0);
rightArm.rotation.z = 0.78;
rightArm.add(robotBox(0.25, 0.9, 0.28, robotWhite, 0, -0.4, 0));
rightArm.add(robotBox(0.29, 0.25, 0.31, robotJoint, 0, -0.91, 0));
robot.add(rightArm);
const questionBadge = makeTextSprite("?", "#ffc857", 0.72);
questionBadge.position.set(0, 3.45, 0);
robot.add(questionBadge);
const confirmedBadge = makeTextSprite("✓", "#63e6d8", 0.72);
confirmedBadge.position.set(0, 3.45, 0);
confirmedBadge.visible = false;
robot.add(confirmedBadge);
// -------------------------------------------------------------------------
// Direct camera controls — no addons
// -------------------------------------------------------------------------
const cameraTarget = new THREE.Vector3(-0.2, 1.0, -0.1);
let cameraRadius = 12.8;
let cameraTheta = 0.61;
let cameraPhi = 1.02;
let dragging = false;
let dragX = 0;
let dragY = 0;
function updateCamera() {
const sinPhi = Math.sin(cameraPhi);
camera.position.set(
cameraTarget.x + cameraRadius * sinPhi * Math.sin(cameraTheta),
cameraTarget.y + cameraRadius * Math.cos(cameraPhi),
cameraTarget.z + cameraRadius * sinPhi * Math.cos(cameraTheta)
);
camera.lookAt(cameraTarget);
}
renderer.domElement.addEventListener("pointerdown", event => {
dragging = true;
dragX = event.clientX;
dragY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (!dragging) return;
const dx = event.clientX - dragX;
const dy = event.clientY - dragY;
cameraTheta -= dx * 0.006;
cameraPhi = THREE.MathUtils.clamp(cameraPhi - dy * 0.005, 0.48, 1.42);
dragX = event.clientX;
dragY = event.clientY;
updateCamera();
});
function stopDragging(event) {
dragging = false;
if (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();
cameraRadius = THREE.MathUtils.clamp(cameraRadius + event.deltaY * 0.008, 8.3, 17);
updateCamera();
}, { passive: false });
function resize() {
const width = viewport.clientWidth;
const height = viewport.clientHeight;
if (!width || !height) return;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setSize(width, height, false);
}
new ResizeObserver(resize).observe(viewport);
resize();
updateCamera();
// -------------------------------------------------------------------------
// Dialogue and target state
// -------------------------------------------------------------------------
let selectedTargetId = null;
let pendingInstruction = null;
let pendingCandidates = [];
let lastResolvedProperty = "";
let robotPulse = 0;
const propertyLabels = {
red: "Red",
blue: "Blue",
yellow: "Yellow",
green: "Green",
cube: "Cube",
sphere: "Sphere",
cone: "Cone",
cylinder: "Cylinder",
small: "Small",
large: "Large"
};
function addMessage(role, text) {
const message = document.createElement("div");
message.className = `message ${role}`;
const avatar = document.createElement("div");
avatar.className = "avatar";
avatar.textContent = role === "robot" ? "BOT" : "YOU";
const body = document.createElement("div");
body.className = "message-body";
body.textContent = text;
message.append(avatar, body);
messages.append(message);
messages.scrollTop = messages.scrollHeight;
}
function extractProperties(text) {
const lower = text.toLowerCase();
const properties = [];
const tests = [
["red", /\bred\b/],
["blue", /\bblue\b/],
["yellow", /\byellow\b/],
["green", /\bgreen\b/],
["cube", /\bcube\b/],
["sphere", /\b(sphere|spherical)\b/],
["cone", /\bcone\b/],
["cylinder", /\bcylinder\b/],
["small", /\b(small|tiny)\b/],
["large", /\b(large|big)\b/]
];
for (const [property, regex] of tests) {
if (regex.test(lower)) properties.push(property);
}
return properties;
}
function findCandidates(text) {
const lower = text.toLowerCase();
let candidates = [...objects];
if (/\b(small|tiny)\b/.test(lower)) {
candidates = candidates.filter(object => object.size === "small");
} else if (/\b(large|big)\b/.test(lower)) {
candidates = candidates.filter(object => object.size === "large");
} else if (/\b(round|spherical)\b/.test(lower)) {
candidates = candidates.filter(object =>
object.shape === "sphere" || object.shape === "cylinder"
);
}
return candidates;
}
function matchesProperty(object, property) {
if (property === "round") {
return object.shape === "sphere" || object.shape === "cylinder";
}
if (["red", "blue", "yellow", "green"].includes(property)) {
return object.color === property;
}
if (["cube", "sphere", "cone", "cylinder"].includes(property)) {
return object.shape === property;
}
if (property === "small" || property === "large") {
return object.size === property;
}
return false;
}
function objectById(id) {
return objects.find(object => object.id === id);
}
function formatProperties(properties) {
return properties.map(property => propertyLabels[property] || property).join(" + ");
}
function updateTargetCard() {
targetCard.classList.remove("confirmed", "pending");
if (pendingInstruction) {
targetCard.classList.add("pending");
targetIcon.textContent = "?";
targetState.textContent = "Locked";
if (selectedTargetId) {
const previous = objectById(selectedTargetId);
targetName.textContent = previous.name;
targetMeta.textContent = "Previous confirmed target • unchanged while clarification is pending.";
} else {
targetName.textContent = "No target selected";
targetMeta.textContent = "The target remains locked until one distinguishing property is supplied.";
}
} else if (selectedTargetId) {
const selected = objectById(selectedTargetId);
targetCard.classList.add("confirmed");
targetIcon.textContent = "◆";
targetState.textContent = "Confirmed";
targetName.textContent = selected.name;
targetMeta.textContent = lastResolvedProperty
? `Confirmed by “${lastResolvedProperty}”.`
: "Confirmed reference target.";
} else {
targetIcon.textContent = "◇";
targetState.textContent = "Locked";
targetName.textContent = "None yet";
targetMeta.textContent = "A distinguishing property is required before selection.";
}
}
function updateSceneState() {
for (const object of objects) {
const isCandidate = pendingCandidates.some(candidate => candidate.id === object.id);
const isSelected = selectedTargetId === object.id;
object.candidateRing.visible = isCandidate;
object.selectedRing.visible = isSelected;
object.badge.visible = isSelected;
object.mesh.material.emissive.set(isSelected ? 0x0a4b48 : 0x000000);
object.mesh.material.emissiveIntensity = isSelected ? 0.22 : 0;
}
if (pendingInstruction) {
scenePill.textContent = `${pendingCandidates.length} candidates`;
scenePill.classList.add("ambiguous");
} else if (selectedTargetId) {
scenePill.textContent = "Target confirmed";
scenePill.classList.remove("ambiguous");
} else {
scenePill.textContent = "Awaiting instruction";
scenePill.classList.remove("ambiguous");
}
questionBadge.visible = Boolean(pendingInstruction) || !selectedTargetId;
confirmedBadge.visible = Boolean(selectedTargetId) && !pendingInstruction;
}
function updatePropertyButtons() {
const buttons = document.querySelectorAll(".property-button");
for (const button of buttons) {
const property = button.dataset.property;
const count = pendingCandidates.filter(object =>
matchesProperty(object, property)
).length;
button.disabled = count !== 1;
button.querySelector(".property-count").textContent =
count === 1 ? "1" : `${count}`;
}
}
function showClarification() {
clarificationPanel.hidden = false;
candidateNames.textContent = pendingCandidates
.map(object => object.name)
.join(" · ");
instructionInput.placeholder = "Add a property, e.g. blue or cube";
updatePropertyButtons();
}
function hideClarification() {
clarificationPanel.hidden = true;
candidateNames.textContent = "";
instructionInput.placeholder = "Try: select an object on the platform";
document.querySelectorAll(".property-button").forEach(button => {
button.disabled = true;
button.querySelector(".property-count").textContent = "";
});
}
function confirmTarget(id, properties, sourceText) {
const selected = objectById(id);
if (!selected || !properties.length) return;
selectedTargetId = id;
lastResolvedProperty = formatProperties(properties);
pendingInstruction = null;
pendingCandidates = [];
robotPulse = 1;
addMessage(
"robot",
`${selected.name} is now the confirmed target. I updated the selection only after you supplied the distinguishing property “${lastResolvedProperty}”.`
);
hideClarification();
updateTargetCard();
updateSceneState();
}
function resolveWithProperties(properties, sourceText) {
if (!pendingInstruction) return;
const filtered = pendingCandidates.filter(object =>
properties.every(property => matchesProperty(object, property))
);
if (filtered.length === 1) {
confirmTarget(filtered[0].id, properties, sourceText);
return;
}
if (filtered.length === 0) {
addMessage(
"robot",
`That property does not match any of the remaining candidates: ${pendingCandidates.map(object => object.name).join(", ")}. The target has not been changed.`
);
} else {
pendingCandidates = filtered;
showClarification();
const names = filtered.map(object => object.name).join(" and ");
addMessage(
"robot",
`“${formatProperties(properties)}” still matches ${filtered.length} objects: ${names}. I need one more distinguishing property, so the target remains unchanged.`
);
}
updateTargetCard();
updateSceneState();
}
function processInstruction(rawText) {
const text = rawText.trim();
if (!text) return;
const lower = text.toLowerCase();
const properties = extractProperties(text);
const looksLikeNewInstruction = /\b(choose|select|pick|find|move|target)\b/.test(lower);
// Once clarification is pending, a bare color/shape/size is treated as
// the requested distinguishing property rather than a new instruction.
if (pendingInstruction && properties.length && !looksLikeNewInstruction) {
addMessage("user", text);
resolveWithProperties(properties, text);
return;
}
const baseCandidates = findCandidates(text);
const filteredCandidates = properties.length
? baseCandidates.filter(object =>
properties.every(property => matchesProperty(object, property))
)
: baseCandidates;
addMessage("user", text);
if (filteredCandidates.length === 1 && properties.length) {
confirmTarget(filteredCandidates[0].id, properties, text);
return;
}
if (filteredCandidates.length > 1) {
pendingInstruction = text;
pendingCandidates = filteredCandidates;
const names = filteredCandidates.map(object => object.name).join(", ");
const lockMessage = selectedTargetId
? "Your previous confirmed target is still unchanged."
: "No target has been selected.";
addMessage(
"robot",
`I found ${filteredCandidates.length} objects that satisfy “${text}”: ${names}. ${lockMessage} Which distinguishing property should I use?`
);
showClarification();
updateTargetCard();
updateSceneState();
return;
}
if (filteredCandidates.length === 1) {
pendingInstruction = text;
pendingCandidates = filteredCandidates;
addMessage(
"robot",
`One object matches “${text}”, but I will not update the target yet. Please supply a distinguishing property to confirm the reference.`
);
showClarification();
updateTargetCard();
updateSceneState();
return;
}
pendingInstruction = text;
pendingCandidates = baseCandidates;
addMessage(
"robot",
`I could not find an object with that property combination. The target has not been changed. Please try a color, shape, or size present in the scene.`
);
showClarification();
updateTargetCard();
updateSceneState();
}
instructionForm.addEventListener("submit", event => {
event.preventDefault();
const text = instructionInput.value.trim();
if (!text) return;
processInstruction(text);
instructionInput.value = "";
});
document.querySelectorAll(".quick-button").forEach(button => {
button.addEventListener("click", () => {
const instruction = button.dataset.instruction;
document.querySelectorAll(".quick-button").forEach(other => {
other.classList.toggle("active", other === button);
});
processInstruction(instruction);
});
});
document.querySelectorAll(".property-button").forEach(button => {
button.addEventListener("click", () => {
const property = button.dataset.property;
if (button.disabled) return;
addMessage("user", `Distinguishing property: ${propertyLabels[property]}`);
resolveWithProperties([property], property);
});
});
addMessage(
"robot",
"Send an instruction. If several objects satisfy it, I’ll ask for a distinguishing property and keep the selected target locked until that property is supplied."
);
hideClarification();
updateTargetCard();
updateSceneState();
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
robotHead.rotation.y = Math.sin(elapsed * 0.72) * 0.035;
robotHead.rotation.x = Math.sin(elapsed * 9) * robotPulse * 0.075;
robotPulse *= 0.93;
rightArm.rotation.z = 0.78 + Math.sin(elapsed * 1.15) * 0.045;
leftArm.rotation.z = -0.18 - Math.sin(elapsed * 1.15 + 1) * 0.025;
antennaTip.position.y = 0.84 + Math.sin(elapsed * 2.2) * 0.025;
antennaTip.rotation.y += 0.012;
for (const object of objects) {
if (object.candidateRing.visible) {
const pulse = 0.62 + Math.sin(elapsed * 3.2 + object.position[0]) * 0.22;
object.candidateRing.material.opacity = pulse;
object.candidateRing.scale.setScalar(1 + Math.sin(elapsed * 3.2) * 0.035);
}
if (object.selectedRing.visible) {
object.selectedRing.material.opacity = 0.78 + Math.sin(elapsed * 4) * 0.18;
object.selectedRing.scale.setScalar(1 + Math.sin(elapsed * 4) * 0.025);
}
}
renderer.render(scene, camera);
}
animate();
loading.hidden = true;
</script>
</body>
</html>
```