Prompt specification
Build or customize the Three.js 3D scene "Winter reading corner" 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: Winter reading corner
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/winter-reading-corner-x0039
Scene Description Prompt:
A calm voxel reading corner where a reader tucks a covered warming bottle beside their feet beneath a blanket. Three.js from cdnjs, one HTML file.
Working Three.js Starter (winter-reading-corner-x0039):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Quiet Pages</title>
<style>
:root {
color-scheme: dark;
--cream: #f1e5cc;
--muted: #b8b8aa;
--glass: rgba(18, 29, 33, 0.62);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #142129;
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;
outline: none;
}
canvas:active {
cursor: grabbing;
}
.title-card {
position: fixed;
top: clamp(20px, 4vw, 44px);
left: clamp(20px, 4vw, 48px);
z-index: 2;
pointer-events: none;
color: var(--cream);
text-shadow: 0 2px 16px rgba(0, 0, 0, 0.45);
}
.eyebrow {
margin-bottom: 8px;
color: #d7ae78;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.24em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(30px, 5vw, 58px);
font-weight: 400;
letter-spacing: -0.035em;
}
.subtitle {
margin: 7px 0 0;
color: rgba(241, 229, 204, 0.72);
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(13px, 1.5vw, 17px);
font-style: italic;
}
.help {
position: fixed;
right: clamp(16px, 3vw, 36px);
bottom: clamp(16px, 3vw, 30px);
z-index: 2;
padding: 10px 14px;
border: 1px solid rgba(241, 229, 204, 0.12);
border-radius: 999px;
background: var(--glass);
color: rgba(241, 229, 204, 0.7);
font-size: 11px;
letter-spacing: 0.04em;
pointer-events: none;
backdrop-filter: blur(10px);
}
.loading {
position: fixed;
inset: 0;
z-index: 5;
display: grid;
place-items: center;
background: #142129;
color: var(--cream);
font-size: 12px;
letter-spacing: 0.18em;
text-transform: uppercase;
transition: opacity 0.7s ease;
pointer-events: none;
}
.loading.ready {
opacity: 0;
}
@media (max-width: 600px) {
.title-card {
top: 22px;
left: 22px;
}
.subtitle {
max-width: 230px;
}
.help {
left: 50%;
right: auto;
transform: translateX(-50%);
white-space: nowrap;
}
}
</style>
</head>
<body>
<div class="title-card">
<div class="eyebrow">After hours</div>
<h1>Quiet Pages</h1>
<p class="subtitle">A little warmth, tucked close.</p>
</div>
<div class="help">Drag to look · Scroll to zoom · Double-click to reset</div>
<div class="loading" id="loading">Settling in…</div>
<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(0x142129);
scene.fog = new THREE.Fog(0x142129, 14, 25);
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;
renderer.domElement.setAttribute(
"aria-label",
"A calm voxel reading corner with a reader, blanket, and covered warming bottle"
);
document.body.prepend(renderer.domElement);
const camera = new THREE.OrthographicCamera(-6, 6, 4, -4, 0.1, 60);
const target = new THREE.Vector3(-0.15, 1.55, -0.65);
const spherical = {
radius: 10.8,
theta: 0.63,
phi: 1.12
};
const hemi = new THREE.HemisphereLight(0xbdd6df, 0x4b3025, 1.35);
scene.add(hemi);
const moonLight = new THREE.DirectionalLight(0xa9c8dc, 1.6);
moonLight.position.set(3.5, 7.5, 5.5);
moonLight.castShadow = true;
moonLight.shadow.mapSize.set(2048, 2048);
moonLight.shadow.camera.left = -7;
moonLight.shadow.camera.right = 7;
moonLight.shadow.camera.top = 7;
moonLight.shadow.camera.bottom = -7;
moonLight.shadow.camera.near = 0.5;
moonLight.shadow.camera.far = 22;
moonLight.shadow.normalBias = 0.025;
scene.add(moonLight);
const roomFill = new THREE.DirectionalLight(0xffe3bd, 0.55);
roomFill.position.set(-4, 4, 2);
scene.add(roomFill);
const lampLight = new THREE.PointLight(0xffa85d, 34, 7, 2);
lampLight.position.set(2.92, 3.34, -1.55);
lampLight.castShadow = true;
lampLight.shadow.mapSize.set(512, 512);
lampLight.shadow.bias = -0.002;
scene.add(lampLight);
const bottleGlow = new THREE.PointLight(0xff9a66, 2.4, 1.5, 2);
bottleGlow.position.set(0.58, 0.48, 0.5);
scene.add(bottleGlow);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
function standard(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.9,
metalness: 0,
...options
});
}
function pixelTexture(base, accent, kind = "quilt") {
const canvas = document.createElement("canvas");
canvas.width = 64;
canvas.height = 64;
const ctx = canvas.getContext("2d");
ctx.fillStyle = base;
ctx.fillRect(0, 0, 64, 64);
if (kind === "quilt") {
ctx.fillStyle = accent;
for (let y = 0; y < 64; y += 16) {
for (let x = 0; x < 64; x += 16) {
if ((x + y) % 32 === 0) {
ctx.fillRect(x + 3, y + 3, 10, 10);
}
}
}
ctx.strokeStyle = "rgba(55, 28, 25, 0.35)";
ctx.lineWidth = 2;
ctx.strokeRect(1, 1, 62, 62);
ctx.fillStyle = "rgba(255, 224, 183, 0.4)";
for (let y = 8; y < 64; y += 16) {
for (let x = 8; x < 64; x += 16) {
ctx.fillRect(x, y, 2, 2);
}
}
} else {
ctx.fillStyle = accent;
for (let y = 0; y < 64; y += 8) {
ctx.fillRect(0, y, 64, 2);
}
for (let x = 0; x < 64; x += 8) {
ctx.fillRect(x, 0, 2, 64);
}
ctx.fillStyle = "rgba(255,255,255,0.18)";
for (let y = 3; y < 64; y += 8) {
ctx.fillRect(3, y, 3, 1);
}
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
texture.magFilter = THREE.NearestFilter;
texture.minFilter = THREE.NearestMipmapNearestFilter;
texture.anisotropy = Math.min(4, renderer.capabilities.getMaxAnisotropy());
return texture;
}
const blanketTexture = pixelTexture("#a75f52", "#c77b66", "quilt");
blanketTexture.repeat.set(1.7, 1.7);
const knitTexture = pixelTexture("#9cafa7", "#d7d4b9", "knit");
knitTexture.repeat.set(1.4, 1.4);
const materials = {
floor: standard(0x8d6650),
floorLine: standard(0x76513f),
wall: standard(0x82918b),
wallLower: standard(0x667872),
trim: standard(0xd4cbb4),
rug: standard(0x496c6b),
rugInner: standard(0x78918a),
rugLine: standard(0xc0a575),
chair: standard(0x496a68),
chairDark: standard(0x314e4d),
cushion: standard(0x73918a),
skin: standard(0xc99070),
skinLight: standard(0xdba483),
hair: standard(0x3b2d2a),
sweater: standard(0xc8a77b),
shirt: standard(0xeee0c4),
trousers: standard(0x3f4d53),
slipper: standard(0x73504b),
sock: standard(0xd7d0b8),
blanket: standard(0xffffff, { map: blanketTexture }),
knit: standard(0xffffff, { map: knitTexture }),
bottleCap: standard(0xc66c50),
wood: standard(0x76513e),
woodLight: standard(0xa57854),
bookBlue: standard(0x405f68),
bookCream: standard(0xe8d9b7),
pages: standard(0xf0e5cc),
lampBase: standard(0x5a4b40),
lampShade: standard(0xd39b58, {
emissive: 0xffb85f,
emissiveIntensity: 0.42
}),
mug: standard(0xd9c9aa),
tea: standard(0x654333),
night: standard(0x243b53),
nightLight: standard(0x8ba9bd, {
emissive: 0x58758d,
emissiveIntensity: 0.25
}),
curtain: standard(0xa88660),
pot: standard(0xa65f47),
soil: standard(0x3a2e26),
leaf: standard(0x4f7358),
leafLight: standard(0x6f8a62),
steam: standard(0xf4ead5, {
transparent: true,
opacity: 0.22,
depthWrite: false
})
};
function box(name, size, position, material, rotation = [0, 0, 0]) {
const mesh = new THREE.Mesh(
unitBox,
material && material.isMaterial ? material : materials[material]
);
mesh.name = name;
mesh.scale.set(size[0], size[1], size[2]);
mesh.position.set(position[0], position[1], position[2]);
mesh.rotation.set(rotation[0], rotation[1], rotation[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
// Room shell
box("floor", [10, 0.36, 9], [0, -0.18, 0], "floor").castShadow = false;
box("back wall", [10, 6, 0.3], [0, 3, -4.3], "wall").castShadow = false;
box("left wall", [0.3, 6, 9], [-4.85, 3, 0], "wall").castShadow = false;
box("lower back wall", [9.7, 1.65, 0.1], [0, 0.82, -4.1], "wallLower");
box("lower left wall", [0.1, 1.65, 8.7], [-4.65, 0.82, 0], "wallLower");
box("back baseboard", [9.7, 0.16, 0.16], [0, 0.12, -4.02], "trim");
box("left baseboard", [0.16, 0.16, 8.7], [-4.57, 0.12, 0], "trim");
for (let x = -4.4; x <= 4.4; x += 0.8) {
box(
"floor seam",
[0.025, 0.012, 8.75],
[x, 0.008, 0],
"floorLine"
).castShadow = false;
}
for (let z = -3.6; z <= 3.6; z += 1.45) {
box(
"floor cross seam",
[9.5, 0.01, 0.018],
[0, 0.009, z],
"floorLine"
).castShadow = false;
}
// Rug
box("rug border", [4.55, 0.06, 3.85], [-0.25, 0.035, -0.35], "rug");
box("rug field", [4.1, 0.035, 3.4], [-0.25, 0.075, -0.35], "rugInner");
for (let x = -1.95; x <= 1.5; x += 0.55) {
box(
"rug woven stripe",
[0.035, 0.012, 2.95],
[x, 0.098, -0.35],
"rugLine"
).castShadow = false;
}
// Window
box("night window", [2.65, 2.15, 0.08], [-0.2, 3.62, -4.08], "night");
box("window top frame", [2.95, 0.18, 0.18], [-0.2, 4.77, -3.98], "trim");
box("window bottom frame", [2.95, 0.2, 0.2], [-0.2, 2.48, -3.97], "trim");
box("window left frame", [0.18, 2.4, 0.18], [-1.59, 3.62, -3.97], "trim");
box("window right frame", [0.18, 2.4, 0.18], [1.19, 3.62, -3.97], "trim");
box("window vertical mullion", [0.11, 2.16, 0.15], [-0.2, 3.62, -3.94], "trim");
box("window horizontal mullion", [2.65, 0.11, 0.15], [-0.2, 3.6, -3.93], "trim");
box("pixel moon", [0.28, 0.28, 0.035], [-0.83, 4.18, -4.015], "nightLight");
const stars = [
[-1.2, 4.1, 0.07], [0.55, 4.35, 0.055], [0.86, 3.82, 0.045],
[-1.23, 3.48, 0.05], [0.45, 3.13, 0.06]
];
stars.forEach(([x, y, s]) => {
box("window star", [s, s, 0.025], [x, y, -4.01], "trim");
});
// Simple block curtains
for (const side of [-1, 1]) {
for (let i = 0; i < 4; i++) {
box(
"curtain fold",
[0.24, 2.75, 0.16],
[-0.2 + side * (1.67 + i * 0.19), 3.55, -3.82 + (i % 2) * 0.05],
"curtain"
);
}
}
// Bookshelf
const shelfX = -3.55;
const shelfZ = -3.5;
box("bookshelf back", [2.2, 3.45, 0.18], [shelfX, 1.85, shelfZ - 0.35], "woodDark" in materials ? "wood" : "wood");
box("bookshelf left", [0.18, 3.55, 0.8], [shelfX - 1.02, 1.88, shelfZ], "wood");
box("bookshelf right", [0.18, 3.55, 0.8], [shelfX + 1.02, 1.88, shelfZ], "wood");
[0.35, 1.25, 2.15, 3.05].forEach((y, index) => {
box("bookshelf shelf", [2.18, 0.14, 0.82], [shelfX, y, shelfZ], "woodLight");
if (index < 3) {
const colors = ["bookBlue", "curtain", "bottleCap", "trim", "chair"];
let cursor = shelfX - 0.87;
for (let i = 0; i < 7; i++) {
const width = 0.16 + (i % 3) * 0.045;
const height = 0.48 + ((i + index) % 3) * 0.1;
box(
"shelf book",
[width, height, 0.5],
[cursor + width / 2, y + height / 2 + 0.07, shelfZ + 0.02],
colors[(i + index * 2) % colors.length]
);
cursor += width + 0.035;
}
}
});
// Armchair
const chairX = -0.35;
[-1.12, 1.12].forEach((offset) => {
[-0.65, 0.65].forEach((depth) => {
box(
"chair leg",
[0.18, 0.9, 0.18],
[chairX + offset, 0.5, -1.35 + depth],
"chairDark"
);
});
});
box("chair seat", [2.25, 0.4, 1.9], [chairX, 1.05, -1.35], "chair");
box("chair cushion", [1.85, 0.25, 1.55], [chairX, 1.32, -1.22], "cushion");
box("chair back", [2.25, 2.35, 0.36], [chairX, 2.18, -2.16], "chair");
box("chair back inset", [1.82, 1.65, 0.12], [chairX, 2.25, -1.93], "cushion");
box("left armrest", [0.36, 1.25, 1.95], [chairX - 1.17, 1.72, -1.3], "chair");
box("right armrest", [0.36, 1.25, 1.95], [chairX + 1.17, 1.72, -1.3], "chair");
box("left arm pad", [0.44, 0.18, 1.75], [chairX - 1.17, 2.38, -1.25], "cushion");
box("right arm pad", [0.44, 0.18, 1.75], [chairX + 1.17, 2.38, -1.25], "cushion");
// Reader's lower body
box("left thigh", [0.48, 0.48, 1.15], [-0.73, 1.25, -0.55], "trousers");
box("right thigh", [0.48, 0.48, 1.15], [0.03, 1.25, -0.55], "trousers");
box("left shin", [0.4, 1.05, 0.38], [-0.73, 0.76, 0.08], "trousers");
box("right shin", [0.4, 1.05, 0.38], [0.03, 0.76, 0.08], "trousers");
box("left sock", [0.37, 0.18, 0.4], [-0.73, 0.31, 0.4], "sock");
box("right sock", [0.37, 0.18, 0.4], [0.03, 0.31, 0.4], "sock");
box("left slipper", [0.5, 0.25, 0.72], [-0.73, 0.19, 0.55], "slipper");
box("right slipper", [0.5, 0.25, 0.72], [0.03, 0.19, 0.55], "slipper");
// Sweater and collar
box("sweater torso", [1.18, 1.25, 0.78], [chairX, 2.02, -0.92], "sweater");
box("sweater collar", [0.7, 0.18, 0.54], [chairX, 2.69, -0.75], "shirt");
box("neck", [0.3, 0.25, 0.3], [chairX, 2.72, -0.84], "skin");
// Head
box("head", [0.72, 0.74, 0.74], [chairX, 3.08, -0.88], "skinLight");
box("hair top", [0.78, 0.18, 0.78], [chairX, 3.43, -0.91], "hair");
box("hair back", [0.78, 0.63, 0.18], [chairX, 3.12, -1.25], "hair");
box("left hair lock", [0.16, 0.56, 0.58], [chairX - 0.37, 3.15, -0.97], "hair");
box("right hair lock", [0.16, 0.45, 0.58], [chairX + 0.37, 3.18, -0.97], "hair");
box("left ear", [0.13, 0.23, 0.18], [chairX - 0.39, 3.05, -0.87], "skin");
box("right ear", [0.13, 0.23, 0.18], [chairX + 0.39, 3.05, -0.87], "skin");
box("left eye", [0.075, 0.045, 0.025], [chairX - 0.15, 3.15, -0.495], "hair");
box("right eye", [0.075, 0.045, 0.025], [chairX + 0.15, 3.15, -0.495], "hair");
box("nose", [0.075, 0.09, 0.055], [chairX, 3.03, -0.46], "skin");
box("mouth", [0.12, 0.025, 0.025], [chairX, 2.92, -0.49], "bottleCap");
// Glasses
box("left glasses lens", [0.2, 0.11, 0.025], [chairX - 0.15, 3.16, -0.47], "hair");
box("right glasses lens", [0.2, 0.11, 0.025], [chairX + 0.15, 3.16, -0.47], "hair");
box("glasses bridge", [0.11, 0.025, 0.025], [chairX, 3.17, -0.465], "hair");
// Arms and hands
box("left upper arm", [0.3, 0.78, 0.38], [-0.86, 2.22, -0.73], "sweater", [0, 0, -0.12]);
box("right upper arm", [0.3, 0.78, 0.38], [0.16, 2.22, -0.73], "sweater", [0, 0, 0.12]);
box("left forearm", [0.58, 0.28, 0.34], [-0.83, 1.93, -0.18], "sweater", [0, 0, -0.15]);
box("right forearm", [0.58, 0.28, 0.34], [0.13, 1.93, -0.18], "sweater", [0, 0, 0.15]);
box("left hand", [0.25, 0.2, 0.3], [-0.98, 2.02, 0.02], "skin");
box("right hand", [0.25, 0.2, 0.3], [0.28, 2.02, 0.02], "skin");
// Open book
box("left book cover", [0.68, 0.08, 0.62], [-0.69, 2.16, 0.12], "bookBlue", [0, 0, -0.13]);
box("right book cover", [0.68, 0.08, 0.62], [-0.01, 2.16, 0.12], "bookBlue", [0, 0, 0.13]);
box("left pages", [0.58, 0.07, 0.53], [-0.68, 2.23, 0.12], "pages", [0, 0, -0.13]);
box("right pages", [0.58, 0.07, 0.53], [-0.02, 2.23, 0.12], "pages", [0, 0, 0.13]);
box("book spine", [0.07, 0.1, 0.56], [-0.35, 2.19, 0.12], "bookCream");
// Quilted blanket over the lap
box("blanket top", [1.76, 0.15, 1.42], [-0.35, 1.42, -0.37], "blanket");
box("blanket front", [1.76, 0.74, 0.14], [-0.35, 0.96, 0.34], "blanket");
box("blanket left side", [0.14, 0.74, 1.35], [-1.16, 0.96, -0.37], "blanket");
box("blanket right side", [0.14, 0.74, 1.35], [0.46, 0.96, -0.37], "blanket");
box("blanket tucked corner", [0.3, 0.12, 0.78], [0.56, 0.47, 0.34], "blanket", [0.05, 0, -0.05]);
for (let i = 0; i < 11; i++) {
box(
"blanket fringe",
[0.045, 0.2, 0.045],
[-1.14 + i * 0.158, 0.5, 0.41],
i % 2 ? "blanket" : "rugLine"
);
}
// Covered warming bottle tucked beside the feet
box("warming bottle cover", [0.6, 0.36, 0.82], [0.58, 0.27, 0.53], "knit");
box("warming bottle neck", [0.28, 0.2, 0.18], [0.58, 0.46, 0.89], "knit");
box("warming bottle cap", [0.33, 0.12, 0.2], [0.58, 0.56, 0.95], "bottleCap");
box("bottle cover seam", [0.62, 0.035, 0.045], [0.58, 0.39, 0.91], "trim");
// Side table
const tableX = 2.65;
const tableZ = -1.45;
box("side table top", [1.55, 0.18, 1.2], [tableX, 1.55, tableZ], "woodLight");
[-0.58, 0.58].forEach((x) => {
[-0.42, 0.42].forEach((z) => {
box(
"side table leg",
[0.16, 1.5, 0.16],
[tableX + x, 0.78, tableZ + z],
"wood"
);
});
});
// Voxel lamp
box("lamp base", [0.7, 0.14, 0.58], [2.94, 1.72, -1.57], "lampBase");
box("lamp stem lower", [0.16, 1.15, 0.16], [2.94, 2.34, -1.57], "lampBase");
box("lamp stem upper", [0.22, 0.55, 0.22], [2.94, 3.08, -1.57], "lampBase");
box("lamp shade lower", [1.02, 0.25, 0.78], [2.94, 3.48, -1.57], "lampShade");
box("lamp shade middle", [0.82, 0.23, 0.62], [2.94, 3.68, -1.57], "lampShade");
box("lamp shade top", [0.58, 0.18, 0.44], [2.94, 3.86, -1.57], "lampShade");
// Mug
box("mug body", [0.35, 0.4, 0.35], [2.2, 1.84, -1.12], "mug");
box("mug tea", [0.27, 0.025, 0.27], [2.2, 2.045, -1.12], "tea");
box("mug handle top", [0.17, 0.08, 0.08], [2.42, 1.94, -1.12], "mug");
box("mug handle bottom", [0.17, 0.08, 0.08], [2.42, 1.74, -1.12], "mug");
box("mug handle outer", [0.07, 0.28, 0.08], [2.48, 1.84, -1.12], "mug");
const steam = [];
for (let i = 0; i < 3; i++) {
const material = materials.steam.clone();
const mesh = box(
"pixel steam",
[0.065, 0.1, 0.065],
[2.17 + i * 0.035, 2.15, -1.13],
material
);
mesh.castShadow = false;
steam.push({ mesh, phase: i * 0.31 });
}
// Plant
box("plant pot", [0.7, 0.62, 0.7], [3.78, 0.34, 0.52], "pot");
box("plant pot rim", [0.82, 0.13, 0.82], [3.78, 0.65, 0.52], "pot");
box("plant soil", [0.62, 0.05, 0.62], [3.78, 0.72, 0.52], "soil");
box("plant stem", [0.12, 1.2, 0.12], [3.78, 1.28, 0.52], "leaf");
box("leaf left", [0.22, 0.8, 0.62], [3.46, 1.42, 0.52], "leaf", [0, 0.25, -0.7]);
box("leaf right", [0.22, 0.88, 0.66], [4.08, 1.62, 0.52], "leafLight", [0, -0.25, 0.72]);
box("leaf front", [0.62, 0.2, 0.22], [3.78, 1.78, 0.31], "leaf", [0, 0, 0.1]);
box("leaf back", [0.58, 0.18, 0.2], [3.77, 1.35, 0.75], "leafLight", [0, 0, -0.15]);
// A couple of books left on the floor
box("floor book lower", [0.9, 0.16, 0.65], [-2.38, 0.13, 0.35], "bookBlue", [0, 0.18, 0]);
box("floor book upper", [0.78, 0.14, 0.58], [-2.36, 0.28, 0.34], "curtain", [0, -0.08, 0]);
// Tiny drifting dust motes
const motes = [];
for (let i = 0; i < 10; i++) {
const mote = box(
"dust mote",
[0.025, 0.025, 0.025],
[-1.7 + (i % 5) * 0.85, 1.2 + (i % 3) * 0.7, -1.3 + Math.floor(i / 5) * 2.5],
"trim"
);
mote.castShadow = false;
motes.push({
mesh: mote,
baseX: mote.position.x,
baseY: mote.position.y,
phase: i * 0.73
});
}
function updateCamera() {
const sinPhi = Math.sin(spherical.phi);
const cosPhi = Math.cos(spherical.phi);
camera.position.set(
target.x + spherical.radius * sinPhi * Math.sin(spherical.theta),
target.y + spherical.radius * cosPhi,
target.z + spherical.radius * sinPhi * Math.cos(spherical.theta)
);
camera.lookAt(target);
camera.updateProjectionMatrix();
}
function resetCamera() {
spherical.theta = 0.63;
spherical.phi = 1.12;
camera.zoom = 1;
updateCamera();
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const viewHeight = Math.max(7.25, 6.65 / aspect);
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
renderer.setSize(width, height);
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;
spherical.theta -= deltaX * 0.006;
spherical.phi = THREE.MathUtils.clamp(
spherical.phi - deltaY * 0.005,
0.72,
1.34
);
updateCamera();
});
function endDrag(event) {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
camera.zoom = THREE.MathUtils.clamp(
camera.zoom * Math.exp(-event.deltaY * 0.001),
0.72,
1.65
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
window.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") spherical.theta += 0.08;
if (event.key === "ArrowRight") spherical.theta -= 0.08;
if (event.key === "ArrowUp") spherical.phi = Math.max(0.72, spherical.phi - 0.06);
if (event.key === "ArrowDown") spherical.phi = Math.min(1.34, spherical.phi + 0.06);
if (event.key === "Escape") resetCamera();
updateCamera();
});
window.addEventListener("resize", resize);
const clock = new THREE.Clock();
renderer.setAnimationLoop(() => {
const time = clock.getElapsedTime();
lampLight.intensity = 34 + Math.sin(time * 2.1) * 0.65 + Math.sin(time * 5.3) * 0.18;
bottleGlow.intensity = 2.35 + Math.sin(time * 1.7) * 0.16;
steam.forEach(({ mesh, phase }, index) => {
const progress = (time * 0.17 + phase) % 1;
mesh.position.y = 2.12 + progress * 0.64;
mesh.position.x = 2.17 + index * 0.035 + Math.sin(time + phase) * 0.025;
mesh.material.opacity = Math.sin(progress * Math.PI) * 0.22;
mesh.scale.y = 0.8 + progress * 1.6;
});
motes.forEach(({ mesh, baseX, baseY, phase }) => {
mesh.position.x = baseX + Math.sin(time * 0.23 + phase) * 0.12;
mesh.position.y = baseY + Math.sin(time * 0.31 + phase) * 0.16;
});
renderer.render(scene, camera);
});
resize();
resetCamera();
renderer.render(scene, camera);
document.getElementById("loading").classList.add("ready");
</script>
</body>
</html>
```