Prompt specification
Build or customize the Three.js 3D scene "Wall Layer Stack With Thermal Resistance Labels" 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: Wall Layer Stack With Thermal Resistance Labels
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/wall-layer-stack-with-thermal-resistance-labels-x3985
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts layered wall insulation and thermal resistance. Model a wall cross-section with three clearly separated layers and hypothetical resistance values. Keep thickness and material labels visible while stating that values are illustrative. A 3D cutaway view.
Working Three.js Starter (wall-layer-stack-with-thermal-resistance-labels-x3985):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Layered Wall Insulation — Illustrative Thermal Resistance</title>
<style>
:root {
--ink: #243039;
--muted: #65727a;
--paper: #f3f0e9;
--panel: rgba(255, 255, 255, 0.86);
--line: rgba(36, 48, 57, 0.14);
--orange: #e9693f;
}
* {
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;
}
#stage {
position: relative;
width: 100%;
height: 100%;
isolation: isolate;
}
#scene {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
cursor: grab;
}
#scene:active {
cursor: grabbing;
}
.ui {
position: absolute;
inset: 0;
pointer-events: none;
z-index: 3;
}
.brand {
position: absolute;
top: 26px;
left: 28px;
width: min(440px, calc(100% - 56px));
}
.eyebrow {
margin-bottom: 9px;
color: #8b4b38;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(26px, 3vw, 42px);
font-weight: 760;
letter-spacing: -0.045em;
line-height: 1.03;
}
.subtitle {
margin: 11px 0 0;
max-width: 390px;
color: var(--muted);
font-size: 14px;
line-height: 1.45;
}
.notice {
display: inline-flex;
align-items: center;
gap: 8px;
margin-top: 14px;
padding: 7px 10px;
border: 1px solid rgba(139, 75, 56, 0.24);
border-radius: 999px;
background: rgba(255, 248, 242, 0.8);
color: #754333;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.notice::before {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--orange);
content: "";
}
.leaders {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
overflow: visible;
pointer-events: none;
}
.leader-path {
fill: none;
stroke-width: 1.35;
opacity: 0.68;
}
.leader-dot {
stroke: white;
stroke-width: 1.5;
}
.callout {
position: absolute;
top: 0;
left: 0;
display: flex;
width: 228px;
gap: 11px;
padding: 11px 12px;
border: 1px solid rgba(36, 48, 57, 0.12);
border-left: 4px solid var(--swatch);
border-radius: 10px;
background: var(--panel);
box-shadow:
0 12px 32px rgba(46, 40, 31, 0.09),
0 2px 6px rgba(46, 40, 31, 0.05);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
will-change: transform;
}
.swatch {
flex: 0 0 auto;
width: 15px;
height: 34px;
margin-top: 1px;
border-radius: 4px;
background:
linear-gradient(135deg, rgba(255, 255, 255, 0.23), transparent),
var(--swatch);
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.callout-name {
margin-bottom: 7px;
font-size: 12px;
font-weight: 800;
line-height: 1.2;
}
.callout-meta {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
color: var(--muted);
font-size: 10px;
white-space: nowrap;
}
.callout-meta b {
color: var(--ink);
font-size: 11px;
}
.total {
position: absolute;
bottom: 26px;
left: 28px;
width: 330px;
padding: 15px 16px 14px;
border: 1px solid var(--line);
border-radius: 13px;
background: rgba(255, 255, 255, 0.84);
box-shadow: 0 14px 36px rgba(46, 40, 31, 0.08);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
.total-top {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 16px;
}
.total-label {
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.total strong {
font-size: 28px;
letter-spacing: -0.04em;
line-height: 1;
}
.unit {
margin-top: 5px;
color: var(--muted);
font-size: 10px;
}
.rbar {
display: flex;
height: 8px;
margin-top: 12px;
overflow: hidden;
border-radius: 999px;
background: #e7e3db;
}
.rbar span {
display: block;
height: 100%;
}
.rbar .brick {
flex: 4.7 1 0;
background: #b85f48;
}
.rbar .insulation {
flex: 19 1 0;
background: #dfb64d;
}
.rbar .gypsum {
flex: 0 1 5px;
min-width: 5px;
background: #8e999d;
}
.rlegend {
display: flex;
justify-content: space-between;
gap: 10px;
margin-top: 8px;
color: var(--muted);
font-size: 9px;
}
.total p {
margin: 10px 0 0;
color: var(--muted);
font-size: 10px;
line-height: 1.4;
}
.controls {
position: absolute;
right: 27px;
bottom: 27px;
display: flex;
align-items: center;
gap: 12px;
pointer-events: auto;
}
.flow-key {
display: flex;
align-items: center;
gap: 8px;
color: var(--muted);
font-size: 10px;
font-weight: 650;
}
.flow-key::before {
width: 26px;
height: 2px;
background: var(--orange);
box-shadow: 5px 0 0 -0.5px var(--orange);
content: "";
}
button {
padding: 9px 12px;
border: 1px solid rgba(36, 48, 57, 0.16);
border-radius: 9px;
background: rgba(255, 255, 255, 0.86);
color: var(--ink);
font: inherit;
font-size: 10px;
font-weight: 800;
cursor: pointer;
box-shadow: 0 5px 16px rgba(46, 40, 31, 0.07);
}
button:hover {
background: white;
transform: translateY(-1px);
}
.hint {
position: absolute;
right: 28px;
bottom: 76px;
color: rgba(36, 48, 57, 0.58);
font-size: 10px;
}
@media (max-width: 700px) {
.brand {
top: 14px;
left: 14px;
width: calc(100% - 28px);
}
.subtitle {
max-width: 290px;
font-size: 12px;
}
.notice {
font-size: 8px;
}
.callout {
width: 188px;
gap: 8px;
padding: 9px;
}
.callout-name {
font-size: 10px;
}
.callout-meta {
font-size: 8px;
}
.callout-meta b {
font-size: 9px;
}
.swatch {
width: 11px;
}
.total {
right: 12px;
bottom: 12px;
left: 12px;
width: auto;
padding: 11px 13px;
}
.total strong {
font-size: 23px;
}
.total p,
.rlegend span:last-child,
.hint,
.flow-key {
display: none;
}
.controls {
top: 13px;
right: 12px;
bottom: auto;
}
}
</style>
</head>
<body>
<main id="stage">
<canvas
id="scene"
tabindex="0"
aria-label="Interactive 3D cutaway of a three-layer insulated wall"
></canvas>
<div class="ui">
<header class="brand">
<div class="eyebrow">Thermal assembly / 3D cutaway</div>
<h1>Layered wall insulation</h1>
<p class="subtitle">
An exploded three-layer wall section showing material thickness and
illustrative thermal resistance.
</p>
<div class="notice">Illustrative values · thickness not to scale</div>
</header>
<svg class="leaders" id="leaders" aria-hidden="true"></svg>
<div
class="callout"
id="callout-brick"
style="--swatch: #b85f48"
>
<span class="swatch"></span>
<div>
<div class="callout-name">Exterior brick veneer</div>
<div class="callout-meta">
<span>90 mm thick</span>
<b>R-4.7</b>
</div>
</div>
</div>
<div
class="callout"
id="callout-insulation"
style="--swatch: #dfb64d"
>
<span class="swatch"></span>
<div>
<div class="callout-name">Fiberglass batt insulation</div>
<div class="callout-meta">
<span>140 mm thick</span>
<b>R-19.0</b>
</div>
</div>
</div>
<div
class="callout"
id="callout-gypsum"
style="--swatch: #8e999d"
>
<span class="swatch"></span>
<div>
<div class="callout-name">Interior gypsum board</div>
<div class="callout-meta">
<span>13 mm thick</span>
<b>R-0.6</b>
</div>
</div>
</div>
<section class="total" aria-label="Illustrative total thermal resistance">
<div class="total-top">
<div>
<div class="total-label">Illustrative total</div>
<div class="unit">h·ft²·°F/Btu</div>
</div>
<strong>R-24.3</strong>
</div>
<div class="rbar" aria-hidden="true">
<span class="brick"></span>
<span class="insulation"></span>
<span class="gypsum"></span>
</div>
<div class="rlegend">
<span>Relative R contribution</span>
<span>Higher R = greater resistance</span>
</div>
<p>
R-4.7 + R-19.0 + R-0.6. Hypothetical values only; not an
engineering calculation.
</p>
</section>
<div class="hint">Drag to orbit · Scroll or pinch to zoom · Arrow keys to rotate</div>
<div class="controls">
<div class="flow-key">Heat flow: exterior → interior</div>
<button id="resetView" type="button">Reset view</button>
</div>
</div>
</main>
<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 canvas = document.querySelector("#scene");
const leaders = document.querySelector("#leaders");
const resetButton = document.querySelector("#resetView");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xf3f0e9);
scene.fog = new THREE.Fog(0xf3f0e9, 19, 39);
const camera = new THREE.PerspectiveCamera(38, 1, 0.1, 100);
const hemisphere = new THREE.HemisphereLight(
0xffffff,
0x8e7962,
2.15
);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff2df, 3.1);
keyLight.position.set(5.5, 9.5, 8.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -10;
keyLight.shadow.camera.right = 10;
keyLight.shadow.camera.top = 10;
keyLight.shadow.camera.bottom = -10;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 30;
keyLight.shadow.normalBias = 0.025;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xc8dcff, 1.05);
fillLight.position.set(-7, 4, -6);
scene.add(fillLight);
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(50, 50),
new THREE.MeshStandardMaterial({
color: 0xe8e3da,
roughness: 0.98,
metalness: 0
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -2.27;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(30, 30, 0xc7bfb2, 0xd4cec3);
grid.position.y = -2.255;
grid.material.transparent = true;
grid.material.opacity = 0.22;
scene.add(grid);
const wall = new THREE.Group();
scene.add(wall);
const wallWidth = 8.8;
const wallBottom = -2.2;
const wallTop = 2.2;
function createBrickTexture() {
const textureCanvas = document.createElement("canvas");
textureCanvas.width = 512;
textureCanvas.height = 512;
const ctx = textureCanvas.getContext("2d");
ctx.fillStyle = "#d2c1ae";
ctx.fillRect(0, 0, 512, 512);
const brickHeight = 64;
const brickWidth = 128;
for (let row = 0; row < 8; row++) {
const offset = row % 2 === 0 ? 0 : -brickWidth / 2;
for (let x = -brickWidth; x < 512; x += brickWidth) {
const lightness = 43 + Math.random() * 12;
const hue = 12 + Math.random() * 9;
ctx.fillStyle = `hsl(${hue}, 42%, ${lightness}%)`;
ctx.fillRect(
x + offset + 3,
row * brickHeight + 3,
brickWidth - 6,
brickHeight - 6
);
ctx.fillStyle = "rgba(255,255,255,0.06)";
ctx.fillRect(
x + offset + 4,
row * brickHeight + 4,
brickWidth - 8,
4
);
}
}
const texture = new THREE.CanvasTexture(textureCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set(0.17, 0.17);
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
function createInsulationTexture() {
const textureCanvas = document.createElement("canvas");
textureCanvas.width = 256;
textureCanvas.height = 256;
const ctx = textureCanvas.getContext("2d");
ctx.fillStyle = "#dfba56";
ctx.fillRect(0, 0, 256, 256);
for (let i = 0; i < 320; i++) {
const x = Math.random() * 256;
const y = Math.random() * 256;
const length = 8 + Math.random() * 30;
const angle = (Math.random() - 0.5) * 0.8;
ctx.strokeStyle =
Math.random() > 0.5
? "rgba(255,239,159,0.34)"
: "rgba(122,91,33,0.22)";
ctx.lineWidth = 0.7 + Math.random() * 1.2;
ctx.beginPath();
ctx.moveTo(x, y);
ctx.lineTo(
x + Math.cos(angle) * length,
y + Math.sin(angle) * length
);
ctx.stroke();
}
const texture = new THREE.CanvasTexture(textureCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set(0.34, 0.34);
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
const brickTexture = createBrickTexture();
const insulationTexture = createInsulationTexture();
/*
Each layer has a progressively larger upper-right cutaway.
This creates stepped ledges that expose every material while retaining
the appearance of a single wall assembly.
*/
const layerDefinitions = [
{
id: "brick",
name: "Exterior brick veneer",
color: 0xb85f48,
z: 1.02,
depth: 0.64,
cutRight: 3.15,
cutTop: 1.20,
thickness: "90 mm",
resistance: "R-4.7",
material: new THREE.MeshStandardMaterial({
map: brickTexture,
color: 0xffffff,
roughness: 0.92
})
},
{
id: "insulation",
name: "Fiberglass batt insulation",
color: 0xdfb64d,
z: 0,
depth: 0.78,
cutRight: 2.65,
cutTop: 1.50,
thickness: "140 mm",
resistance: "R-19.0",
material: new THREE.MeshStandardMaterial({
map: insulationTexture,
color: 0xffffff,
roughness: 1
})
},
{
id: "gypsum",
name: "Interior gypsum board",
color: 0xd9d6cf,
z: -1,
depth: 0.18,
cutRight: 2.15,
cutTop: 1.80,
thickness: "13 mm",
resistance: "R-0.6",
material: new THREE.MeshStandardMaterial({
color: 0xe8e3d8,
roughness: 0.88
})
}
];
function createCutawayShape(cutRight, cutTop) {
const shape = new THREE.Shape();
shape.moveTo(-wallWidth / 2, wallBottom);
shape.lineTo(wallWidth / 2, wallBottom);
shape.lineTo(wallWidth / 2, cutTop);
shape.lineTo(cutRight, cutTop);
shape.lineTo(cutRight, wallTop);
shape.lineTo(-wallWidth / 2, wallTop);
shape.closePath();
return shape;
}
for (const layer of layerDefinitions) {
const shape = createCutawayShape(layer.cutRight, layer.cutTop);
const geometry = new THREE.ExtrudeGeometry(shape, {
depth: layer.depth,
bevelEnabled: false,
steps: 1,
curveSegments: 2
});
geometry.translate(0, 0, -layer.depth / 2);
const mesh = new THREE.Mesh(geometry, layer.material);
mesh.position.z = layer.z;
mesh.castShadow = true;
mesh.receiveShadow = true;
wall.add(mesh);
const edgeGeometry = new THREE.EdgesGeometry(geometry, 25);
const edgeMaterial = new THREE.LineBasicMaterial({
color: 0x343a3e,
transparent: true,
opacity: layer.id === "gypsum" ? 0.25 : 0.34
});
const edges = new THREE.LineSegments(edgeGeometry, edgeMaterial);
edges.position.z = layer.z;
wall.add(edges);
layer.anchor = new THREE.Vector3(
(layer.cutRight + wallWidth / 2) / 2,
layer.cutTop,
layer.z
);
}
/*
Orange arrows above the assembly indicate heat traveling from the
exterior toward the interior. The moving dots emphasize direction.
*/
const heatGroup = new THREE.Group();
scene.add(heatGroup);
const flowDots = [];
for (const x of [-2.65, -0.55, 1.55]) {
const arrow = new THREE.ArrowHelper(
new THREE.Vector3(0, 0, -1),
new THREE.Vector3(x, 2.74, 1.62),
3.08,
0xe9693f,
0.32,
0.18
);
arrow.line.material.transparent = true;
arrow.line.material.opacity = 0.58;
arrow.cone.material.transparent = true;
arrow.cone.material.opacity = 0.82;
heatGroup.add(arrow);
const dot = new THREE.Mesh(
new THREE.SphereGeometry(0.075, 12, 12),
new THREE.MeshBasicMaterial({
color: 0xf07b4d,
transparent: true,
opacity: 0.9
})
);
dot.userData.x = x;
dot.userData.phase = Math.random();
heatGroup.add(dot);
flowDots.push(dot);
}
// Camera controls implemented locally without addons.
const orbit = {
target: new THREE.Vector3(-0.25, -0.1, 0),
azimuth: 0.63,
polar: 1.14,
radius: 14.6,
minimumRadius: 9.5,
maximumRadius: 21
};
let fitScale = 1;
let dragging = false;
let pointerX = 0;
let pointerY = 0;
function updateCamera() {
const radius = orbit.radius * fitScale;
const horizontalRadius = radius * Math.sin(orbit.polar);
camera.position.set(
orbit.target.x + horizontalRadius * Math.sin(orbit.azimuth),
orbit.target.y + radius * Math.cos(orbit.polar),
orbit.target.z + horizontalRadius * Math.cos(orbit.azimuth)
);
camera.lookAt(orbit.target);
}
function resize() {
const width = stage.clientWidth;
const height = stage.clientHeight;
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
fitScale = Math.max(1, 0.9 / camera.aspect);
leaders.setAttribute("viewBox", `0 0 ${width} ${height}`);
updateCamera();
}
function resetView() {
orbit.azimuth = 0.63;
orbit.polar = 1.14;
orbit.radius = 14.6;
updateCamera();
}
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - pointerX;
const deltaY = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
orbit.azimuth -= deltaX * 0.006;
orbit.polar = THREE.MathUtils.clamp(
orbit.polar + deltaY * 0.005,
0.48,
1.48
);
updateCamera();
});
function stopDragging(event) {
dragging = false;
if (event.pointerId !== undefined && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius + event.deltaY * 0.012,
orbit.minimumRadius,
orbit.maximumRadius
);
updateCamera();
},
{ passive: false }
);
canvas.addEventListener("keydown", (event) => {
let handled = true;
switch (event.key) {
case "ArrowLeft":
orbit.azimuth += 0.08;
break;
case "ArrowRight":
orbit.azimuth -= 0.08;
break;
case "ArrowUp":
orbit.polar = Math.max(0.48, orbit.polar - 0.06);
break;
case "ArrowDown":
orbit.polar = Math.min(1.48, orbit.polar + 0.06);
break;
case "+":
case "=":
orbit.radius = Math.max(
orbit.minimumRadius,
orbit.radius - 0.7
);
break;
case "-":
orbit.radius = Math.min(
orbit.maximumRadius,
orbit.radius + 0.7
);
break;
default:
handled = false;
}
if (handled) {
event.preventDefault();
updateCamera();
}
});
resetButton.addEventListener("click", resetView);
canvas.addEventListener("dblclick", resetView);
window.addEventListener("resize", resize);
// Create SVG leader lines and anchor dots.
const svgNamespace = "http://www.w3.org/2000/svg";
for (const layer of layerDefinitions) {
const path = document.createElementNS(svgNamespace, "path");
path.setAttribute("class", "leader-path");
path.setAttribute("stroke", `#${layer.color.toString(16).padStart(6, "0")}`);
const dot = document.createElementNS(svgNamespace, "circle");
dot.setAttribute("class", "leader-dot");
dot.setAttribute("r", "4");
dot.setAttribute("fill", `#${layer.color.toString(16).padStart(6, "0")}`);
leaders.append(path, dot);
layer.leaderPath = path;
layer.leaderDot = dot;
layer.card = document.querySelector(`#callout-${layer.id}`);
}
const calloutOffsets = {
brick: { x: 100, y: 55 },
insulation: { x: 125, y: 0 },
gypsum: { x: 95, y: -70 }
};
const projectedAnchor = new THREE.Vector3();
function updateCallouts() {
const width = stage.clientWidth;
const height = stage.clientHeight;
const mobile = width < 700;
for (const layer of layerDefinitions) {
projectedAnchor.copy(layer.anchor);
wall.localToWorld(projectedAnchor);
projectedAnchor.project(camera);
const anchorX = (projectedAnchor.x * 0.5 + 0.5) * width;
const anchorY = (-projectedAnchor.y * 0.5 + 0.5) * height;
const card = layer.card;
const cardWidth = card.offsetWidth;
const cardHeight = card.offsetHeight;
let offsetX = calloutOffsets[layer.id].x;
let offsetY = calloutOffsets[layer.id].y;
if (mobile) {
offsetX = 22;
offsetY *= 0.82;
}
let left = anchorX + offsetX;
let top = anchorY + offsetY;
left = THREE.MathUtils.clamp(left, 10, width - cardWidth - 10);
top = THREE.MathUtils.clamp(
top,
mobile ? 82 : 26,
height - cardHeight - (mobile ? 170 : 24)
);
card.style.transform = `translate3d(${left}px, ${top}px, 0)`;
const endX =
offsetX >= 0 ? left : left + cardWidth;
const endY = top + cardHeight / 2;
const control1X = anchorX + (endX - anchorX) * 0.38;
const control2X = anchorX + (endX - anchorX) * 0.72;
layer.leaderPath.setAttribute(
"d",
`M ${anchorX} ${anchorY}
C ${control1X} ${anchorY},
${control2X} ${endY},
${endX} ${endY}`
);
layer.leaderDot.setAttribute("cx", anchorX);
layer.leaderDot.setAttribute("cy", anchorY);
const visible =
projectedAnchor.z >= -1 &&
projectedAnchor.z <= 1 &&
anchorY > -50 &&
anchorY < height + 50;
card.style.opacity = visible ? "1" : "0";
layer.leaderPath.style.opacity = visible ? "0.68" : "0";
layer.leaderDot.style.opacity = visible ? "1" : "0";
}
}
resize();
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
for (const dot of flowDots) {
const progress = (elapsed * 0.22 + dot.userData.phase) % 1;
dot.position.set(
dot.userData.x,
2.74 + Math.sin(elapsed * 3 + dot.userData.phase * 8) * 0.055,
1.58 - progress * 3.04
);
}
updateCallouts();
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```