Prompt specification
Build or customize the Three.js 3D scene "Layered immiscible-liquid cylinder" 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: Layered immiscible-liquid cylinder
Category: Science & Physics · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/layered-immiscible-liquid-cylinder-x1461
Scene Description Prompt:
Please make a low-poly Three.js scene in one standalone HTML file using cdnjs. Build a transparent cylinder with three clearly labeled hypothetical immiscible liquids ordered by density; distinguish the layers from a universal claim about all liquids.
Working Three.js Starter (layered-immiscible-liquid-cylinder-x1461):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hypothetical Immiscible Liquids</title>
<style>
:root {
color-scheme: dark;
--top: #ffb547;
--middle: #38d6c7;
--bottom: #8b6cff;
--panel: rgba(9, 17, 31, 0.86);
--border: rgba(180, 220, 255, 0.18);
--text: #eef7ff;
--muted: #9eb1c8;
}
* {
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(--text);
background:
radial-gradient(circle at 50% 42%, #172b46 0%, #0b1627 42%, #060b14 100%);
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.hud {
position: fixed;
z-index: 5;
top: 24px;
left: 26px;
width: min(460px, calc(100vw - 130px));
pointer-events: none;
}
.eyebrow {
margin: 0 0 8px;
color: #72d9ff;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(25px, 3.1vw, 42px);
line-height: 1.04;
letter-spacing: -0.035em;
}
.subtitle {
margin: 12px 0 0;
max-width: 430px;
color: var(--muted);
font-size: 14px;
line-height: 1.55;
}
.disclaimer {
margin-top: 16px;
padding: 12px 14px;
border: 1px solid var(--border);
border-radius: 12px;
background: rgba(9, 17, 31, 0.72);
color: #b9c9dc;
font-size: 12px;
line-height: 1.5;
backdrop-filter: blur(12px);
}
.disclaimer strong {
color: #fff1c9;
}
.density-key {
display: inline-flex;
align-items: center;
gap: 9px;
margin-top: 13px;
color: #aebed1;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.density-key .arrow {
color: #72d9ff;
font-size: 18px;
line-height: 1;
}
#reset {
position: fixed;
z-index: 7;
top: 24px;
right: 26px;
padding: 10px 14px;
border: 1px solid var(--border);
border-radius: 10px;
color: var(--text);
background: rgba(9, 17, 31, 0.78);
font: inherit;
font-size: 12px;
font-weight: 700;
cursor: pointer;
backdrop-filter: blur(10px);
}
#reset:hover,
#reset:focus-visible {
border-color: rgba(114, 217, 255, 0.65);
background: rgba(20, 39, 62, 0.9);
outline: none;
}
#leaders,
#labels {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
pointer-events: none;
}
#leaders {
z-index: 2;
overflow: visible;
}
#leaders line {
stroke-width: 1.5;
opacity: 0.72;
}
#leaders circle {
stroke: rgba(255, 255, 255, 0.8);
stroke-width: 1;
}
#labels {
z-index: 3;
}
.callout {
position: absolute;
top: -1000px;
left: -1000px;
display: flex;
width: 222px;
gap: 11px;
align-items: flex-start;
padding: 12px 13px;
border: 1px solid var(--border);
border-left: 3px solid var(--layer);
border-radius: 12px;
background: var(--panel);
box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
backdrop-filter: blur(12px);
}
.badge {
display: grid;
flex: 0 0 27px;
width: 27px;
height: 27px;
place-items: center;
border-radius: 8px;
color: #09111f;
background: var(--layer);
font-size: 13px;
font-weight: 900;
}
.phase {
margin-bottom: 3px;
color: var(--layer);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.11em;
line-height: 1.25;
}
.name {
color: #f5f9ff;
font-size: 13px;
font-weight: 760;
line-height: 1.25;
}
.meta {
margin-top: 4px;
color: #9eb1c8;
font-size: 10px;
line-height: 1.3;
}
#controls-hint {
position: fixed;
z-index: 5;
right: 26px;
bottom: 22px;
padding: 9px 12px;
border: 1px solid var(--border);
border-radius: 9px;
color: #91a7bf;
background: rgba(9, 17, 31, 0.66);
font-size: 11px;
pointer-events: none;
}
#fallback {
position: fixed;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
padding: 30px;
color: white;
background: #08111f;
text-align: center;
}
[hidden] {
display: none !important;
}
@media (max-width: 700px) {
.hud {
top: 14px;
left: 14px;
width: calc(100vw - 90px);
}
h1 {
font-size: 25px;
}
.subtitle {
margin-top: 8px;
font-size: 12px;
}
.disclaimer {
margin-top: 10px;
padding: 9px 11px;
font-size: 10px;
}
.density-key {
display: none;
}
#reset {
top: 14px;
right: 14px;
padding: 9px 11px;
}
.callout {
width: 170px;
gap: 8px;
padding: 9px 10px;
}
.badge {
flex-basis: 23px;
width: 23px;
height: 23px;
}
.phase {
font-size: 8px;
}
.name {
font-size: 11px;
}
.meta {
font-size: 9px;
}
#controls-hint {
right: 12px;
bottom: 10px;
font-size: 9px;
}
}
</style>
</head>
<body>
<main id="scene" aria-label="Interactive three-dimensional liquid-layer demonstration"></main>
<header class="hud">
<p class="eyebrow">Low-poly density study</p>
<h1>Three hypothetical immiscible liquids</h1>
<p class="subtitle">
One illustrative equilibrium arrangement, ordered from least dense at
the top to most dense at the bottom.
</p>
<div class="density-key" aria-hidden="true">
<span>Less dense</span>
<span class="arrow">↓</span>
<span>More dense</span>
</div>
<aside class="disclaimer" role="note">
<strong>Illustrative, not universal.</strong>
This is one possible order for three hypothetical, immiscible liquids.
Real liquids do not have one fixed stacking order. Clean layers occur
when liquids are immiscible and have distinct densities; miscible
liquids mix, while similar densities can blur or eliminate a boundary.
</aside>
</header>
<button id="reset" type="button">Reset view</button>
<svg id="leaders" aria-hidden="true">
<line></line><circle r="4"></circle>
<line></line><circle r="4"></circle>
<line></line><circle r="4"></circle>
</svg>
<div id="labels" aria-label="Liquid layer labels">
<div class="callout" id="label-top" style="--layer: var(--top)">
<span class="badge">A</span>
<div>
<div class="phase">Top · Least dense</div>
<div class="name">Hypothetical Liquid A</div>
<div class="meta">Relative density ρ* = 0.65</div>
</div>
</div>
<div class="callout" id="label-middle" style="--layer: var(--middle)">
<span class="badge">B</span>
<div>
<div class="phase">Middle · Intermediate density</div>
<div class="name">Hypothetical Liquid B</div>
<div class="meta">Relative density ρ* = 1.00</div>
</div>
</div>
<div class="callout" id="label-bottom" style="--layer: var(--bottom)">
<span class="badge">C</span>
<div>
<div class="phase">Bottom · Most dense</div>
<div class="name">Hypothetical Liquid C</div>
<div class="meta">Relative density ρ* = 1.35</div>
</div>
</div>
</div>
<div id="controls-hint">
Drag to orbit · Scroll to zoom · Arrow keys to move · Double-click to reset
</div>
<div id="fallback" hidden>
This demonstration requires a browser with WebGL enabled.
</div>
<noscript>
<div id="fallback">JavaScript is required to display this Three.js scene.</div>
</noscript>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const container = document.getElementById("scene");
const resetButton = document.getElementById("reset");
const panels = [
document.getElementById("label-top"),
document.getElementById("label-middle"),
document.getElementById("label-bottom")
];
const leaderLines = [...document.querySelectorAll("#leaders line")];
const leaderDots = [...document.querySelectorAll("#leaders circle")];
const leaderSvg = document.getElementById("leaders");
let renderer;
try {
renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
} catch (error) {
document.getElementById("fallback").hidden = false;
throw error;
}
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0x08111f, 0);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute(
"aria-label",
"A transparent cylinder containing three colored hypothetical liquid layers"
);
container.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0x091321, 13, 30);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const target = new THREE.Vector3(0, 2.72, 0);
const spherical = {
theta: 0.64,
phi: 1.16,
radius: window.innerWidth < 700 ? 12.2 : 9.6
};
function updateCamera() {
const sinPhi = Math.sin(spherical.phi);
camera.position.set(
target.x + spherical.radius * sinPhi * Math.sin(spherical.theta),
target.y + spherical.radius * Math.cos(spherical.phi),
target.z + spherical.radius * sinPhi * Math.cos(spherical.theta)
);
camera.lookAt(target);
}
updateCamera();
// Lighting.
scene.add(new THREE.HemisphereLight(0xb9e7ff, 0x152033, 2.0));
const keyLight = new THREE.DirectionalLight(0xffffff, 3.0);
keyLight.position.set(5, 10, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1024, 1024);
keyLight.shadow.camera.left = -7;
keyLight.shadow.camera.right = 7;
keyLight.shadow.camera.top = 9;
keyLight.shadow.camera.bottom = -2;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 25;
scene.add(keyLight);
const rimLight = new THREE.PointLight(0x53d8ff, 24, 14, 2);
rimLight.position.set(-4, 4, -3);
scene.add(rimLight);
const warmLight = new THREE.PointLight(0xffb45c, 15, 12, 2);
warmLight.position.set(4, 3, 2);
scene.add(warmLight);
// Floor and low-poly pedestal.
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(40, 40),
new THREE.MeshStandardMaterial({
color: 0x0b1422,
roughness: 0.96,
metalness: 0.02
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.1;
floor.receiveShadow = true;
scene.add(floor);
const pedestal = new THREE.Mesh(
new THREE.CylinderGeometry(2.65, 2.86, 0.36, 12),
new THREE.MeshStandardMaterial({
color: 0x1b2b42,
roughness: 0.68,
metalness: 0.18,
flatShading: true
})
);
pedestal.position.y = 0.12;
pedestal.castShadow = true;
pedestal.receiveShadow = true;
scene.add(pedestal);
const pedestalRing = new THREE.Mesh(
new THREE.TorusGeometry(2.66, 0.035, 6, 36),
new THREE.MeshStandardMaterial({
color: 0x4e789e,
emissive: 0x173149,
emissiveIntensity: 0.35,
roughness: 0.35,
metalness: 0.55
})
);
pedestalRing.rotation.x = Math.PI / 2;
pedestalRing.position.y = 0.305;
scene.add(pedestalRing);
const liquidRadius = 1.98;
const glassRadius = 2.25;
const glassBottom = 0.34;
const glassTop = 5.38;
const layers = [
{
id: "top",
color: 0xffb547,
css: "#ffb547",
y0: 3.67,
y1: 5.14
},
{
id: "middle",
color: 0x38d6c7,
css: "#38d6c7",
y0: 2.18,
y1: 3.67
},
{
id: "bottom",
color: 0x8b6cff,
css: "#8b6cff",
y0: 0.40,
y1: 2.18
}
];
const animatedParticles = [];
const particleGeometry = new THREE.IcosahedronGeometry(1, 0);
layers.forEach((layer, layerIndex) => {
const height = layer.y1 - layer.y0;
// Open-ended side volume.
const side = new THREE.Mesh(
new THREE.CylinderGeometry(
liquidRadius,
liquidRadius,
height,
24,
1,
true
),
new THREE.MeshPhysicalMaterial({
color: layer.color,
roughness: 0.3,
metalness: 0,
transparent: true,
opacity: 0.76,
side: THREE.FrontSide,
depthWrite: true,
flatShading: true
})
);
side.position.y = (layer.y0 + layer.y1) / 2;
side.renderOrder = 2;
scene.add(side);
// Visible liquid surface.
const surface = new THREE.Mesh(
new THREE.CircleGeometry(liquidRadius, 24),
new THREE.MeshBasicMaterial({
color: layer.color,
transparent: true,
opacity: 0.38,
side: THREE.DoubleSide,
depthWrite: false
})
);
surface.rotation.x = -Math.PI / 2;
surface.position.y = layer.y1;
surface.renderOrder = 3;
scene.add(surface);
// Low-poly ring emphasizing the phase boundary.
const boundary = new THREE.Mesh(
new THREE.TorusGeometry(liquidRadius, 0.035, 6, 32),
new THREE.MeshStandardMaterial({
color: layer.color,
emissive: layer.color,
emissiveIntensity: 0.3,
roughness: 0.28,
metalness: 0.05,
transparent: true,
opacity: 0.95
})
);
boundary.rotation.x = Math.PI / 2;
boundary.position.y = layer.y1;
boundary.renderOrder = 4;
scene.add(boundary);
// A few suspended low-poly particles provide scale and depth.
for (let i = 0; i < 7; i++) {
const angle = Math.random() * Math.PI * 2;
const radius = Math.sqrt(Math.random()) * 1.38;
const baseY = THREE.MathUtils.lerp(
layer.y0 + 0.18,
layer.y1 - 0.18,
Math.random()
);
const size = THREE.MathUtils.lerp(0.055, 0.115, Math.random());
const particleColor = new THREE.Color(layer.color).lerp(
new THREE.Color(0xffffff),
0.36
);
const particle = new THREE.Mesh(
particleGeometry,
new THREE.MeshStandardMaterial({
color: particleColor,
emissive: layer.color,
emissiveIntensity: 0.12,
roughness: 0.32,
transparent: true,
opacity: 0.72,
flatShading: true
})
);
particle.position.set(
Math.cos(angle) * radius,
baseY,
Math.sin(angle) * radius
);
particle.scale.setScalar(size);
particle.rotation.set(
Math.random() * Math.PI,
Math.random() * Math.PI,
Math.random() * Math.PI
);
particle.renderOrder = 3;
scene.add(particle);
animatedParticles.push({
mesh: particle,
baseY,
phase: Math.random() * Math.PI * 2,
speed: 0.55 + Math.random() * 0.45,
amplitude: 0.035 + Math.random() * 0.025
});
}
leaderLines[layerIndex].setAttribute("stroke", layer.css);
leaderDots[layerIndex].setAttribute("fill", layer.css);
});
// Close the bottom of the lowest liquid volume.
const liquidBottom = new THREE.Mesh(
new THREE.CircleGeometry(liquidRadius, 24),
new THREE.MeshBasicMaterial({
color: layers[2].color,
transparent: true,
opacity: 0.32,
side: THREE.DoubleSide,
depthWrite: false
})
);
liquidBottom.rotation.x = -Math.PI / 2;
liquidBottom.position.y = layers[2].y0;
liquidBottom.renderOrder = 3;
scene.add(liquidBottom);
// Transparent outer cylinder.
const glassHeight = glassTop - glassBottom;
const glass = new THREE.Mesh(
new THREE.CylinderGeometry(
glassRadius,
glassRadius,
glassHeight,
24,
1,
true
),
new THREE.MeshPhysicalMaterial({
color: 0xc5efff,
roughness: 0.08,
metalness: 0,
transparent: true,
opacity: 0.14,
side: THREE.DoubleSide,
depthWrite: false
})
);
glass.position.y = (glassBottom + glassTop) / 2;
glass.renderOrder = 10;
scene.add(glass);
// Subtle transparent top.
const glassTopSurface = new THREE.Mesh(
new THREE.CircleGeometry(glassRadius, 24),
new THREE.MeshBasicMaterial({
color: 0xbdeeff,
transparent: true,
opacity: 0.045,
side: THREE.DoubleSide,
depthWrite: false
})
);
glassTopSurface.rotation.x = -Math.PI / 2;
glassTopSurface.position.y = glassTop;
glassTopSurface.renderOrder = 11;
scene.add(glassTopSurface);
const rimMaterial = new THREE.MeshStandardMaterial({
color: 0x93cfe8,
emissive: 0x15374b,
emissiveIntensity: 0.35,
roughness: 0.23,
metalness: 0.55
});
[glassBottom, glassTop].forEach((y) => {
const rim = new THREE.Mesh(
new THREE.TorusGeometry(glassRadius, 0.045, 6, 36),
rimMaterial
);
rim.rotation.x = Math.PI / 2;
rim.position.y = y;
rim.renderOrder = 12;
scene.add(rim);
});
// Sparse vertical lines reveal the cylinder's low-poly construction.
const edgePoints = [];
for (let i = 0; i < 12; i++) {
const angle = (i / 12) * Math.PI * 2;
const x = Math.cos(angle) * glassRadius;
const z = Math.sin(angle) * glassRadius;
edgePoints.push(
new THREE.Vector3(x, glassBottom, z),
new THREE.Vector3(x, glassTop, z)
);
}
const edgeGeometry = new THREE.BufferGeometry().setFromPoints(edgePoints);
const edges = new THREE.LineSegments(
edgeGeometry,
new THREE.LineBasicMaterial({
color: 0xb9edff,
transparent: true,
opacity: 0.32
})
);
edges.renderOrder = 12;
scene.add(edges);
// ---------------------------------------------------------------------
// Camera controls implemented directly without Three.js add-ons.
// ---------------------------------------------------------------------
const pointers = new Map();
let lastPinchDistance = 0;
function clamp(value, min, max) {
return Math.min(max, Math.max(min, value));
}
function resetCamera() {
spherical.theta = 0.64;
spherical.phi = 1.16;
spherical.radius = window.innerWidth < 700 ? 12.2 : 9.6;
updateCamera();
}
function pointerDistance() {
const values = [...pointers.values()];
if (values.length < 2) return 0;
return Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
}
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 2) {
lastPinchDistance = pointerDistance();
}
renderer.domElement.focus({ preventScroll: true });
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size >= 2) {
const distance = pointerDistance();
if (lastPinchDistance > 0 && distance > 0) {
spherical.radius = clamp(
spherical.radius * (lastPinchDistance / distance),
6.2,
17
);
updateCamera();
}
lastPinchDistance = distance;
return;
}
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
spherical.theta -= dx * 0.008;
spherical.phi = clamp(spherical.phi - dy * 0.006, 0.62, 1.48);
updateCamera();
});
function endPointer(event) {
pointers.delete(event.pointerId);
lastPinchDistance = pointers.size >= 2 ? pointerDistance() : 0;
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
spherical.radius = clamp(
spherical.radius * Math.exp(event.deltaY * 0.001),
6.2,
17
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
resetButton.addEventListener("click", resetCamera);
renderer.domElement.addEventListener("keydown", (event) => {
let handled = true;
switch (event.key) {
case "ArrowLeft":
spherical.theta += 0.08;
break;
case "ArrowRight":
spherical.theta -= 0.08;
break;
case "ArrowUp":
spherical.phi = clamp(spherical.phi - 0.05, 0.62, 1.48);
break;
case "ArrowDown":
spherical.phi = clamp(spherical.phi + 0.05, 0.62, 1.48);
break;
case "+":
case "=":
spherical.radius = clamp(spherical.radius * 0.9, 6.2, 17);
break;
case "-":
case "_":
spherical.radius = clamp(spherical.radius * 1.1, 6.2, 17);
break;
case "Home":
resetCamera();
break;
default:
handled = false;
}
if (handled) {
event.preventDefault();
updateCamera();
}
});
// Projected DOM labels and SVG leader lines.
let panelSizes = [];
function measurePanels() {
panelSizes = panels.map((panel) => ({
width: panel.offsetWidth,
height: panel.offsetHeight
}));
}
const projected = new THREE.Vector3();
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
const cameraDirection = new THREE.Vector3(
camera.position.x - target.x,
0,
camera.position.z - target.z
).normalize();
leaderSvg.setAttribute("viewBox", `0 0 ${width} ${height}`);
panels.forEach((panel, index) => {
const layer = layers[index];
const size = panelSizes[index] || {
width: panel.offsetWidth,
height: panel.offsetHeight
};
// Put the anchor on the camera-facing side of each layer.
projected.set(
target.x + cameraDirection.x * 1.3,
(layer.y0 + layer.y1) / 2,
target.z + cameraDirection.z * 1.3
);
projected.project(camera);
const anchorX = (projected.x * 0.5 + 0.5) * width;
const anchorY = (-projected.y * 0.5 + 0.5) * height;
const preferLeft = index === 1;
const gap = width < 700 ? 28 : 62;
const margin = width < 700 ? 10 : 20;
let panelX = preferLeft
? anchorX - size.width - gap
: anchorX + gap;
let panelY = anchorY - size.height / 2;
const minimumY = width < 700 ? 178 : 32;
const maximumY = Math.max(
minimumY,
height - size.height - 58
);
panelX = clamp(
panelX,
margin,
Math.max(margin, width - size.width - margin)
);
panelY = clamp(panelY, minimumY, maximumY);
panel.style.left = `${panelX}px`;
panel.style.top = `${panelY}px`;
const isLeftOfAnchor = panelX + size.width / 2 < anchorX;
const endX = isLeftOfAnchor
? panelX + size.width
: panelX;
const endY = panelY + size.height / 2;
const line = leaderLines[index];
const dot = leaderDots[index];
line.setAttribute("x1", anchorX);
line.setAttribute("y1", anchorY);
line.setAttribute("x2", endX);
line.setAttribute("y2", endY);
dot.setAttribute("cx", anchorX);
dot.setAttribute("cy", anchorY);
});
}
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
measurePanels();
}
window.addEventListener("resize", resize);
measurePanels();
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
animatedParticles.forEach((particle) => {
particle.mesh.position.y =
particle.baseY +
Math.sin(elapsed * particle.speed + particle.phase) *
particle.amplitude;
particle.mesh.rotation.y += 0.003;
particle.mesh.rotation.x += 0.002;
});
updateLabels();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```