Prompt specification
Build or customize the Three.js 3D scene "Window and high vent 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: Window and high vent cutaway
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/window-and-high-vent-cutaway-x2190
Scene Description Prompt:
Create a standalone low-poly scene in one HTML file using Three.js from cdnjs. Create a room with a lower inlet and higher outlet. Animate clearly illustrative airflow particles along a rising path, distinguishing the assumed mechanism from measured performance.
Working Three.js Starter (window-and-high-vent-cutaway-x2190):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Illustrative Room Airflow</title>
<style>
:root {
color-scheme: light;
--ink: #17332f;
--muted: #61736e;
--cyan: #13bfc9;
--cyan-dark: #087f89;
--amber: #e69a49;
--panel: rgba(255, 255, 255, 0.88);
--line: rgba(31, 68, 61, 0.17);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
}
body {
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
background:
radial-gradient(circle at 50% 32%, #f7fbf8 0%, #e5eee9 45%, #d5e1dc 100%);
}
canvas {
position: fixed;
inset: 0;
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
cursor: grab;
}
canvas.dragging {
cursor: grabbing;
}
.hud {
position: fixed;
inset: 0;
z-index: 10;
pointer-events: none;
}
.card {
border: 1px solid var(--line);
border-radius: 16px;
background: var(--panel);
box-shadow: 0 14px 38px rgba(35, 67, 59, 0.10);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
}
.intro {
position: absolute;
top: 24px;
left: 24px;
width: min(430px, calc(100vw - 48px));
padding: 20px 22px;
}
.eyebrow {
margin-bottom: 8px;
color: var(--cyan-dark);
font-size: 0.69rem;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(1.55rem, 3vw, 2.25rem);
line-height: 1.05;
letter-spacing: -0.035em;
}
.subtitle {
margin: 10px 0 0;
color: var(--muted);
font-size: 0.93rem;
line-height: 1.45;
}
.assumption {
margin-top: 15px;
padding-top: 13px;
border-top: 1px solid var(--line);
}
.assumption strong {
display: block;
margin-bottom: 4px;
font-size: 0.78rem;
letter-spacing: 0.02em;
}
.assumption p {
margin: 0;
color: var(--muted);
font-size: 0.8rem;
line-height: 1.45;
}
.actions {
position: absolute;
top: 24px;
right: 24px;
display: flex;
gap: 8px;
pointer-events: auto;
}
button {
min-height: 38px;
padding: 0 14px;
border: 1px solid rgba(31, 68, 61, 0.18);
border-radius: 11px;
color: var(--ink);
background: rgba(255, 255, 255, 0.88);
box-shadow: 0 7px 20px rgba(35, 67, 59, 0.08);
font: inherit;
font-size: 0.8rem;
font-weight: 700;
cursor: pointer;
backdrop-filter: blur(12px);
transition: transform 150ms ease, background 150ms ease;
}
button:hover {
transform: translateY(-1px);
background: #fff;
}
button:focus-visible {
outline: 3px solid rgba(19, 191, 201, 0.28);
outline-offset: 2px;
}
.legend {
position: absolute;
bottom: 24px;
left: 24px;
width: min(340px, calc(100vw - 48px));
padding: 15px 17px;
}
.legend-title {
margin-bottom: 10px;
font-size: 0.72rem;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.legend-row {
display: flex;
align-items: center;
gap: 10px;
margin-top: 8px;
color: var(--muted);
font-size: 0.78rem;
}
.legend-mark {
display: inline-block;
flex: 0 0 30px;
width: 30px;
text-align: center;
font-weight: 900;
}
.legend-mark.flow {
color: var(--cyan-dark);
letter-spacing: -0.13em;
transform: rotate(-8deg);
}
.legend-mark.geometry {
color: var(--amber);
}
.legend-mark.measured {
color: #84928e;
border-top: 2px dashed #84928e;
line-height: 8px;
}
.measurement {
position: absolute;
right: 24px;
bottom: 24px;
width: min(365px, calc(100vw - 48px));
padding: 17px 19px;
border-style: dashed;
border-color: rgba(66, 84, 79, 0.32);
background: rgba(247, 249, 248, 0.91);
}
.measurement .eyebrow {
color: #66756f;
}
.measurement h2 {
margin: 0 0 7px;
font-size: 1rem;
}
.measurement p {
margin: 0;
color: var(--muted);
font-size: 0.78rem;
line-height: 1.48;
}
.measurements {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 7px;
margin-top: 12px;
}
.measurement-cell {
padding: 8px 6px;
border: 1px solid rgba(66, 84, 79, 0.16);
border-radius: 9px;
text-align: center;
background: rgba(255, 255, 255, 0.56);
}
.measurement-cell span {
display: block;
color: #77847f;
font-size: 0.61rem;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.measurement-cell strong {
display: block;
margin-top: 3px;
font-size: 0.76rem;
}
.controls-hint {
position: absolute;
left: 50%;
bottom: 24px;
transform: translateX(-50%);
padding: 8px 12px;
border: 1px solid rgba(31, 68, 61, 0.13);
border-radius: 999px;
color: #65756f;
background: rgba(255, 255, 255, 0.72);
font-size: 0.7rem;
white-space: nowrap;
backdrop-filter: blur(10px);
}
.world-label {
position: absolute;
z-index: 4;
transform: translate(-50%, calc(-100% - 18px));
min-width: 112px;
padding: 8px 11px;
border: 1px solid rgba(31, 68, 61, 0.14);
border-radius: 10px;
color: var(--ink);
background: rgba(255, 255, 255, 0.91);
box-shadow: 0 7px 22px rgba(29, 58, 51, 0.12);
text-align: center;
backdrop-filter: blur(10px);
transition: opacity 100ms linear;
}
.world-label::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
width: 1px;
height: 18px;
background: rgba(31, 68, 61, 0.36);
}
.world-label b {
display: block;
font-size: 0.76rem;
}
.world-label small {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 0.63rem;
}
.world-label.inlet {
border-bottom: 3px solid var(--amber);
}
.world-label.outlet {
border-bottom: 3px solid var(--amber);
}
.world-label.path {
border-bottom: 3px solid var(--cyan);
}
.loading {
position: fixed;
inset: 0;
z-index: 30;
display: grid;
place-items: center;
color: var(--muted);
background: #e5eee9;
font-size: 0.85rem;
letter-spacing: 0.08em;
text-transform: uppercase;
}
@media (max-width: 760px) {
.intro {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 15px 16px;
}
.subtitle {
font-size: 0.82rem;
}
.actions {
top: auto;
right: 12px;
bottom: 12px;
}
.legend,
.controls-hint {
display: none;
}
.measurement {
right: 12px;
bottom: 62px;
width: calc(100vw - 24px);
padding: 13px 15px;
}
.measurement p {
font-size: 0.72rem;
}
.measurements {
margin-top: 9px;
}
.world-label {
min-width: 95px;
padding: 6px 8px;
}
.world-label b {
font-size: 0.67rem;
}
.world-label small {
font-size: 0.56rem;
}
}
</style>
</head>
<body>
<canvas
id="scene"
tabindex="0"
aria-label="Low-poly cutaway room with a lower inlet, rising illustrative airflow path, and higher outlet"
></canvas>
<div class="hud">
<header class="intro card">
<div class="eyebrow">Low-poly cutaway · illustrative model</div>
<h1>Rising room airflow</h1>
<p class="subtitle">
A lower inlet and a higher outlet are shown with moving arrows along a
schematic rising route.
</p>
<div class="assumption">
<strong>Assumed mechanism</strong>
<p>
Air is depicted entering low, rising through the room, and exiting
high. This is a visual hypothesis—not a fluid simulation.
</p>
</div>
</header>
<div class="actions">
<button id="pause" type="button" aria-pressed="false">Pause</button>
<button id="reset" type="button">Reset view</button>
</div>
<section class="legend card" aria-label="Scene legend">
<div class="legend-title">Legend</div>
<div class="legend-row">
<span class="legend-mark flow">➤➤➤</span>
<span>Illustrative flow path and particle direction</span>
</div>
<div class="legend-row">
<span class="legend-mark geometry">■</span>
<span>Room, duct, inlet, and outlet geometry</span>
</div>
<div class="legend-row">
<span class="legend-mark measured"></span>
<span>Measured flow: no data represented</span>
</div>
</section>
<section class="measurement card" aria-label="Measured performance status">
<div class="eyebrow">Measured performance</div>
<h2>No measurements supplied</h2>
<p>
No sensor readings or validated CFD results are encoded in this scene.
Particle speed, spacing, and direction are animation choices and do not
represent real air velocity, pressure, flow rate, or effectiveness.
</p>
<div class="measurements">
<div class="measurement-cell">
<span>Flow rate</span>
<strong>Not measured</strong>
</div>
<div class="measurement-cell">
<span>Pressure</span>
<strong>Not measured</strong>
</div>
<div class="measurement-cell">
<span>Efficiency</span>
<strong>Not measured</strong>
</div>
</div>
</section>
<div class="controls-hint">Drag to orbit · Wheel to zoom · Arrow keys to rotate</div>
<div id="label-inlet" class="world-label inlet">
<b>Lower inlet</b>
<small>assumed entry location</small>
</div>
<div id="label-outlet" class="world-label outlet">
<b>Higher outlet</b>
<small>assumed exit location</small>
</div>
<div id="label-path" class="world-label path">
<b>Illustrative path</b>
<small>not sensor data</small>
</div>
</div>
<div id="loading" class="loading">Building scene…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.querySelector("#scene");
const loading = document.querySelector("#loading");
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0xdfe8e4, 19, 34);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
canvas,
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.05;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const hemisphere = new THREE.HemisphereLight(0xf8fffb, 0x657b72, 2.2);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff8e9, 2.6);
sun.position.set(-5, 10, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -12;
sun.shadow.camera.right = 12;
sun.shadow.camera.top = 12;
sun.shadow.camera.bottom = -12;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const rim = new THREE.DirectionalLight(0xb9e9ee, 0.8);
rim.position.set(8, 5, -8);
scene.add(rim);
function standardMaterial(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0,
flatShading: true,
...options
});
}
const materials = {
floor: standardMaterial(0xd9d2bf),
wall: standardMaterial(0xc8d4ce),
frame: standardMaterial(0x61766e),
plinth: standardMaterial(0x9eb3aa),
glass: standardMaterial(0xbfd4cd, {
transparent: true,
opacity: 0.16,
depthWrite: false
}),
duct: standardMaterial(0x93a59e, {
transparent: true,
opacity: 0.46,
depthWrite: false,
roughness: 0.7
}),
collar: standardMaterial(0xe69a49, {
roughness: 0.62,
emissive: 0x4b2307,
emissiveIntensity: 0.12
}),
slat: standardMaterial(0x526760),
wood: standardMaterial(0xb88758),
cabinet: standardMaterial(0x718a80),
cabinetTop: standardMaterial(0xd3b17e),
dark: standardMaterial(0x334943)
};
function addBox(
width,
height,
depth,
material,
x,
y,
z,
castShadow = true,
receiveShadow = true
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = receiveShadow;
scene.add(mesh);
return mesh;
}
// Low-poly ground and room plinth.
const ground = new THREE.Mesh(
new THREE.CylinderGeometry(13, 13, 0.28, 12),
materials.plinth
);
ground.position.y = -0.34;
ground.receiveShadow = true;
scene.add(ground);
// Cutaway room: opaque floor/back wall, translucent sides and ceiling.
addBox(9.4, 0.25, 5.4, materials.floor, 0, -0.125, 0);
addBox(9.4, 5.1, 0.18, materials.wall, 0, 2.55, -2.62);
addBox(0.14, 5.1, 5.3, materials.glass, -4.65, 2.55, 0, false, false);
addBox(0.14, 5.1, 5.3, materials.glass, 4.65, 2.55, 0, false, false);
addBox(9.4, 0.12, 5.3, materials.glass, 0, 5.1, 0, false, false);
// Visible room-frame edges make the cutaway boundaries easy to read.
const roomEdgeGeometry = new THREE.EdgesGeometry(
new THREE.BoxGeometry(9.4, 5.25, 5.4)
);
const roomEdges = new THREE.LineSegments(
roomEdgeGeometry,
new THREE.LineBasicMaterial({
color: 0x60786f,
transparent: true,
opacity: 0.68
})
);
roomEdges.position.y = 2.49;
scene.add(roomEdges);
// Structural corner posts.
for (const x of [-4.65, 4.65]) {
for (const z of [-2.62, 2.62]) {
addBox(0.13, 5.15, 0.13, materials.frame, x, 2.55, z);
}
}
// Minimal low-poly furnishings to establish scale.
addBox(2.0, 0.14, 0.72, materials.wood, -2.65, 1.04, -1.95);
addBox(0.12, 1.0, 0.58, materials.frame, -3.42, 0.5, -1.95);
addBox(0.12, 1.0, 0.58, materials.frame, -1.88, 0.5, -1.95);
addBox(1.25, 1.45, 0.65, materials.cabinet, 2.65, 0.725, -2.0);
addBox(1.34, 0.12, 0.72, materials.cabinetTop, 2.65, 1.51, -2.0);
addBox(0.28, 0.045, 0.05, materials.dark, 2.65, 1.02, -1.66);
// Small stool.
addBox(0.55, 0.10, 0.55, materials.wood, 1.25, 0.52, -1.55);
addBox(0.08, 0.48, 0.08, materials.frame, 1.04, 0.24, -1.55);
addBox(0.08, 0.48, 0.08, materials.frame, 1.46, 0.24, -1.55);
function createDuct(sign, centerY) {
const nearX = 4.66;
const farX = 6.36;
const centerX = sign * (nearX + farX) * 0.5;
const length = farX - nearX;
// Transparent duct shell keeps the illustrative particles visible.
addBox(
length,
0.12,
1.18,
materials.duct,
centerX,
centerY + 0.49,
0,
false,
false
);
addBox(
length,
0.12,
1.18,
materials.duct,
centerX,
centerY - 0.49,
0,
false,
false
);
addBox(
length,
0.88,
0.10,
materials.duct,
centerX,
centerY,
0.57,
false,
false
);
addBox(
length,
0.88,
0.10,
materials.duct,
centerX,
centerY,
-0.57,
false,
false
);
// Amber collar identifies the physical opening.
addBox(
0.18,
0.13,
1.30,
materials.collar,
sign * nearX,
centerY + 0.55,
0
);
addBox(
0.18,
0.13,
1.30,
materials.collar,
sign * nearX,
centerY - 0.55,
0
);
addBox(
0.18,
1.02,
0.13,
materials.collar,
sign * nearX,
centerY,
0.61
);
addBox(
0.18,
1.02,
0.13,
materials.collar,
sign * nearX,
centerY,
-0.61
);
// Louvres at the outside end.
for (let i = -2; i <= 2; i++) {
addBox(
0.08,
0.86,
0.065,
materials.slat,
sign * (farX - 0.10),
centerY,
i * 0.21,
false,
false
);
}
}
createDuct(-1, 0.90);
createDuct(1, 4.05);
/*
This curve is intentionally a hand-authored visual hypothesis.
It is not a CFD result, and it does not use measured flow data.
*/
const flowCurve = new THREE.CatmullRomCurve3(
[
new THREE.Vector3(-6.18, 0.90, 0.00),
new THREE.Vector3(-4.62, 0.90, 0.00),
new THREE.Vector3(-3.45, 0.94, 0.03),
new THREE.Vector3(-2.40, 1.18, -0.08),
new THREE.Vector3(-1.45, 1.73, -0.17),
new THREE.Vector3(-0.35, 2.48, -0.20),
new THREE.Vector3(0.78, 3.13, -0.14),
new THREE.Vector3(1.90, 3.67, -0.05),
new THREE.Vector3(3.22, 4.00, 0.04),
new THREE.Vector3(4.62, 4.05, 0.00),
new THREE.Vector3(6.18, 4.05, 0.00)
],
false,
"catmullrom",
0.35
);
// Dashed streamline communicates that this is a schematic route.
const pathGeometry = new THREE.BufferGeometry().setFromPoints(
flowCurve.getPoints(180)
);
const pathLine = new THREE.Line(
pathGeometry,
new THREE.LineDashedMaterial({
color: 0x12b8c4,
dashSize: 0.17,
gapSize: 0.12,
transparent: true,
opacity: 0.58,
depthWrite: false
})
);
pathLine.computeLineDistances();
pathLine.renderOrder = 2;
scene.add(pathLine);
const faintTube = new THREE.Mesh(
new THREE.TubeGeometry(flowCurve, 100, 0.027, 5, false),
new THREE.MeshBasicMaterial({
color: 0x4edce3,
transparent: true,
opacity: 0.18,
depthWrite: false
})
);
faintTube.renderOrder = 2;
scene.add(faintTube);
// Low-poly cone arrowheads show the assumed direction of travel.
const particleCount = 44;
const particleGeometry = new THREE.ConeGeometry(0.09, 0.29, 4);
const particleMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.42,
metalness: 0.05,
emissive: 0x07535c,
emissiveIntensity: 0.65,
flatShading: true,
transparent: true,
opacity: 0.96,
depthWrite: false
});
const particles = new THREE.InstancedMesh(
particleGeometry,
particleMaterial,
particleCount
);
particles.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
particles.frustumCulled = false;
particles.renderOrder = 4;
for (let i = 0; i < particleCount; i++) {
const color = new THREE.Color(
i % 6 === 0 ? 0xf2ffff : (i % 2 === 0 ? 0x22d3dc : 0x8bf0f1)
);
particles.setColorAt(i, color);
}
particles.instanceColor.needsUpdate = true;
scene.add(particles);
const dummy = new THREE.Object3D();
const tangent = new THREE.Vector3();
const up = new THREE.Vector3(0, 1, 0);
let flowTime = 0;
let running = true;
function updateParticles() {
for (let i = 0; i < particleCount; i++) {
const u = (i / particleCount + flowTime * 0.043) % 1;
dummy.position.copy(flowCurve.getPointAt(u));
flowCurve.getTangentAt(u, tangent).normalize();
dummy.quaternion.setFromUnitVectors(up, tangent);
dummy.scale.setScalar(i % 7 === 0 ? 1.18 : 0.9);
dummy.updateMatrix();
particles.setMatrixAt(i, dummy.matrix);
}
particles.instanceMatrix.needsUpdate = true;
}
// Direct camera controls: no Three.js examples/addons are used.
const target = new THREE.Vector3(0, 2.35, 0);
let yaw = 0.68;
let pitch = 0.43;
let radius = 14.0;
function updateCamera() {
const horizontalRadius = radius * Math.cos(pitch);
camera.position.set(
target.x + Math.sin(yaw) * horizontalRadius,
target.y + Math.sin(pitch) * radius,
target.z + Math.cos(yaw) * horizontalRadius
);
camera.lookAt(target);
}
function resetCamera() {
yaw = 0.68;
pitch = 0.43;
radius = 14.0;
updateCamera();
}
let dragging = false;
let previousX = 0;
let previousY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
canvas.setPointerCapture(event.pointerId);
canvas.classList.add("dragging");
canvas.focus();
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
yaw -= deltaX * 0.006;
pitch -= deltaY * 0.005;
pitch = THREE.MathUtils.clamp(pitch, 0.12, 1.12);
previousX = event.clientX;
previousY = event.clientY;
});
function stopDragging(event) {
dragging = false;
canvas.classList.remove("dragging");
if (event.pointerId !== undefined && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
radius = THREE.MathUtils.clamp(
radius * Math.exp(event.deltaY * 0.001),
8.5,
21
);
},
{ passive: false }
);
canvas.addEventListener("keydown", (event) => {
const orbitStep = 0.09;
if (event.key === "ArrowLeft") yaw += orbitStep;
else if (event.key === "ArrowRight") yaw -= orbitStep;
else if (event.key === "ArrowUp") pitch += orbitStep;
else if (event.key === "ArrowDown") pitch -= orbitStep;
else if (event.key === "+" || event.key === "=") radius -= 0.6;
else if (event.key === "-" || event.key === "_") radius += 0.6;
else return;
event.preventDefault();
pitch = THREE.MathUtils.clamp(pitch, 0.12, 1.12);
radius = THREE.MathUtils.clamp(radius, 8.5, 21);
});
const pauseButton = document.querySelector("#pause");
const resetButton = document.querySelector("#reset");
pauseButton.addEventListener("click", () => {
running = !running;
pauseButton.textContent = running ? "Pause" : "Resume";
pauseButton.setAttribute("aria-pressed", String(!running));
});
resetButton.addEventListener("click", resetCamera);
// HTML labels are projected from their 3D anchors each frame.
const labels = [
{
element: document.querySelector("#label-inlet"),
anchor: new THREE.Vector3(-4.68, 0.90, 0.68)
},
{
element: document.querySelector("#label-outlet"),
anchor: new THREE.Vector3(4.68, 4.05, 0.68)
},
{
element: document.querySelector("#label-path"),
anchor: new THREE.Vector3(-0.65, 2.42, 0.10)
}
];
const projected = new THREE.Vector3();
function updateLabels() {
const rect = canvas.getBoundingClientRect();
for (const label of labels) {
projected.copy(label.anchor).project(camera);
const visible = projected.z > -1 && projected.z < 1;
const x = (projected.x * 0.5 + 0.5) * rect.width + rect.left;
const y = (-projected.y * 0.5 + 0.5) * rect.height + rect.top;
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);
}
window.addEventListener("resize", resize);
resetCamera();
updateParticles();
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
if (running) flowTime += delta;
updateCamera();
updateParticles();
renderer.render(scene, camera);
updateLabels();
}
animate();
loading.remove();
</script>
</body>
</html>
```