Prompt specification
Build or customize the Three.js 3D scene "Information desk sightline model" 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: Information desk sightline model
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/information-desk-sightline-model-x0401
Scene Description Prompt:
Model a stylized foyer whose help desk is visible immediately from the entrance, between two corridors. One HTML file using Three.js from cdnjs.
Working Three.js Starter (information-desk-sightline-model-x0401):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Stylized Foyer</title>
<style>
:root {
--ink: #20343a;
--paper: #f4efe6;
--glass: rgba(244, 239, 230, 0.82);
--accent: #bd774e;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e8e3da;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.title-card {
position: fixed;
top: 24px;
left: 24px;
z-index: 10;
max-width: min(380px, calc(100vw - 48px));
padding: 18px 20px;
border: 1px solid rgba(32, 52, 58, 0.12);
border-radius: 16px;
background: var(--glass);
box-shadow: 0 14px 40px rgba(32, 52, 58, 0.1);
backdrop-filter: blur(14px);
pointer-events: none;
}
.eyebrow {
margin-bottom: 6px;
color: var(--accent);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(22px, 3vw, 34px);
line-height: 1.04;
letter-spacing: -0.04em;
}
.subtitle {
margin: 9px 0 0;
color: rgba(32, 52, 58, 0.68);
font-size: 12px;
line-height: 1.5;
}
.controls-card {
position: fixed;
right: 24px;
bottom: 24px;
z-index: 10;
display: flex;
align-items: center;
gap: 14px;
padding: 10px 12px 10px 16px;
border: 1px solid rgba(32, 52, 58, 0.12);
border-radius: 999px;
background: var(--glass);
box-shadow: 0 10px 30px rgba(32, 52, 58, 0.1);
backdrop-filter: blur(14px);
color: rgba(32, 52, 58, 0.68);
font-size: 11px;
pointer-events: none;
}
.controls-card strong {
color: var(--ink);
font-weight: 700;
}
button {
border: 0;
border-radius: 999px;
padding: 9px 14px;
background: var(--ink);
color: white;
font: inherit;
font-size: 11px;
font-weight: 700;
cursor: pointer;
pointer-events: auto;
transition:
transform 150ms ease,
background 150ms ease;
}
button:hover {
background: #2e7370;
transform: translateY(-1px);
}
@media (max-width: 700px) {
.title-card {
top: 14px;
left: 14px;
padding: 14px 16px;
}
.subtitle {
display: none;
}
.controls-card {
right: 14px;
bottom: 14px;
left: 14px;
justify-content: space-between;
border-radius: 16px;
}
}
</style>
</head>
<body>
<section class="title-card">
<div class="eyebrow">Spatial Wayfinding Study</div>
<h1>Foyer & Information Point</h1>
<p class="subtitle">
A help desk positioned directly on the entrance axis, framed by west and
east corridor entrances.
</p>
</section>
<div class="controls-card">
<span><strong>Drag</strong> orbit · <strong>Shift-drag</strong> pan · <strong>Scroll</strong> zoom</span>
<button id="reset-view" type="button">Reset view</button>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe8e3da);
scene.fog = new THREE.Fog(0xe8e3da, 25, 48);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute("aria-label", "Interactive 3D model of a foyer");
document.body.prepend(renderer.domElement);
const world = new THREE.Group();
scene.add(world);
// -------------------------------------------------------------------------
// Materials
// -------------------------------------------------------------------------
const materials = {
floor: new THREE.MeshStandardMaterial({
color: 0xd4cdc0,
roughness: 0.88
}),
wall: new THREE.MeshStandardMaterial({
color: 0xf0ebe1,
roughness: 0.84
}),
wallAccent: new THREE.MeshStandardMaterial({
color: 0xc8bda9,
roughness: 0.9
}),
navy: new THREE.MeshStandardMaterial({
color: 0x22343a,
roughness: 0.55
}),
teal: new THREE.MeshStandardMaterial({
color: 0x347f7b,
roughness: 0.46
}),
tealDark: new THREE.MeshStandardMaterial({
color: 0x205c60,
roughness: 0.5
}),
wood: new THREE.MeshStandardMaterial({
color: 0xb9784d,
roughness: 0.68
}),
woodDark: new THREE.MeshStandardMaterial({
color: 0x815039,
roughness: 0.74
}),
brass: new THREE.MeshStandardMaterial({
color: 0xd1a55f,
metalness: 0.55,
roughness: 0.32
}),
white: new THREE.MeshStandardMaterial({
color: 0xfffaf0,
roughness: 0.6
}),
black: new THREE.MeshStandardMaterial({
color: 0x182326,
roughness: 0.48
}),
rug: new THREE.MeshStandardMaterial({
color: 0xd9d2c5,
roughness: 1
}),
rugEdge: new THREE.MeshStandardMaterial({
color: 0x536568,
roughness: 1
}),
soil: new THREE.MeshStandardMaterial({
color: 0x3c3028,
roughness: 1
}),
leaf: new THREE.MeshStandardMaterial({
color: 0x557b55,
roughness: 0.78
}),
leafLight: new THREE.MeshStandardMaterial({
color: 0x78966a,
roughness: 0.8
}),
glass: new THREE.MeshStandardMaterial({
color: 0xb9d2d1,
transparent: true,
opacity: 0.13,
roughness: 0.08,
metalness: 0.05,
depthWrite: false
}),
light: new THREE.MeshStandardMaterial({
color: 0xffedbf,
emissive: 0xffd88b,
emissiveIntensity: 1.7,
roughness: 0.35
}),
screen: new THREE.MeshStandardMaterial({
color: 0x7ca6a7,
emissive: 0x416f73,
emissiveIntensity: 0.5,
roughness: 0.35
}),
skin: new THREE.MeshStandardMaterial({
color: 0xc98f6f,
roughness: 0.78
}),
hair: new THREE.MeshStandardMaterial({
color: 0x352a28,
roughness: 0.9
})
};
// -------------------------------------------------------------------------
// Geometry helpers
// -------------------------------------------------------------------------
function box(size, position, material, parent = world) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
material
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(
radiusTop,
radiusBottom,
height,
position,
material,
parent = world,
segments = 32
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
height,
segments
),
material
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function roundedRectShape(width, height, radius) {
const shape = new THREE.Shape();
const x = -width / 2;
const y = -height / 2;
const r = Math.min(radius, width / 2, height / 2);
shape.moveTo(x + r, y);
shape.lineTo(x + width - r, y);
shape.quadraticCurveTo(x + width, y, x + width, y + r);
shape.lineTo(x + width, y + height - r);
shape.quadraticCurveTo(
x + width,
y + height,
x + width - r,
y + height
);
shape.lineTo(x + r, y + height);
shape.quadraticCurveTo(x, y + height, x, y + height - r);
shape.lineTo(x, y + r);
shape.quadraticCurveTo(x, y, x + r, y);
shape.closePath();
return shape;
}
function roundedBox(
width,
height,
depth,
radius,
position,
material,
parent = world
) {
const bevel = Math.min(0.055, radius * 0.18, depth * 0.2);
const geometry = new THREE.ExtrudeGeometry(
roundedRectShape(width, height, radius),
{
depth,
bevelEnabled: true,
bevelSegments: 3,
steps: 1,
bevelSize: bevel,
bevelThickness: bevel,
curveSegments: 8
}
);
geometry.translate(0, 0, -depth / 2);
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function roundedFloor(
width,
depth,
radius,
position,
material,
parent = world
) {
const geometry = new THREE.ShapeGeometry(
roundedRectShape(width, depth, radius),
12
);
geometry.rotateX(-Math.PI / 2);
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(position[0], position[1], position[2]);
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeLabel(
text,
width,
height,
position,
options = {}
) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = Math.max(128, Math.round((1024 * height) / width));
const context = canvas.getContext("2d");
const background = options.background ?? null;
const foreground = options.foreground ?? "#22343a";
if (background) {
context.fillStyle = background;
context.fillRect(0, 0, canvas.width, canvas.height);
}
context.textAlign = "center";
context.textBaseline = "middle";
context.fillStyle = foreground;
context.font = `${options.weight ?? 700} ${
options.fontSize ?? Math.floor(canvas.height * 0.42)
}px ${options.font ?? "Arial, sans-serif"}`;
const mainY = options.subtext
? canvas.height * 0.4
: canvas.height * 0.5;
context.fillText(text, canvas.width / 2, mainY);
if (options.subtext) {
context.fillStyle = options.subtextColor ?? foreground;
context.font = `${options.subtextWeight ?? 600} ${
Math.floor(canvas.height * 0.17)
}px Arial, sans-serif`;
context.fillText(
options.subtext,
canvas.width / 2,
canvas.height * 0.72
);
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
toneMapped: false
})
);
mesh.position.set(position[0], position[1], position[2]);
mesh.renderOrder = 2;
if (options.rotation) {
mesh.rotation.set(
options.rotation[0],
options.rotation[1],
options.rotation[2]
);
}
world.add(mesh);
return mesh;
}
function makeInfoIcon(position, size) {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 512;
const context = canvas.getContext("2d");
context.clearRect(0, 0, 512, 512);
context.beginPath();
context.arc(256, 256, 220, 0, Math.PI * 2);
context.fillStyle = "#f7f0e4";
context.fill();
context.lineWidth = 18;
context.strokeStyle = "#d1a55f";
context.stroke();
context.fillStyle = "#205c60";
context.textAlign = "center";
context.textBaseline = "middle";
context.font = "700 330px Georgia, serif";
context.fillText("i", 256, 275);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(size, size),
new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
toneMapped: false
})
);
mesh.position.set(position[0], position[1], position[2]);
mesh.renderOrder = 3;
world.add(mesh);
return mesh;
}
function makeFloorArrow(x, z, material) {
const shape = new THREE.Shape();
shape.moveTo(-0.22, 0.8);
shape.lineTo(0.22, 0.8);
shape.lineTo(0.22, 0);
shape.lineTo(0.68, 0);
shape.lineTo(0, -1);
shape.lineTo(-0.68, 0);
shape.lineTo(-0.22, 0);
shape.closePath();
const geometry = new THREE.ShapeGeometry(shape);
geometry.rotateX(-Math.PI / 2);
const arrow = new THREE.Mesh(geometry, material);
arrow.position.set(x, 0.035, z);
world.add(arrow);
return arrow;
}
// -------------------------------------------------------------------------
// Main architecture
// -------------------------------------------------------------------------
// Main floor and faint tile grid.
box([22, 0.3, 24], [0, -0.15, 1], materials.floor);
const gridVertices = [];
for (let x = -10; x <= 10; x += 2) {
gridVertices.push(x, 0.008, -10.5, x, 0.008, 12.5);
}
for (let z = -10; z <= 12; z += 2) {
gridVertices.push(-10.5, 0.008, z, 10.5, 0.008, z);
}
const gridGeometry = new THREE.BufferGeometry();
gridGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(gridVertices, 3)
);
world.add(
new THREE.LineSegments(
gridGeometry,
new THREE.LineBasicMaterial({
color: 0x7b756c,
transparent: true,
opacity: 0.16
})
)
);
// Side walls.
box([0.25, 5.6, 22], [-11.2, 2.8, 0], materials.wall);
box([0.25, 5.6, 22], [11.2, 2.8, 0], materials.wall);
// Base trims.
box([0.1, 0.25, 21.6], [-11.04, 0.13, 0], materials.wallAccent);
box([0.1, 0.25, 21.6], [11.04, 0.13, 0], materials.wallAccent);
// Rear wall is divided around two corridor openings.
box([9.6, 5.6, 0.36], [0, 2.8, -10.8], materials.wall);
box([1.6, 5.6, 0.36], [-10.4, 2.8, -10.8], materials.wall);
box([1.6, 5.6, 0.36], [10.4, 2.8, -10.8], materials.wall);
// Lintels above the openings.
box([4.8, 1.6, 0.36], [-7.2, 4.8, -10.8], materials.wall);
box([4.8, 1.6, 0.36], [7.2, 4.8, -10.8], materials.wall);
// Two rear corridor interiors.
for (const x of [-7.2, 7.2]) {
box([4.8, 0.3, 12], [x, -0.15, -16.8], materials.floor);
box([0.2, 4.8, 12], [x - 2.4, 2.4, -16.8], materials.wallAccent);
box([0.2, 4.8, 12], [x + 2.4, 2.4, -16.8], materials.wallAccent);
box([4.8, 4.8, 0.2], [x, 2.4, -22.9], materials.wall);
// Distant doors.
box([3.25, 3.35, 0.08], [x, 1.68, -22.76], materials.navy);
box([0.05, 3.35, 0.05], [x, 1.68, -22.7], materials.brass);
box([0.08, 0.35, 0.08], [x - 0.24, 1.55, -22.66], materials.brass);
box([0.08, 0.35, 0.08], [x + 0.24, 1.55, -22.66], materials.brass);
// Ceiling light rails.
box([0.08, 0.05, 10.4], [x, 4.48, -16.6], materials.light);
}
// Directional arrows inside both corridors.
const arrowMaterial = new THREE.MeshBasicMaterial({
color: 0x347f7b,
side: THREE.DoubleSide
});
makeFloorArrow(-7.2, -12.2, arrowMaterial);
makeFloorArrow(7.2, -12.2, arrowMaterial);
// Centered area rug guides the entrance toward the desk.
roundedFloor(8.2, 13.4, 0.65, [0, 0.012, 1], materials.rugEdge);
roundedFloor(7.5, 12.7, 0.5, [0, 0.021, 1], materials.rug);
// -------------------------------------------------------------------------
// Entrance portal
// -------------------------------------------------------------------------
box([0.36, 5.6, 0.48], [-9.5, 2.8, 11.25], materials.navy);
box([0.36, 5.6, 0.48], [9.5, 2.8, 11.25], materials.navy);
box([19.35, 0.2, 0.48], [0, 5.58, 11.25], materials.navy);
box([19.5, 0.08, 0.72], [0, 0.035, 11.25], materials.brass);
// Open glass door panels.
for (const x of [-7.45, 7.45]) {
box([3.15, 4.9, 0.04], [x, 2.6, 11.18], materials.glass);
box([0.07, 5.05, 0.12], [x - 1.6, 2.62, 11.25], materials.navy);
box([0.07, 5.05, 0.12], [x + 1.6, 2.62, 11.25], materials.navy);
box([3.25, 0.07, 0.12], [x, 5.08, 11.25], materials.navy);
box([0.05, 1.05, 0.08], [x + (x < 0 ? 1.25 : -1.25), 2.25, 11.3], materials.brass);
}
// Entrance sign and welcome mat.
box([5.8, 0.72, 0.12], [0, 5.12, 11.43], materials.tealDark);
makeLabel("FOYER / WELCOME", 5.25, 0.48, [0, 5.12, 11.51], {
foreground: "#fff7e8",
fontSize: 58
});
box([7.2, 0.035, 2.35], [0, 0.025, 12.55], materials.navy);
makeLabel("WELCOME", 3.5, 0.55, [0, 0.047, 12.55], {
foreground: "#e9ddc8",
fontSize: 68
});
// -------------------------------------------------------------------------
// Wayfinding signs
// -------------------------------------------------------------------------
box([4.35, 0.82, 0.1], [-7.2, 4.75, -10.57], materials.tealDark);
makeLabel("WEST CORRIDOR", 3.95, 0.5, [-7.2, 4.75, -10.505], {
foreground: "#fff8e9",
fontSize: 57
});
box([4.35, 0.82, 0.1], [7.2, 4.75, -10.57], materials.tealDark);
makeLabel("EAST CORRIDOR", 3.95, 0.5, [7.2, 4.75, -10.505], {
foreground: "#fff8e9",
fontSize: 57
});
box([5.65, 1.08, 0.1], [0, 3.85, -10.57], materials.navy);
makeLabel("INFORMATION", 5.1, 0.72, [0, 3.85, -10.505], {
foreground: "#fff8e9",
fontSize: 75,
subtext: "ASK US — WE'LL POINT THE WAY",
subtextColor: "#d7b36f"
});
// -------------------------------------------------------------------------
// Help desk
// -------------------------------------------------------------------------
roundedBox(7, 1.65, 2.4, 0.34, [0, 0.825, -8.3], materials.teal);
roundedBox(6.7, 1.25, 0.08, 0.26, [0, 0.88, -7.065], materials.tealDark);
roundedBox(7.55, 0.2, 2.78, 0.12, [0, 1.78, -8.3], materials.white);
roundedBox(6.45, 0.13, 1.9, 0.06, [0, 0.09, -8.3], materials.navy);
// Fine brass details on the front.
box([0.035, 1.02, 0.025], [-3.12, 0.92, -7.005], materials.brass);
box([0.035, 1.02, 0.025], [3.12, 0.92, -7.005], materials.brass);
makeInfoIcon([0, 1.03, -6.985], 1.18);
makeLabel("HELP DESK", 2.35, 0.44, [2.02, 1.02, -6.985], {
foreground: "#fff8e9",
fontSize: 62
});
// Desktop monitor and stand.
roundedBox(0.72, 0.06, 0.46, 0.05, [-1.9, 1.91, -8.45], materials.navy);
box([0.09, 0.46, 0.09], [-1.9, 2.15, -8.45], materials.navy);
roundedBox(1.02, 0.64, 0.1, 0.08, [-1.9, 2.5, -8.48], materials.navy);
box([0.88, 0.49, 0.015], [-1.9, 2.5, -8.418], materials.screen);
// Small visitor-facing tablet.
box([0.55, 0.035, 0.38], [0.45, 1.92, -8.02], materials.navy);
const tablet = box([0.47, 0.04, 0.32], [0.45, 2.02, -8.02], materials.screen);
tablet.rotation.x = -0.45;
// Desk lamp.
const lampCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(2.75, 1.9, -8.55),
new THREE.Vector3(2.75, 2.55, -8.55),
new THREE.Vector3(2.58, 2.95, -8.35),
new THREE.Vector3(2.28, 3.02, -8.12)
]);
const lampArm = new THREE.Mesh(
new THREE.TubeGeometry(lampCurve, 24, 0.035, 8, false),
materials.brass
);
lampArm.castShadow = true;
world.add(lampArm);
cylinder(0.25, 0.3, 0.08, [2.75, 1.91, -8.55], materials.brass);
const lampShade = cylinder(
0.12,
0.3,
0.28,
[2.28, 2.93, -8.12],
materials.navy
);
lampShade.rotation.z = -0.2;
cylinder(0.19, 0.19, 0.025, [2.28, 2.79, -8.12], materials.light);
// Bell and nameplate.
const bell = new THREE.Mesh(
new THREE.SphereGeometry(0.23, 24, 12, 0, Math.PI * 2, 0, Math.PI / 2),
materials.brass
);
bell.position.set(1.55, 1.88, -8.02);
bell.scale.y = 0.55;
bell.castShadow = true;
world.add(bell);
cylinder(0.24, 0.24, 0.035, [1.55, 1.885, -8.02], materials.navy);
box([0.9, 0.3, 0.08], [-0.8, 2.0, -7.85], materials.navy);
makeLabel("VISITOR SERVICES", 0.8, 0.19, [-0.8, 2.0, -7.8], {
foreground: "#f7e4bd",
fontSize: 45
});
// Brochure holders.
for (let i = 0; i < 3; i++) {
const brochure = box(
[0.12, 0.38, 0.18],
[-3.02 + i * 0.14, 2.04, -7.72],
i === 1 ? materials.wood : materials.tealDark
);
brochure.rotation.z = -0.08 + i * 0.07;
}
// -------------------------------------------------------------------------
// Stylized staff member behind the desk
// -------------------------------------------------------------------------
const staff = new THREE.Group();
staff.position.set(0, 0, -9.48);
world.add(staff);
const torso = new THREE.Mesh(
new THREE.CapsuleGeometry(0.34, 0.67, 5, 14),
materials.navy
);
torso.position.y = 2.33;
torso.castShadow = true;
staff.add(torso);
const apron = roundedBox(
0.66,
0.86,
0.09,
0.15,
[0, 2.2, 0.34],
materials.teal,
staff
);
apron.rotation.x = -0.06;
cylinder(0.11, 0.11, 0.2, [0, 2.97, 0], materials.skin, staff);
const head = new THREE.Mesh(
new THREE.SphereGeometry(0.3, 24, 16),
materials.skin
);
head.position.set(0, 3.24, 0);
head.castShadow = true;
staff.add(head);
const hair = new THREE.Mesh(
new THREE.SphereGeometry(0.315, 24, 16),
materials.hair
);
hair.position.set(0, 3.39, -0.035);
hair.scale.set(1, 0.63, 0.94);
hair.castShadow = true;
staff.add(hair);
for (const x of [-0.095, 0.095]) {
const eye = new THREE.Mesh(
new THREE.SphereGeometry(0.022, 10, 8),
materials.black
);
eye.position.set(x, 3.26, 0.285);
staff.add(eye);
}
for (const x of [-0.42, 0.42]) {
const arm = new THREE.Mesh(
new THREE.CapsuleGeometry(0.105, 0.58, 4, 10),
materials.navy
);
arm.position.set(x, 2.24, 0.16);
arm.rotation.z = x < 0 ? -0.18 : 0.18;
arm.castShadow = true;
staff.add(arm);
const hand = new THREE.Mesh(
new THREE.SphereGeometry(0.11, 14, 10),
materials.skin
);
hand.position.set(x, 1.98, 0.42);
hand.scale.y = 0.7;
staff.add(hand);
}
box([0.16, 0.11, 0.025], [0.16, 2.49, 0.395], materials.brass, staff);
// -------------------------------------------------------------------------
// Benches and wall art
// -------------------------------------------------------------------------
function makeBench(x, z) {
const bench = new THREE.Group();
bench.position.set(x, 0, z);
world.add(bench);
for (let i = -2; i <= 2; i++) {
box([0.2, 0.12, 3.8], [i * 0.28, 0.62, 0], materials.wood, bench);
}
box([1.45, 0.12, 0.12], [0, 0.42, -1.35], materials.navy, bench);
box([1.45, 0.12, 0.12], [0, 0.42, 1.35], materials.navy, bench);
for (const zLocal of [-1.3, 1.3]) {
box([0.12, 0.6, 0.12], [-0.55, 0.3, zLocal], materials.navy, bench);
box([0.12, 0.6, 0.12], [0.55, 0.3, zLocal], materials.navy, bench);
}
}
makeBench(-8.65, 1.1);
makeBench(8.65, 1.1);
// Geometric mural on the right wall.
box([0.07, 2.65, 4.8], [11.04, 3.15, 0.8], materials.tealDark);
const muralCircleA = new THREE.Mesh(
new THREE.CircleGeometry(0.72, 40),
materials.brass
);
muralCircleA.rotation.y = -Math.PI / 2;
muralCircleA.position.set(10.99, 3.15, 0.1);
world.add(muralCircleA);
const muralCircleB = new THREE.Mesh(
new THREE.CircleGeometry(0.48, 40),
materials.wood
);
muralCircleB.rotation.y = -Math.PI / 2;
muralCircleB.position.set(10.985, 3.35, 1.3);
world.add(muralCircleB);
box([0.04, 0.22, 2.4], [10.98, 2.35, 1.1], materials.white);
// A simple wall clock on the left.
const clock = cylinder(
0.62,
0.62,
0.09,
[-11.02, 3.7, -2.1],
materials.white
);
clock.rotation.z = Math.PI / 2;
box([0.035, 0.05, 0.38], [-10.96, 3.85, -2.18], materials.navy);
box([0.035, 0.31, 0.05], [-10.955, 3.68, -2.05], materials.navy);
// -------------------------------------------------------------------------
// Plants
// -------------------------------------------------------------------------
const swayingLeaves = [];
function makePlant(x, z, scale = 1) {
const plant = new THREE.Group();
plant.position.set(x, 0, z);
plant.scale.setScalar(scale);
world.add(plant);
cylinder(0.48, 0.34, 0.7, [0, 0.35, 0], materials.wood, plant);
cylinder(0.43, 0.43, 0.04, [0, 0.71, 0], materials.soil, plant);
const stem = cylinder(
0.035,
0.055,
2.05,
[0, 1.65, 0],
materials.woodDark,
plant,
12
);
stem.rotation.z = 0.035;
for (let i = 0; i < 13; i++) {
const angle = i * 2.399;
const radius = 0.18 + (i % 4) * 0.09;
const height = 0.95 + i * 0.145;
const leaf = new THREE.Mesh(
new THREE.SphereGeometry(1, 16, 10),
i % 2 === 0 ? materials.leaf : materials.leafLight
);
leaf.scale.set(0.23, 0.54, 0.075);
leaf.position.set(
Math.cos(angle) * radius,
height,
Math.sin(angle) * radius
);
leaf.rotation.set(
Math.sin(angle) * 0.5,
-angle,
Math.cos(angle) * 0.65
);
leaf.castShadow = true;
plant.add(leaf);
leaf.userData.baseRotationZ = leaf.rotation.z;
leaf.userData.phase = i * 0.7;
swayingLeaves.push(leaf);
}
}
makePlant(-9.75, 8.5, 0.88);
makePlant(9.75, 8.5, 0.88);
makePlant(-4.05, -6.35, 0.95);
makePlant(4.05, -6.35, 0.95);
// -------------------------------------------------------------------------
// Pendant lighting over the help desk
// -------------------------------------------------------------------------
for (const x of [-2.25, 0, 2.25]) {
cylinder(0.018, 0.018, 1.05, [x, 5.08, -7.95], materials.navy, world, 10);
cylinder(0.18, 0.52, 0.4, [x, 4.43, -7.95], materials.navy, world, 32);
cylinder(0.4, 0.4, 0.025, [x, 4.22, -7.95], materials.light, world, 32);
}
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
scene.add(
new THREE.HemisphereLight(0xfff8e9, 0x78868a, 2.05)
);
const sunlight = new THREE.DirectionalLight(0xfff0d8, 3.1);
sunlight.position.set(-10, 19, 13);
sunlight.castShadow = true;
sunlight.shadow.mapSize.set(2048, 2048);
sunlight.shadow.camera.left = -18;
sunlight.shadow.camera.right = 18;
sunlight.shadow.camera.top = 18;
sunlight.shadow.camera.bottom = -18;
sunlight.shadow.camera.near = 1;
sunlight.shadow.camera.far = 48;
sunlight.shadow.bias = -0.00035;
sunlight.shadow.normalBias = 0.025;
scene.add(sunlight);
scene.add(sunlight.target);
const deskLight = new THREE.PointLight(0xffd89b, 34, 12, 2);
deskLight.position.set(0, 4.1, -7.4);
scene.add(deskLight);
const westLight = new THREE.PointLight(0xffe1b2, 24, 11, 2);
westLight.position.set(-7.2, 3.7, -14.2);
scene.add(westLight);
const eastLight = new THREE.PointLight(0xffe1b2, 24, 11, 2);
eastLight.position.set(7.2, 3.7, -14.2);
scene.add(eastLight);
const entranceLight = new THREE.PointLight(0xd9eeed, 20, 15, 2);
entranceLight.position.set(0, 5, 8);
scene.add(entranceLight);
// -------------------------------------------------------------------------
// Floating dust motes
// -------------------------------------------------------------------------
const dustCount = 130;
const dustPositions = new Float32Array(dustCount * 3);
for (let i = 0; i < dustCount; i++) {
dustPositions[i * 3] = (Math.random() - 0.5) * 18;
dustPositions[i * 3 + 1] = 0.4 + Math.random() * 5.6;
dustPositions[i * 3 + 2] = -11 + Math.random() * 22;
}
const dustGeometry = new THREE.BufferGeometry();
dustGeometry.setAttribute(
"position",
new THREE.BufferAttribute(dustPositions, 3)
);
const dust = new THREE.Points(
dustGeometry,
new THREE.PointsMaterial({
color: 0xfff3d4,
size: 0.045,
transparent: true,
opacity: 0.35,
depthWrite: false
})
);
world.add(dust);
// -------------------------------------------------------------------------
// Custom orbit / pan / zoom controls
// -------------------------------------------------------------------------
const controls = {
target: new THREE.Vector3(0, 1.15, -5.2),
radius: 28.5,
theta: 0.45,
phi: 1.14
};
const defaultControls = {
target: controls.target.clone(),
radius: controls.radius,
theta: controls.theta,
phi: controls.phi
};
function updateCamera() {
const offset = new THREE.Vector3().setFromSphericalCoords(
controls.radius,
controls.phi,
controls.theta
);
camera.position.copy(controls.target).add(offset);
camera.lookAt(controls.target);
camera.updateMatrixWorld();
}
function resetView() {
controls.target.copy(defaultControls.target);
controls.radius = defaultControls.radius;
controls.theta = defaultControls.theta;
controls.phi = defaultControls.phi;
updateCamera();
}
updateCamera();
const pointers = new Map();
let interactionMode = "orbit";
let previousX = 0;
let previousY = 0;
let pinchDistance = 0;
const canvas = renderer.domElement;
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener("pointerdown", (event) => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 2) {
interactionMode = "pinch";
const points = [...pointers.values()];
pinchDistance = Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
return;
}
interactionMode =
event.shiftKey || event.button === 2 ? "pan" : "orbit";
previousX = event.clientX;
previousY = event.clientY;
});
canvas.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size >= 2) {
const points = [...pointers.values()];
const distance = Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
if (pinchDistance > 0) {
controls.radius = THREE.MathUtils.clamp(
controls.radius * (pinchDistance / distance),
12,
38
);
updateCamera();
}
pinchDistance = distance;
return;
}
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
if (interactionMode === "orbit") {
controls.theta -= deltaX * 0.005;
controls.phi = THREE.MathUtils.clamp(
controls.phi - deltaY * 0.0045,
0.28,
1.45
);
} else if (interactionMode === "pan") {
const right = new THREE.Vector3().setFromMatrixColumn(
camera.matrix,
0
);
const up = new THREE.Vector3().setFromMatrixColumn(camera.matrix, 1);
const panScale = controls.radius * 0.00125;
controls.target.addScaledVector(right, -deltaX * panScale);
controls.target.addScaledVector(up, deltaY * panScale);
controls.target.x = THREE.MathUtils.clamp(
controls.target.x,
-8,
8
);
controls.target.y = THREE.MathUtils.clamp(
controls.target.y,
0.4,
4.5
);
controls.target.z = THREE.MathUtils.clamp(
controls.target.z,
-13,
8
);
}
updateCamera();
});
function endPointer(event) {
pointers.delete(event.pointerId);
if (pointers.size === 0) {
interactionMode = "orbit";
pinchDistance = 0;
} else if (pointers.size === 1) {
const remaining = [...pointers.values()][0];
previousX = remaining.x;
previousY = remaining.y;
interactionMode = "orbit";
}
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(
controls.radius * Math.exp(event.deltaY * 0.001),
12,
38
);
updateCamera();
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetView);
window.addEventListener("keydown", (event) => {
const key = event.key.toLowerCase();
if (key === "arrowleft") controls.theta += 0.08;
else if (key === "arrowright") controls.theta -= 0.08;
else if (key === "arrowup") controls.phi -= 0.05;
else if (key === "arrowdown") controls.phi += 0.05;
else if (key === "+" || key === "=") controls.radius -= 1;
else if (key === "-") controls.radius += 1;
else if (key === "r") {
resetView();
return;
} else {
return;
}
controls.phi = THREE.MathUtils.clamp(controls.phi, 0.28, 1.45);
controls.radius = THREE.MathUtils.clamp(controls.radius, 12, 38);
updateCamera();
});
document.getElementById("reset-view").addEventListener("click", resetView);
// -------------------------------------------------------------------------
// Resize and animation
// -------------------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
const animationClock = new THREE.Clock();
renderer.setAnimationLoop(() => {
const delta = Math.min(animationClock.getDelta(), 0.05);
const elapsed = animationClock.elapsedTime;
// Gentle plant movement.
for (const leaf of swayingLeaves) {
leaf.rotation.z =
leaf.userData.baseRotationZ +
Math.sin(elapsed * 0.8 + leaf.userData.phase) * 0.025;
}
// Slow rising dust.
const positions = dustGeometry.attributes.position.array;
for (let i = 0; i < dustCount; i++) {
positions[i * 3 + 1] += delta * 0.045;
positions[i * 3] += Math.sin(elapsed * 0.25 + i) * delta * 0.007;
if (positions[i * 3 + 1] > 6.2) {
positions[i * 3 + 1] = 0.35;
}
}
dustGeometry.attributes.position.needsUpdate = true;
deskLight.intensity = 33 + Math.sin(elapsed * 1.1) * 1.4;
renderer.render(scene, camera);
});
</script>
</body>
</html>
```