Prompt specification
Build or customize the Three.js 3D scene "Half-fruit serving comparison" 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: Half-fruit serving comparison
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/half-fruit-serving-comparison-x0082
Scene Description Prompt:
Low-poly avocado, peach, and mango sections on separate boards, with seeds clearly distinguished from edible flesh. One HTML file with Three.js from cdnjs.
Working Three.js Starter (half-fruit-serving-comparison-x0082):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Low-Poly Fruit Sections</title>
<style>
:root {
color-scheme: light;
--ink: #332820;
--muted: #76695c;
--paper: #f3eadc;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--paper);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
#app,
canvas {
width: 100%;
height: 100%;
display: block;
}
canvas {
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.overlay {
position: fixed;
inset: 0;
pointer-events: none;
}
.heading {
position: absolute;
top: 28px;
left: 32px;
max-width: 360px;
}
.eyebrow {
margin: 0 0 6px;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.22em;
text-transform: uppercase;
color: #9b7657;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(30px, 4vw, 52px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.04em;
}
.subtitle {
margin: 12px 0 0;
max-width: 300px;
font-size: 12px;
line-height: 1.55;
color: var(--muted);
}
.legend {
position: absolute;
top: 30px;
right: 32px;
display: grid;
gap: 10px;
padding: 14px 16px;
border: 1px solid rgba(91, 70, 52, 0.16);
border-radius: 12px;
background: rgba(255, 251, 244, 0.68);
backdrop-filter: blur(8px);
box-shadow: 0 8px 28px rgba(79, 57, 38, 0.07);
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
font-size: 11px;
font-weight: 650;
letter-spacing: 0.02em;
}
.swatch {
width: 13px;
height: 13px;
border-radius: 4px;
box-shadow: inset 0 0 0 1px rgba(45, 34, 26, 0.14);
}
.flesh-swatch {
background: linear-gradient(135deg, #b7d45c 0 33%, #f5bd61 33% 66%, #f6cf54 66%);
}
.seed-swatch {
background: linear-gradient(135deg, #754222 0 33%, #8c3027 33% 66%, #ead9ab 66%);
}
.fruit-label {
position: absolute;
left: 0;
top: 0;
display: grid;
grid-template-columns: 9px auto;
grid-template-rows: auto auto;
column-gap: 8px;
min-width: 118px;
padding: 9px 12px;
border: 1px solid rgba(88, 64, 45, 0.14);
border-radius: 9px;
background: rgba(255, 252, 246, 0.84);
backdrop-filter: blur(7px);
box-shadow: 0 6px 20px rgba(75, 53, 34, 0.08);
transform: translate(-50%, -50%);
will-change: left, top;
}
.fruit-label .dot {
grid-row: 1 / 3;
align-self: center;
width: 8px;
height: 8px;
border-radius: 50%;
box-shadow: 0 0 0 3px rgba(80, 61, 43, 0.08);
}
.fruit-label strong {
font-size: 10px;
line-height: 1.1;
letter-spacing: 0.13em;
}
.fruit-label small {
margin-top: 3px;
font-size: 9px;
color: var(--muted);
}
.hint {
position: absolute;
right: 32px;
bottom: 24px;
margin: 0;
font-size: 10px;
letter-spacing: 0.06em;
color: rgba(74, 57, 43, 0.62);
}
@media (max-width: 700px) {
.heading {
top: 20px;
left: 20px;
}
.legend {
top: 20px;
right: 20px;
padding: 10px 12px;
}
.subtitle,
.hint {
display: none;
}
}
</style>
</head>
<body>
<div id="app"></div>
<div class="overlay">
<header class="heading">
<p class="eyebrow">Low-poly still life · 03</p>
<h1>Cut fruit<br />study</h1>
<p class="subtitle">
Avocado, peach, and mango sections arranged on individual wooden boards.
Seeds and pits are recessed and color-separated from the edible flesh.
</p>
</header>
<aside class="legend" aria-label="Fruit color legend">
<div class="legend-row">
<span class="swatch flesh-swatch"></span>
<span>Edible flesh</span>
</div>
<div class="legend-row">
<span class="swatch seed-swatch"></span>
<span>Seed / pit</span>
</div>
</aside>
<div
id="avocado-label"
class="fruit-label"
style="--dot: #754422"
>
<span class="dot" style="background:#754422"></span>
<strong>AVOCADO</strong>
<small>brown pit</small>
</div>
<div
id="peach-label"
class="fruit-label"
>
<span class="dot" style="background:#8c3027"></span>
<strong>PEACH</strong>
<small>red-brown pit</small>
</div>
<div
id="mango-label"
class="fruit-label"
>
<span class="dot" style="background:#ead9ab"></span>
<strong>MANGO</strong>
<small>cream seed</small>
</div>
<p class="hint">Drag to orbit · Scroll to zoom</p>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const host = document.getElementById("app");
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;
host.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xf3eadc);
scene.fog = new THREE.Fog(0xf3eadc, 20, 38);
const camera = new THREE.PerspectiveCamera(
35,
window.innerWidth / window.innerHeight,
0.1,
100
);
const cameraTarget = new THREE.Vector3(0, 0.45, 0);
let cameraTheta = 0;
let cameraPhi = 0.98;
let cameraZoom = 1;
let fittedRadius = 15;
const hemisphere = new THREE.HemisphereLight(0xfff8e9, 0x796b5a, 2.15);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff1d4, 3.2);
keyLight.position.set(-6, 11, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -12;
keyLight.shadow.camera.right = 12;
keyLight.shadow.camera.top = 10;
keyLight.shadow.camera.bottom = -10;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 30;
keyLight.shadow.bias = -0.00035;
keyLight.shadow.normalBias = 0.025;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xdbe9ff, 1.15);
fillLight.position.set(8, 6, -7);
scene.add(fillLight);
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(60, 60),
new THREE.MeshStandardMaterial({
color: 0xe9ddca,
roughness: 1,
metalness: 0
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.015;
ground.receiveShadow = true;
scene.add(ground);
function makeShape(points) {
const shape = new THREE.Shape();
shape.moveTo(points[0][0], points[0][1]);
for (let i = 1; i < points.length; i++) {
shape.lineTo(points[i][0], points[i][1]);
}
shape.closePath();
return shape;
}
function makeExtrudedMesh(
points,
depth,
topMaterial,
sideMaterial,
bevelSize = 0.025
) {
const geometry = new THREE.ExtrudeGeometry(makeShape(points), {
depth,
steps: 1,
curveSegments: 1,
bevelEnabled: true,
bevelSegments: 1,
bevelSize,
bevelThickness: bevelSize
});
const mesh = new THREE.Mesh(geometry, [topMaterial, sideMaterial]);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
function roundedRectangle(width, height, radius) {
const x = -width / 2;
const y = -height / 2;
const shape = new THREE.Shape();
shape.moveTo(x + radius, y);
shape.lineTo(x + width - radius, y);
shape.quadraticCurveTo(x + width, y, x + width, y + radius);
shape.lineTo(x + width, y + height - radius);
shape.quadraticCurveTo(
x + width,
y + height,
x + width - radius,
y + height
);
shape.lineTo(x + radius, y + height);
shape.quadraticCurveTo(x, y + height, x, y + height - radius);
shape.lineTo(x, y + radius);
shape.quadraticCurveTo(x, y, x + radius, y);
shape.closePath();
return shape;
}
function addWoodGrain(boardX, phase) {
const material = new THREE.LineBasicMaterial({
color: 0x714728,
transparent: true,
opacity: 0.17
});
for (let row = -3; row <= 3; row++) {
const points = [];
const baseZ = row * 0.43 + (row % 2) * 0.07;
for (let step = 0; step <= 28; step++) {
const t = -1.48 + (step / 28) * 2.96;
const z =
baseZ +
Math.sin(t * 2.15 + phase + row * 0.7) * 0.035 +
Math.sin(t * 5.1 + row) * 0.012;
points.push(new THREE.Vector3(boardX + t, 0.225, z));
}
const geometry = new THREE.BufferGeometry().setFromPoints(points);
scene.add(new THREE.Line(geometry, material));
}
}
const boards = [
{ x: -4.15, color: 0xc99b62, side: 0x8f5d36 },
{ x: 0.0, color: 0xd6ad75, side: 0x95623a },
{ x: 4.15, color: 0xc7955e, side: 0x875431 }
];
for (let i = 0; i < boards.length; i++) {
const board = boards[i];
const geometry = new THREE.ExtrudeGeometry(
roundedRectangle(3.55, 3.75, 0.29),
{
depth: 0.14,
steps: 1,
curveSegments: 3,
bevelEnabled: true,
bevelSegments: 1,
bevelSize: 0.035,
bevelThickness: 0.035
}
);
const topMaterial = new THREE.MeshStandardMaterial({
color: board.color,
roughness: 0.86,
flatShading: true
});
const sideMaterial = new THREE.MeshStandardMaterial({
color: board.side,
roughness: 0.94,
flatShading: true
});
const mesh = new THREE.Mesh(geometry, [topMaterial, sideMaterial]);
mesh.rotation.x = -Math.PI / 2;
mesh.position.set(board.x, 0.04, 0);
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
addWoodGrain(board.x, i * 1.7);
}
// Creates a triangulated polygon with two radial bands and flat color facets.
function makeFacetedDisk(points, center, palette, z) {
const positions = [];
const colors = [];
const normals = [];
const centerPoint = new THREE.Vector2(center[0], center[1]);
const innerPoints = points.map((point) => {
const p = new THREE.Vector2(point[0], point[1]);
return p.clone().lerp(centerPoint, 0.48);
});
function addTriangle(a, b, c, color) {
positions.push(
a.x, a.y, z,
b.x, b.y, z,
c.x, c.y, z
);
for (let n = 0; n < 3; n++) {
colors.push(color.r, color.g, color.b);
normals.push(0, 0, 1);
}
}
for (let i = 0; i < points.length; i++) {
const next = (i + 1) % points.length;
const outerA = new THREE.Vector2(points[i][0], points[i][1]);
const outerB = new THREE.Vector2(points[next][0], points[next][1]);
const innerA = innerPoints[i];
const innerB = innerPoints[next];
const centerColor = new THREE.Color(
palette[(i + 1) % palette.length]
);
const innerColor = new THREE.Color(palette[i % palette.length]);
const outerColor = new THREE.Color(
palette[(i + 2) % palette.length]
);
addTriangle(centerPoint, innerA, innerB, centerColor);
addTriangle(innerA, outerA, outerB, outerColor);
addTriangle(innerA, outerB, innerB, innerColor);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(colors, 3)
);
geometry.setAttribute(
"normal",
new THREE.Float32BufferAttribute(normals, 3)
);
geometry.computeBoundingSphere();
const material = new THREE.MeshStandardMaterial({
color: 0xffffff,
vertexColors: true,
roughness: 0.8,
metalness: 0,
flatShading: true,
side: THREE.DoubleSide
});
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
function addPitGroove(parent, points, radius, color) {
const curve = new THREE.CatmullRomCurve3(
points.map((point) => new THREE.Vector3(...point))
);
const geometry = new THREE.TubeGeometry(
curve,
16,
radius,
5,
false
);
const material = new THREE.MeshStandardMaterial({
color,
roughness: 0.95,
flatShading: true
});
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
parent.add(mesh);
}
function createFruitSection({
position,
angle,
outerPoints,
innerPoints,
center,
palette,
skinColor,
skinSideColor,
fleshSideColor,
cavity,
cavityScale,
cavityPosition,
seed,
seedScale = seed.scale,
seedPosition = seed.position,
seedColor = seed.color,
seedDetail = seed
}) {
const root = new THREE.Group();
root.position.set(position[0], 0.23, position[1]);
root.rotation.x = -Math.PI / 2;
scene.add(root);
const tiltedFruit = new THREE.Group();
tiltedFruit.rotation.z = angle;
root.add(tiltedFruit);
const skinTop = new THREE.MeshStandardMaterial({
color: skinColor,
roughness: 0.78,
flatShading: true
});
const skinSide = new THREE.MeshStandardMaterial({
color: skinSideColor,
roughness: 0.9,
flatShading: true
});
const outer = makeExtrudedMesh(
outerPoints,
0.16,
skinTop,
skinSide,
0.025
);
tiltedFruit.add(outer);
const fleshTop = new THREE.MeshStandardMaterial({
color: palette[0],
roughness: 0.78,
flatShading: true
});
const fleshSide = new THREE.MeshStandardMaterial({
color: fleshSideColor,
roughness: 0.88,
flatShading: true
});
const fleshBody = makeExtrudedMesh(
innerPoints,
0.075,
fleshTop,
fleshSide,
0.012
);
fleshBody.position.z = 0.15;
tiltedFruit.add(fleshBody);
const facets = makeFacetedDisk(
innerPoints,
center,
palette,
0.24
);
tiltedFruit.add(facets);
const cavityMaterial = new THREE.MeshStandardMaterial({
color: cavity,
roughness: 0.96,
flatShading: true
});
const cavityMesh = new THREE.Mesh(
new THREE.CircleGeometry(1, 24),
cavityMaterial
);
cavityMesh.scale.set(cavityScale[0], cavityScale[1], 1);
cavityMesh.position.set(
cavityPosition[0],
cavityPosition[1],
0.247
);
cavityMesh.receiveShadow = true;
tiltedFruit.add(cavityMesh);
const seedMaterial = new THREE.MeshStandardMaterial({
color: seedColor,
roughness: 0.76,
metalness: 0,
flatShading: true
});
const seedMesh = new THREE.Mesh(
new THREE.IcosahedronGeometry(1, seed.detail),
seedMaterial
);
seedMesh.scale.set(
seedScale[0],
seedScale[1],
seedScale[2]
);
seedMesh.position.set(
seedPosition[0],
seedPosition[1],
seedPosition[2]
);
seedMesh.rotation.z = seed.rotation || 0;
seedMesh.castShadow = true;
seedMesh.receiveShadow = true;
tiltedFruit.add(seedMesh);
if (seedDetail.points) {
addPitGroove(
tiltedFruit,
seedDetail.points,
seedDetail.radius,
seedDetail.color
);
}
return root;
}
const avocadoOuter = [
[0.00, 1.55],
[-0.30, 1.30],
[-0.48, 0.92],
[-0.68, 0.46],
[-0.78, -0.05],
[-0.72, -0.62],
[-0.48, -1.08],
[-0.15, -1.34],
[0.18, -1.35],
[0.50, -1.08],
[0.72, -0.62],
[0.78, -0.06],
[0.66, 0.48],
[0.47, 0.95],
[0.28, 1.31]
];
const avocadoInner = [
[0.00, 1.35],
[-0.23, 1.15],
[-0.39, 0.81],
[-0.55, 0.41],
[-0.62, -0.03],
[-0.57, -0.50],
[-0.38, -0.87],
[-0.12, -1.09],
[0.13, -1.10],
[0.39, -0.87],
[0.57, -0.50],
[0.62, -0.02],
[0.53, 0.42],
[0.38, 0.82],
[0.22, 1.15]
];
createFruitSection({
position: [-4.15, 0],
angle: 0.025,
outerPoints: avocadoOuter,
innerPoints: avocadoInner,
center: [0, -0.04],
palette: [
0xaac84e,
0x9bbc3c,
0xb7d45b,
0x8eaf35,
0xc0d86a,
0x9fbe45
],
skinColor: 0x315d2b,
skinSideColor: 0x183b20,
fleshSideColor: 0x78982e,
cavity: 0x526b24,
cavityScale: [0.61, 0.52],
cavityPosition: [0, -0.03],
seed: {
detail: 2,
scale: [0.53, 0.47, 0.37],
position: [0, -0.03, 0.39],
color: 0x774321,
rotation: -0.04
}
});
const peachOuter = [
[1.00, 0.12],
[0.92, 0.52],
[0.68, 0.88],
[0.35, 1.05],
[0.00, 1.08],
[-0.35, 1.04],
[-0.68, 0.88],
[-0.93, 0.52],
[-1.00, 0.08],
[-0.94, -0.38],
[-0.72, -0.78],
[-0.38, -1.04],
[0.00, -1.10],
[0.38, -1.02],
[0.72, -0.77],
[0.94, -0.38]
];
const peachInner = peachOuter.map(([x, y]) => [x * 0.79, y * 0.80]);
createFruitSection({
position: [0, 0],
angle: -0.018,
outerPoints: peachOuter,
innerPoints: peachInner,
center: [0, 0],
palette: [
0xf5b45e,
0xf9c779,
0xee9f50,
0xf3ad58,
0xffd486,
0xe99148
],
skinColor: 0xd75b4f,
skinSideColor: 0x9c3934,
fleshSideColor: 0xdb8d46,
cavity: 0xb14b33,
cavityScale: [0.35, 0.45],
cavityPosition: [0, -0.02],
seed: {
detail: 1,
scale: [0.25, 0.37, 0.22],
position: [0, -0.02, 0.37],
color: 0x842f25,
rotation: 0.04,
points: [
[0, 0.25, 0.51],
[0.02, 0.12, 0.57],
[0, 0.00, 0.595],
[-0.02, -0.12, 0.57],
[0, -0.25, 0.51]
],
radius: 0.014,
color: 0x4c211c
}
});
const mangoOuter = [
[0.05, 1.62],
[-0.32, 1.50],
[-0.58, 1.12],
[-0.72, 0.62],
[-0.77, 0.08],
[-0.84, -0.45],
[-0.73, -0.95],
[-0.47, -1.34],
[-0.10, -1.55],
[0.29, -1.49],
[0.58, -1.26],
[0.65, -0.93],
[0.53, -0.60],
[0.30, -0.33],
[0.42, -0.05],
[0.65, 0.27],
[0.72, 0.67],
[0.53, 1.14],
[0.30, 1.46]
];
const mangoInner = [
[0.03, 1.42],
[-0.25, 1.32],
[-0.46, 1.00],
[-0.58, 0.55],
[-0.62, 0.08],
[-0.68, -0.38],
[-0.59, -0.79],
[-0.38, -1.11],
[-0.08, -1.28],
[0.24, -1.24],
[0.47, -1.05],
[0.51, -0.78],
[0.41, -0.51],
[0.22, -0.30],
[0.34, -0.03],
[0.52, 0.25],
[0.56, 0.58],
[0.41, 0.98],
[0.25, 1.26]
];
createFruitSection({
position: [4.15, 0],
angle: -0.075,
outerPoints: mangoOuter,
innerPoints: mangoInner,
center: [0, 0.10],
palette: [
0xf5c84e,
0xffd867,
0xedb93c,
0xffe17b,
0xf2bd40,
0xffce58
],
skinColor: 0xb7b83e,
skinSideColor: 0x83882b,
fleshSideColor: 0xd9a72e,
cavity: 0xc18b2f,
cavityScale: [0.31, 0.55],
cavityPosition: [0, -0.49],
seed: {
detail: 2,
scale: [0.25, 0.49, 0.16],
position: [0, -0.49, 0.35],
color: 0xf2e6ba,
rotation: -0.08,
points: [
[0, -0.30, 0.47],
[0.015, -0.12, 0.515],
[0, 0.05, 0.525],
[-0.015, 0.21, 0.49],
[0, 0.34, 0.455]
],
radius: 0.012,
color: 0xb99a61
}
});
const labels = [
{
element: document.getElementById("avocado-label"),
anchor: new THREE.Vector3(-4.15, 0.34, 1.70)
},
{
element: document.getElementById("peach-label"),
anchor: new THREE.Vector3(0, 0.34, 1.70)
},
{
element: document.getElementById("mango-label"),
anchor: new THREE.Vector3(4.15, 0.34, 1.70)
}
];
function updateCamera() {
const radius = fittedRadius * cameraZoom;
const sinPhi = Math.sin(cameraPhi);
camera.position.set(
cameraTarget.x + radius * sinPhi * Math.sin(cameraTheta),
cameraTarget.y + radius * Math.cos(cameraPhi),
cameraTarget.z + radius * sinPhi * Math.cos(cameraTheta)
);
camera.lookAt(cameraTarget);
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
camera.aspect = width / height;
camera.updateProjectionMatrix();
const halfFov = THREE.MathUtils.degToRad(camera.fov / 2);
fittedRadius = Math.max(
14.8,
7.15 / (Math.tan(halfFov) * camera.aspect)
);
updateCamera();
}
window.addEventListener("resize", resize);
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;
cameraTheta -= deltaX * 0.005;
cameraPhi = THREE.MathUtils.clamp(
cameraPhi + deltaY * 0.004,
0.36,
1.30
);
previousX = event.clientX;
previousY = event.clientY;
updateCamera();
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined) {
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();
cameraZoom = THREE.MathUtils.clamp(
cameraZoom * Math.exp(event.deltaY * 0.001),
0.66,
1.85
);
updateCamera();
},
{ passive: false }
);
function updateLabels() {
for (const label of labels) {
const projected = label.anchor.clone().project(camera);
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
label.element.style.left = `${x}px`;
label.element.style.top = `${y}px`;
label.element.style.opacity = projected.z < 1 ? "1" : "0";
}
}
function animate() {
updateLabels();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
resize();
animate();
</script>
</body>
</html>
```