Prompt specification
Build or customize the Three.js 3D scene "Gate Desk Queue and Boarding Door" 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: Gate Desk Queue and Boarding Door
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/gate-desk-queue-and-boarding-door-x2081
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows a small airport boarding gate in a clean stylized solid style. Place a service desk against the back wall, an ordinary boarding doorway to one side, and a short queue guided by posts. Beside that queue, leave a separate unobstructed passage wide enough for a schematic wheelchair or stroller proxy. Add a compact waiting area with several seats facing the desk and luggage placed outside the walking routes. Make the distinction between waiting, queuing, and passing through apparent from the layout itself. Keep the scene focused on public boarding space and everyday passenger circulation.
Working Three.js Starter (gate-desk-queue-and-boarding-door-x2081):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Airport Boarding Gate</title>
<style>
:root {
--ink: #20383f;
--muted: #61757b;
--panel: rgba(255, 255, 255, 0.9);
--waiting: #78aeca;
--queue: #e6b75c;
--passage: #72b9a6;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e8eef0;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene canvas:active {
cursor: grabbing;
}
.title-card {
position: fixed;
top: 22px;
left: 22px;
z-index: 2;
width: min(330px, calc(100vw - 44px));
padding: 16px 18px;
border: 1px solid rgba(32, 56, 63, 0.1);
border-radius: 16px;
background: var(--panel);
box-shadow: 0 12px 35px rgba(36, 62, 69, 0.12);
backdrop-filter: blur(12px);
pointer-events: none;
}
.eyebrow {
margin-bottom: 5px;
color: #4f8f8a;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: 23px;
line-height: 1.15;
letter-spacing: -0.025em;
}
.subtitle {
margin: 7px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.4;
}
.legend {
position: fixed;
left: 22px;
bottom: 22px;
z-index: 2;
display: flex;
flex-wrap: wrap;
gap: 8px;
max-width: calc(100vw - 44px);
padding: 10px;
border: 1px solid rgba(32, 56, 63, 0.1);
border-radius: 14px;
background: var(--panel);
box-shadow: 0 10px 30px rgba(36, 62, 69, 0.1);
backdrop-filter: blur(12px);
pointer-events: none;
}
.legend-item {
display: flex;
align-items: center;
gap: 7px;
padding: 5px 8px;
color: #466067;
font-size: 12px;
font-weight: 650;
white-space: nowrap;
}
.swatch {
width: 11px;
height: 11px;
border-radius: 3px;
box-shadow: inset 0 0 0 1px rgba(20, 40, 45, 0.08);
}
.swatch.waiting {
background: var(--waiting);
}
.swatch.queue {
background: var(--queue);
}
.swatch.passage {
background: var(--passage);
}
.controls {
position: fixed;
right: 22px;
bottom: 22px;
z-index: 3;
display: flex;
align-items: center;
gap: 10px;
}
.hint {
padding: 8px 11px;
border-radius: 10px;
background: rgba(255, 255, 255, 0.78);
color: #64777c;
font-size: 11px;
box-shadow: 0 6px 20px rgba(36, 62, 69, 0.08);
pointer-events: none;
}
button {
min-height: 38px;
padding: 0 14px;
border: 1px solid rgba(32, 56, 63, 0.13);
border-radius: 10px;
background: rgba(255, 255, 255, 0.94);
color: var(--ink);
font: inherit;
font-size: 12px;
font-weight: 750;
cursor: pointer;
box-shadow: 0 7px 22px rgba(36, 62, 69, 0.1);
}
button:hover {
background: #fff;
transform: translateY(-1px);
}
@media (max-width: 700px) {
.title-card {
top: 12px;
left: 12px;
width: min(280px, calc(100vw - 24px));
padding: 12px 14px;
}
h1 {
font-size: 19px;
}
.subtitle,
.hint {
display: none;
}
.legend {
left: 12px;
bottom: 12px;
gap: 3px;
padding: 7px;
}
.legend-item {
padding: 4px 5px;
font-size: 10px;
}
.controls {
right: 12px;
bottom: 12px;
}
}
</style>
</head>
<body>
<div id="scene" aria-label="Interactive three-dimensional airport boarding gate"></div>
<header class="title-card">
<div class="eyebrow">Public boarding space</div>
<h1>Boarding Gate 12</h1>
<p class="subtitle">
A compact gate with separate waiting, queuing, and step-free circulation zones.
</p>
</header>
<div class="legend" aria-label="Zone legend">
<div class="legend-item">
<span class="swatch waiting"></span>
Waiting
</div>
<div class="legend-item">
<span class="swatch queue"></span>
Queue
</div>
<div class="legend-item">
<span class="swatch passage"></span>
Clear passage
</div>
</div>
<div class="controls">
<div class="hint">Drag to orbit · Scroll to zoom</div>
<button id="reset" 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";
const host = document.querySelector("#scene");
// -------------------------------------------------------------------------
// Renderer, scene, and lighting
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe8eef0);
scene.fog = new THREE.Fog(0xe8eef0, 22, 38);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
host.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-8, 8, 5, -5, 0.1, 80);
const hemisphere = new THREE.HemisphereLight(0xf7fcff, 0x8b9b9a, 2.05);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff8e9, 3.1);
keyLight.position.set(-5, 11, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -11;
keyLight.shadow.camera.right = 11;
keyLight.shadow.camera.top = 11;
keyLight.shadow.camera.bottom = -11;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 30;
keyLight.shadow.bias = -0.00035;
keyLight.shadow.normalBias = 0.025;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xcce7ef, 1.0);
fillLight.position.set(8, 6, -2);
scene.add(fillLight);
// -------------------------------------------------------------------------
// Palette and small construction helpers
// -------------------------------------------------------------------------
const palette = {
floor: 0xdfe5e4,
slab: 0xb9c6c5,
wall: 0xf2f1eb,
wallTrim: 0xd8dfdc,
teal: 0x367f7c,
tealLight: 0x8fc1b7,
tealDark: 0x245b5c,
navy: 0x294a59,
blue: 0x6d9fbb,
blueDark: 0x416e84,
queue: 0xe8c778,
belt: 0x31565b,
metal: 0x718286,
metalLight: 0xaab7b8,
white: 0xf8f8f3,
path: 0xa9d3c3,
pathEdge: 0x77b7a3,
wood: 0xcba77d,
luggage: 0xc77962,
green: 0x568c6f,
dark: 0x233f47
};
const materialCache = new Map();
function material(color, roughness = 0.78, metalness = 0.0) {
const key = `${color}-${roughness}-${metalness}`;
if (!materialCache.has(key)) {
materialCache.set(
key,
new THREE.MeshStandardMaterial({
color,
roughness,
metalness
})
);
}
return materialCache.get(key);
}
function box(parent, size, position, color, options = {}) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
options.material || material(color, options.roughness, options.metalness)
);
mesh.position.set(position[0], position[1], position[2]);
if (options.rotationY) {
mesh.rotation.y = options.rotationY;
}
mesh.castShadow = options.castShadow !== false;
mesh.receiveShadow = options.receiveShadow !== false;
parent.add(mesh);
return mesh;
}
function cylinder(
parent,
radius,
height,
position,
color,
options = {}
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radius,
options.bottomRadius ?? radius,
height,
options.segments ?? 24
),
options.material || material(color, options.roughness, options.metalness)
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = options.castShadow !== false;
mesh.receiveShadow = options.receiveShadow !== false;
parent.add(mesh);
return mesh;
}
function sphere(parent, radius, position, color, options = {}) {
const mesh = new THREE.Mesh(
new THREE.SphereGeometry(radius, options.segments ?? 20, 14),
options.material || material(color, options.roughness, options.metalness)
);
mesh.position.set(position[0], position[1], position[2]);
if (options.scale) {
mesh.scale.set(...options.scale);
}
if (options.rotation) {
mesh.rotation.set(...options.rotation);
}
mesh.castShadow = options.castShadow !== false;
mesh.receiveShadow = options.receiveShadow !== false;
parent.add(mesh);
return mesh;
}
function canvasTexture(canvas) {
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
renderer.capabilities.getMaxAnisotropy(),
8
);
return texture;
}
function roundedRectPath(ctx, x, y, width, height, radius) {
const r = Math.min(radius, width / 2, height / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.arcTo(x + width, y, x + width, y + height, r);
ctx.arcTo(x + width, y + height, x, y + height, r);
ctx.arcTo(x, y + height, x, y, r);
ctx.arcTo(x, y, x + width, y, r);
ctx.closePath();
}
function makeSign(text, background, foreground, width = 768, height = 192) {
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, width, height);
roundedRectPath(ctx, 8, 8, width - 16, height - 16, 28);
ctx.fillStyle = background;
ctx.fill();
ctx.fillStyle = foreground;
ctx.font = `800 ${Math.floor(height * 0.43)}px Inter, system-ui, sans-serif`;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, width / 2, height / 2 + 2);
return canvasTexture(canvas);
}
function addWallSign(text, width, height, position, background, foreground) {
const texture = makeSign(text, background, foreground);
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
toneMapped: false,
depthWrite: false
})
);
mesh.position.set(...position);
scene.add(mesh);
return mesh;
}
// -------------------------------------------------------------------------
// Floor and back wall
// -------------------------------------------------------------------------
const architecture = new THREE.Group();
scene.add(architecture);
box(
architecture,
[12.8, 0.30, 10.7],
[0, -0.18, 0.10],
palette.slab,
{ roughness: 0.9 }
);
box(
architecture,
[12.45, 0.08, 10.25],
[0, -0.01, 0.10],
palette.floor,
{ roughness: 0.92 }
);
// Back wall with a real opening for the boarding doorway.
const doorLeft = 2.40;
const doorRight = 4.10;
const doorWidth = doorRight - doorLeft;
const wallHeight = 3.30;
const doorHeight = 2.35;
const wallZ = -4.78;
const leftSegmentWidth = doorLeft - (-6.15);
box(
architecture,
[leftSegmentWidth, wallHeight, 0.22],
[(-6.15 + doorLeft) / 2, wallHeight / 2, wallZ],
palette.wall
);
const rightSegmentWidth = 6.15 - doorRight;
box(
architecture,
[rightSegmentWidth, wallHeight, 0.22],
[(doorRight + 6.15) / 2, wallHeight / 2, wallZ],
palette.wall
);
box(
architecture,
[doorWidth, wallHeight - doorHeight, 0.22],
[(doorLeft + doorRight) / 2, doorHeight + (wallHeight - doorHeight) / 2, wallZ],
palette.wall
);
// Skirting gives the wall a solid architectural edge without clutter.
box(
architecture,
[leftSegmentWidth, 0.16, 0.08],
[(-6.15 + doorLeft) / 2, 0.08, wallZ + 0.15],
palette.wallTrim
);
box(
architecture,
[rightSegmentWidth, 0.16, 0.08],
[(doorRight + 6.15) / 2, 0.08, wallZ + 0.15],
palette.wallTrim
);
// Pale accent panel behind the service counter.
box(
architecture,
[4.05, 1.36, 0.055],
[-2.55, 1.87, wallZ + 0.145],
0xd7e9e3
);
addWallSign(
"SERVICE",
2.15,
0.58,
[-2.55, 1.91, wallZ + 0.18],
"#f8fbf7",
"#2f6968"
);
addWallSign(
"GATE 12",
1.38,
0.40,
[3.25, 2.83, wallZ + 0.18],
"#2f6968",
"#ffffff"
);
// Doorway frame and a simple corridor beyond it.
box(
architecture,
[0.11, doorHeight, 0.16],
[doorLeft, doorHeight / 2, wallZ + 0.14],
palette.tealDark
);
box(
architecture,
[0.11, doorHeight, 0.16],
[doorRight, doorHeight / 2, wallZ + 0.14],
palette.tealDark
);
box(
architecture,
[doorWidth + 0.11, 0.11, 0.16],
[(doorLeft + doorRight) / 2, doorHeight, wallZ + 0.14],
palette.tealDark
);
box(
architecture,
[doorWidth, 0.035, 1.35],
[3.25, 0.052, -5.15],
0x789593
);
box(
architecture,
[doorWidth, doorHeight, 0.08],
[3.25, doorHeight / 2, -5.62],
0x36565b
);
// The door is visibly open into the corridor, leaving the approach clear.
const doorHinge = new THREE.Group();
doorHinge.position.set(4.045, 0, wallZ + 0.02);
doorHinge.rotation.y = -1.15;
scene.add(doorHinge);
box(
doorHinge,
[1.60, 2.24, 0.08],
[-0.80, 1.13, 0],
0x9dc3c5
);
box(
doorHinge,
[1.22, 0.75, 0.025],
[-0.80, 1.55, 0.053],
0x6f9ca2
);
box(
doorHinge,
[0.10, 0.38, 0.10],
[-1.43, 1.02, 0.11],
palette.metalLight,
{ metalness: 0.5, roughness: 0.35 }
);
// -------------------------------------------------------------------------
// Service desk against the back wall
// -------------------------------------------------------------------------
const desk = new THREE.Group();
desk.position.set(-2.55, 0, -4.00);
scene.add(desk);
box(
desk,
[3.45, 0.88, 0.83],
[0, 0.49, 0],
palette.teal
);
box(
desk,
[3.62, 0.13, 0.98],
[0, 0.995, 0.02],
palette.white,
{ roughness: 0.55 }
);
box(
desk,
[3.08, 0.47, 0.025],
[0, 0.54, 0.428],
0x2f706e
);
box(
desk,
[0.62, 0.18, 0.025],
[0.73, 0.54, 0.451],
palette.tealLight
);
// Small countertop terminal, kept low so the desk remains public-facing.
box(
desk,
[0.12, 0.23, 0.12],
[-0.72, 1.17, -0.10],
palette.metal,
{ metalness: 0.45, roughness: 0.35 }
);
box(
desk,
[0.58, 0.36, 0.08],
[-0.72, 1.42, -0.11],
palette.navy,
{ rotationY: 0.08 }
);
box(
desk,
[0.48, 0.25, 0.012],
[-0.72, 1.42, -0.063],
0x8ec5c6,
{ rotationY: 0.08 }
);
// -------------------------------------------------------------------------
// Waiting zone: inset floor mat, four seats facing the service desk
// -------------------------------------------------------------------------
box(
scene,
[4.25, 0.018, 2.15],
[-3.25, 0.046, 0.86],
0xb8d1df,
{ castShadow: false }
);
box(
scene,
[4.02, 0.006, 1.92],
[-3.25, 0.059, 0.86],
0xc5dbe5,
{ castShadow: false }
);
function createChair(x, z, index) {
const chair = new THREE.Group();
chair.position.set(x, 0, z);
scene.add(chair);
const seatColor = index % 2 === 0 ? palette.blue : palette.blueDark;
box(chair, [0.74, 0.14, 0.66], [0, 0.48, 0], seatColor);
box(chair, [0.74, 0.63, 0.13], [0, 0.83, 0.29], seatColor);
// Backrest is on the +Z side, so every seat faces the desk at -Z.
for (const legX of [-0.25, 0.25]) {
for (const legZ of [-0.21, 0.21]) {
box(
chair,
[0.055, 0.40, 0.055],
[legX, 0.23, legZ],
palette.metal,
{ metalness: 0.48, roughness: 0.38 }
);
}
}
for (const armX of [-0.405, 0.405]) {
box(chair, [0.055, 0.055, 0.54], [armX, 0.69, 0.02], palette.metal);
box(chair, [0.045, 0.27, 0.045], [armX, 0.55, 0.18], palette.metal);
}
}
[-4.40, -3.65, -2.90, -2.15].forEach((x, index) => {
createChair(x, 0.72, index);
});
// Compact side table.
cylinder(
scene,
0.30,
0.09,
[-1.48, 0.57, 0.55],
palette.white,
{ roughness: 0.55 }
);
cylinder(
scene,
0.055,
0.47,
[-1.48, 0.29, 0.55],
palette.metal,
{ metalness: 0.55, roughness: 0.35 }
);
cylinder(
scene,
0.22,
0.05,
[-1.48, 0.07, 0.55],
palette.metal,
{ metalness: 0.55, roughness: 0.35 }
);
// -------------------------------------------------------------------------
// Luggage kept beside the waiting seats, outside all walking routes
// -------------------------------------------------------------------------
function createSuitcase(x, z, color, rotationY = 0) {
const luggage = new THREE.Group();
luggage.position.set(x, 0, z);
luggage.rotation.y = rotationY;
scene.add(luggage);
box(luggage, [0.49, 0.68, 0.30], [0, 0.42, 0], color);
box(luggage, [0.055, 0.60, 0.018], [-0.15, 0.42, 0.158], 0xffffff);
box(luggage, [0.055, 0.60, 0.018], [0.15, 0.42, 0.158], 0xffffff);
box(
luggage,
[0.18, 0.045, 0.055],
[0, 0.80, 0],
palette.metalLight,
{ metalness: 0.5, roughness: 0.35 }
);
box(
luggage,
[0.045, 0.19, 0.045],
[-0.07, 0.73, 0],
palette.metalLight,
{ metalness: 0.5, roughness: 0.35 }
);
box(
luggage,
[0.045, 0.19, 0.045],
[0.07, 0.73, 0],
palette.metalLight,
{ metalness: 0.5, roughness: 0.35 }
);
for (const wheelX of [-0.17, 0.17]) {
const wheel = cylinder(
luggage,
0.065,
0.06,
[wheelX, 0.075, 0.02],
palette.dark
);
wheel.rotation.z = Math.PI / 2;
}
}
createSuitcase(-5.05, 1.48, palette.luggage, 0.12);
createSuitcase(-1.48, 1.67, palette.navy, -0.18);
// -------------------------------------------------------------------------
// Short queue: floor inset, stanchions, and alternating belt dividers
// -------------------------------------------------------------------------
box(
scene,
[1.82, 0.018, 4.04],
[0.05, 0.046, -1.17],
0xead69f,
{ castShadow: false }
);
function createStanchion(x, z) {
const group = new THREE.Group();
group.position.set(x, 0, z);
scene.add(group);
cylinder(
group,
0.15,
0.055,
[0, 0.075, 0],
palette.metal,
{ metalness: 0.55, roughness: 0.35 }
);
cylinder(
group,
0.037,
0.79,
[0, 0.49, 0],
palette.metalLight,
{ metalness: 0.72, roughness: 0.28 }
);
cylinder(
group,
0.075,
0.10,
[0, 0.91, 0],
palette.belt,
{ metalness: 0.25, roughness: 0.45 }
);
}
function createBelt(x1, z1, x2, z2) {
const dx = x2 - x1;
const dz = z2 - z1;
const length = Math.hypot(dx, dz);
const belt = box(
scene,
[length, 0.075, 0.035],
[(x1 + x2) / 2, 0.86, (z1 + z2) / 2],
palette.belt,
{ roughness: 0.6 }
);
belt.rotation.y = -Math.atan2(dz, dx);
}
const leftPostX = -0.80;
const rightPostX = 0.90;
const queueZs = [0.78, -0.52, -1.82, -3.12];
queueZs.forEach((z) => {
createStanchion(leftPostX, z);
createStanchion(rightPostX, z);
});
// Outer rails.
for (let i = 0; i < queueZs.length - 1; i++) {
createBelt(leftPostX, queueZs[i], leftPostX, queueZs[i + 1]);
createBelt(rightPostX, queueZs[i], rightPostX, queueZs[i + 1]);
}
// Alternating dividers create an obvious short serpentine queue.
createStanchion(0.18, -0.52);
createBelt(leftPostX, -0.52, 0.18, -0.52);
createStanchion(-0.10, -1.82);
createBelt(-0.10, -1.82, rightPostX, -1.82);
// A small, freestanding queue marker sits outside the queue footprint.
const queueMarker = new THREE.Group();
queueMarker.position.set(-1.10, 0, 0.35);
scene.add(queueMarker);
cylinder(
queueMarker,
0.035,
1.14,
[0, 0.62, 0],
palette.metal,
{ metalness: 0.5, roughness: 0.35 }
);
const queueSignTexture = makeSign(
"QUEUE",
"#f1ca70",
"#304b50",
512,
160
);
const queueSign = new THREE.Mesh(
new THREE.PlaneGeometry(0.88, 0.275),
new THREE.MeshBasicMaterial({
map: queueSignTexture,
transparent: true,
toneMapped: false,
depthWrite: false
})
);
queueSign.position.set(0, 1.24, 0.02);
queueMarker.add(queueSign);
// -------------------------------------------------------------------------
// Separate, permanently clear passage leading directly to the doorway
// -------------------------------------------------------------------------
// This strip is only a flush floor marking: no rails, curbs, or furniture.
box(
scene,
[1.70, 0.016, 8.12],
[3.25, 0.046, -0.43],
palette.path,
{ castShadow: false }
);
for (const edgeX of [2.39, 4.11]) {
box(
scene,
[0.035, 0.006, 8.05],
[edgeX, 0.059, -0.43],
palette.pathEdge,
{ castShadow: false }
);
}
// Painted wheelchair symbol, used as a flat circulation symbol.
const iconCanvas = document.createElement("canvas");
iconCanvas.width = 256;
iconCanvas.height = 256;
const iconContext = iconCanvas.getContext("2d");
iconContext.clearRect(0, 0, 256, 256);
iconContext.strokeStyle = "#2d716c";
iconContext.fillStyle = "#2d716c";
iconContext.lineWidth = 18;
iconContext.lineCap = "round";
iconContext.lineJoin = "round";
// Head.
iconContext.beginPath();
iconContext.arc(151, 42, 18, 0, Math.PI * 2);
iconContext.fill();
// Torso, seat, arm, and legs.
iconContext.beginPath();
iconContext.moveTo(143, 74);
iconContext.lineTo(131, 121);
iconContext.lineTo(173, 121);
iconContext.stroke();
iconContext.beginPath();
iconContext.moveTo(139, 91);
iconContext.lineTo(176, 91);
iconContext.stroke();
iconContext.beginPath();
iconContext.moveTo(173, 121);
iconContext.lineTo(201, 165);
iconContext.lineTo(224, 165);
iconContext.stroke();
// Wheel.
iconContext.beginPath();
iconContext.arc(102, 158, 49, 0, Math.PI * 2);
iconContext.stroke();
const iconTexture = canvasTexture(iconCanvas);
const floorIcon = new THREE.Mesh(
new THREE.PlaneGeometry(0.90, 0.90),
new THREE.MeshBasicMaterial({
map: iconTexture,
transparent: true,
depthWrite: false,
toneMapped: false,
side: THREE.DoubleSide
})
);
floorIcon.rotation.x = -Math.PI / 2;
floorIcon.position.set(3.25, 0.064, 2.05);
scene.add(floorIcon);
// Subtle directional chevrons point toward the doorway.
function addChevron(z) {
const shape = new THREE.Shape();
shape.moveTo(-0.18, 0);
shape.lineTo(0, 0.17);
shape.lineTo(0.18, 0);
shape.lineTo(0, 0.07);
shape.closePath();
const geometry = new THREE.ShapeGeometry(shape);
const mesh = new THREE.Mesh(
geometry,
new THREE.MeshBasicMaterial({
color: 0x5b9c8e,
transparent: true,
opacity: 0.68,
side: THREE.DoubleSide,
depthWrite: false
})
);
mesh.rotation.x = -Math.PI / 2;
mesh.rotation.z = Math.PI;
mesh.position.set(3.25, 0.064, z);
scene.add(mesh);
}
addChevron(3.05);
addChevron(-3.72);
// -------------------------------------------------------------------------
// Small architectural plant to the far side of the doorway
// -------------------------------------------------------------------------
const plant = new THREE.Group();
plant.position.set(5.30, 0, -3.82);
scene.add(plant);
cylinder(
plant,
0.27,
0.48,
[0, 0.29, 0],
0xd3b58e,
{ bottomRadius: 0.22 }
);
const leafData = [
[-0.10, 0.90, 0.02, 0.22, 0.70, 0.20, -0.50],
[0.13, 0.78, 0.00, 0.24, 0.63, 0.20, 0.48],
[0.00, 1.12, -0.02, 0.22, 0.78, 0.19, 0.04],
[-0.22, 0.72, 0.03, 0.20, 0.55, 0.18, -0.85],
[0.23, 1.00, -0.02, 0.20, 0.62, 0.18, 0.85]
];
for (const leaf of leafData) {
sphere(
plant,
0.28,
[leaf[0], leaf[1], leaf[2]],
leaf[3] > 0.225 ? palette.green : 0x6d9f7d,
{
scale: [leaf[4], leaf[5], leaf[6]],
rotation: [leaf[6] * 0.45, leaf[3] * 2, leaf[6] * 0.6]
}
);
}
// -------------------------------------------------------------------------
// Direct camera controls: drag to orbit and wheel/pinch to zoom
// -------------------------------------------------------------------------
const target = new THREE.Vector3(-0.15, 0.72, -0.45);
let theta = 0.43;
let phi = 0.84;
let zoom = 1.0;
const defaultView = {
theta: 0.43,
phi: 0.84,
zoom: 1.0
};
function updateCamera() {
const radius = 18;
const sinPhi = Math.sin(phi);
camera.position.set(
target.x + radius * sinPhi * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + radius * sinPhi * Math.cos(theta)
);
camera.lookAt(target);
camera.updateMatrixWorld();
}
function updateProjection() {
const aspect = window.innerWidth / window.innerHeight;
const fittingHeight = Math.max(9.7, 14.2 / aspect);
const viewHeight = fittingHeight / zoom;
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
}
function resize() {
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
updateProjection();
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;
theta = THREE.MathUtils.clamp(
theta - deltaX * 0.006,
-0.68,
0.92
);
phi = THREE.MathUtils.clamp(
phi - deltaY * 0.005,
0.58,
1.08
);
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("lostpointercapture", () => {
dragging = false;
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
zoom = THREE.MathUtils.clamp(
zoom * Math.exp(event.deltaY * 0.001),
0.76,
1.55
);
updateProjection();
},
{ passive: false }
);
document.querySelector("#reset").addEventListener("click", () => {
theta = defaultView.theta;
phi = defaultView.phi;
zoom = defaultView.zoom;
updateProjection();
updateCamera();
});
window.addEventListener("resize", resize);
resize();
updateCamera();
renderer.render(scene, camera);
</script>
</body>
</html>
```