Prompt specification
Build or customize the Three.js 3D scene "Conflicting Gaze and Pointing Cues" 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: Conflicting Gaze and Pointing Cues
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/conflicting-gaze-and-pointing-cues-x3384
Scene Description Prompt:
A low-poly character looks at one object while pointing elsewhere; let viewers inspect ambiguity and request clarification. Three.js from cdnjs, one HTML file.
Working Three.js Starter (conflicting-gaze-and-pointing-cues-x3384):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Signal / Intent — Three.js Ambiguity Study</title>
<style>
:root {
--ink: #24323b;
--muted: #657078;
--paper: #f7f3eb;
--glass: rgba(250, 247, 240, 0.88);
--line: rgba(36, 50, 59, 0.14);
--amber: #d79228;
--cyan: #169a9b;
--shadow: 0 18px 50px rgba(41, 48, 48, 0.16);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #eae5db;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button,
input,
textarea {
font: inherit;
}
button {
color: inherit;
}
#app,
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
}
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
radial-gradient(circle at 50% 43%, transparent 46%, rgba(55, 48, 38, 0.08) 100%),
linear-gradient(to bottom, rgba(255, 255, 255, 0.08), transparent 30%);
}
.ui {
position: fixed;
inset: 0;
pointer-events: none;
}
.ui button,
.ui a,
.ui input,
.ui textarea,
.ui label,
.ui .modal-card {
pointer-events: auto;
}
.brand {
position: absolute;
top: 24px;
left: 28px;
display: flex;
align-items: flex-start;
gap: 13px;
}
.brand-mark {
width: 38px;
height: 38px;
display: grid;
place-items: center;
border: 1px solid rgba(36, 50, 59, 0.22);
border-radius: 11px;
background: rgba(247, 243, 235, 0.65);
backdrop-filter: blur(12px);
font-size: 18px;
font-weight: 800;
letter-spacing: -0.08em;
}
.brand h1 {
margin: 0;
font-size: 17px;
line-height: 1.1;
letter-spacing: 0.01em;
font-weight: 760;
}
.brand p {
margin: 5px 0 0;
color: var(--muted);
font-size: 12px;
letter-spacing: 0.035em;
}
.top-controls {
position: absolute;
top: 24px;
right: 26px;
display: flex;
gap: 8px;
align-items: center;
}
.control-button {
min-height: 40px;
padding: 0 14px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(250, 247, 240, 0.82);
box-shadow: 0 5px 18px rgba(39, 46, 45, 0.07);
backdrop-filter: blur(12px);
cursor: pointer;
font-size: 12px;
font-weight: 650;
transition:
transform 160ms ease,
background 160ms ease,
border-color 160ms ease;
}
.control-button:hover {
transform: translateY(-1px);
background: rgba(255, 253, 248, 0.96);
border-color: rgba(36, 50, 59, 0.28);
}
.control-button.active {
background: var(--ink);
color: #fbf8f0;
border-color: var(--ink);
}
.toggle-dot {
display: inline-block;
width: 7px;
height: 7px;
margin-right: 8px;
border-radius: 50%;
background: #e2b85d;
vertical-align: 1px;
box-shadow: 0 0 0 3px rgba(226, 184, 93, 0.15);
}
.inspection {
--accent: var(--amber);
position: absolute;
top: 88px;
right: 26px;
width: 330px;
padding: 20px;
border: 1px solid var(--line);
border-radius: 20px;
background: var(--glass);
box-shadow: var(--shadow);
backdrop-filter: blur(18px);
}
.eyebrow {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 11px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.live-pill {
display: inline-flex;
align-items: center;
gap: 6px;
letter-spacing: 0.08em;
}
.live-pill::before {
content: "";
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--accent);
}
.inspection h2 {
margin: 0;
font-size: 30px;
line-height: 1;
letter-spacing: -0.045em;
}
.object-kind {
display: inline-flex;
margin-top: 10px;
padding: 6px 8px;
border-radius: 7px;
background: color-mix(in srgb, var(--accent) 13%, transparent);
color: var(--accent);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.inspection > p {
min-height: 58px;
margin: 14px 0 16px;
color: #58646c;
font-size: 13px;
line-height: 1.55;
}
.cue-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-bottom: 12px;
}
.cue-cell {
padding: 11px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(255, 255, 255, 0.42);
}
.cue-cell small {
display: block;
margin-bottom: 4px;
color: var(--muted);
font-size: 9px;
font-weight: 750;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.cue-cell strong {
font-size: 12px;
font-weight: 720;
}
.object-tabs {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
.object-tab {
display: flex;
align-items: center;
gap: 8px;
padding: 10px 11px;
border: 1px solid var(--line);
border-radius: 11px;
background: rgba(255, 255, 255, 0.45);
cursor: pointer;
text-align: left;
font-size: 12px;
font-weight: 700;
transition: 160ms ease;
}
.object-tab:hover {
border-color: rgba(36, 50, 59, 0.3);
}
.object-tab[aria-pressed="true"] {
border-color: var(--tab-color);
background: color-mix(in srgb, var(--tab-color) 10%, white);
}
.swatch {
width: 10px;
height: 10px;
flex: 0 0 auto;
border-radius: 3px;
background: var(--tab-color);
}
.split-note {
display: flex;
gap: 10px;
margin-top: 14px;
padding: 12px;
border: 1px solid rgba(36, 50, 59, 0.1);
border-radius: 12px;
background: rgba(36, 50, 59, 0.045);
}
.split-note .symbol {
width: 21px;
height: 21px;
display: grid;
place-items: center;
flex: 0 0 auto;
border-radius: 50%;
background: var(--ink);
color: white;
font-size: 12px;
font-weight: 800;
}
.split-note strong {
display: block;
margin-bottom: 3px;
font-size: 11px;
}
.split-note p {
margin: 0;
color: var(--muted);
font-size: 11px;
line-height: 1.45;
}
.request-button {
width: 100%;
margin-top: 14px;
padding: 12px 15px;
border: 0;
border-radius: 11px;
background: var(--ink);
color: #fffaf0;
cursor: pointer;
font-size: 12px;
font-weight: 750;
transition:
transform 160ms ease,
background 160ms ease;
}
.request-button:hover {
transform: translateY(-1px);
background: #17252d;
}
.request-button span {
float: right;
opacity: 0.65;
}
.hint {
position: absolute;
left: 28px;
bottom: 25px;
display: flex;
align-items: center;
gap: 9px;
color: rgba(36, 50, 59, 0.66);
font-size: 11px;
font-weight: 600;
letter-spacing: 0.015em;
}
.hint kbd {
padding: 5px 7px;
border: 1px solid rgba(36, 50, 59, 0.18);
border-bottom-width: 2px;
border-radius: 6px;
background: rgba(250, 247, 240, 0.66);
color: var(--ink);
font-family: inherit;
font-size: 10px;
}
.legend {
position: absolute;
left: 50%;
bottom: 24px;
display: flex;
gap: 18px;
transform: translateX(-50%);
padding: 10px 14px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(250, 247, 240, 0.73);
backdrop-filter: blur(12px);
color: var(--muted);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.04em;
}
.legend span {
display: flex;
align-items: center;
gap: 7px;
}
.legend i {
width: 15px;
height: 3px;
border-radius: 3px;
background: var(--legend-color);
}
#labels {
position: fixed;
inset: 0;
overflow: hidden;
pointer-events: none;
}
.world-label {
position: absolute;
left: 0;
top: 0;
transform: translate(-50%, -50%);
white-space: nowrap;
transition: opacity 120ms ease;
}
.object-label {
padding: 5px 8px;
border: 1px solid rgba(36, 50, 59, 0.16);
border-radius: 7px;
background: rgba(250, 247, 240, 0.82);
box-shadow: 0 5px 14px rgba(36, 50, 59, 0.08);
color: var(--ink);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.intent-label {
padding: 5px 8px;
border-radius: 7px;
background: var(--label-color);
color: white;
box-shadow: 0 5px 14px rgba(36, 50, 59, 0.12);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.12em;
}
.speech-bubble {
position: absolute;
max-width: 210px;
padding: 11px 14px;
border-radius: 14px 14px 14px 3px;
background: #fffdf7;
box-shadow: 0 12px 30px rgba(36, 50, 59, 0.16);
color: var(--ink);
font-size: 12px;
font-weight: 700;
opacity: 0;
transition: opacity 300ms ease;
}
.speech-bubble.visible {
opacity: 1;
}
.modal {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
padding: 20px;
background: rgba(31, 39, 42, 0.35);
backdrop-filter: blur(8px);
opacity: 0;
visibility: hidden;
transition:
opacity 180ms ease,
visibility 180ms ease;
}
.modal.open {
opacity: 1;
visibility: visible;
}
.modal-card {
width: min(470px, 100%);
padding: 25px;
border: 1px solid rgba(255, 255, 255, 0.55);
border-radius: 22px;
background: #f9f5ed;
box-shadow: 0 30px 90px rgba(23, 30, 33, 0.3);
transform: translateY(12px) scale(0.98);
transition: transform 180ms ease;
}
.modal.open .modal-card {
transform: translateY(0) scale(1);
}
.modal-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 20px;
margin-bottom: 8px;
}
.modal h2 {
margin: 0;
font-size: 25px;
letter-spacing: -0.04em;
}
.close-button {
width: 34px;
height: 34px;
border: 1px solid var(--line);
border-radius: 10px;
background: transparent;
cursor: pointer;
font-size: 20px;
line-height: 1;
}
.modal-intro {
margin: 0 0 18px;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.question-list {
display: grid;
gap: 8px;
margin-bottom: 16px;
}
.question-option {
display: flex;
align-items: center;
gap: 10px;
padding: 12px;
border: 1px solid var(--line);
border-radius: 11px;
cursor: pointer;
font-size: 12px;
font-weight: 650;
}
.question-option:has(input:checked) {
border-color: var(--ink);
background: rgba(36, 50, 59, 0.05);
}
.question-option input {
accent-color: var(--ink);
}
textarea {
width: 100%;
min-height: 88px;
resize: vertical;
padding: 12px;
border: 1px solid var(--line);
border-radius: 11px;
outline: none;
background: rgba(255, 255, 255, 0.55);
color: var(--ink);
font-size: 12px;
line-height: 1.45;
}
textarea:focus {
border-color: var(--ink);
}
.form-label {
display: block;
margin-bottom: 7px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.send-button {
width: 100%;
margin-top: 13px;
padding: 12px 15px;
border: 0;
border-radius: 11px;
background: var(--ink);
color: white;
cursor: pointer;
font-size: 12px;
font-weight: 750;
}
.privacy-note {
margin: 10px 0 0;
color: #8a9295;
font-size: 10px;
text-align: center;
}
.success {
padding: 18px 4px 8px;
text-align: center;
}
.success-mark {
width: 48px;
height: 48px;
display: grid;
place-items: center;
margin: 0 auto 15px;
border-radius: 50%;
background: #dcebe4;
color: #2b7156;
font-size: 22px;
font-weight: 800;
}
.success h3 {
margin: 0 0 7px;
font-size: 21px;
}
.success p {
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
[hidden] {
display: none !important;
}
@media (max-width: 780px) {
.brand {
top: 16px;
left: 16px;
}
.brand p {
display: none;
}
.top-controls {
top: 16px;
right: 16px;
}
.control-button {
padding: 0 11px;
}
.inspection {
top: auto;
right: 12px;
bottom: 12px;
left: 12px;
width: auto;
max-height: 43vh;
overflow: auto;
padding: 16px;
border-radius: 17px;
}
.inspection h2 {
font-size: 25px;
}
.inspection > p {
min-height: 0;
margin: 10px 0 12px;
}
.hint,
.legend {
display: none;
}
.object-label {
font-size: 8px;
}
}
@media (max-width: 460px) {
.brand-mark {
width: 34px;
height: 34px;
}
.brand h1 {
font-size: 14px;
}
#resetView {
display: none;
}
}
</style>
</head>
<body>
<main id="app">
<div id="scene"></div>
<div class="vignette"></div>
<div id="labels">
<div id="haloLabel" class="world-label object-label">Halo</div>
<div id="prismLabel" class="world-label object-label">Prism</div>
<div id="gazeLabel" class="world-label intent-label">Gaze</div>
<div id="pointLabel" class="world-label intent-label">Point</div>
<div id="speechBubble" class="world-label speech-bubble">
Which one did you mean?
</div>
</div>
<div class="ui">
<header class="brand">
<div class="brand-mark">S/</div>
<div>
<h1>Signal / Intent</h1>
<p>A low-poly study in ambiguous attention</p>
</div>
</header>
<nav class="top-controls" aria-label="Scene controls">
<button
id="toggleGuides"
class="control-button active"
aria-pressed="true"
title="Toggle gaze and pointing guides"
>
<span class="toggle-dot"></span>Intent guides
</button>
<button id="resetView" class="control-button" title="Reset camera">
Reset view
</button>
</nav>
<section id="inspection" class="inspection" aria-live="polite">
<div class="eyebrow">
<span>Object inspection</span>
<span class="live-pill">Live cue</span>
</div>
<h2 id="objectName">Halo</h2>
<span id="objectKind" class="object-kind">Look target</span>
<p id="objectDescription"></p>
<div class="cue-row">
<div class="cue-cell">
<small>Body signal</small>
<strong id="bodySignal">Eyes + head turn</strong>
</div>
<div class="cue-cell">
<small>Competing cue</small>
<strong id="competingSignal">Hand points to Prism</strong>
</div>
</div>
<div class="object-tabs" aria-label="Inspect an object">
<button
class="object-tab"
data-object="halo"
aria-pressed="true"
style="--tab-color: var(--amber)"
>
<span class="swatch"></span>Inspect Halo
</button>
<button
class="object-tab"
data-object="prism"
aria-pressed="false"
style="--tab-color: var(--cyan)"
>
<span class="swatch"></span>Inspect Prism
</button>
</div>
<div class="split-note">
<span class="symbol">!</span>
<div>
<strong>Intent remains split</strong>
<p id="splitText"></p>
</div>
</div>
<button id="requestButton" class="request-button">
Request clarification <span>↗</span>
</button>
</section>
<div class="hint">
<kbd>Drag</kbd> orbit
<span>·</span>
<kbd>Scroll</kbd> zoom
<span>·</span>
<kbd>Shift + drag</kbd> pan
<span>·</span>
Click an object
</div>
<div class="legend" aria-hidden="true">
<span><i style="--legend-color: var(--amber)"></i>Gaze target</span>
<span><i style="--legend-color: var(--cyan)"></i>Pointing target</span>
</div>
</div>
<div id="modal" class="modal" role="dialog" aria-modal="true" aria-labelledby="modalTitle">
<div class="modal-card">
<form id="clarificationForm">
<div class="modal-head">
<h2 id="modalTitle">Request clarification</h2>
<button id="closeModal" class="close-button" type="button" aria-label="Close dialog">×</button>
</div>
<p class="modal-intro">
The character’s gaze and gesture identify different objects.
Choose the ambiguity you would like the character to resolve.
</p>
<div class="question-list">
<label class="question-option">
<input type="radio" name="question" value="look" checked>
What are you looking at?
</label>
<label class="question-option">
<input type="radio" name="question" value="point">
What are you pointing to?
</label>
<label class="question-option">
<input type="radio" name="question" value="both">
Which object should I inspect?
</label>
</div>
<label class="form-label" for="customQuestion">Optional message</label>
<textarea
id="customQuestion"
maxlength="240"
placeholder="Add context for your request..."
></textarea>
<button class="send-button" type="button" id="sendClarification">Send clarification request</button>
<p class="privacy-note">This interactive demo does not transmit personal data.</p>
</form>
<div id="successState" class="success" hidden>
<div class="success-mark">✓</div>
<h3>Request sent</h3>
<p>
The character has been asked to restate its intention.
The competing gaze and gesture cues remain visible for inspection.
</p>
<button id="successClose" class="send-button" type="button">Continue inspecting</button>
</div>
</div>
</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 scene = new THREE.Scene();
scene.background = new THREE.Color(0xeae5db);
scene.fog = new THREE.Fog(0xeae5db, 12, 25);
const camera = new THREE.PerspectiveCamera(
40,
window.innerWidth / window.innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
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;
const canvas = renderer.domElement;
canvas.tabIndex = 0;
canvas.setAttribute(
"aria-label",
"Interactive 3D scene: a character looks at Halo while pointing at Prism"
);
document.querySelector("#scene").appendChild(canvas);
const hemi = new THREE.HemisphereLight(0xfff9ec, 0x6b7776, 2.2);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff1d6, 3.2);
sun.position.set(-4.5, 8, 6);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -7;
sun.shadow.camera.right = 7;
sun.shadow.camera.top = 7;
sun.shadow.camera.bottom = -5;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb8d7d8, 1.2);
fill.position.set(5, 4, -5);
scene.add(fill);
const floorMaterial = new THREE.MeshStandardMaterial({
color: 0xe7e0d4,
roughness: 0.94,
metalness: 0
});
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(50, 50),
floorMaterial
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.02;
floor.receiveShadow = true;
scene.add(floor);
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0.02,
flatShading: true,
...options
});
const palette = {
skin: material(0xe9b78d),
hair: material(0x3b302e),
shirt: material(0xe46f52),
shirtDark: material(0xc95842),
trousers: material(0x344c58),
shoes: material(0x25343b),
white: material(0xfff9e9),
pupil: material(0x172329),
pedestal: material(0xd8d3c9),
pedestalTop: material(0xf0eadf),
amber: material(0xe4a13a, {
emissive: 0x7b4305,
emissiveIntensity: 0.06,
roughness: 0.42
}),
cyan: material(0x35b4b4, {
emissive: 0x075f61,
emissiveIntensity: 0.06,
roughness: 0.38
})
};
function addMesh(geometry, mat, position, parent = scene) {
const mesh = new THREE.Mesh(geometry, mat);
mesh.position.set(...position);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addLimb(start, end, radius, mat, parent, radialSegments = 6) {
const a = new THREE.Vector3(...start);
const b = new THREE.Vector3(...end);
const direction = b.clone().sub(a);
const length = direction.length();
const mesh = addMesh(
new THREE.CylinderGeometry(radius, radius, length, radialSegments),
mat,
a.clone().add(b).multiplyScalar(0.5).toArray(),
parent
);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
return mesh;
}
function addPedestal(group) {
addMesh(
new THREE.CylinderGeometry(0.67, 0.79, 0.48, 6),
palette.pedestal,
[0, 0.24, 0],
group
);
addMesh(
new THREE.CylinderGeometry(0.7, 0.7, 0.08, 6),
palette.pedestalTop,
[0, 0.51, 0],
group
);
const floorRing = addMesh(
new THREE.RingGeometry(0.91, 0.95, 48),
new THREE.MeshBasicMaterial({
color: 0x9a948a,
transparent: true,
opacity: 0.22,
side: THREE.DoubleSide
}),
[0, 0.012, 0],
group
);
floorRing.rotation.x = -Math.PI / 2;
floorRing.castShadow = false;
}
// The object receiving the character's gaze.
const haloGroup = new THREE.Group();
haloGroup.position.set(-2.85, 0, 1.55);
scene.add(haloGroup);
addPedestal(haloGroup);
const haloCore = addMesh(
new THREE.IcosahedronGeometry(0.48, 1),
palette.amber,
[0, 1.16, 0],
haloGroup
);
const haloRingA = addMesh(
new THREE.TorusGeometry(0.67, 0.025, 4, 24),
material(0xf2bd59, { roughness: 0.45 }),
[0, 1.16, 0],
haloGroup
);
haloRingA.rotation.x = Math.PI / 2;
const haloRingB = addMesh(
new THREE.TorusGeometry(0.62, 0.022, 4, 24),
material(0xbc7720, { roughness: 0.5 }),
[0, 1.16, 0],
haloGroup
);
haloRingB.rotation.y = Math.PI / 3;
// The object indicated by the character's hand.
const prismGroup = new THREE.Group();
prismGroup.position.set(2.75, 0, 0.65);
scene.add(prismGroup);
addPedestal(prismGroup);
const prismCore = addMesh(
new THREE.OctahedronGeometry(0.58, 0),
palette.cyan,
[0, 1.27, 0],
prismGroup
);
const prismRing = addMesh(
new THREE.TorusGeometry(0.74, 0.025, 4, 24),
material(0x77d0cb, { roughness: 0.5 }),
[0, 1.27, 0],
prismGroup
);
prismRing.rotation.x = Math.PI / 2;
// Low-poly character.
const character = new THREE.Group();
character.position.set(0, 0, -0.2);
scene.add(character);
addMesh(
new THREE.CylinderGeometry(0.2, 0.23, 0.78, 5),
palette.trousers,
[-0.24, 0.58, 0],
character
);
addMesh(
new THREE.CylinderGeometry(0.2, 0.23, 0.78, 5),
palette.trousers,
[0.24, 0.58, 0],
character
);
addMesh(
new THREE.BoxGeometry(0.38, 0.22, 0.57),
palette.shoes,
[-0.24, 0.14, 0.1],
character
);
addMesh(
new THREE.BoxGeometry(0.38, 0.22, 0.57),
palette.shoes,
[0.24, 0.14, 0.1],
character
);
addMesh(
new THREE.CylinderGeometry(0.51, 0.4, 0.94, 6),
palette.shirt,
[0, 1.43, 0],
character
);
addMesh(
new THREE.CylinderGeometry(0.27, 0.34, 0.18, 6),
palette.shirtDark,
[0, 1.95, 0],
character
);
addMesh(
new THREE.BoxGeometry(0.2, 0.13, 0.035),
material(0xf8d775),
[-0.18, 1.52, 0.45],
character
);
// Relaxed left arm.
addLimb(
[-0.43, 1.72, 0],
[-0.65, 1.23, 0.02],
0.14,
palette.shirt,
character
);
addLimb(
[-0.65, 1.23, 0.02],
[-0.57, 0.91, 0.1],
0.12,
palette.skin,
character
);
addMesh(
new THREE.DodecahedronGeometry(0.15, 0),
palette.skin,
[-0.55, 0.86, 0.11],
character
);
// Pointing right arm.
addLimb(
[0.43, 1.72, 0],
[0.86, 1.38, 0.12],
0.145,
palette.shirt,
character
);
addLimb(
[0.86, 1.38, 0.12],
[1.62, 1.43, 0.44],
0.115,
palette.skin,
character
);
addMesh(
new THREE.DodecahedronGeometry(0.16, 0),
palette.skin,
[1.65, 1.43, 0.46],
character
);
// Extended index finger establishes the pointing cue.
addLimb(
[1.75, 1.44, 0.51],
[2.34, 1.36, 0.68],
0.052,
palette.skin,
character,
5
);
// Head and facial features.
const head = new THREE.Group();
head.position.set(0, 2.27, 0);
head.rotation.y = -1.02;
character.add(head);
addMesh(
new THREE.DodecahedronGeometry(0.48, 0),
palette.skin,
[0, 0, 0],
head
);
addMesh(
new THREE.CylinderGeometry(0.33, 0.47, 0.24, 7),
palette.hair,
[0, 0.37, -0.025],
head
);
for (const side of [-1, 1]) {
addMesh(
new THREE.SphereGeometry(0.09, 8, 6),
palette.white,
[side * 0.155, 0.055, 0.445],
head
);
addMesh(
new THREE.SphereGeometry(0.043, 8, 5),
palette.pupil,
[side * 0.15, 0.055, 0.515],
head
);
const eyebrow = addMesh(
new THREE.BoxGeometry(0.16, 0.025, 0.025),
palette.hair,
[side * 0.155, 0.18, 0.435],
head
);
eyebrow.rotation.z = side * -0.09;
}
addMesh(
new THREE.BoxGeometry(0.15, 0.025, 0.025),
palette.pupil,
[0, -0.15, 0.455],
head
);
const gazeAnchor = new THREE.Object3D();
gazeAnchor.position.set(0, 0.055, 0.55);
head.add(gazeAnchor);
const pointAnchor = new THREE.Object3D();
pointAnchor.position.set(2.38, 1.36, 0.69);
character.add(pointAnchor);
// Intent guides.
const guideGroup = new THREE.Group();
scene.add(guideGroup);
const gazeMaterial = new THREE.LineDashedMaterial({
color: 0xd79228,
dashSize: 0.14,
gapSize: 0.09,
transparent: true,
opacity: 0.85,
depthTest: false
});
const pointMaterial = new THREE.LineDashedMaterial({
color: 0x169a9b,
dashSize: 0.14,
gapSize: 0.09,
transparent: true,
opacity: 0.85,
depthTest: false
});
const gazeLine = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(),
new THREE.Vector3()
]),
gazeMaterial
);
gazeLine.renderOrder = 5;
guideGroup.add(gazeLine);
const pointLine = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(),
new THREE.Vector3()
]),
pointMaterial
);
pointLine.renderOrder = 5;
guideGroup.add(pointLine);
const gazeArrow = new THREE.Mesh(
new THREE.ConeGeometry(0.085, 0.25, 5),
new THREE.MeshBasicMaterial({
color: 0xd79228,
depthTest: false
})
);
gazeArrow.renderOrder = 6;
guideGroup.add(gazeArrow);
const pointArrow = new THREE.Mesh(
new THREE.ConeGeometry(0.085, 0.25, 5),
new THREE.MeshBasicMaterial({
color: 0x169a9b,
depthTest: false
})
);
pointArrow.renderOrder = 6;
guideGroup.add(pointArrow);
// Mark object descendants for raycasting.
function tagGroup(group, id) {
group.traverse((child) => {
child.userData.objectId = id;
});
}
tagGroup(haloGroup, "halo");
tagGroup(prismGroup, "prism");
const pickRoots = [haloGroup, prismGroup];
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
// Direct camera controls: orbit, zoom and shift-drag pan.
const initialCamera = {
theta: 0.025,
phi: 1.16,
radius: 9.7,
target: new THREE.Vector3(0, 1.25, 0.45)
};
const cameraState = {
theta: initialCamera.theta,
phi: initialCamera.phi,
radius: initialCamera.radius,
target: initialCamera.target.clone()
};
const cameraGoal = {
theta: initialCamera.theta,
phi: initialCamera.phi,
radius: initialCamera.radius,
target: initialCamera.target.clone()
};
const drag = {
active: false,
moved: false,
pointerId: null,
x: 0,
y: 0
};
canvas.addEventListener("pointerdown", (event) => {
if (event.button !== 0 && event.button !== 1 && event.button !== 2) return;
drag.active = true;
drag.moved = false;
drag.pointerId = event.pointerId;
drag.x = event.clientX;
drag.y = event.clientY;
canvas.setPointerCapture(event.pointerId);
canvas.style.cursor = "grabbing";
});
canvas.addEventListener("pointermove", (event) => {
if (!drag.active || event.pointerId !== drag.pointerId) {
updateHover(event);
return;
}
const dx = event.clientX - drag.x;
const dy = event.clientY - drag.y;
drag.x = event.clientX;
drag.y = event.clientY;
if (Math.abs(dx) + Math.abs(dy) > 1) drag.moved = true;
if (event.shiftKey) {
const forward = camera.getWorldDirection(new THREE.Vector3());
const right = new THREE.Vector3()
.crossVectors(forward, camera.up)
.normalize();
const panScale = cameraGoal.radius * 0.00125;
cameraGoal.target.addScaledVector(right, -dx * panScale);
cameraGoal.target.y += dy * panScale;
cameraGoal.target.y = THREE.MathUtils.clamp(cameraGoal.target.y, 0.35, 2.6);
} else {
cameraGoal.theta -= dx * 0.006;
cameraGoal.phi = THREE.MathUtils.clamp(
cameraGoal.phi - dy * 0.005,
0.65,
1.43
);
}
});
canvas.addEventListener("pointerup", (event) => {
if (event.pointerId !== drag.pointerId) return;
const wasClick = !drag.moved;
drag.active = false;
canvas.style.cursor = "";
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
if (wasClick) inspectAt(event);
});
canvas.addEventListener("pointercancel", () => {
drag.active = false;
canvas.style.cursor = "";
});
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraGoal.radius = THREE.MathUtils.clamp(
cameraGoal.radius * Math.exp(event.deltaY * 0.001),
6,
16
);
},
{ passive: false }
);
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
function updateHover(event) {
const hit = pickAt(event);
canvas.style.cursor = hit ? "pointer" : "grab";
}
function pickAt(event) {
const rect = canvas.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(pickRoots, true);
return hits.length ? hits[0].object.userData.objectId : null;
}
function inspectAt(event) {
const id = pickAt(event);
if (id) selectObject(id);
}
const inspection = document.querySelector("#inspection");
const objectName = document.querySelector("#objectName");
const objectKind = document.querySelector("#objectKind");
const objectDescription = document.querySelector("#objectDescription");
const bodySignal = document.querySelector("#bodySignal");
const competingSignal = document.querySelector("#competingSignal");
const splitText = document.querySelector("#splitText");
const objectTabs = [...document.querySelectorAll(".object-tab")];
const objectInfo = {
halo: {
name: "Halo",
kind: "Look target",
color: "#d79228",
description:
"The head turns and both pupils are aligned toward this amber icosahedron. It is the strongest visual candidate for the character’s attention.",
body: "Eyes + head turn",
competing: "Hand points to Prism",
split:
"The extended index finger indicates Prism instead, so looking and pointing do not agree."
},
prism: {
name: "Prism",
kind: "Point target",
color: "#169a9b",
description:
"The extended index finger and forearm align toward this cyan octahedron. It is the strongest gestural candidate for the character’s intent.",
body: "Index finger + arm",
competing: "Eyes look at Halo",
split:
"The face remains turned toward Halo, so the gesture and gaze identify different objects."
}
};
let selectedObject = "halo";
function selectObject(id) {
selectedObject = id;
const info = objectInfo[id];
inspection.style.setProperty("--accent", info.color);
objectName.textContent = info.name;
objectKind.textContent = info.kind;
objectDescription.textContent = info.description;
bodySignal.textContent = info.body;
competingSignal.textContent = info.competing;
splitText.textContent = info.split;
objectTabs.forEach((tab) => {
tab.setAttribute(
"aria-pressed",
String(tab.dataset.object === id)
);
});
palette.amber.emissiveIntensity = id === "halo" ? 0.22 : 0.04;
palette.cyan.emissiveIntensity = id === "prism" ? 0.22 : 0.04;
}
objectTabs.forEach((tab) => {
tab.addEventListener("click", () => selectObject(tab.dataset.object));
});
selectObject("halo");
let guidesVisible = true;
const toggleGuides = document.querySelector("#toggleGuides");
toggleGuides.addEventListener("click", () => {
guidesVisible = !guidesVisible;
guideGroup.visible = guidesVisible;
toggleGuides.classList.toggle("active", guidesVisible);
toggleGuides.setAttribute("aria-pressed", String(guidesVisible));
});
document.querySelector("#resetView").addEventListener("click", () => {
cameraGoal.theta = initialCamera.theta;
cameraGoal.phi = initialCamera.phi;
cameraGoal.radius = initialCamera.radius;
cameraGoal.target.copy(initialCamera.target);
});
// Clarification dialog.
const modal = document.querySelector("#modal");
const form = document.querySelector("#clarificationForm");
const successState = document.querySelector("#successState");
const speechBubble = document.querySelector("#speechBubble");
let speechTimer;
function openModal() {
const question = document.querySelector(
'input[name="question"]:checked'
);
question.checked = selectedObject === "prism" ? false : true;
if (selectedObject === "prism") {
document.querySelector('input[value="point"]').checked = true;
}
form.hidden = false;
successState.hidden = true;
modal.classList.add("open");
document.querySelector("#closeModal").focus();
}
function closeModal() {
modal.classList.remove("open");
canvas.focus();
}
document.querySelector("#requestButton").addEventListener("click", openModal);
document.querySelector("#closeModal").addEventListener("click", closeModal);
document.querySelector("#successClose").addEventListener("click", closeModal);
modal.addEventListener("click", (event) => {
if (event.target === modal) closeModal();
});
document.querySelector("#sendClarification").addEventListener("click", () => {
const selectedQuestion = document.querySelector(
'input[name="question"]:checked'
)?.value;
const messages = {
look: "Please clarify which object you are looking at.",
point: "Please clarify which object you are pointing to.",
both: "Please clarify which object I should inspect."
};
const custom = document.querySelector("#customQuestion").value.trim();
const fullMessage = custom
? `${messages[selectedQuestion]} ${custom}`
: messages[selectedQuestion];
console.log("Clarification request:", fullMessage);
form.hidden = true;
successState.hidden = false;
speechBubble.textContent = "Which one did you mean?";
speechBubble.classList.add("visible");
clearTimeout(speechTimer);
speechTimer = setTimeout(() => {
speechBubble.classList.remove("visible");
}, 6500);
});
window.addEventListener("keydown", (event) => {
if (event.key === "Escape" && modal.classList.contains("open")) {
closeModal();
}
if (event.key.toLowerCase() === "g" && !modal.classList.contains("open")) {
toggleGuides.click();
}
if (event.key.toLowerCase() === "r" && !modal.classList.contains("open")) {
document.querySelector("#resetView").click();
}
});
// Project DOM labels from their 3D anchors.
const haloLabel = document.querySelector("#haloLabel");
const prismLabel = document.querySelector("#prismLabel");
const gazeLabel = document.querySelector("#gazeLabel");
const pointLabel = document.querySelector("#pointLabel");
const haloLabelPosition = new THREE.Vector3();
const prismLabelPosition = new THREE.Vector3();
const speechPosition = new THREE.Vector3(0.15, 3.0, -0.1);
function placeLabel(element, worldPosition, offsetY = 0) {
const projected = worldPosition.clone().project(camera);
if (projected.z < -1 || projected.z > 1) {
element.style.opacity = "0";
return;
}
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight + offsetY;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
element.style.opacity = "1";
}
function updateLine(line, start, end) {
const positions = line.geometry.attributes.position.array;
positions[0] = start.x;
positions[1] = start.y;
positions[2] = start.z;
positions[3] = end.x;
positions[4] = end.y;
positions[5] = end.z;
line.geometry.attributes.position.needsUpdate = true;
line.computeLineDistances();
line.geometry.computeBoundingSphere();
}
const yAxis = new THREE.Vector3(0, 1, 0);
const gazeStart = new THREE.Vector3();
const pointStart = new THREE.Vector3();
const haloTarget = new THREE.Vector3();
const prismTarget = new THREE.Vector3();
function updateCamera() {
const smoothing = 0.09;
cameraState.theta = THREE.MathUtils.lerp(
cameraState.theta,
cameraGoal.theta,
smoothing
);
cameraState.phi = THREE.MathUtils.lerp(
cameraState.phi,
cameraGoal.phi,
smoothing
);
cameraState.radius = THREE.MathUtils.lerp(
cameraState.radius,
cameraGoal.radius,
smoothing
);
cameraState.target.lerp(cameraGoal.target, smoothing);
const sinPhi = Math.sin(cameraState.phi);
const cosPhi = Math.cos(cameraState.phi);
camera.position.set(
cameraState.target.x +
cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraState.target.y + cameraState.radius * cosPhi,
cameraState.target.z +
cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraState.target);
}
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
updateCamera();
haloCore.rotation.y = elapsed * 0.24;
haloCore.rotation.x = Math.sin(elapsed * 0.45) * 0.08;
haloRingA.rotation.z = elapsed * 0.35;
haloRingB.rotation.z = -elapsed * 0.25;
prismCore.rotation.y = elapsed * 0.32;
prismCore.rotation.z = Math.sin(elapsed * 0.5) * 0.08;
prismRing.rotation.z = elapsed * 0.22;
scene.updateMatrixWorld(true);
gazeAnchor.getWorldPosition(gazeStart);
pointAnchor.getWorldPosition(pointStart);
haloCore.getWorldPosition(haloTarget);
prismCore.getWorldPosition(prismTarget);
updateLine(gazeLine, gazeStart, haloTarget);
updateLine(pointLine, pointStart, prismTarget);
const gazeDirection = haloTarget.clone().sub(gazeStart).normalize();
gazeArrow.position.copy(gazeStart).lerp(haloTarget, 0.91);
gazeArrow.quaternion.setFromUnitVectors(yAxis, gazeDirection);
const pointDirection = prismTarget.clone().sub(pointStart).normalize();
pointArrow.position.copy(pointStart).lerp(prismTarget, 0.91);
pointArrow.quaternion.setFromUnitVectors(yAxis, pointDirection);
haloLabelPosition.copy(haloTarget).add(new THREE.Vector3(0, 0.98, 0));
prismLabelPosition.copy(prismTarget).add(new THREE.Vector3(0, 0.95, 0));
placeLabel(haloLabel, haloLabelPosition);
placeLabel(prismLabel, prismLabelPosition);
placeLabel(
gazeLabel,
gazeStart.clone().lerp(haloTarget, 0.5).add(new THREE.Vector3(0, 0.28, 0))
);
placeLabel(
pointLabel,
pointStart.clone().lerp(prismTarget, 0.52).add(new THREE.Vector3(0, -0.32, 0))
);
placeLabel(speechBubble, speechPosition, -8);
renderer.render(scene, camera);
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```