Prompt specification
Build or customize the Three.js 3D scene "Fruit-shaped refrigerator magnet set" 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: Fruit-shaped refrigerator magnet set
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/fruit-shaped-refrigerator-magnet-set-x0033
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts refrigerator magnets. Arrange three chunky fruit magnets beside a thin steel panel, separating raised fruit bodies from backing discs so their attachment surfaces remain visible. Voxel style.
Working Three.js Starter (fruit-shaped-refrigerator-magnet-set-x0033):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voxel Fruit Refrigerator Magnets</title>
<style>
:root {
--ink: #252522;
--muted: #6f6c62;
--paper: #eee8dc;
--orange: #ef7627;
--red: #d83d49;
--yellow: #edc83d;
--green: #527f46;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--paper);
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%;
outline: none;
touch-action: none;
}
.header {
position: fixed;
top: clamp(22px, 4vw, 54px);
left: clamp(22px, 4vw, 58px);
z-index: 2;
pointer-events: none;
max-width: 430px;
}
.eyebrow {
display: inline-flex;
align-items: center;
gap: 9px;
margin-bottom: 13px;
padding: 7px 10px;
border: 1px solid rgba(37, 37, 34, 0.18);
border-radius: 5px;
background: rgba(238, 232, 220, 0.72);
backdrop-filter: blur(8px);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.eyebrow::before {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--orange);
box-shadow: 0 0 0 3px rgba(239, 118, 39, 0.14);
content: "";
}
h1 {
margin: 0;
font-size: clamp(36px, 6vw, 78px);
font-weight: 900;
letter-spacing: -0.065em;
line-height: 0.88;
text-transform: uppercase;
}
.description {
max-width: 370px;
margin: 18px 0 0;
color: var(--muted);
font-size: 13px;
font-weight: 600;
line-height: 1.55;
}
.legend {
position: fixed;
bottom: clamp(22px, 4vw, 48px);
left: clamp(22px, 4vw, 58px);
z-index: 2;
display: flex;
flex-wrap: wrap;
gap: 18px;
pointer-events: none;
}
.legend-item {
display: flex;
align-items: center;
gap: 8px;
color: #555249;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.swatch {
width: 11px;
height: 11px;
border: 2px solid rgba(37, 37, 34, 0.12);
border-radius: 2px;
}
.controls {
position: fixed;
right: clamp(22px, 4vw, 58px);
bottom: clamp(22px, 4vw, 48px);
z-index: 3;
display: flex;
align-items: center;
gap: 14px;
}
.hint {
color: var(--muted);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
pointer-events: none;
}
button {
border: 1px solid rgba(37, 37, 34, 0.2);
border-radius: 6px;
padding: 10px 14px;
background: rgba(238, 232, 220, 0.8);
color: var(--ink);
font: inherit;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
cursor: pointer;
backdrop-filter: blur(8px);
transition:
background 160ms ease,
transform 160ms ease;
}
button:hover {
background: #fffaf0;
transform: translateY(-1px);
}
button:active {
transform: translateY(0);
}
@media (max-width: 700px) {
.description {
max-width: 280px;
}
.hint {
display: none;
}
.legend {
gap: 12px;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<header class="header">
<div class="eyebrow">Exploded attachment view</div>
<h1>Fridge<br />Fruits</h1>
<p class="description">
Three chunky voxel refrigerator magnets float beside a thin steel panel.
Each raised fruit is separated from its backing disc so the attachment
surface remains visible.
</p>
</header>
<div class="legend" aria-label="Fruit colors">
<div class="legend-item">
<span class="swatch" style="background: var(--orange)"></span>
Orange
</div>
<div class="legend-item">
<span class="swatch" style="background: var(--red)"></span>
Strawberry
</div>
<div class="legend-item">
<span class="swatch" style="background: var(--yellow)"></span>
Lemon
</div>
</div>
<div class="controls">
<span class="hint">Drag to orbit · Scroll to zoom</span>
<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 container = document.querySelector("#scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xeee8dc);
scene.fog = new THREE.Fog(0xeee8dc, 19, 36);
const camera = new THREE.PerspectiveCamera(
37,
window.innerWidth / window.innerHeight,
0.1,
80
);
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;
container.appendChild(renderer.domElement);
renderer.domElement.setAttribute(
"aria-label",
"Interactive 3D scene showing three voxel fruit refrigerator magnets beside a steel panel."
);
// Lighting
scene.add(new THREE.HemisphereLight(0xfff7e6, 0x77736a, 2.05));
const keyLight = new THREE.DirectionalLight(0xfff0d2, 4.2);
keyLight.position.set(-5, 11, 9);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -11;
keyLight.shadow.camera.right = 11;
keyLight.shadow.camera.top = 12;
keyLight.shadow.camera.bottom = -7;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 30;
keyLight.shadow.bias = -0.0003;
keyLight.shadow.normalBias = 0.035;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xd9e8ff, 1.7);
fillLight.position.set(9, 6, 5);
scene.add(fillLight);
const rimLight = new THREE.DirectionalLight(0xffd1a1, 2.0);
rimLight.position.set(1, 7, -8);
scene.add(rimLight);
// Ground
const groundMaterial = new THREE.MeshStandardMaterial({
color: 0xe4ddcf,
roughness: 0.95,
metalness: 0
});
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(50, 50),
groundMaterial
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.015;
ground.receiveShadow = true;
scene.add(ground);
// Thin steel panel
const panel = new THREE.Group();
panel.position.set(4.65, 3.68, -0.9);
panel.rotation.y = -0.12;
const steelMaterial = new THREE.MeshStandardMaterial({
color: 0xb9bec0,
roughness: 0.38,
metalness: 0.48
});
const steelEdgeMaterial = new THREE.MeshStandardMaterial({
color: 0x737a7d,
roughness: 0.29,
metalness: 0.62
});
const steelFaceMaterial = new THREE.MeshStandardMaterial({
color: 0xc8cccd,
roughness: 0.42,
metalness: 0.42
});
const panelBody = new THREE.Mesh(
new THREE.BoxGeometry(3.12, 6.85, 0.18),
steelMaterial
);
panelBody.castShadow = true;
panelBody.receiveShadow = true;
panel.add(panelBody);
const panelFace = new THREE.Mesh(
new THREE.BoxGeometry(2.96, 6.69, 0.035),
steelFaceMaterial
);
panelFace.position.z = 0.105;
panelFace.receiveShadow = true;
panel.add(panelFace);
const rightEdge = new THREE.Mesh(
new THREE.BoxGeometry(0.12, 6.87, 0.235),
steelEdgeMaterial
);
rightEdge.position.x = 1.56;
rightEdge.castShadow = true;
panel.add(rightEdge);
const topEdge = new THREE.Mesh(
new THREE.BoxGeometry(3.12, 0.11, 0.235),
steelEdgeMaterial
);
topEdge.position.y = 3.42;
topEdge.castShadow = true;
panel.add(topEdge);
// Subtle vertical brushing.
const brushMaterial = new THREE.MeshBasicMaterial({
color: 0xe5e7e5,
transparent: true,
opacity: 0.15
});
for (let i = 0; i < 18; i++) {
const brush = new THREE.Mesh(
new THREE.BoxGeometry(0.008, 6.5, 0.012),
brushMaterial
);
brush.position.set(
-1.38 + i * 0.155,
Math.sin(i * 4.7) * 0.07,
0.128
);
panel.add(brush);
}
const footMaterial = new THREE.MeshStandardMaterial({
color: 0x555958,
roughness: 0.45,
metalness: 0.55
});
for (const x of [-1.0, 1.0]) {
const foot = new THREE.Mesh(
new THREE.BoxGeometry(0.42, 0.24, 0.82),
footMaterial
);
foot.position.set(x, -3.55, -0.04);
foot.castShadow = true;
foot.receiveShadow = true;
panel.add(foot);
}
scene.add(panel);
// Shared geometry and materials
const voxelGeometry = new THREE.BoxGeometry(1, 1, 1);
const leafDarkMaterial = new THREE.MeshStandardMaterial({
color: 0x315f35,
roughness: 0.82
});
const leafLightMaterial = new THREE.MeshStandardMaterial({
color: 0x5b914b,
roughness: 0.78
});
const stemMaterial = new THREE.MeshStandardMaterial({
color: 0x6c5532,
roughness: 0.86
});
const seedMaterial = new THREE.MeshStandardMaterial({
color: 0xffe39a,
roughness: 0.7
});
function hash3(x, y, z) {
const value = Math.sin(x * 12.9898 + y * 78.233 + z * 37.719) * 43758.5453;
return value - Math.floor(value);
}
function makeVoxelBody(voxels, palette, step = 0.305) {
const material = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.72,
metalness: 0.015
});
const mesh = new THREE.InstancedMesh(
voxelGeometry,
material,
voxels.length
);
const dummy = new THREE.Object3D();
const color = new THREE.Color();
voxels.forEach((voxel, index) => {
const [x, y, z] = voxel;
dummy.position.set(x * step, y * step, z * step);
dummy.rotation.set(0, 0, 0);
dummy.scale.set(0.302, 0.302, 0.302);
dummy.updateMatrix();
mesh.setMatrixAt(index, dummy.matrix);
const n = hash3(x, y, z);
const paletteIndex = n < 0.58 ? 0 : n < 0.86 ? 1 : 2;
color.set(palette[paletteIndex]);
mesh.setColorAt(index, color);
});
mesh.instanceMatrix.needsUpdate = true;
if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
function addBlock(group, size, position, material, rotation = [0, 0, 0]) {
const block = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
material
);
block.position.set(position[0], position[1], position[2]);
block.rotation.set(rotation[0], rotation[1], rotation[2]);
block.castShadow = true;
block.receiveShadow = true;
group.add(block);
return block;
}
function createOrange() {
const group = new THREE.Group();
const voxels = [];
for (let x = -3; x <= 3; x++) {
for (let y = -3; y <= 3; y++) {
for (let z = -3; z <= 3; z++) {
if (x * x + y * y + z * z <= 10.2) {
voxels.push([x, y, z]);
}
}
}
}
group.add(
makeVoxelBody(
voxels,
[0xee7022, 0xf68a2e, 0xd95c1c],
0.305
)
);
addBlock(
group,
[0.14, 0.34, 0.14],
[0, 1.09, 0],
stemMaterial,
[0, 0, -0.12]
);
addBlock(
group,
[0.55, 0.13, 0.25],
[0.21, 1.25, 0],
leafLightMaterial,
[0.08, -0.2, -0.25]
);
addBlock(
group,
[0.38, 0.11, 0.21],
[-0.16, 1.22, 0.04],
leafDarkMaterial,
[0.05, 0.3, 0.34]
);
return group;
}
function createStrawberry() {
const group = new THREE.Group();
const voxels = [];
const radii = {
"-4": 0.45,
"-3": 1.15,
"-2": 1.9,
"-1": 2.55,
"0": 2.9,
"1": 3.0,
"2": 2.78,
"3": 2.18
};
for (let y = -4; y <= 3; y++) {
const radius = radii[String(y)];
for (let x = -3; x <= 3; x++) {
for (let z = -3; z <= 3; z++) {
if (x * x + z * z <= radius * radius) {
voxels.push([x, y, z]);
}
}
}
}
group.add(
makeVoxelBody(
voxels,
[0xd83c48, 0xeb4d58, 0xb92d3a],
0.3
)
);
// Small voxel-like seeds on the visible front.
const seeds = [
[-0.72, 0.61, 2.86],
[0.66, 0.61, 2.86],
[0.0, 0.23, 3.0],
[-0.82, -0.2, 2.57],
[0.82, -0.2, 2.57],
[-0.48, -0.68, 1.94],
[0.48, -0.68, 1.94],
[0.0, -1.02, 1.35]
];
for (const [x, y, radius] of seeds) {
const z = Math.sqrt(Math.max(0, radius * radius - x * x)) * 0.3 + 0.145;
addBlock(
group,
[0.085, 0.145, 0.06],
[x, y, z],
seedMaterial,
[0, 0, x * 0.15]
);
}
// Blocky green crown.
addBlock(
group,
[0.22, 0.2, 0.22],
[0, 1.04, 0],
stemMaterial
);
for (let i = 0; i < 6; i++) {
const angle = (i / 6) * Math.PI * 2;
addBlock(
group,
[0.57, 0.14, 0.23],
[
Math.cos(angle) * 0.28,
1.03,
Math.sin(angle) * 0.28
],
i % 2 ? leafDarkMaterial : leafLightMaterial,
[0, -angle, 0]
);
}
return group;
}
function createLemon() {
const group = new THREE.Group();
const voxels = [];
const radii = [
0.38, 0.9, 1.5, 2.05, 2.35, 2.45,
2.35, 2.05, 1.5, 0.9, 0.38
];
for (let xi = -5; xi <= 5; xi++) {
const radius = radii[xi + 5];
for (let y = -3; y <= 3; y++) {
for (let z = -3; z <= 3; z++) {
if (y * y + z * z <= radius * radius) {
voxels.push([xi, y, z]);
}
}
}
}
group.add(
makeVoxelBody(
voxels,
[0xe9c83b, 0xf4d957, 0xd2ad27],
0.3
)
);
addBlock(
group,
[0.48, 0.12, 0.24],
[0.65, 0.82, 0.02],
leafLightMaterial,
[0.05, -0.3, -0.28]
);
addBlock(
group,
[0.12, 0.18, 0.12],
[0.43, 0.79, 0],
stemMaterial,
[0, 0, 0.25]
);
return group;
}
function createBackingDisc() {
const group = new THREE.Group();
const outerMaterial = new THREE.MeshStandardMaterial({
color: 0x303332,
roughness: 0.55,
metalness: 0.38
});
const rimMaterial = new THREE.MeshStandardMaterial({
color: 0x929a9b,
roughness: 0.3,
metalness: 0.72
});
const faceMaterial = new THREE.MeshStandardMaterial({
color: 0x555c5d,
roughness: 0.34,
metalness: 0.64
});
const contactMaterial = new THREE.MeshStandardMaterial({
color: 0x202322,
roughness: 0.7,
metalness: 0.28
});
const outer = new THREE.Mesh(
new THREE.CylinderGeometry(0.64, 0.64, 0.14, 16),
outerMaterial
);
outer.rotation.x = Math.PI / 2;
outer.castShadow = true;
outer.receiveShadow = true;
group.add(outer);
const rim = new THREE.Mesh(
new THREE.TorusGeometry(0.545, 0.065, 4, 16),
rimMaterial
);
rim.position.z = 0.075;
rim.castShadow = true;
group.add(rim);
const face = new THREE.Mesh(
new THREE.CylinderGeometry(0.47, 0.47, 0.075, 16),
faceMaterial
);
face.rotation.x = Math.PI / 2;
face.position.z = 0.08;
face.castShadow = true;
group.add(face);
const contact = new THREE.Mesh(
new THREE.CylinderGeometry(0.235, 0.235, 0.055, 12),
contactMaterial
);
contact.rotation.x = Math.PI / 2;
contact.position.z = 0.135;
contact.castShadow = true;
group.add(contact);
// Small machined highlight.
const highlight = new THREE.Mesh(
new THREE.BoxGeometry(0.08, 0.025, 0.018),
new THREE.MeshBasicMaterial({ color: 0xd9dddd })
);
highlight.position.set(-0.27, 0.34, 0.155);
highlight.rotation.z = -0.35;
group.add(highlight);
return group;
}
function createAlignmentGuide(start, end) {
const group = new THREE.Group();
const direction = new THREE.Vector3().subVectors(end, start);
const length = direction.length();
direction.normalize();
const guideStart = start.clone().addScaledVector(direction, 0.66);
const guideEnd = end.clone().addScaledVector(direction, -0.92);
const count = 5;
const material = new THREE.MeshStandardMaterial({
color: 0x8b8980,
roughness: 0.85,
metalness: 0.05
});
for (let i = 0; i < count; i++) {
const t = i / (count - 1);
const point = new THREE.Vector3().lerpVectors(
guideStart,
guideEnd,
t
);
const marker = new THREE.Mesh(
new THREE.BoxGeometry(0.065, 0.065, 0.065),
material
);
marker.position.copy(point);
marker.castShadow = true;
group.add(marker);
}
return group;
}
const magnets = [];
function createMagnet(type, bodyPosition, discPosition, phase) {
const group = new THREE.Group();
let body;
if (type === "orange") body = createOrange();
if (type === "strawberry") body = createStrawberry();
if (type === "lemon") body = createLemon();
body.position.copy(bodyPosition);
const disc = createBackingDisc();
disc.position.copy(discPosition);
const guide = createAlignmentGuide(discPosition, bodyPosition);
group.add(guide, disc, body);
scene.add(group);
magnets.push({
group,
phase,
baseY: 0
});
}
createMagnet(
"orange",
new THREE.Vector3(-3.65, 3.75, 0.72),
new THREE.Vector3(-2.08, 2.92, -0.02),
0
);
createMagnet(
"strawberry",
new THREE.Vector3(-1.47, 5.13, 0.62),
new THREE.Vector3(-0.08, 4.28, -0.12),
2.1
);
createMagnet(
"lemon",
new THREE.Vector3(0.94, 2.62, 0.78),
new THREE.Vector3(2.12, 1.84, 0.02),
4.2
);
// Small voxel blocks on the ground add scale and visual rhythm.
const floorBlockMaterial = new THREE.MeshStandardMaterial({
color: 0xd2c9b7,
roughness: 0.9
});
const floorBlocks = [
[-4.4, 0.1, 1.4, 0.2],
[-3.9, 0.075, 1.85, 0.15],
[2.8, 0.09, 1.55, 0.18]
];
for (const [x, y, z, s] of floorBlocks) {
const block = new THREE.Mesh(
new THREE.BoxGeometry(s, s, s),
floorBlockMaterial
);
block.position.set(x, y, z);
block.rotation.y = 0.2;
block.castShadow = true;
block.receiveShadow = true;
scene.add(block);
}
// Custom orbit controls; no Three.js addons are used.
const orbit = {
target: new THREE.Vector3(0.55, 3.02, 0),
radius: 14.8,
theta: 0.52,
phi: 1.3
};
const defaultOrbit = { ...orbit };
function updateCamera() {
const sinPhi = Math.sin(orbit.phi);
const cosPhi = Math.cos(orbit.phi);
camera.position.set(
orbit.target.x + orbit.radius * sinPhi * Math.sin(orbit.theta),
orbit.target.y + orbit.radius * cosPhi,
orbit.target.z + orbit.radius * sinPhi * Math.cos(orbit.theta)
);
camera.lookAt(orbit.target);
}
function resetView() {
orbit.target.copy(defaultOrbit.target);
orbit.radius = defaultOrbit.radius;
orbit.theta = defaultOrbit.theta;
orbit.phi = defaultOrbit.phi;
updateCamera();
}
const pointers = new Map();
let previousPinchDistance = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
previousPinchDistance = Math.hypot(a.x - b.x, a.y - b.y);
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
const current = {
x: event.clientX,
y: event.clientY
};
pointers.set(event.pointerId, current);
if (pointers.size === 1) {
const dx = current.x - previous.x;
const dy = current.y - previous.y;
orbit.theta -= dx * 0.006;
orbit.phi = THREE.MathUtils.clamp(
orbit.phi - dy * 0.006,
0.38,
1.48
);
} else if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
const distance = Math.hypot(a.x - b.x, a.y - b.y);
if (previousPinchDistance > 0) {
orbit.radius = THREE.MathUtils.clamp(
orbit.radius * (previousPinchDistance / distance),
8,
23
);
}
previousPinchDistance = distance;
}
updateCamera();
});
function releasePointer(event) {
pointers.delete(event.pointerId);
previousPinchDistance = 0;
}
renderer.domElement.addEventListener("pointerup", releasePointer);
renderer.domElement.addEventListener("pointercancel", releasePointer);
renderer.domElement.addEventListener("lostpointercapture", releasePointer);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius * Math.exp(event.deltaY * 0.001),
8,
23
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetView);
document.querySelector("#reset").addEventListener("click", resetView);
window.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") orbit.theta -= 0.1;
if (event.key === "ArrowRight") orbit.theta += 0.1;
if (event.key === "ArrowUp") orbit.phi = Math.max(0.38, orbit.phi - 0.08);
if (event.key === "ArrowDown") orbit.phi = Math.min(1.48, orbit.phi + 0.08);
if (event.key === "+" || event.key === "=") orbit.radius = Math.max(8, orbit.radius - 0.8);
if (event.key === "-") orbit.radius = Math.min(23, orbit.radius + 0.8);
if (event.key.toLowerCase() === "r") resetView();
updateCamera();
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
updateCamera();
const clock = new THREE.Clock();
renderer.setAnimationLoop(() => {
const elapsed = clock.getElapsedTime();
for (const magnet of magnets) {
magnet.group.position.y =
magnet.baseY + Math.sin(elapsed * 0.85 + magnet.phase) * 0.035;
}
renderer.render(scene, camera);
});
</script>
</body>
</html>
```