Prompt specification
Build or customize the Three.js 3D scene "Same surface different enclosed volume models" 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: Same surface different enclosed volume models
Category: Algorithms & Systems · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/same-surface-different-enclosed-volume-models-x1758
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows volume and its relationship to scale. Compare a few boxes with equal chosen surface area but different dimensions; compute enclosed volumes explicitly and avoid implying the displayed examples prove a universal optimum. Stylized solid forms.
Working Three.js Starter (same-surface-different-enclosed-volume-models-x1758):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#eee9df" />
<title>Same Surface, Different Volume</title>
<style>
:root {
--paper: #eee9df;
--ink: #17221f;
--muted: #66706b;
--line: rgba(23, 34, 31, 0.15);
--glass: rgba(255, 255, 255, 0.74);
--coral: #e56550;
--teal: #288b80;
--gold: #dca63a;
}
* {
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;
}
button,
input {
font: inherit;
}
#stage {
position: fixed;
inset: 0;
}
#stage canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#stage canvas:active {
cursor: grabbing;
}
.ui {
position: fixed;
inset: 0;
pointer-events: none;
}
.hero {
position: absolute;
top: 30px;
left: 32px;
width: min(520px, calc(100vw - 64px));
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 13px;
color: #43504b;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--coral);
box-shadow: 0 0 0 5px rgba(229, 101, 80, 0.12);
content: "";
}
h1 {
margin: 0;
font-size: clamp(42px, 5.2vw, 74px);
font-weight: 780;
letter-spacing: -0.055em;
line-height: 0.94;
}
h1 em {
color: var(--coral);
font-family: Georgia, "Times New Roman", serif;
font-weight: 500;
}
.hero p {
max-width: 460px;
margin: 17px 0 0;
color: #4f5b56;
font-size: 14px;
line-height: 1.55;
}
.control {
position: absolute;
top: 28px;
right: 28px;
width: 310px;
padding: 18px;
border: 1px solid rgba(255, 255, 255, 0.74);
border-radius: 18px;
background: var(--glass);
box-shadow: 0 18px 50px rgba(41, 47, 42, 0.11);
backdrop-filter: blur(18px);
pointer-events: auto;
}
.control-head {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 12px;
margin-bottom: 12px;
}
.control-head label {
font-size: 12px;
font-weight: 750;
}
#areaOutput {
color: var(--coral);
font-size: 15px;
font-weight: 850;
white-space: nowrap;
}
input[type="range"] {
width: 100%;
margin: 0;
accent-color: var(--coral);
cursor: pointer;
}
.range-ends {
display: flex;
justify-content: space-between;
margin-top: 4px;
color: #858d88;
font-size: 10px;
font-weight: 700;
}
.formula-grid {
display: grid;
grid-template-columns: 1fr auto;
gap: 7px 12px;
margin-top: 16px;
padding-top: 14px;
border-top: 1px solid var(--line);
font-size: 12px;
}
.formula-grid span {
color: var(--muted);
}
.formula-grid b {
font-variant-numeric: tabular-nums;
}
.scale-law {
margin-top: 14px;
padding: 10px 11px;
border-radius: 10px;
background: rgba(23, 34, 31, 0.06);
color: #43504b;
font-size: 11px;
line-height: 1.45;
}
.control-footer {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-top: 13px;
}
.hint {
color: #7a827e;
font-size: 10px;
}
button {
padding: 7px 10px;
border: 1px solid var(--line);
border-radius: 8px;
background: rgba(255, 255, 255, 0.68);
color: var(--ink);
font-size: 10px;
font-weight: 800;
cursor: pointer;
}
button:hover {
background: #fff;
}
.callout {
position: absolute;
left: 32px;
bottom: 250px;
width: 365px;
padding: 16px 17px;
border-left: 4px solid var(--coral);
border-radius: 0 13px 13px 0;
background: rgba(248, 245, 238, 0.79);
box-shadow: 0 12px 35px rgba(41, 47, 42, 0.08);
backdrop-filter: blur(12px);
}
.callout h2 {
margin: 0 0 7px;
font-size: 12px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.callout p {
margin: 0;
color: #4f5b56;
font-size: 12px;
line-height: 1.5;
}
.callout .scope {
margin-top: 9px;
padding-top: 9px;
border-top: 1px solid var(--line);
color: #7a827e;
font-size: 10px;
line-height: 1.45;
}
.cards {
position: absolute;
right: 28px;
bottom: 24px;
left: 28px;
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 13px;
pointer-events: auto;
}
.box-card {
position: relative;
min-width: 0;
overflow: hidden;
padding: 15px 16px 13px;
border: 1px solid rgba(255, 255, 255, 0.8);
border-radius: 16px;
background: rgba(255, 255, 255, 0.79);
box-shadow: 0 14px 40px rgba(41, 47, 42, 0.1);
backdrop-filter: blur(16px);
}
.box-card::before {
position: absolute;
top: 0;
right: 0;
left: 0;
height: 4px;
background: var(--accent);
content: "";
}
.card-top {
display: flex;
align-items: center;
gap: 8px;
}
.card-index {
color: var(--accent);
font-size: 10px;
font-weight: 900;
letter-spacing: 0.12em;
}
.card-top h3 {
margin: 0;
font-size: 15px;
letter-spacing: -0.02em;
}
.matched {
margin-left: auto;
padding: 4px 6px;
border-radius: 5px;
background: rgba(23, 34, 31, 0.06);
color: #69716d;
font-size: 8px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.dimensions {
margin: 9px 0 10px;
font-size: clamp(17px, 1.6vw, 24px);
font-weight: 780;
letter-spacing: -0.035em;
font-variant-numeric: tabular-nums;
white-space: nowrap;
}
.dimensions span {
padding: 0 4px;
color: #9a9f9c;
font-weight: 500;
}
.calc {
display: grid;
grid-template-columns: 22px 1fr;
gap: 5px;
margin-top: 5px;
font-size: 10px;
line-height: 1.35;
font-variant-numeric: tabular-nums;
}
.calc span {
color: var(--accent);
font-weight: 900;
}
.calc b {
color: #59635e;
font-weight: 650;
}
.volume-row {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 10px;
margin-top: 12px;
}
.volume-value {
font-size: 21px;
font-weight: 850;
letter-spacing: -0.035em;
font-variant-numeric: tabular-nums;
}
.volume-value small {
color: #737d78;
font-size: 10px;
font-weight: 750;
letter-spacing: 0;
}
.relative {
color: #7a827e;
font-size: 9px;
text-align: right;
}
.bar {
height: 5px;
margin-top: 7px;
overflow: hidden;
border-radius: 99px;
background: rgba(23, 34, 31, 0.08);
}
.bar i {
display: block;
height: 100%;
border-radius: inherit;
background: var(--accent);
transition: width 250ms ease;
}
.world-label {
position: absolute;
z-index: 2;
display: flex;
align-items: center;
gap: 7px;
padding: 6px 8px;
border: 1px solid rgba(255, 255, 255, 0.8);
border-radius: 8px;
background: rgba(255, 255, 255, 0.78);
box-shadow: 0 6px 18px rgba(30, 38, 34, 0.1);
color: #39443f;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.05em;
pointer-events: none;
transform: translate(-50%, -100%);
white-space: nowrap;
backdrop-filter: blur(8px);
}
.world-label::after {
position: absolute;
bottom: -5px;
left: 50%;
width: 8px;
height: 8px;
background: rgba(255, 255, 255, 0.78);
transform: translateX(-50%) rotate(45deg);
content: "";
}
.world-label .dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--accent);
}
.world-label .label-volume {
color: #737c77;
font-weight: 650;
letter-spacing: 0;
}
.fallback {
display: grid;
width: 100%;
height: 100%;
place-items: center;
padding: 30px;
color: var(--ink);
text-align: center;
}
@media (max-width: 980px) {
.hero {
left: 22px;
width: 390px;
}
h1 {
font-size: 48px;
}
.control {
right: 18px;
width: 270px;
}
.callout {
left: 22px;
width: 315px;
}
.cards {
right: 18px;
left: 18px;
}
.box-card {
padding-right: 12px;
padding-left: 12px;
}
.dimensions {
font-size: 17px;
}
}
@media (max-width: 700px) {
.hero {
top: 15px;
left: 15px;
width: calc(100vw - 30px);
}
h1 {
font-size: 38px;
}
.hero p {
max-width: 285px;
margin-top: 11px;
font-size: 12px;
}
.control {
top: 173px;
right: 15px;
left: 15px;
width: auto;
padding: 13px 15px;
}
.formula-grid {
margin-top: 10px;
padding-top: 10px;
}
.scale-law {
margin-top: 10px;
padding: 8px 10px;
}
.control-footer {
margin-top: 9px;
}
.callout {
display: none;
}
.cards {
right: 15px;
bottom: 15px;
left: 15px;
display: flex;
gap: 10px;
overflow-x: auto;
padding: 2px 1px 5px;
scroll-snap-type: x mandatory;
}
.box-card {
flex: 0 0 286px;
scroll-snap-align: start;
}
.world-label {
font-size: 8px;
}
}
@media (max-height: 650px) {
.hero p,
.callout {
display: none;
}
.cards {
bottom: 12px;
}
}
</style>
</head>
<body>
<div id="stage" aria-label="Interactive three-dimensional comparison of rectangular boxes"></div>
<main class="ui">
<header class="hero">
<div class="eyebrow">Geometry / Scale Lab</div>
<h1>Same surface.<br /><em>Different volume.</em></h1>
<p>
Three rectangular solids share one surface-area budget.
Their dimensions—and the space they enclose—do not.
</p>
</header>
<aside class="control" aria-label="Scale controls">
<div class="control-head">
<label for="areaSlider">Shared surface area</label>
<output id="areaOutput" for="areaSlider">384 u²</output>
</div>
<input
id="areaSlider"
type="range"
min="192"
max="768"
step="96"
value="384"
aria-label="Shared surface area"
/>
<div class="range-ends">
<span>192 u²</span>
<span>768 u²</span>
</div>
<div class="formula-grid">
<span>Box area</span>
<b>A = 2(xy + xz + yz)</b>
<span>Linear scale</span>
<b id="linearScale">×1.00</b>
<span>Volume scale</span>
<b id="volumeScale">×1.00</b>
</div>
<div class="scale-law" id="scaleLaw">
Relative to A₀ = 384 u²: edges ×1.00, volume ×1.00.
</div>
<div class="control-footer">
<span class="hint">Drag to orbit · scroll to zoom</span>
<button id="resetView" type="button">Reset view</button>
</div>
</aside>
<aside class="callout">
<h2>Equal area does not force equal volume</h2>
<p>
Surface area constrains the pair products xy, xz, and yz.
Enclosed volume is the separate product xyz.
</p>
<p class="scope">
Scope: these are three rectangular examples, not an exhaustive search.
The display illustrates a relationship; it does not establish a universal optimum.
</p>
</aside>
<section class="cards" id="cards" aria-live="polite" aria-label="Box calculations"></section>
</main>
<noscript>
<div class="fallback">JavaScript is required to render the interactive comparison.</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 stage = document.querySelector("#stage");
const cards = document.querySelector("#cards");
const areaSlider = document.querySelector("#areaSlider");
const areaOutput = document.querySelector("#areaOutput");
const linearScaleOutput = document.querySelector("#linearScale");
const volumeScaleOutput = document.querySelector("#volumeScale");
const scaleLaw = document.querySelector("#scaleLaw");
const BASE_AREA = 384;
const WORLD_SCALE = 0.24;
const PLINTH_TOP = 0.045;
const boxes = [
{
name: "Slender",
dimensions: [2, 12, 12],
volume: 288,
color: "#e56550",
x: -5.8
},
{
name: "Intermediate",
dimensions: [6, 6, 13],
volume: 468,
color: "#288b80",
x: 0
},
{
name: "Cube",
dimensions: [8, 8, 8],
volume: 512,
color: "#dca63a",
x: 5.8
}
];
const numberFormat = new Intl.NumberFormat(undefined, {
minimumFractionDigits: 2,
maximumFractionDigits: 2
});
const wholeFormat = new Intl.NumberFormat(undefined, {
maximumFractionDigits: 0
});
const fmt = (value) => numberFormat.format(value);
const fmtWhole = (value) => wholeFormat.format(value);
// ---------- Three.js scene ----------
let renderer;
try {
renderer = new THREE.WebGLRenderer({ antialias: true });
} catch (error) {
stage.innerHTML = `
<div class="fallback">
WebGL could not start. Please try a browser with hardware acceleration enabled.
</div>
`;
throw error;
}
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.domElement.setAttribute(
"aria-label",
"Three boxes with equal surface area and different enclosed volumes"
);
stage.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color("#eee9df");
scene.fog = new THREE.Fog("#eee9df", 28, 52);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const hemisphere = new THREE.HemisphereLight("#fffaf0", "#6b756d", 2.1);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight("#fff8e9", 3.2);
keyLight.position.set(-7, 13, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -13;
keyLight.shadow.camera.right = 13;
keyLight.shadow.camera.top = 13;
keyLight.shadow.camera.bottom = -13;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 35;
keyLight.shadow.normalBias = 0.025;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight("#9dc8c2", 1.1);
fillLight.position.set(9, 7, -8);
scene.add(fillLight);
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(80, 80),
new THREE.MeshStandardMaterial({
color: "#e8e2d7",
roughness: 1,
metalness: 0
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.12;
ground.receiveShadow = true;
scene.add(ground);
const grid = new THREE.GridHelper(36, 36, "#c8c0b3", "#d9d2c6");
grid.position.y = -0.112;
grid.material.transparent = true;
grid.material.opacity = 0.44;
scene.add(grid);
const plinth = new THREE.Mesh(
new THREE.BoxGeometry(16.8, 0.16, 7.4),
new THREE.MeshStandardMaterial({
color: "#ded7ca",
roughness: 0.88,
metalness: 0.02
})
);
plinth.position.set(0, -0.035, 0);
plinth.receiveShadow = true;
scene.add(plinth);
const unitBoxGeometry = new THREE.BoxGeometry(1, 1, 1);
const worldLabels = [];
boxes.forEach((box, index) => {
const group = new THREE.Group();
const mesh = new THREE.Mesh(
unitBoxGeometry,
new THREE.MeshStandardMaterial({
color: box.color,
roughness: 0.58,
metalness: 0.035
})
);
mesh.castShadow = true;
mesh.receiveShadow = true;
group.add(mesh);
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(unitBoxGeometry),
new THREE.LineBasicMaterial({
color: "#24302c",
transparent: true,
opacity: 0.48
})
);
edges.scale.setScalar(1.003);
group.add(edges);
group.position.x = box.x;
scene.add(group);
box.group = group;
const label = document.createElement("div");
label.className = "world-label";
label.style.setProperty("--accent", box.color);
label.innerHTML = `
<span class="dot"></span>
<span>${String(index + 1).padStart(2, "0")} · ${box.name.toUpperCase()}</span>
<span class="label-volume"></span>
`;
stage.appendChild(label);
worldLabels.push({
element: label,
volumeElement: label.querySelector(".label-volume"),
group
});
});
// ---------- Directly implemented camera controls ----------
const cameraState = {
radius: 19.5,
theta: 0.27,
phi: 1.05,
target: new THREE.Vector3(0, 0.85, 0)
};
function updateCamera() {
const responsiveDistance = Math.max(1, 1.05 / camera.aspect);
const radius = cameraState.radius * responsiveDistance;
camera.position.set(
cameraState.target.x +
radius * Math.sin(cameraState.phi) * Math.sin(cameraState.theta),
cameraState.target.y + radius * Math.cos(cameraState.phi),
cameraState.target.z +
radius * Math.sin(cameraState.phi) * Math.cos(cameraState.theta)
);
camera.lookAt(cameraState.target);
}
function resetView() {
cameraState.radius = 19.5;
cameraState.theta = 0.27;
cameraState.phi = 1.05;
}
let dragging = false;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
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;
cameraState.theta -= deltaX * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi + deltaY * 0.005,
0.48,
1.42
);
previousX = event.clientX;
previousY = event.clientY;
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined && 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();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.012,
13,
29
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetView);
document.querySelector("#resetView").addEventListener("click", resetView);
window.addEventListener("keydown", (event) => {
if (event.target instanceof HTMLInputElement) return;
if (event.key === "ArrowLeft") cameraState.theta += 0.09;
if (event.key === "ArrowRight") cameraState.theta -= 0.09;
if (event.key === "ArrowUp") {
cameraState.phi = THREE.MathUtils.clamp(cameraState.phi - 0.07, 0.48, 1.42);
}
if (event.key === "ArrowDown") {
cameraState.phi = THREE.MathUtils.clamp(cameraState.phi + 0.07, 0.48, 1.42);
}
if (event.key === "+" || event.key === "=") {
cameraState.radius = THREE.MathUtils.clamp(cameraState.radius - 1, 13, 29);
}
if (event.key === "-") {
cameraState.radius = THREE.MathUtils.clamp(cameraState.radius + 1, 13, 29);
}
});
// ---------- Calculations and UI ----------
function updateComparison() {
const area = Number(areaSlider.value);
const linearScale = Math.sqrt(area / BASE_AREA);
const volumeScale = Math.pow(linearScale, 3);
areaOutput.textContent = `${fmtWhole(area)} u²`;
linearScaleOutput.textContent = `×${fmt(linearScale)}`;
volumeScaleOutput.textContent = `×${fmt(volumeScale)}`;
scaleLaw.textContent =
`Relative to A₀ = 384 u²: edges ×${fmt(linearScale)}, ` +
`volume ×${fmt(volumeScale)}. ` +
`Area ×s gives edge length ×√s and volume ×s^(3/2).`;
const currentVolumes = boxes.map((box) => {
return box.volume * volumeScale;
});
const largestShown = Math.max(...currentVolumes);
boxes.forEach((box, index) => {
const [baseX, baseY, baseZ] = box.dimensions;
const x = baseX * linearScale;
const y = baseY * linearScale;
const z = baseZ * linearScale;
const volume = x * y * z;
const xy = x * y;
const xz = x * z;
const yz = y * z;
const calculatedArea = 2 * (xy + xz + yz);
const percentage = (volume / largestShown) * 100;
box.group.scale.set(
x * WORLD_SCALE,
y * WORLD_SCALE,
z * WORLD_SCALE
);
box.group.position.y = PLINTH_TOP + (y * WORLD_SCALE) / 2;
worldLabels[index].volumeElement.textContent = `${fmt(volume)} u³`;
const card = document.createElement("article");
card.className = "box-card";
card.style.setProperty("--accent", box.color);
card.innerHTML = `
<div class="card-top">
<span class="card-index">${String(index + 1).padStart(2, "0")}</span>
<h3>${box.name}</h3>
<span class="matched">Area matched</span>
</div>
<div class="dimensions">
${fmt(x)} <span>×</span> ${fmt(y)} <span>×</span> ${fmt(z)}
</div>
<div class="calc">
<span>A</span>
<b>2(${fmt(xy)} + ${fmt(xz)} + ${fmt(yz)}) = ${fmt(calculatedArea)} u²</b>
</div>
<div class="calc">
<span>V</span>
<b>${fmt(x)} × ${fmt(y)} × ${fmt(z)} = ${fmt(volume)} u³</b>
</div>
<div class="volume-row">
<div class="volume-value">${fmt(volume)} <small>u³</small></div>
<div class="relative">${fmt(percentage)}% of<br />largest shown</div>
</div>
<div class="bar">
<i style="width: ${percentage}%"></i>
</div>
`;
cards.appendChild(card);
});
}
areaSlider.addEventListener("input", () => {
cards.replaceChildren();
updateComparison();
});
cards.replaceChildren();
updateComparison();
// ---------- Projection of HTML labels onto the 3D scene ----------
const projected = new THREE.Vector3();
function updateWorldLabels() {
worldLabels.forEach(({ element, group }) => {
projected.set(0, group.scale.y / 2 + 0.38, 0);
projected.applyMatrix4(group.matrixWorld);
projected.project(camera);
const visible = projected.z > -1 && projected.z < 1;
element.style.display = visible ? "flex" : "none";
if (visible) {
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
}
});
}
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
}
window.addEventListener("resize", resize);
function animate() {
requestAnimationFrame(animate);
updateCamera();
renderer.render(scene, camera);
updateWorldLabels();
}
animate();
</script>
</body>
</html>
```