Prompt specification
Build or customize the Three.js 3D scene "Following Another Character's Point" 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: Following Another Character's Point
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/following-another-character-s-point-x3382
Scene Description Prompt:
Animate one character pointing while another turns toward the indicated shelf. Keep the target fixed and avoid claiming this depicts a universal developmental milestone. Use Three.js from cdnjs in a single HTML file, with visible voxel blocks.
Working Three.js Starter (following-another-character-s-point-x3382):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voxel Pointing and Turning Interaction</title>
<style>
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e8e0d2;
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
#hud {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 2;
}
.panel {
position: absolute;
top: 18px;
left: 18px;
max-width: min(360px, calc(100vw - 36px));
padding: 14px 16px;
border: 1px solid rgba(50, 45, 40, 0.14);
border-radius: 12px;
background: rgba(255, 252, 246, 0.88);
box-shadow: 0 8px 28px rgba(60, 48, 30, 0.12);
backdrop-filter: blur(8px);
}
h1 {
margin: 0 0 7px;
color: #39342d;
font-size: 17px;
letter-spacing: 0.01em;
}
#phase {
margin: 0;
color: #5b554c;
font-size: 13px;
line-height: 1.45;
}
.note {
margin-top: 8px;
color: #80776b;
font-size: 11px;
line-height: 1.4;
}
#replay {
pointer-events: auto;
margin-top: 11px;
padding: 7px 11px;
border: 0;
border-radius: 7px;
color: white;
background: #3c7772;
font: inherit;
font-size: 12px;
font-weight: 650;
cursor: pointer;
}
#replay:hover {
background: #315f5b;
}
#target-label {
position: absolute;
left: 50%;
top: 50%;
padding: 5px 8px;
border-radius: 6px;
color: #493711;
background: rgba(255, 238, 164, 0.94);
border: 1px solid rgba(115, 83, 21, 0.25);
box-shadow: 0 3px 12px rgba(65, 45, 15, 0.15);
font-size: 11px;
font-weight: 650;
white-space: nowrap;
transform: translate(-50%, -100%);
opacity: 0;
}
#target-label::after {
content: "";
position: absolute;
left: 50%;
bottom: -5px;
width: 8px;
height: 8px;
background: inherit;
border-right: 1px solid rgba(115, 83, 21, 0.25);
border-bottom: 1px solid rgba(115, 83, 21, 0.25);
transform: translateX(-50%) rotate(45deg);
}
#instructions {
position: absolute;
left: 50%;
bottom: 16px;
padding: 8px 12px;
border-radius: 8px;
color: #625b51;
background: rgba(255, 252, 246, 0.82);
font-size: 11px;
transform: translateX(-50%);
white-space: nowrap;
box-shadow: 0 4px 18px rgba(60, 48, 30, 0.09);
}
@media (max-width: 600px) {
.panel {
top: 10px;
left: 10px;
max-width: calc(100vw - 20px);
}
#instructions {
bottom: 10px;
font-size: 10px;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<div id="hud">
<div class="panel">
<h1>Voxel interaction</h1>
<p id="phase">Ready</p>
<div class="note">
Interaction scene visualization; no developmental milestone is implied.
</div>
<button id="replay" type="button">Replay</button>
</div>
<div id="target-label">Fixed shelf target</div>
<div id="instructions">
Drag to orbit · Scroll to zoom · Double-click to reset
</div>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const sceneContainer = document.getElementById("scene");
const phaseElement = document.getElementById("phase");
const targetLabel = document.getElementById("target-label");
const replayButton = document.getElementById("replay");
// ---------- Renderer and scene ----------
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
sceneContainer.appendChild(renderer.domElement);
renderer.domElement.setAttribute(
"aria-label",
"A voxel scene showing one character pointing toward a shelf while another turns."
);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe8e0d2);
scene.fog = new THREE.Fog(0xe8e0d2, 16, 30);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const hemisphere = new THREE.HemisphereLight(
0xfff8e8,
0x8c877d,
2.15
);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff1d2, 3.1);
sun.position.set(-5, 9, 7);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -9;
sun.shadow.camera.right = 9;
sun.shadow.camera.top = 9;
sun.shadow.camera.bottom = -9;
sun.shadow.camera.near = 0.5;
sun.shadow.camera.far = 25;
sun.shadow.bias = -0.0004;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xcce5ef, 0.75);
fill.position.set(7, 4, -5);
scene.add(fill);
// ---------- Helpers ----------
function block(
width,
height,
depth,
color,
x = 0,
y = 0,
z = 0,
parent = scene
) {
const material =
color && color.isMaterial
? color
: new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0
});
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function smoothstep(min, max, value) {
const t = THREE.MathUtils.clamp((value - min) / (max - min), 0, 1);
return t * t * (3 - 2 * t);
}
// ---------- Voxel floor and wall ----------
block(14, 0.3, 10, 0xbab3a8, 0, -0.18, 0);
const tileColors = [
0xd8cdbd,
0xded4c5,
0xd3c7b7,
0xe1d8ca,
0xd9cfbf
];
for (let x = -6; x <= 6; x++) {
for (let z = -4; z <= 4; z++) {
const colorIndex = Math.abs((x * 3 + z * 5) % tileColors.length);
block(
0.98,
0.07,
0.98,
tileColors[colorIndex],
x,
0.015,
z
);
}
}
for (let i = 0; i < 8; i++) {
const x = -5.45 + i * 1.56;
block(
1.47,
2.7,
0.25,
i % 2 ? 0xe4dccd : 0xded5c5,
x,
1.35,
-3.48
);
}
// ---------- Fixed shelf ----------
const shelf = new THREE.Group();
scene.add(shelf);
// Back panel and vertical side panels.
block(0.16, 3.7, 3.25, 0x947154, 4.22, 1.88, -0.2, shelf);
block(1.14, 3.7, 0.14, 0x9a704f, 3.65, 1.88, -1.84, shelf);
block(1.14, 3.7, 0.14, 0x9a704f, 3.65, 1.88, 1.44, shelf);
// Horizontal shelf boards.
[0.28, 1.42, 2.56, 3.65].forEach((y) => {
block(1.18, 0.14, 3.32, 0xb88456, 3.64, y, -0.2, shelf);
});
// Books and storage blocks on the fixed shelves.
const bookColors = [0x4f7378, 0xc16c55, 0x6f855a, 0x6f6685, 0xd3a44d];
[-1.38, -1.08, -0.76, 0.62, 0.94].forEach((z, index) => {
const height = 0.48 + (index % 3) * 0.08;
block(
0.56,
height,
0.19,
bookColors[index % bookColors.length],
3.52,
2.56 + 0.07 + height / 2,
z,
shelf
);
});
[-1.34, -1.02, -0.67, 0.65, 0.98].forEach((z, index) => {
const height = 0.52 + (index % 2) * 0.12;
block(
0.58,
height,
0.2,
bookColors[(index + 2) % bookColors.length],
3.52,
0.35 + height / 2,
z,
shelf
);
});
block(0.65, 0.55, 0.72, 0x718782, 3.58, 0.625, 0.95, shelf);
// The target is intentionally static.
const shelfTarget = block(
0.48,
0.4,
0.44,
0xf1c453,
3.35,
1.71,
0.78,
shelf
);
// A small fixed front marker makes the target easy to identify.
block(
0.035,
0.12,
0.18,
0xfff0a8,
3.092,
1.71,
0.78,
shelf
);
const targetOutline = new THREE.LineSegments(
new THREE.EdgesGeometry(shelfTarget.geometry),
new THREE.LineBasicMaterial({ color: 0x715019 })
);
targetOutline.position.copy(shelfTarget.position);
targetOutline.scale.setScalar(1.025);
shelf.add(targetOutline);
const targetAnchor = new THREE.Object3D();
targetAnchor.position.set(0, 0.32, 0);
shelfTarget.add(targetAnchor);
// ---------- Voxel character factory ----------
function makeCharacter({
x,
z,
shirt,
pants,
skin,
hair,
shoe = 0x34383d
}) {
const root = new THREE.Group();
root.position.set(x, 0.05, z);
scene.add(root);
// Fixed lower body.
block(0.72, 0.22, 0.44, pants, 0, 0.64, 0, root);
block(0.25, 0.48, 0.32, pants, -0.2, 0.31, 0, root);
block(0.25, 0.48, 0.32, pants, 0.2, 0.31, 0, root);
block(0.31, 0.17, 0.45, shoe, -0.2, 0.1, 0.08, root);
block(0.31, 0.17, 0.45, shoe, 0.2, 0.1, 0.08, root);
// The upper body rotates independently from the feet.
const upper = new THREE.Group();
upper.position.y = 0.68;
root.add(upper);
block(0.76, 0.74, 0.46, shirt, 0, 0.34, 0, upper);
block(0.34, 0.23, 0.035, 0xffffff, -0.12, 0.43, 0.248, upper);
block(0.24, 0.14, 0.24, skin, 0, 0.79, 0, upper);
const head = new THREE.Group();
head.position.set(0, 0.8, 0);
upper.add(head);
block(0.68, 0.62, 0.58, skin, 0, 0.31, 0, head);
block(0.72, 0.16, 0.62, hair, 0, 0.59, 0, head);
// Hair blocks at the back and sides.
block(0.68, 0.31, 0.11, hair, 0, 0.37, -0.285, head);
block(0.11, 0.34, 0.56, hair, -0.335, 0.36, 0, head);
block(0.11, 0.34, 0.56, hair, 0.335, 0.36, 0, head);
// Face is made from small blocks and faces local +Z.
block(0.09, 0.1, 0.035, 0x28272a, -0.16, 0.36, 0.302, head);
block(0.09, 0.1, 0.035, 0x28272a, 0.16, 0.36, 0.302, head);
block(0.1, 0.09, 0.08, skin, 0, 0.27, 0.325, head);
block(0.16, 0.035, 0.03, 0x754b43, 0, 0.16, 0.305, head);
// Ears.
block(0.11, 0.19, 0.16, skin, -0.37, 0.3, 0, head);
block(0.11, 0.19, 0.16, skin, 0.37, 0.3, 0, head);
function makeArm(side) {
const pivot = new THREE.Group();
pivot.position.set(side * 0.52, 0.62, 0);
upper.add(pivot);
// Sleeve, forearm, and hand are all rectangular blocks.
block(0.29, 0.22, 0.32, shirt, 0, -0.09, 0, pivot);
block(0.23, 0.4, 0.27, skin, 0, -0.38, 0, pivot);
block(0.27, 0.23, 0.3, skin, 0, -0.64, 0, pivot);
return pivot;
}
const leftArm = makeArm(-1);
const rightArm = makeArm(1);
// Extended index finger makes the pointing pose unambiguous.
block(0.1, 0.18, 0.1, skin, 0, -0.83, 0, rightArm);
return {
root,
upper,
head,
leftArm,
rightArm
};
}
const pointer = makeCharacter({
x: -1.55,
z: 0.65,
shirt: 0x3f817a,
pants: 0x4d5676,
skin: 0xd6a276,
hair: 0x49372f,
shoe: 0x34343b
});
const listener = makeCharacter({
x: 0.65,
z: 0.74,
shirt: 0xb76455,
pants: 0x4b5669,
skin: 0x8f6048,
hair: 0x27272c,
shoe: 0x303238
});
// ---------- Direct camera controls ----------
const cameraFocus = new THREE.Vector3(0.75, 1.0, -0.1);
let cameraYaw = -0.62;
let cameraPhi = 1.2;
let cameraRadius = 11.8;
const initialCamera = {
yaw: cameraYaw,
phi: cameraPhi,
radius: cameraRadius
};
function updateCamera() {
const sinPhi = Math.sin(cameraPhi);
camera.position.set(
cameraFocus.x + cameraRadius * sinPhi * Math.sin(cameraYaw),
cameraFocus.y + cameraRadius * Math.cos(cameraPhi),
cameraFocus.z + cameraRadius * sinPhi * Math.cos(cameraYaw)
);
camera.lookAt(cameraFocus);
}
function resetCamera() {
cameraYaw = initialCamera.yaw;
cameraPhi = initialCamera.phi;
cameraRadius = initialCamera.radius;
updateCamera();
}
let dragging = false;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
cameraYaw -= deltaX * 0.006;
cameraPhi = THREE.MathUtils.clamp(
cameraPhi + deltaY * 0.005,
0.55,
1.38
);
updateCamera();
});
function stopDragging(event) {
dragging = false;
if (
event.pointerId !== undefined &&
renderer.domElement.hasPointerCapture(event.pointerId)
) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraRadius = THREE.MathUtils.clamp(
cameraRadius * Math.exp(event.deltaY * 0.001),
7.5,
18
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
// ---------- Animation ----------
const duration = 8.4;
let animationStart = performance.now();
replayButton.addEventListener("click", () => {
animationStart = performance.now();
});
const downDirection = new THREE.Vector3(0, -1, 0);
const restingArmQuaternion = new THREE.Quaternion();
const pointingArmQuaternion = new THREE.Quaternion();
const targetWorld = new THREE.Vector3();
const targetInPointerSpace = new THREE.Vector3();
const pointerDirection = new THREE.Vector3();
// The listener's complete facing angle toward the shelf.
const listenerTargetYaw = Math.atan2(
shelfTarget.position.x - listener.root.position.x,
shelfTarget.position.z - listener.root.position.z
);
function updatePhase(time) {
let text;
if (time < 0.7) {
text = "Ready";
} else if (time < 2.2) {
text = "Character A raises an arm and points to the fixed shelf target.";
} else if (time < 3.7) {
text = "Character A holds the point while Character B turns toward the shelf.";
} else if (time < 6.4) {
text = "Character B is oriented toward the indicated shelf.";
} else if (time < 7.8) {
text = "The characters return to their neutral positions.";
} else {
text = "Ready";
}
phaseElement.textContent = text;
}
function animate(now) {
const elapsed = (now - animationStart) / 1000;
const time = elapsed % duration;
// Pointing begins first and remains active while the listener turns.
let pointAmount;
if (time < 0.7) {
pointAmount = 0;
} else if (time < 2.2) {
pointAmount = smoothstep(0.7, 2.2, time);
} else if (time < 6.4) {
pointAmount = 1;
} else if (time < 7.5) {
pointAmount = 1 - smoothstep(6.4, 7.5, time);
} else {
pointAmount = 0;
}
// Turning begins while the pointing gesture is being held.
let turnAmount;
if (time < 2.2) {
turnAmount = 0;
} else if (time < 3.7) {
turnAmount = smoothstep(2.2, 3.7, time);
} else if (time < 6.6) {
turnAmount = 1;
} else if (time < 7.8) {
turnAmount = 1 - smoothstep(6.6, 7.8, time);
} else {
turnAmount = 0;
}
scene.updateMatrixWorld(true);
// Calculate the point direction from the shoulder to the static target.
shelfTarget.getWorldPosition(targetWorld);
pointer.upper.worldToLocal(targetInPointerSpace.copy(targetWorld));
pointerDirection
.copy(targetInPointerSpace)
.sub(pointer.rightArm.position)
.normalize();
pointingArmQuaternion.setFromUnitVectors(
downDirection,
pointerDirection
);
pointer.rightArm.quaternion
.copy(restingArmQuaternion)
.slerp(pointingArmQuaternion, pointAmount);
// A slight head motion reinforces that the pointer is indicating the shelf.
pointer.head.rotation.y = 0.12 * pointAmount;
// Most of the turn occurs in the torso, with the head completing it.
const bodyYaw = listenerTargetYaw * 0.72 * turnAmount;
listener.upper.rotation.y = bodyYaw;
listener.head.rotation.y = listenerTargetYaw * turnAmount - bodyYaw;
updateCamera();
updatePhase(time);
renderer.render(scene, camera);
// Keep the HTML label attached to the fixed target while orbiting.
const projectedTarget = targetAnchor
.getWorldPosition(new THREE.Vector3())
.project(camera);
const visible = projectedTarget.z > -1 && projectedTarget.z < 1;
if (visible) {
const x = (projectedTarget.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projectedTarget.y * 0.5 + 0.5) * window.innerHeight;
targetLabel.style.left = `${x}px`;
targetLabel.style.top = `${y}px`;
targetLabel.style.opacity = "1";
} else {
targetLabel.style.opacity = "0";
}
requestAnimationFrame(animate);
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
}
window.addEventListener("resize", resize);
resize();
updateCamera();
requestAnimationFrame(animate);
</script>
</body>
</html>
```