Prompt specification
Build or customize the Three.js 3D scene "Soup pot circulation cutaway" 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: Soup pot circulation cutaway
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/soup-pot-circulation-cutaway-x0153
Scene Description Prompt:
Please use Three.js from cdnjs for a voxel scene based on this idea: soup pot circulation cutaway. Model a transparent-sided pot with vegetables and paired upward and downward arrow bands; label the arrows as a qualitative convection diagram instead of measured fluid motion. Return one self-contained HTML file.
Working Three.js Starter (soup-pot-circulation-cutaway-x0153):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voxel Soup Pot — Qualitative Convection Cutaway</title>
<style>
:root {
--ink: #edf8f5;
--muted: #a9c2c0;
--panel: rgba(10, 27, 32, 0.76);
--line: rgba(193, 230, 224, 0.16);
--warm: #ffb44d;
--warm-soft: rgba(255, 180, 77, 0.17);
--cool: #65d2da;
--cool-soft: rgba(101, 210, 218, 0.15);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 68% 28%, rgba(42, 92, 91, 0.34), transparent 38%),
radial-gradient(circle at 20% 78%, rgba(111, 66, 37, 0.18), transparent 36%),
linear-gradient(145deg, #102b31 0%, #09171d 58%, #071117 100%);
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#app,
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
}
#scene canvas:focus-visible {
outline: 2px solid var(--cool);
outline-offset: -4px;
}
.header {
position: fixed;
z-index: 10;
top: 24px;
left: 26px;
max-width: min(560px, calc(100vw - 52px));
pointer-events: none;
}
.eyebrow {
margin-bottom: 8px;
color: var(--cool);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(27px, 4vw, 49px);
font-weight: 760;
letter-spacing: -0.045em;
line-height: 0.98;
text-shadow: 0 4px 30px rgba(0, 0, 0, 0.35);
}
.subtitle {
margin: 12px 0 0;
color: var(--muted);
font-size: 14px;
line-height: 1.5;
}
.subtitle strong {
color: #d8ebe7;
font-weight: 650;
}
.controls {
position: fixed;
z-index: 20;
top: 22px;
right: 24px;
display: flex;
gap: 8px;
}
button {
border: 1px solid var(--line);
border-radius: 9px;
padding: 9px 12px;
background: rgba(9, 25, 30, 0.76);
color: var(--ink);
font: inherit;
font-size: 12px;
font-weight: 650;
cursor: pointer;
backdrop-filter: blur(12px);
transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
button:hover {
border-color: rgba(101, 210, 218, 0.65);
background: rgba(18, 45, 51, 0.9);
}
button:active {
transform: translateY(1px);
}
.legend {
position: fixed;
z-index: 12;
left: 24px;
bottom: 24px;
width: min(460px, calc(100vw - 48px));
padding: 15px 17px 14px;
border: 1px solid var(--line);
border-radius: 13px;
background: var(--panel);
box-shadow: 0 18px 60px rgba(0, 0, 0, 0.3);
backdrop-filter: blur(14px);
pointer-events: none;
}
.legend-title {
margin-bottom: 7px;
color: #effbf8;
font-size: 11px;
font-weight: 850;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.legend p {
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.5;
}
.swatches {
display: flex;
flex-wrap: wrap;
gap: 9px 17px;
margin-top: 11px;
color: #d9ece9;
font-size: 11px;
font-weight: 650;
}
.swatch {
display: inline-flex;
align-items: center;
gap: 7px;
}
.swatch::before {
content: "";
display: inline-block;
width: 20px;
height: 4px;
border-radius: 4px;
background: currentColor;
box-shadow: 0 0 10px currentColor;
}
.swatch.warm {
color: var(--warm);
}
.swatch.cool {
color: var(--cool);
}
.hint {
position: fixed;
z-index: 10;
right: 24px;
bottom: 25px;
color: rgba(209, 230, 227, 0.62);
font-size: 11px;
letter-spacing: 0.04em;
pointer-events: none;
}
#labels {
position: fixed;
z-index: 9;
inset: 0;
overflow: hidden;
pointer-events: none;
}
.world-label {
position: absolute;
width: max-content;
max-width: 235px;
padding: 9px 11px 9px 12px;
border: 1px solid var(--line);
border-left-width: 3px;
border-radius: 8px;
background: rgba(8, 24, 29, 0.84);
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
backdrop-filter: blur(10px);
transition: opacity 120ms ease;
}
.world-label strong {
display: block;
color: #f1fbf8;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.09em;
line-height: 1.25;
text-transform: uppercase;
}
.world-label small {
display: block;
margin-top: 4px;
color: var(--muted);
font-size: 10px;
line-height: 1.35;
}
#label-up {
border-left-color: var(--warm);
transform: translate(12px, -100%);
}
#label-down {
border-left-color: var(--cool);
transform: translate(calc(-100% - 12px), 0);
}
#label-heat {
border-left-color: #ff7040;
transform: translate(-50%, 10px);
text-align: center;
}
#loading {
position: fixed;
z-index: 100;
inset: 0;
display: grid;
place-items: center;
background: #09171d;
color: var(--muted);
font-size: 12px;
letter-spacing: 0.12em;
text-transform: uppercase;
transition: opacity 300ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 700px) {
.header {
top: 18px;
left: 18px;
}
.controls {
top: auto;
right: 16px;
bottom: 16px;
}
.legend {
left: 14px;
bottom: 14px;
width: calc(100vw - 28px);
padding: 12px 13px;
}
.hint {
display: none;
}
.world-label {
max-width: 170px;
padding: 7px 9px;
}
.world-label strong {
font-size: 9px;
}
.world-label small {
font-size: 9px;
}
}
</style>
</head>
<body>
<main id="app">
<div
id="scene"
role="img"
aria-label="A voxel-style transparent soup pot cutaway with vegetables, a heating source, and paired schematic upward and downward convection arrow bands."
></div>
<header class="header">
<div class="eyebrow">Voxel Kitchen Science / Cutaway 01</div>
<h1>Soup Pot<br />Convection Study</h1>
<p class="subtitle">
<strong>Qualitative convection diagram</strong> with an illustrative
circulation path through a transparent, cutaway pot.
</p>
</header>
<div class="controls">
<button id="reset-view" type="button">Reset view</button>
</div>
<div id="labels" aria-hidden="true">
<div id="label-up" class="world-label">
<strong>↑ Illustrative upward band</strong>
<small>Schematic warmer-fluid rise; not measured motion.</small>
</div>
<div id="label-down" class="world-label">
<strong>↓ Illustrative downward band</strong>
<small>Schematic return path; not measured motion.</small>
</div>
<div id="label-heat" class="world-label">
<strong>Conceptual heat input</strong>
<small>Heating from below</small>
</div>
</div>
<aside class="legend" aria-label="Diagram interpretation">
<div class="legend-title">Qualitative convection diagram</div>
<p>
The paired arrow bands are simplified teaching cues for circulation.
They do not represent measured velocity, a fluid-flow simulation, or the
exact direction of motion at every point in the pot.
</p>
<div class="swatches">
<span class="swatch warm">Conceptual rise</span>
<span class="swatch cool">Conceptual descent</span>
</div>
</aside>
<div class="hint">Drag to orbit · Scroll to zoom · R to reset</div>
<div id="loading">Building voxel cutaway…</div>
</main>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const sceneHost = document.getElementById("scene");
const loading = document.getElementById("loading");
const scene = new THREE.Scene();
scene.fog = new THREE.FogExp2(0x0a181d, 0.022);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight, false);
renderer.setClearColor(0x000000, 0);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute(
"aria-label",
"Interactive three-dimensional voxel soup pot cutaway"
);
sceneHost.appendChild(renderer.domElement);
// Lighting
const hemisphere = new THREE.HemisphereLight(0xffefd0, 0x18333a, 2.2);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffedcf, 3.2);
keyLight.position.set(5, 10, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -9;
keyLight.shadow.camera.right = 9;
keyLight.shadow.camera.top = 10;
keyLight.shadow.camera.bottom = -7;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 28;
keyLight.shadow.bias = -0.00035;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x7bd9df, 1.8);
rimLight.position.set(-7, 5, -6);
scene.add(rimLight);
const heatLight = new THREE.PointLight(0xff6a2f, 9, 7, 2);
heatLight.position.set(0, 0.45, 0);
scene.add(heatLight);
// Materials
const frameMaterial = new THREE.MeshStandardMaterial({
color: 0x35535a,
roughness: 0.48,
metalness: 0.68
});
const frameEdgeMaterial = new THREE.MeshStandardMaterial({
color: 0x6f8b89,
roughness: 0.38,
metalness: 0.72
});
const baseMaterial = new THREE.MeshStandardMaterial({
color: 0x24383c,
roughness: 0.64,
metalness: 0.5
});
const cutEdgeMaterial = new THREE.MeshStandardMaterial({
color: 0xc58a50,
roughness: 0.42,
metalness: 0.58
});
const glassMaterial = new THREE.MeshStandardMaterial({
color: 0x9ae2df,
transparent: true,
opacity: 0.13,
roughness: 0.16,
metalness: 0.03,
side: THREE.DoubleSide,
depthWrite: false
});
const brothMaterial = new THREE.MeshStandardMaterial({
color: 0xe99d3e,
transparent: true,
opacity: 0.27,
roughness: 0.38,
side: THREE.DoubleSide,
depthWrite: false
});
const heatMaterial = new THREE.MeshStandardMaterial({
color: 0xff7136,
emissive: 0xff3f0e,
emissiveIntensity: 1.35,
roughness: 0.5
});
const vegetableMaterials = {
carrot: new THREE.MeshStandardMaterial({
color: 0xec762c,
roughness: 0.66
}),
cabbage: new THREE.MeshStandardMaterial({
color: 0x80bd62,
roughness: 0.76
}),
onion: new THREE.MeshStandardMaterial({
color: 0xf1e1b8,
roughness: 0.72
}),
tomato: new THREE.MeshStandardMaterial({
color: 0xd94d3d,
roughness: 0.61
}),
potato: new THREE.MeshStandardMaterial({
color: 0xe4b75a,
roughness: 0.78
}),
pea: new THREE.MeshStandardMaterial({
color: 0x58a85a,
roughness: 0.74
})
};
function addBox(parent, size, position, material, shadows = true) {
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 = shadows;
mesh.receiveShadow = shadows;
parent.add(mesh);
return mesh;
}
// Stage
const floorMaterial = new THREE.MeshStandardMaterial({
color: 0x081419,
roughness: 0.95
});
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(36, 36),
floorMaterial
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.24;
floor.receiveShadow = true;
scene.add(floor);
const platformMaterial = new THREE.MeshStandardMaterial({
color: 0x12272c,
roughness: 0.83,
metalness: 0.12
});
addBox(scene, [7.5, 0.22, 6.25], [0, -0.12, 0], platformMaterial);
const platformEdgeMaterial = new THREE.MeshStandardMaterial({
color: 0x427c7b,
emissive: 0x173b3b,
emissiveIntensity: 0.5,
roughness: 0.42,
metalness: 0.45
});
addBox(scene, [7.28, 0.045, 0.045], [0, 0.015, -3.04], platformEdgeMaterial, false);
addBox(scene, [7.28, 0.045, 0.045], [0, 0.015, 3.04], platformEdgeMaterial, false);
addBox(scene, [0.045, 0.045, 6.05], [-3.67, 0.015, 0], platformEdgeMaterial, false);
addBox(scene, [0.045, 0.045, 6.05], [3.67, 0.015, 0], platformEdgeMaterial, false);
const grid = new THREE.GridHelper(30, 30, 0x416266, 0x294148);
grid.position.y = -0.225;
grid.material.transparent = true;
grid.material.opacity = 0.16;
scene.add(grid);
// Voxel heating source beneath the pot
for (const x of [-1.8, -0.9, 0, 0.9, 1.8]) {
addBox(scene, [0.68, 0.15, 0.72], [x, 0.05, 2.18], heatMaterial, false);
addBox(scene, [0.68, 0.15, 0.72], [x, 0.05, -2.18], heatMaterial, false);
}
// Pot base
addBox(scene, [6.55, 0.42, 4.9], [0, 0.4, 0], baseMaterial);
addBox(scene, [6.18, 0.14, 4.53], [0, 0.67, 0], frameEdgeMaterial);
const pot = new THREE.Group();
scene.add(pot);
// Transparent back and side walls. The front wall is intentionally omitted.
const backGlass = addBox(
pot,
[5.82, 3.78, 0.075],
[0, 2.48, -2.14],
glassMaterial,
false
);
backGlass.renderOrder = 4;
const leftGlass = addBox(
pot,
[0.075, 3.78, 4.18],
[-2.9, 2.48, 0],
glassMaterial,
false
);
leftGlass.renderOrder = 4;
const rightGlass = addBox(
pot,
[0.075, 3.78, 4.18],
[2.9, 2.48, 0],
glassMaterial,
false
);
rightGlass.renderOrder = 4;
// Voxel frame
for (const x of [-3.1, 3.1]) {
for (const z of [-2.35, 2.35]) {
addBox(pot, [0.18, 3.9, 0.18], [x, 2.55, z], frameMaterial);
}
}
for (const y of [0.7, 4.5]) {
addBox(pot, [6.35, 0.16, 0.16], [0, y, -2.35], frameMaterial);
addBox(pot, [6.35, 0.16, 0.16], [0, y, 2.35], frameMaterial);
addBox(pot, [0.16, 0.16, 4.55], [-3.1, y, 0], frameMaterial);
addBox(pot, [0.16, 0.16, 4.55], [3.1, y, 0], frameMaterial);
}
// Warm-colored cut edges emphasize the removed front panel.
addBox(pot, [0.09, 3.7, 0.09], [-2.9, 2.48, 2.12], cutEdgeMaterial);
addBox(pot, [0.09, 3.7, 0.09], [2.9, 2.48, 2.12], cutEdgeMaterial);
// Handles
addBox(pot, [0.72, 0.24, 0.62], [-3.55, 4.2, 0], frameEdgeMaterial);
addBox(pot, [0.72, 0.24, 0.62], [3.55, 4.2, 0], frameEdgeMaterial);
addBox(pot, [0.32, 0.28, 0.68], [-3.32, 4.2, 0], frameMaterial);
addBox(pot, [0.32, 0.28, 0.68], [3.32, 4.2, 0], frameMaterial);
// Translucent broth volume
const broth = addBox(
scene,
[5.63, 3.16, 3.9],
[0, 2.2, 0],
brothMaterial,
false
);
broth.renderOrder = 1;
// Voxel broth surface: a grid of small square tiles with a warmer center.
const tileGeometry = new THREE.BoxGeometry(0.54, 0.08, 0.54);
const tileMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.64,
metalness: 0.02,
transparent: true,
opacity: 0.91
});
const nx = 10;
const nz = 7;
const surfaceTiles = new THREE.InstancedMesh(
tileGeometry,
tileMaterial,
nx * nz
);
surfaceTiles.receiveShadow = true;
surfaceTiles.renderOrder = 0;
const dummy = new THREE.Object3D();
const coolSurface = new THREE.Color(0xd78b3c);
const warmSurface = new THREE.Color(0xf7c45d);
let tileIndex = 0;
for (let iz = 0; iz < nz; iz++) {
for (let ix = 0; ix < nx; ix++) {
const x = (ix - (nx - 1) / 2) * 0.565;
const z = (iz - (nz - 1) / 2) * 0.57;
const jitter = Math.sin(ix * 4.7 + iz * 2.3) * 0.012;
dummy.position.set(x, 3.81 + jitter, z);
dummy.rotation.set(0, 0, 0);
dummy.scale.set(1, 1, 1);
dummy.updateMatrix();
surfaceTiles.setMatrixAt(tileIndex, dummy.matrix);
const radial = Math.min(
1,
Math.hypot(x / 2.8, z / 1.95)
);
const color = warmSurface.clone().lerp(coolSurface, radial);
color.offsetHSL(0, 0, Math.sin(ix * 8.1 + iz * 5.4) * 0.025);
surfaceTiles.setColorAt(tileIndex, color);
tileIndex++;
}
}
surfaceTiles.instanceMatrix.needsUpdate = true;
if (surfaceTiles.instanceColor) {
surfaceTiles.instanceColor.needsUpdate = true;
}
scene.add(surfaceTiles);
// Vegetable voxel clusters
const animatedIngredients = [];
function createIngredient(type, x, y, z, scale = 1, phase = 0) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
group.userData.baseY = y;
group.userData.phase = phase;
let blocks = [];
if (type === "carrot") {
blocks = [
[0, 0, 0, 0.62, 0.25, 0.34],
[-0.25, 0.07, 0.04, 0.3, 0.22, 0.27],
[0.28, 0.05, -0.04, 0.31, 0.19, 0.26]
];
} else if (type === "cabbage") {
blocks = [
[-0.18, 0, 0, 0.34, 0.3, 0.34],
[0.18, 0.02, 0.02, 0.34, 0.3, 0.34],
[0, 0.3, 0.02, 0.42, 0.28, 0.38],
[0, 0.03, 0.23, 0.36, 0.27, 0.34]
];
} else if (type === "onion") {
blocks = [
[0, 0, 0, 0.48, 0.3, 0.42],
[0.28, 0.06, 0.02, 0.32, 0.25, 0.3],
[-0.25, 0.04, 0.03, 0.3, 0.24, 0.28]
];
} else if (type === "tomato") {
blocks = [
[-0.18, 0.02, 0, 0.34, 0.32, 0.34],
[0.18, 0.03, 0.02, 0.34, 0.3, 0.34],
[0, 0.28, 0.02, 0.4, 0.25, 0.38],
[0, 0.02, 0.2, 0.35, 0.28, 0.32]
];
} else if (type === "potato") {
blocks = [
[-0.2, 0.03, 0.02, 0.42, 0.32, 0.38],
[0.22, 0.02, -0.02, 0.36, 0.3, 0.34],
[0, 0.27, 0.02, 0.38, 0.24, 0.36]
];
} else {
blocks = [
[-0.18, 0, -0.08, 0.15, 0.15, 0.15],
[0.02, 0.02, 0.06, 0.16, 0.16, 0.16],
[0.2, 0, -0.04, 0.14, 0.14, 0.14],
[-0.04, 0.03, -0.22, 0.13, 0.13, 0.13],
[0.16, 0.05, 0.2, 0.12, 0.12, 0.12]
];
}
for (const block of blocks) {
addBox(
group,
[block[3], block[4], block[5]],
[block[0], block[1], block[2]],
vegetableMaterials[type]
);
}
scene.add(group);
animatedIngredients.push(group);
return group;
}
createIngredient("carrot", -1.48, 3.89, 0.35, 1.0, 0.1);
createIngredient("cabbage", -0.2, 3.89, -0.55, 1.05, 1.2);
createIngredient("onion", 1.35, 3.89, 0.3, 0.98, 2.3);
createIngredient("tomato", -2.02, 3.86, -0.82, 0.92, 3.1);
createIngredient("potato", 0.35, 3.87, 1.02, 0.98, 4.2);
createIngredient("carrot", 2.03, 3.88, -0.65, 0.82, 5.1);
createIngredient("pea", -0.7, 3.92, 1.0, 1.0, 0.7);
// Ingredients visible through the broth and open front.
createIngredient("carrot", -1.8, 2.35, 1.28, 0.86, 1.1);
createIngredient("onion", 1.52, 2.26, 1.32, 0.82, 2.6);
createIngredient("cabbage", 0.22, 2.6, 0.48, 0.8, 4.0);
createIngredient("tomato", -0.58, 2.4, -1.14, 0.78, 5.2);
createIngredient("potato", 2.02, 2.75, -0.25, 0.8, 2.0);
createIngredient("pea", 0.72, 2.18, -1.4, 1.1, 3.6);
// Paired qualitative arrow bands, built entirely from voxel cubes.
const arrowGeometry = new THREE.BoxGeometry(0.29, 0.29, 0.29);
function createVoxelArrow(x, material, upward) {
const group = new THREE.Group();
group.position.set(x, 0, 2.65);
const bandMaterial = new THREE.MeshBasicMaterial({
color: material.color,
transparent: true,
opacity: 0.075,
depthWrite: false,
side: THREE.DoubleSide
});
const band = addBox(
group,
[1.5, 4.08, 0.045],
[0, 2.14, -0.07],
bandMaterial,
false
);
band.renderOrder = 2;
const addVoxel = (vx, vy) => {
const cube = new THREE.Mesh(arrowGeometry, material);
cube.position.set(vx, vy, 0);
cube.castShadow = true;
cube.receiveShadow = true;
group.add(cube);
};
for (let row = 0; row < 8; row++) {
const y = upward ? 0.92 + row * 0.33 : 3.57 - row * 0.33;
for (const vx of [-0.33, 0, 0.33]) {
addVoxel(vx, y);
}
}
const headRows = upward
? [
[3.25, 5],
[3.58, 3],
[3.91, 1]
]
: [
[0.92, 5],
[0.59, 3],
[0.26, 1]
];
for (const [y, width] of headRows) {
for (let column = 0; column < width; column++) {
const vx = (column - (width - 1) / 2) * 0.31;
addVoxel(vx, y);
}
}
scene.add(group);
return group;
}
const warmArrowMaterial = new THREE.MeshStandardMaterial({
color: 0xffaa43,
emissive: 0xff7a1c,
emissiveIntensity: 0.28,
roughness: 0.42,
metalness: 0.12
});
const coolArrowMaterial = new THREE.MeshStandardMaterial({
color: 0x5bcbd4,
emissive: 0x168a9b,
emissiveIntensity: 0.24,
roughness: 0.42,
metalness: 0.12
});
createVoxelArrow(-1.95, coolArrowMaterial, false);
createVoxelArrow(1.95, warmArrowMaterial, true);
// Custom camera controls implemented without external addons.
const target = new THREE.Vector3(0, 2.05, 0);
const orbit = {
theta: 0.68,
phi: 1.08,
radius: 10.7
};
function updateCamera() {
const sinPhi = Math.sin(orbit.phi);
camera.position.set(
target.x + orbit.radius * sinPhi * Math.sin(orbit.theta),
target.y + orbit.radius * Math.cos(orbit.phi),
target.z + orbit.radius * sinPhi * Math.cos(orbit.theta)
);
camera.lookAt(target);
}
function resetView() {
orbit.theta = 0.68;
orbit.phi = 1.08;
orbit.radius = window.innerWidth < 700 ? 12.1 : 10.7;
updateCamera();
}
resetView();
let dragging = false;
let lastX = 0;
let lastY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
lastX = event.clientX;
lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - lastX;
const deltaY = event.clientY - lastY;
lastX = event.clientX;
lastY = event.clientY;
orbit.theta -= deltaX * 0.008;
orbit.phi = THREE.MathUtils.clamp(orbit.phi - deltaY * 0.006, 0.48, 1.45);
updateCamera();
});
const 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();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius * Math.exp(event.deltaY * 0.001),
7.2,
16
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetView);
renderer.domElement.addEventListener("keydown", (event) => {
const key = event.key.toLowerCase();
if (key === "arrowleft") orbit.theta += 0.1;
else if (key === "arrowright") orbit.theta -= 0.1;
else if (key === "arrowup") orbit.phi -= 0.07;
else if (key === "arrowdown") orbit.phi += 0.07;
else if (key === "+" || key === "=") orbit.radius -= 0.45;
else if (key === "-") orbit.radius += 0.45;
else if (key === "r") {
resetView();
return;
} else {
return;
}
orbit.phi = THREE.MathUtils.clamp(orbit.phi, 0.48, 1.45);
orbit.radius = THREE.MathUtils.clamp(orbit.radius, 7.2, 16);
updateCamera();
event.preventDefault();
});
document.getElementById("reset-view").addEventListener("click", resetView);
// World-anchored labels
const labels = [
{
element: document.getElementById("label-up"),
position: new THREE.Vector3(1.95, 4.28, 2.68)
},
{
element: document.getElementById("label-down"),
position: new THREE.Vector3(-1.95, 0.26, 2.68)
},
{
element: document.getElementById("label-heat"),
position: new THREE.Vector3(0, 0.02, 2.72)
}
];
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const label of labels) {
const projected = label.position.clone().project(camera);
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
const visible = projected.z > -1 && projected.z < 1;
label.element.style.left = `${x}px`;
label.element.style.top = `${y}px`;
label.element.style.opacity = visible ? "1" : "0";
}
}
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight, false);
resetView();
}
window.addEventListener("resize", resize);
const clock = new THREE.Clock();
const reducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
function animate() {
const elapsed = clock.getElapsedTime();
if (!reducedMotion) {
for (const ingredient of animatedIngredients) {
ingredient.position.y =
ingredient.userData.baseY +
Math.sin(elapsed * 1.05 + ingredient.userData.phase) * 0.018;
}
heatMaterial.emissiveIntensity =
1.25 + Math.sin(elapsed * 1.7) * 0.14;
heatLight.intensity = 8.5 + Math.sin(elapsed * 1.7) * 0.8;
}
updateLabels();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
updateLabels();
renderer.render(scene, camera);
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 350);
animate();
</script>
</body>
</html>
```