Prompt specification
Build or customize the Three.js 3D scene "Contracting ring around a soft tube" 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: Contracting ring around a soft tube
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/contracting-ring-around-a-soft-tube-x1009
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts a technical cutaway of a soft tube with one circular constriction. Remove a narrow longitudinal wall strip so the lumen remains visible, and place a symbolic bolus just ahead of the contraction. Distinguish the wall, muscular ring, and contents with restrained colors. Keep the narrowed passage connected to the wider tube on both sides, without a solid plug or broken mesh. Focus on this local geometry rather than constructing an entire digestive system.
Working Three.js Starter (contracting-ring-around-a-soft-tube-x1009):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Technical Cutaway — Soft Tube Constriction</title>
<style>
:root {
--ink: #263438;
--muted: #637277;
--wall: #78939a;
--ring: #b67c70;
--contents: #d5a94f;
--panel: rgba(247, 249, 246, 0.88);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e9eeeb;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active { cursor: grabbing; }
.panel {
position: fixed;
z-index: 5;
top: 24px;
left: 24px;
width: min(360px, calc(100vw - 48px));
padding: 17px 19px 16px;
border: 1px solid rgba(50, 72, 78, 0.16);
border-radius: 12px;
background: var(--panel);
backdrop-filter: blur(10px);
box-shadow: 0 8px 30px rgba(48, 63, 67, 0.08);
pointer-events: none;
}
.kicker {
margin-bottom: 7px;
color: #76868a;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: 20px;
line-height: 1.25;
font-weight: 680;
letter-spacing: -0.025em;
}
.panel p {
margin: 9px 0 14px;
color: var(--muted);
font-size: 12px;
line-height: 1.45;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 8px 14px;
padding-top: 12px;
border-top: 1px solid rgba(50, 72, 78, 0.12);
}
.legend-item {
display: inline-flex;
align-items: center;
gap: 7px;
color: #4f6065;
font-size: 11px;
font-weight: 600;
}
.swatch {
width: 9px;
height: 9px;
border-radius: 50%;
box-shadow: inset 0 0 0 1px rgba(0,0,0,.09);
}
#callout-lines {
position: fixed;
inset: 0;
z-index: 3;
width: 100%;
height: 100%;
overflow: visible;
pointer-events: none;
}
#callout-lines line {
stroke-width: 1.2;
stroke-dasharray: 3 3;
opacity: .72;
}
#callout-lines circle {
stroke: rgba(255,255,255,.9);
stroke-width: 1.5;
}
.annotation {
position: fixed;
z-index: 4;
padding: 6px 9px;
border: 1px solid rgba(45, 65, 70, .16);
border-left-width: 3px;
border-radius: 5px;
background: rgba(248, 250, 247, .91);
box-shadow: 0 4px 16px rgba(47, 63, 67, .08);
color: #405257;
font-size: 10px;
font-weight: 720;
letter-spacing: .055em;
line-height: 1;
text-transform: uppercase;
white-space: nowrap;
pointer-events: none;
transform: translate(-50%, -50%);
}
.help {
position: fixed;
z-index: 5;
right: 22px;
bottom: 19px;
padding: 8px 11px;
border: 1px solid rgba(50, 72, 78, .12);
border-radius: 7px;
background: rgba(247, 249, 246, .78);
color: #6a7a7e;
font-size: 10px;
letter-spacing: .035em;
pointer-events: none;
}
@media (max-width: 760px) {
.panel {
top: 14px;
left: 14px;
width: min(330px, calc(100vw - 28px));
padding: 14px 15px;
}
h1 { font-size: 17px; }
.panel p { display: none; }
.legend { margin-top: 10px; }
.annotation, #callout-lines { display: none !important; }
.help { right: 14px; bottom: 14px; }
}
</style>
</head>
<body>
<div id="scene" aria-label="Interactive technical cutaway of a soft tube with one circular constriction"></div>
<header class="panel">
<div class="kicker">Technical cutaway · local geometry</div>
<h1>Soft tube with one circular constriction</h1>
<p>
A narrow longitudinal wall strip is removed to expose the continuous lumen.
The reinforced neck remains joined to the wider tube on both sides.
</p>
<div class="legend">
<span class="legend-item">
<span class="swatch" style="background:var(--wall)"></span>
Wall
</span>
<span class="legend-item">
<span class="swatch" style="background:var(--ring)"></span>
Muscular ring
</span>
<span class="legend-item">
<span class="swatch" style="background:var(--contents)"></span>
Contents / bolus
</span>
</div>
</header>
<svg id="callout-lines" aria-hidden="true">
<line id="line-wall" stroke="#78939a"></line>
<circle id="dot-wall" r="4" fill="#78939a"></circle>
<line id="line-ring" stroke="#b67c70"></line>
<circle id="dot-ring" r="4" fill="#b67c70"></circle>
<line id="line-bolus" stroke="#d5a94f"></line>
<circle id="dot-bolus" r="4" fill="#d5a94f"></circle>
</svg>
<div id="label-wall" class="annotation" style="border-left-color:#78939a">Cutaway wall</div>
<div id="label-ring" class="annotation" style="border-left-color:#b67c70">Muscular ring</div>
<div id="label-bolus" class="annotation" style="border-left-color:#d5a94f">Symbolic bolus</div>
<div class="help">Drag to orbit · scroll to zoom · double-click to reset</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.getElementById("scene");
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
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.08;
container.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe9eeeb);
scene.fog = new THREE.Fog(0xe9eeeb, 11, 22);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
50
);
const controls = {
target: new THREE.Vector3(0, 0, 0),
radius: 8.5,
azimuth: 0.53,
polar: 1.13,
reset() {
this.radius = 8.5;
this.azimuth = 0.53;
this.polar = 1.13;
}
};
function updateCamera() {
const sinPolar = Math.sin(controls.polar);
camera.position.set(
controls.target.x +
controls.radius * sinPolar * Math.sin(controls.azimuth),
controls.target.y +
controls.radius * Math.cos(controls.polar),
controls.target.z +
controls.radius * sinPolar * Math.cos(controls.azimuth)
);
camera.lookAt(controls.target);
camera.updateMatrixWorld();
}
updateCamera();
// Lighting
scene.add(new THREE.HemisphereLight(0xffffff, 0x84918e, 2.15));
const key = new THREE.DirectionalLight(0xfffbf2, 3.0);
key.position.set(3.5, 6.5, 5.5);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -7;
key.shadow.camera.right = 7;
key.shadow.camera.top = 6;
key.shadow.camera.bottom = -6;
key.shadow.camera.near = 0.5;
key.shadow.camera.far = 20;
key.shadow.bias = -0.0004;
scene.add(key);
const fill = new THREE.DirectionalLight(0xb8d2da, 1.35);
fill.position.set(-5, 2.5, -4);
scene.add(fill);
const warmLight = new THREE.PointLight(0xffd8a7, 8, 12, 2);
warmLight.position.set(1.5, 3.2, 3.2);
scene.add(warmLight);
// Ground plane and a restrained flow axis
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(30, 22),
new THREE.MeshStandardMaterial({
color: 0xe9eeeb,
roughness: 1,
metalness: 0
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -1.72;
ground.receiveShadow = true;
scene.add(ground);
const axisMaterial = new THREE.LineBasicMaterial({
color: 0x879894,
transparent: true,
opacity: 0.45
});
const axisGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-4.15, -1.585, 0),
new THREE.Vector3(4.15, -1.585, 0)
]);
scene.add(new THREE.Line(axisGeometry, axisMaterial));
const tickPositions = [];
for (const x of [-3, -1.5, 0, 1.5, 3]) {
tickPositions.push(
x, -1.62, 0,
x, -1.51, 0
);
}
const tickGeometry = new THREE.BufferGeometry();
tickGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(tickPositions, 3)
);
scene.add(new THREE.LineSegments(tickGeometry, axisMaterial));
const flowArrow = new THREE.ArrowHelper(
new THREE.Vector3(1, 0, 0),
new THREE.Vector3(-3.95, -1.45, 0),
7.7,
0x8b9b97,
0.25,
0.12
);
flowArrow.line.material.transparent = true;
flowArrow.line.material.opacity = 0.35;
flowArrow.cone.material.transparent = true;
flowArrow.cone.material.opacity = 0.35;
scene.add(flowArrow);
/*
Tube geometry:
- x is the longitudinal axis.
- radius is continuous through the neck.
- a narrow angular sector is omitted over the full length.
- the remaining shell has thickness, exposing the lumen.
*/
const X_MIN = -3.4;
const X_MAX = 3.4;
const BASE_RADIUS = 1.34;
const NECK_DEPTH = 0.62;
const NECK_WIDTH = 0.78;
const WALL_THICKNESS = 0.20;
const CUT_CENTER = 1.10;
const CUT_HALF_WIDTH = 0.28;
const THETA_START = CUT_CENTER + CUT_HALF_WIDTH;
const THETA_END = CUT_CENTER + Math.PI * 2 - CUT_HALF_WIDTH;
function contractionProfile(x) {
return Math.exp(-Math.pow(x / NECK_WIDTH, 2));
}
function outerRadius(x) {
return BASE_RADIUS - NECK_DEPTH * contractionProfile(x);
}
function innerRadius(x) {
return outerRadius(x) - WALL_THICKNESS;
}
function makeSurface(
radiusFunction,
xMin,
xMax,
thetaStart,
thetaEnd,
xSegments,
thetaSegments,
inward = false
) {
const positions = [];
const indices = [];
for (let i = 0; i <= xSegments; i++) {
const x = THREE.MathUtils.lerp(xMin, xMax, i / xSegments);
const radius = radiusFunction(x);
for (let j = 0; j <= thetaSegments; j++) {
const theta = THREE.MathUtils.lerp(
thetaStart,
thetaEnd,
j / thetaSegments
);
positions.push(
x,
radius * Math.cos(theta),
radius * Math.sin(theta)
);
}
}
const stride = thetaSegments + 1;
for (let i = 0; i < xSegments; i++) {
for (let j = 0; j < thetaSegments; j++) {
const a = i * stride + j;
const b = (i + 1) * stride + j;
if (inward) {
indices.push(a, b, a + 1, a + 1, b, b + 1);
} else {
indices.push(a, a + 1, b, a + 1, b + 1, b);
}
}
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
geometry.computeBoundingSphere();
return geometry;
}
function makeQuadMesh(quads, material) {
const positions = [];
const indices = [];
for (const quad of quads) {
const base = positions.length / 3;
for (const point of quad) {
positions.push(point.x, point.y, point.z);
}
indices.push(
base, base + 1, base + 2,
base, base + 2, base + 3
);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
function buildShell({
xMin,
xMax,
outerFunction,
innerFunction,
outerMaterial,
innerMaterial,
edgeMaterial,
xSegments = 170,
thetaSegments = 96
}) {
const group = new THREE.Group();
const outer = new THREE.Mesh(
makeSurface(
outerFunction,
xMin,
xMax,
THETA_START,
THETA_END,
xSegments,
thetaSegments,
false
),
outerMaterial
);
outer.castShadow = true;
outer.receiveShadow = true;
group.add(outer);
const inner = new THREE.Mesh(
makeSurface(
innerFunction,
xMin,
xMax,
THETA_START,
THETA_END,
xSegments,
thetaSegments,
true
),
innerMaterial
);
inner.receiveShadow = true;
group.add(inner);
const startEdgeQuads = [];
const endEdgeQuads = [];
const startEndQuads = [];
// Longitudinal cut faces: these show the actual wall thickness.
for (let i = 0; i < xSegments; i++) {
const x0 = THREE.MathUtils.lerp(xMin, xMax, i / xSegments);
const x1 = THREE.MathUtils.lerp(xMin, xMax, (i + 1) / xSegments);
startEdgeQuads.push([
new THREE.Vector3(
x0,
outerFunction(x0) * Math.cos(THETA_START),
outerFunction(x0) * Math.sin(THETA_START)
),
new THREE.Vector3(
x1,
outerFunction(x1) * Math.cos(THETA_START),
outerFunction(x1) * Math.sin(THETA_START)
),
new THREE.Vector3(
x1,
innerFunction(x1) * Math.cos(THETA_START),
innerFunction(x1) * Math.sin(THETA_START)
),
new THREE.Vector3(
x0,
innerFunction(x0) * Math.cos(THETA_START),
innerFunction(x0) * Math.sin(THETA_START)
)
]);
endEdgeQuads.push([
new THREE.Vector3(
x0,
outerFunction(x0) * Math.cos(THETA_END),
outerFunction(x0) * Math.sin(THETA_END)
),
new THREE.Vector3(
x1,
outerFunction(x1) * Math.cos(THETA_END),
outerFunction(x1) * Math.sin(THETA_END)
),
new THREE.Vector3(
x1,
innerFunction(x1) * Math.cos(THETA_END),
innerFunction(x1) * Math.sin(THETA_END)
),
new THREE.Vector3(
x0,
innerFunction(x0) * Math.cos(THETA_END),
innerFunction(x0) * Math.sin(THETA_END)
)
]);
}
group.add(makeQuadMesh(startEdgeQuads, edgeMaterial));
group.add(makeQuadMesh(endEdgeQuads, edgeMaterial));
// Annular end faces only; the lumen itself remains open.
for (const x of [xMin, xMax]) {
for (let j = 0; j < thetaSegments; j++) {
const t0 = THREE.MathUtils.lerp(
THETA_START,
THETA_END,
j / thetaSegments
);
const t1 = THREE.MathUtils.lerp(
THETA_START,
THETA_END,
(j + 1) / thetaSegments
);
startEndQuads.push([
new THREE.Vector3(
x,
outerFunction(x) * Math.cos(t0),
outerFunction(x) * Math.sin(t0)
),
new THREE.Vector3(
x,
outerFunction(x) * Math.cos(t1),
outerFunction(x) * Math.sin(t1)
),
new THREE.Vector3(
x,
innerFunction(x) * Math.cos(t1),
innerFunction(x) * Math.sin(t1)
),
new THREE.Vector3(
x,
innerFunction(x) * Math.cos(t0),
innerFunction(x) * Math.sin(t0)
)
]);
}
}
group.add(makeQuadMesh(startEndQuads, edgeMaterial));
return group;
}
const wallOuterMaterial = new THREE.MeshStandardMaterial({
color: 0x78939a,
roughness: 0.67,
metalness: 0.015
});
const wallInnerMaterial = new THREE.MeshStandardMaterial({
color: 0xc4cfca,
roughness: 0.82,
metalness: 0
});
const wallEdgeMaterial = new THREE.MeshStandardMaterial({
color: 0x536c73,
roughness: 0.78,
metalness: 0.015,
side: THREE.DoubleSide
});
const wall = buildShell({
xMin: X_MIN,
xMax: X_MAX,
outerFunction: outerRadius,
innerFunction: innerRadius,
outerMaterial: wallOuterMaterial,
innerMaterial: wallInnerMaterial,
edgeMaterial: wallEdgeMaterial
});
scene.add(wall);
// Thin technical outlines emphasize the two continuous cut boundaries.
const cutLineMaterial = new THREE.LineBasicMaterial({
color: 0x3f5960,
transparent: true,
opacity: 0.72
});
for (const theta of [THETA_START, THETA_END]) {
for (const radiusFunction of [outerRadius, innerRadius]) {
const points = [];
for (let i = 0; i <= 170; i++) {
const x = THREE.MathUtils.lerp(X_MIN, X_MAX, i / 170);
const radius = radiusFunction(x);
points.push(
new THREE.Vector3(
x,
radius * Math.cos(theta),
radius * Math.sin(theta)
)
);
}
scene.add(
new THREE.Line(
new THREE.BufferGeometry().setFromPoints(points),
cutLineMaterial
)
);
}
}
/*
The muscular component is an annular sleeve around the neck.
It shares the same cutaway sector, so it cannot cover or plug
the lumen.
*/
const RING_X_MIN = -0.54;
const RING_X_MAX = 0.54;
function ringInnerRadius(x) {
return outerRadius(x) - 0.012;
}
function ringOuterRadius(x) {
const normalized = x / RING_X_MAX;
const centerBulge = Math.pow(Math.max(0, 1 - normalized * normalized), 2);
return outerRadius(x) + 0.095 + 0.055 * centerBulge;
}
const ringOuterMaterial = new THREE.MeshStandardMaterial({
color: 0xb67c70,
roughness: 0.72,
metalness: 0
});
const ringInnerMaterial = new THREE.MeshStandardMaterial({
color: 0x9e685e,
roughness: 0.82,
metalness: 0
});
const ringEdgeMaterial = new THREE.MeshStandardMaterial({
color: 0x8c5d55,
roughness: 0.76,
metalness: 0,
side: THREE.DoubleSide
});
const muscularRing = buildShell({
xMin: RING_X_MIN,
xMax: RING_X_MAX,
outerFunction: ringOuterRadius,
innerFunction: ringInnerRadius,
outerMaterial: ringOuterMaterial,
innerMaterial: ringInnerMaterial,
edgeMaterial: ringEdgeMaterial,
xSegments: 44,
thetaSegments: 96
});
scene.add(muscularRing);
// Symbolic bolus immediately upstream of the narrowed region.
const bolus = new THREE.Mesh(
new THREE.SphereGeometry(1, 64, 40),
new THREE.MeshStandardMaterial({
color: 0xd5a94f,
roughness: 0.43,
metalness: 0
})
);
bolus.position.set(1.08, 0, 0);
bolus.scale.set(0.52, 0.48, 0.48);
bolus.castShadow = true;
bolus.receiveShadow = true;
scene.add(bolus);
// Direct camera controls; no examples/addons are used.
const canvas = renderer.domElement;
const pointers = new Map();
let lastSinglePointer = null;
let lastPinchDistance = 0;
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
);
}
canvas.addEventListener("pointerdown", event => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 1) {
lastSinglePointer = {
x: event.clientX,
y: event.clientY
};
} else if (pointers.size === 2) {
lastPinchDistance = pointerDistance();
}
});
canvas.addEventListener("pointermove", event => {
const previous = pointers.get(event.pointerId);
if (!previous) return;
previous.x = event.clientX;
previous.y = event.clientY;
if (pointers.size === 1 && lastSinglePointer) {
const dx = event.clientX - lastSinglePointer.x;
const dy = event.clientY - lastSinglePointer.y;
controls.azimuth -= dx * 0.006;
controls.polar = THREE.MathUtils.clamp(
controls.polar - dy * 0.005,
0.35,
2.55
);
lastSinglePointer = {
x: event.clientX,
y: event.clientY
};
} else if (pointers.size === 2) {
const distance = pointerDistance();
if (lastPinchDistance > 0 && distance > 0) {
controls.radius = THREE.MathUtils.clamp(
controls.radius * (lastPinchDistance / distance),
5.1,
14
);
}
lastPinchDistance = distance;
}
});
function releasePointer(event) {
pointers.delete(event.pointerId);
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
if (pointers.size === 1) {
const remaining = [...pointers.values()][0];
lastSinglePointer = { x: remaining.x, y: remaining.y };
} else {
lastSinglePointer = null;
lastPinchDistance = 0;
}
}
canvas.addEventListener("pointerup", releasePointer);
canvas.addEventListener("pointercancel", releasePointer);
canvas.addEventListener("wheel", event => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(
controls.radius + event.deltaY * 0.005,
5.1,
14
);
}, { passive: false });
canvas.addEventListener("dblclick", () => controls.reset());
// Screen-space technical callouts
const callouts = [
{
point: new THREE.Vector3(-1.95, 0.92, 0.88),
offset: new THREE.Vector2(-115, -60),
label: document.getElementById("label-wall"),
line: document.getElementById("line-wall"),
dot: document.getElementById("dot-wall")
},
{
point: new THREE.Vector3(0.0, 0.23, 0.76),
offset: new THREE.Vector2(92, -77),
label: document.getElementById("label-ring"),
line: document.getElementById("line-ring"),
dot: document.getElementById("dot-ring")
},
{
point: new THREE.Vector3(1.08, 0.26, 0.39),
offset: new THREE.Vector2(95, 38),
label: document.getElementById("label-bolus"),
line: document.getElementById("line-bolus"),
dot: document.getElementById("dot-bolus")
}
];
const projectedPoint = new THREE.Vector3();
function updateCallouts() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const callout of callouts) {
projectedPoint.copy(callout.point).project(camera);
const visible =
projectedPoint.z > -1 &&
projectedPoint.z < 1 &&
Math.abs(projectedPoint.x) < 1.35 &&
Math.abs(projectedPoint.y) < 1.35;
const display = visible ? "block" : "none";
callout.label.style.display = display;
callout.line.style.display = display;
callout.dot.style.display = display;
if (!visible) continue;
const anchorX = (projectedPoint.x * 0.5 + 0.5) * width;
const anchorY = (-projectedPoint.y * 0.5 + 0.5) * height;
const labelX = THREE.MathUtils.clamp(
anchorX + callout.offset.x,
90,
width - 90
);
const labelY = THREE.MathUtils.clamp(
anchorY + callout.offset.y,
90,
height - 90
);
callout.label.style.left = `${labelX}px`;
callout.label.style.top = `${labelY}px`;
callout.line.setAttribute("x1", anchorX);
callout.line.setAttribute("y1", anchorY);
callout.line.setAttribute("x2", labelX);
callout.line.setAttribute("y2", labelY);
callout.dot.setAttribute("cx", anchorX);
callout.dot.setAttribute("cy", anchorY);
}
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
}
window.addEventListener("resize", resize);
function animate() {
requestAnimationFrame(animate);
updateCamera();
updateCallouts();
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```