Prompt specification
Build or customize the Three.js 3D scene "Compare continuous and interrupted insulation" 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: Compare continuous and interrupted insulation
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/compare-continuous-and-interrupted-insulation-x2180
Scene Description Prompt:
Please use Three.js from cdnjs for a low-poly scene based on this idea: compare continuous and interrupted insulation. Let users introduce an insulation gap in a schematic wall assembly. Show a qualitative heat-flow path change, keeping material assumptions visible and avoiding claims of certified energy performance. Return one self-contained HTML file.
Working Three.js Starter (compare-continuous-and-interrupted-insulation-x2180):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Continuous vs. Interrupted Insulation — Qualitative Schematic</title>
<style>
:root {
--ink: #203532;
--muted: #667773;
--paper: #f4f2eb;
--panel: rgba(255, 255, 252, 0.94);
--line: rgba(32, 53, 50, 0.14);
--teal: #326c65;
--teal-dark: #24534e;
--coral: #ef6548;
--insulation: #deb04f;
--finish: #e8dfd0;
--sheathing: #b97f55;
--cladding: #4f7777;
--shadow: 0 18px 50px rgba(28, 45, 42, 0.16);
}
* {
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;
}
#viewport {
position: fixed;
inset: 0;
background:
radial-gradient(circle at 50% 38%, rgba(255, 255, 255, 0.72), transparent 43%),
linear-gradient(180deg, #f7f5ef 0%, #ecebe4 100%);
}
#scene {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
cursor: grab;
}
#scene:active {
cursor: grabbing;
}
#scene:focus-visible {
outline: 3px solid rgba(50, 108, 101, 0.55);
outline-offset: -4px;
}
.topbar {
position: fixed;
z-index: 10;
top: 0;
left: 0;
right: 0;
min-height: 82px;
padding: 18px 24px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
background: linear-gradient(
180deg,
rgba(247, 245, 239, 0.98) 0%,
rgba(247, 245, 239, 0.84) 76%,
rgba(247, 245, 239, 0) 100%
);
pointer-events: none;
}
.title-group {
display: flex;
align-items: center;
gap: 13px;
}
.title-mark {
width: 42px;
height: 42px;
flex: 0 0 auto;
position: relative;
border: 1px solid rgba(32, 53, 50, 0.18);
border-radius: 12px;
background: rgba(255, 255, 255, 0.66);
box-shadow: 0 6px 18px rgba(32, 53, 50, 0.08);
overflow: hidden;
}
.title-mark span {
position: absolute;
left: 8px;
right: 8px;
height: 5px;
border-radius: 3px;
transform: skewY(-10deg);
}
.title-mark span:nth-child(1) {
top: 8px;
background: var(--finish);
border: 1px solid rgba(32, 53, 50, 0.14);
}
.title-mark span:nth-child(2) {
top: 17px;
background: var(--insulation);
}
.title-mark span:nth-child(3) {
top: 26px;
background: var(--cladding);
}
h1 {
margin: 0;
font-size: clamp(18px, 2.2vw, 26px);
line-height: 1.05;
letter-spacing: -0.035em;
font-weight: 740;
}
.subtitle {
margin: 5px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.3;
}
.top-actions {
display: flex;
gap: 8px;
pointer-events: auto;
}
.tool-button {
appearance: none;
border: 1px solid rgba(32, 53, 50, 0.16);
border-radius: 10px;
padding: 9px 12px;
color: var(--ink);
background: rgba(255, 255, 252, 0.82);
box-shadow: 0 5px 16px rgba(32, 53, 50, 0.06);
cursor: pointer;
font-size: 12px;
font-weight: 650;
transition: background 160ms ease, transform 160ms ease;
}
.tool-button:hover {
background: white;
transform: translateY(-1px);
}
.tool-button:focus-visible,
input:focus-visible {
outline: 3px solid rgba(50, 108, 101, 0.34);
outline-offset: 2px;
}
.scene-legend {
position: fixed;
z-index: 5;
top: 103px;
left: 24px;
width: 198px;
padding: 13px 14px;
border: 1px solid var(--line);
border-radius: 14px;
background: rgba(255, 255, 252, 0.82);
box-shadow: 0 10px 30px rgba(32, 53, 50, 0.08);
backdrop-filter: blur(12px);
}
.legend-heading {
margin-bottom: 9px;
color: var(--muted);
font-size: 10px;
font-weight: 760;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.layer-row {
display: flex;
align-items: center;
gap: 9px;
margin-top: 7px;
font-size: 11px;
color: #435753;
}
.swatch {
width: 12px;
height: 12px;
flex: 0 0 auto;
border-radius: 3px;
border: 1px solid rgba(32, 53, 50, 0.16);
}
.direction-note {
display: flex;
align-items: center;
gap: 7px;
margin-top: 12px;
padding-top: 10px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 10px;
line-height: 1.35;
}
.direction-arrow {
color: var(--coral);
font-size: 18px;
line-height: 1;
}
.orbit-hint {
position: fixed;
z-index: 5;
right: 24px;
top: 108px;
padding: 8px 11px;
border-radius: 999px;
color: rgba(32, 53, 50, 0.68);
background: rgba(255, 255, 252, 0.68);
border: 1px solid rgba(32, 53, 50, 0.09);
font-size: 10px;
letter-spacing: 0.015em;
pointer-events: none;
}
.dock-wrap {
position: fixed;
z-index: 12;
left: 50%;
bottom: 16px;
width: min(1180px, calc(100% - 32px));
transform: translateX(-50%);
}
.control-dock {
display: grid;
grid-template-columns: 1.02fr 0.94fr 1.32fr;
overflow: hidden;
border: 1px solid rgba(32, 53, 50, 0.14);
border-radius: 18px;
background: var(--panel);
box-shadow: var(--shadow);
backdrop-filter: blur(16px);
}
.dock-section {
min-width: 0;
padding: 16px 18px;
}
.dock-section + .dock-section {
border-left: 1px solid var(--line);
}
.eyebrow {
color: var(--muted);
font-size: 9px;
font-weight: 780;
letter-spacing: 0.105em;
text-transform: uppercase;
}
.control-title {
margin-top: 5px;
font-size: 13px;
font-weight: 720;
}
.range-row {
display: flex;
align-items: center;
gap: 11px;
margin-top: 12px;
}
input[type="range"] {
width: 100%;
height: 5px;
appearance: none;
border-radius: 999px;
background: linear-gradient(
90deg,
var(--teal) 0%,
var(--teal) var(--fill, 54%),
#d9dedb var(--fill, 54%),
#d9dedb 100%
);
cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
width: 17px;
height: 17px;
appearance: none;
border: 3px solid white;
border-radius: 50%;
background: var(--teal);
box-shadow: 0 2px 7px rgba(32, 53, 50, 0.25);
}
input[type="range"]::-moz-range-thumb {
width: 13px;
height: 13px;
border: 3px solid white;
border-radius: 50%;
background: var(--teal);
box-shadow: 0 2px 7px rgba(32, 53, 50, 0.25);
}
.range-value {
min-width: 48px;
padding: 5px 7px;
border-radius: 8px;
background: #e6eeeb;
color: var(--teal-dark);
text-align: center;
font-size: 11px;
font-weight: 760;
}
.microcopy {
margin: 8px 0 0;
color: var(--muted);
font-size: 10px;
line-height: 1.4;
}
.readout-title {
margin: 6px 0 0;
font-size: 14px;
line-height: 1.25;
letter-spacing: -0.01em;
}
.readout-copy {
margin: 7px 0 0;
color: var(--muted);
font-size: 10.5px;
line-height: 1.45;
}
.state-pill {
display: inline-flex;
align-items: center;
gap: 6px;
margin-top: 9px;
padding: 5px 8px;
border-radius: 999px;
color: #8b4938;
background: #fce9e1;
font-size: 9px;
font-weight: 760;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.state-pill::before {
content: "";
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--coral);
}
.assumptions {
max-height: 145px;
overflow: auto;
padding-right: 8px;
}
.assumptions ul {
margin: 7px 0 0;
padding-left: 16px;
color: #536763;
font-size: 10px;
line-height: 1.42;
}
.assumptions li + li {
margin-top: 4px;
}
.disclaimer {
margin: 8px 4px 0;
color: #6a6f6b;
font-size: 9.5px;
line-height: 1.4;
text-align: center;
}
.disclaimer strong {
color: #805144;
}
#loading {
position: fixed;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
color: var(--teal-dark);
background: var(--paper);
font-size: 13px;
font-weight: 650;
letter-spacing: 0.02em;
}
#loading.hidden {
display: none;
}
@media (max-width: 850px) {
.topbar {
padding: 14px 16px;
}
.subtitle {
display: none;
}
.scene-legend {
top: 76px;
left: 14px;
width: 168px;
padding: 10px 11px;
}
.orbit-hint {
display: none;
}
.dock-wrap {
bottom: 9px;
width: calc(100% - 18px);
}
.control-dock {
grid-template-columns: 1fr 1fr;
max-height: 42vh;
overflow: auto;
}
.dock-section {
padding: 12px 14px;
}
.dock-section + .dock-section {
border-left: 0;
}
.dock-section:nth-child(2) {
border-left: 1px solid var(--line);
}
.dock-section:nth-child(3) {
grid-column: 1 / -1;
border-top: 1px solid var(--line);
border-left: 0 !important;
}
.assumptions {
max-height: none;
}
}
@media (max-width: 560px) {
.title-mark {
display: none;
}
h1 {
font-size: 17px;
max-width: 220px;
}
.top-actions {
gap: 5px;
}
.tool-button {
padding: 8px 9px;
font-size: 10px;
}
.scene-legend {
width: 150px;
}
.layer-row {
font-size: 9.5px;
}
.direction-note {
font-size: 9px;
}
}
@media (prefers-reduced-motion: reduce) {
* {
scroll-behavior: auto !important;
transition: none !important;
}
}
</style>
</head>
<body>
<div id="viewport">
<canvas
id="scene"
tabindex="0"
aria-label="Interactive three-dimensional comparison of continuous and interrupted insulation. Drag to orbit, scroll to zoom, and use arrow keys to rotate."
></canvas>
</div>
<header class="topbar">
<div class="title-group">
<div class="title-mark" aria-hidden="true">
<span></span><span></span><span></span>
</div>
<div>
<h1>Heat paths, made visible</h1>
<p class="subtitle">Continuous vs. interrupted insulation · qualitative schematic</p>
</div>
</div>
<div class="top-actions">
<button class="tool-button" id="resetView" type="button">Reset view</button>
<button class="tool-button" id="toggleLabels" type="button" aria-pressed="true">
Labels on
</button>
</div>
</header>
<aside class="scene-legend" aria-label="Wall layer legend">
<div class="legend-heading">Wall layers · warm → cool</div>
<div class="layer-row"><span class="swatch" style="background:#e8dfd0"></span>Interior finish</div>
<div class="layer-row"><span class="swatch" style="background:#deb04f"></span>Insulation</div>
<div class="layer-row"><span class="swatch" style="background:#b97f55"></span>Sheathing</div>
<div class="layer-row"><span class="swatch" style="background:#4f7777"></span>Outer cladding</div>
<div class="direction-note">
<span class="direction-arrow">→</span>
<span>Coral tracer indicates the illustrated warm-to-cool direction.</span>
</div>
</aside>
<div class="orbit-hint">Drag to orbit · Scroll to zoom · Double-click to reset</div>
<div class="dock-wrap">
<div class="control-dock">
<section class="dock-section" aria-labelledby="gapTitle">
<div class="eyebrow">Adjustable interruption</div>
<div class="control-title" id="gapTitle">Width of the top insulation notch</div>
<div class="range-row">
<input
id="gapRange"
type="range"
min="0"
max="70"
value="38"
step="1"
aria-describedby="gapDescription"
/>
<output class="range-value" id="gapValue" for="gapRange">38%</output>
</div>
<p class="microcopy" id="gapDescription">
Graphic model width only — not a construction dimension.
</p>
</section>
<section class="dock-section" aria-labelledby="readingTitle">
<div class="eyebrow">Qualitative reading</div>
<h2 class="readout-title" id="readingTitle">A visible detour appears</h2>
<p class="readout-copy" id="readingCopy">
The right-hand tracer bends around the interruption before continuing toward the cool side.
</p>
<span class="state-pill" id="statePill">Illustrative route only</span>
</section>
<section class="dock-section assumptions" aria-labelledby="assumptionsTitle">
<div class="eyebrow" id="assumptionsTitle">Material assumptions</div>
<ul>
<li>Graphic layer depths are illustrative and do not represent thermal resistance.</li>
<li>The right sample has a centered top notch; only its width is adjusted.</li>
<li>The coral path is hand-routed for explanation, not calculated from material properties.</li>
</ul>
</section>
</div>
<p class="disclaimer">
<strong>Schematic comparison only.</strong>
No U-values, heat-loss rates, thermal-bridge magnitudes, airtightness, moisture behavior,
or energy savings are calculated. This is not a certified energy-performance assessment.
</p>
</div>
<div id="loading">Building the schematic…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.getElementById("scene");
const loading = document.getElementById("loading");
const gapRange = document.getElementById("gapRange");
const gapValue = document.getElementById("gapValue");
const readingTitle = document.getElementById("readingTitle");
const readingCopy = document.getElementById("readingCopy");
const statePill = document.getElementById("statePill");
const resetViewButton = document.getElementById("resetView");
const toggleLabelsButton = document.getElementById("toggleLabels");
const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
let renderer;
try {
renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
} catch (error) {
loading.textContent = "WebGL is unavailable in this browser.";
throw error;
}
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xf3f1ea);
scene.fog = new THREE.Fog(0xf3f1ea, 19, 38);
const camera = new THREE.PerspectiveCamera(42, 1, 0.1, 80);
const cameraTarget = new THREE.Vector3(0, 1.72, 0);
const orbit = {
theta: 0.67,
phi: 1.20,
radius: 15.8,
targetTheta: 0.67,
targetPhi: 1.20,
targetRadius: 15.8,
dragging: false,
pointerX: 0,
pointerY: 0
};
function responsiveRadius() {
const aspect = window.innerWidth / window.innerHeight;
if (aspect < 0.72) return 21.8;
if (aspect < 1.05) return 19.0;
if (aspect < 1.35) return 17.2;
return 15.8;
}
function resetCamera() {
orbit.targetTheta = 0.67;
orbit.targetPhi = 1.20;
orbit.targetRadius = responsiveRadius();
}
function updateCamera() {
orbit.theta += (orbit.targetTheta - orbit.theta) * 0.11;
orbit.phi += (orbit.targetPhi - orbit.phi) * 0.11;
orbit.radius += (orbit.targetRadius - orbit.radius) * 0.11;
const sinPhi = Math.sin(orbit.phi);
camera.position.set(
cameraTarget.x + orbit.radius * sinPhi * Math.sin(orbit.theta),
cameraTarget.y + orbit.radius * Math.cos(orbit.phi),
cameraTarget.z + orbit.radius * sinPhi * Math.cos(orbit.theta)
);
camera.lookAt(cameraTarget);
}
resetCamera();
orbit.radius = orbit.targetRadius;
updateCamera();
const hemi = new THREE.HemisphereLight(0xfff9ed, 0x7e9690, 2.05);
scene.add(hemi);
const keyLight = new THREE.DirectionalLight(0xfff4db, 3.15);
keyLight.position.set(7, 12, 9);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -11;
keyLight.shadow.camera.right = 11;
keyLight.shadow.camera.top = 11;
keyLight.shadow.camera.bottom = -8;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 35;
keyLight.shadow.bias = -0.0007;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0xaeced0, 1.15);
rimLight.position.set(-8, 6, -8);
scene.add(rimLight);
const material = (color, extra = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0.0,
flatShading: true,
...extra
});
const materials = {
finish: material(0xe8dfd0),
insulation: material(0xdeb04f),
insulationLight: material(0xe6bd62),
insulationDark: material(0xd5a447),
sheathing: material(0xb97f55),
cladding: material(0x4f7777),
claddingAlt: material(0x5b8381),
claddingDark: material(0x456a6b),
plinth: material(0xd9ded8),
fastener: material(0x4b5e5b, { metalness: 0.12, roughness: 0.6 })
};
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const unitEdges = new THREE.EdgesGeometry(unitBox);
const edgeMaterial = new THREE.LineBasicMaterial({
color: 0x25413d,
transparent: true,
opacity: 0.24
});
function makeBlock(blockMaterial) {
const group = new THREE.Group();
const mesh = new THREE.Mesh(unitBox, blockMaterial);
mesh.castShadow = true;
mesh.receiveShadow = true;
group.add(mesh);
const edges = new THREE.LineSegments(unitEdges, edgeMaterial);
edges.renderOrder = 2;
group.add(edges);
return group;
}
function sizeBlock(group, width, height, depth) {
group.scale.set(width, height, depth);
}
function positionBlock(group, x, y, z) {
group.position.set(x, y, z);
}
const WALL_WIDTH = 2.8;
const WALL_BOTTOM = 0.35;
const WALL_HEIGHT = 3.2;
const WALL_TOP = WALL_BOTTOM + WALL_HEIGHT;
const NOTCH_BOTTOM = 2.05;
function addCornerGuides(parent, xOffset) {
const guideMaterial = new THREE.LineDashedMaterial({
color: 0x5e7771,
transparent: true,
opacity: 0.28,
dashSize: 0.09,
gapSize: 0.08
});
const corners = [
[-1.42, WALL_BOTTOM],
[1.42, WALL_BOTTOM],
[-1.42, WALL_TOP],
[1.42, WALL_TOP]
];
corners.forEach(([x, y]) => {
const geometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(xOffset + x, y, 1.13),
new THREE.Vector3(xOffset + x, y, -0.60)
]);
const line = new THREE.Line(geometry, guideMaterial);
line.computeLineDistances();
parent.add(line);
});
}
function addFasteners(parent, xOffset) {
const fastenerGeometry = new THREE.CylinderGeometry(0.035, 0.035, 0.024, 6);
const offsets = [
[-1.25, 0.55],
[1.25, 0.55],
[-1.25, 3.33],
[1.25, 3.33]
];
offsets.forEach(([x, y]) => {
const fastener = new THREE.Mesh(fastenerGeometry, materials.fastener);
fastener.rotation.x = Math.PI / 2;
fastener.position.set(xOffset + x, y, 1.135);
parent.add(fastener);
});
}
function createAssembly(xOffset, isAdjustable) {
const group = new THREE.Group();
const plinth = makeBlock(materials.plinth);
sizeBlock(plinth, 3.28, 0.16, 3.15);
positionBlock(plinth, xOffset, 0.18, 0.28);
group.add(plinth);
const finish = makeBlock(materials.finish);
sizeBlock(finish, WALL_WIDTH, WALL_HEIGHT, 0.18);
positionBlock(finish, xOffset, WALL_BOTTOM + WALL_HEIGHT / 2, 1.03);
group.add(finish);
let lowerInsulation;
let upperLeft;
let upperRight;
if (isAdjustable) {
lowerInsulation = makeBlock(materials.insulation);
sizeBlock(lowerInsulation, WALL_WIDTH, NOTCH_BOTTOM - WALL_BOTTOM, 0.72);
positionBlock(
lowerInsulation,
xOffset,
WALL_BOTTOM + (NOTCH_BOTTOM - WALL_BOTTOM) / 2,
0.34
);
group.add(lowerInsulation);
upperLeft = makeBlock(materials.insulationLight);
upperRight = makeBlock(materials.insulationLight);
sizeBlock(upperLeft, WALL_WIDTH / 2, WALL_TOP - NOTCH_BOTTOM, 0.72);
sizeBlock(upperRight, WALL_WIDTH / 2, WALL_TOP - NOTCH_BOTTOM, 0.72);
positionBlock(upperLeft, xOffset - WALL_WIDTH / 4, (NOTCH_BOTTOM + WALL_TOP) / 2, 0.34);
positionBlock(upperRight, xOffset + WALL_WIDTH / 4, (NOTCH_BOTTOM + WALL_TOP) / 2, 0.34);
group.add(upperLeft, upperRight);
} else {
const insulation = makeBlock(materials.insulation);
sizeBlock(insulation, WALL_WIDTH, WALL_HEIGHT, 0.72);
positionBlock(insulation, xOffset, WALL_BOTTOM + WALL_HEIGHT / 2, 0.34);
group.add(insulation);
}
const sheathing = makeBlock(materials.sheathing);
sizeBlock(sheathing, WALL_WIDTH, WALL_HEIGHT, 0.16);
positionBlock(sheathing, xOffset, WALL_BOTTOM + WALL_HEIGHT / 2, -0.17);
group.add(sheathing);
const slatCount = 6;
const slatGap = 0.025;
const slatWidth = (WALL_WIDTH - slatGap * (slatCount - 1)) / slatCount;
const claddingMaterials = [
materials.cladding,
materials.claddingAlt,
materials.cladding,
materials.claddingDark,
materials.claddingAlt,
materials.cladding
];
for (let i = 0; i < slatCount; i++) {
const slat = makeBlock(claddingMaterials[i]);
sizeBlock(slat, slatWidth, WALL_HEIGHT, 0.22);
const x = xOffset - WALL_WIDTH / 2 + slatWidth / 2 + i * (slatWidth + slatGap);
positionBlock(slat, x, WALL_BOTTOM + WALL_HEIGHT / 2, -0.48);
group.add(slat);
}
addCornerGuides(group, xOffset);
addFasteners(group, xOffset);
scene.add(group);
return { group, upperLeft, upperRight };
}
const continuousAssembly = createAssembly(-3.15, false);
const adjustableAssembly = createAssembly(3.15, true);
function updateNotch(percent) {
const gapWidth = WALL_WIDTH * (percent / 100);
const sideWidth = (WALL_WIDTH - gapWidth) / 2;
sizeBlock(adjustableAssembly.upperLeft, sideWidth, WALL_TOP - NOTCH_BOTTOM, 0.72);
sizeBlock(adjustableAssembly.upperRight, sideWidth, WALL_TOP - NOTCH_BOTTOM, 0.72);
positionBlock(
adjustableAssembly.upperLeft,
3.15 - gapWidth / 2 - sideWidth / 2,
(NOTCH_BOTTOM + WALL_TOP) / 2,
0.34
);
positionBlock(
adjustableAssembly.upperRight,
3.15 + gapWidth / 2 + sideWidth / 2,
(NOTCH_BOTTOM + WALL_TOP) / 2,
0.34
);
}
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(60, 60),
material(0xe9e7df, { roughness: 1 })
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.025;
ground.receiveShadow = true;
scene.add(ground);
const grid = new THREE.GridHelper(34, 34, 0x8ea09a, 0x9eaaa4);
grid.position.y = -0.012;
grid.material.transparent = true;
grid.material.opacity = 0.14;
scene.add(grid);
const pathRoot = new THREE.Group();
scene.add(pathRoot);
const pathMaterial = new THREE.MeshBasicMaterial({
color: 0xef6548,
transparent: true,
opacity: 0.95,
depthTest: false,
depthWrite: false
});
const pathGlowMaterial = new THREE.MeshBasicMaterial({
color: 0xef6548,
transparent: true,
opacity: 0.14,
depthTest: false,
depthWrite: false
});
const particleGeometry = new THREE.SphereGeometry(0.068, 8, 6);
const particleMaterial = new THREE.MeshBasicMaterial({
color: 0xfff6d7,
depthTest: false,
depthWrite: false
});
const paths = [];
function removePath(pathIndex) {
const old = paths[pathIndex];
if (!old || !old.group) return;
old.group.traverse((object) => {
if (object.geometry && object.geometry !== particleGeometry) {
object.geometry.dispose();
}
});
pathRoot.remove(old.group);
paths[pathIndex] = null;
}
function createPath(pathIndex, points) {
removePath(pathIndex);
const group = new THREE.Group();
const curve = new THREE.CatmullRomCurve3(
points.map((point) => new THREE.Vector3(point[0], point[1], point[2])),
false,
"catmullrom",
0.2
);
const glow = new THREE.Mesh(
new THREE.TubeGeometry(curve, 72, 0.105, 6, false),
pathGlowMaterial
);
glow.renderOrder = 18;
const tube = new THREE.Mesh(
new THREE.TubeGeometry(curve, 72, 0.038, 6, false),
pathMaterial
);
tube.renderOrder = 20;
group.add(glow, tube);
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(0.13, 0.32, 7),
pathMaterial
);
arrow.position.copy(curve.getPointAt(1));
arrow.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
curve.getTangentAt(1).normalize()
);
arrow.renderOrder = 21;
group.add(arrow);
const particles = [];
for (let i = 0; i < 5; i++) {
const particle = new THREE.Mesh(particleGeometry, particleMaterial);
particle.renderOrder = 22;
group.add(particle);
particles.push(particle);
}
pathRoot.add(group);
paths[pathIndex] = { group, curve, particles };
}
const continuousPoints = [
[0, 2.38, 1.42],
[0, 2.40, 0.94],
[-0.055, 2.35, 0.53],
[0.025, 2.38, 0.13],
[0, 2.38, -0.22],
[0, 2.36, -0.61],
[0, 2.38, -0.93]
];
function interruptedPoints() {
return [
[0, 2.38, 1.42],
[0, 2.38, 0.96],
[0, 2.35, 0.62],
[0, 2.25, 0.36],
[0, 1.96, 0.12],
[0, 1.88, -0.13],
[0, 2.02, -0.36],
[0, 2.34, -0.61],
[0, 2.38, -0.93]
];
}
createPath(0, continuousPoints);
const labelRoot = new THREE.Group();
scene.add(labelRoot);
function roundedRect(ctx, x, y, width, height, radius) {
const r = Math.min(radius, width / 2, height / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.arcTo(x + width, y, x + width, y + height, r);
ctx.arcTo(x + width, y + height, x, y + height, r);
ctx.arcTo(x, y + height, x, y, r);
ctx.arcTo(x, y, x + width, y, r);
ctx.closePath();
}
function makeBanner(title, subtitle, background = "#285a54") {
const bannerCanvas = document.createElement("canvas");
bannerCanvas.width = 768;
bannerCanvas.height = 176;
const context = bannerCanvas.getContext("2d");
const texture = new THREE.CanvasTexture(bannerCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.scale.set(3.0, 0.69, 1);
sprite.renderOrder = 40;
function draw(nextTitle, nextSubtitle, nextBackground = background) {
context.clearRect(0, 0, bannerCanvas.width, bannerCanvas.height);
context.fillStyle = "rgba(20, 45, 42, 0.14)";
roundedRect(context, 12, 14, 744, 148, 30);
context.fill();
context.fillStyle = nextBackground;
roundedRect(context, 8, 7, 744, 148, 30);
context.fill();
context.textAlign = "center";
context.textBaseline = "middle";
context.fillStyle = "#fffdf4";
context.font = "700 42px system-ui, sans-serif";
context.fillText(nextTitle, bannerCanvas.width / 2, 57);
context.fillStyle = "rgba(255,255,255,0.78)";
context.font = "600 25px system-ui, sans-serif";
context.fillText(nextSubtitle, bannerCanvas.width / 2, 112);
texture.needsUpdate = true;
}
draw(title, subtitle, background);
return { sprite, draw };
}
const continuousBanner = makeBanner("CONTINUOUS", "Uninterrupted insulation strip");
continuousBanner.sprite.position.set(-3.15, 4.08, 0);
labelRoot.add(continuousBanner.sprite);
const adjustableBanner = makeBanner("INTERRUPTED", "Notch width · 38%", "#765144");
adjustableBanner.sprite.position.set(3.15, 4.08, 0);
labelRoot.add(adjustableBanner.sprite);
const warmBanner = makeBanner("WARM SIDE", "Path starts here", "#9a5946");
warmBanner.sprite.position.set(-5.25, 3.47, 1.10);
warmBanner.sprite.scale.set(1.62, 0.39, 1);
labelRoot.add(warmBanner.sprite);
const coolBanner = makeBanner("COOL SIDE", "Path continues here", "#416c79");
coolBanner.sprite.position.set(5.25, 3.47, -0.72);
coolBanner.sprite.scale.set(1.62, 0.39, 1);
labelRoot.add(coolBanner.sprite);
let currentGap = Number(gapRange.value);
let labelsVisible = true;
function updateInterface() {
const percent = Number(gapRange.value);
currentGap = percent;
gapValue.value = `${percent}%`;
gapValue.textContent = `${percent}%`;
gapRange.style.setProperty("--fill", `${(percent / 70) * 100}%`);
gapRange.setAttribute("aria-valuetext", `${percent} percent of model wall width`);
updateNotch(percent);
if (percent === 0) {
createPath(1, continuousPoints);
adjustableBanner.draw("CONTINUOUS", "Notch closed · matches left", "#285a54");
readingTitle.textContent = "Both routes remain continuous";
readingCopy.textContent =
"With the interruption closed, the right-hand tracer follows essentially the same route as the left.";
statePill.textContent = "No visible interruption";
} else {
createPath(1, interruptedPoints());
adjustableBanner.draw("INTERRUPTED", `Top notch width · ${percent}%`, "#765144");
readingTitle.textContent = "A visible detour appears";
readingCopy.textContent =
"The right-hand tracer bends around the interruption before continuing toward the cool side.";
statePill.textContent = "Illustrative route only";
if (percent <= 15) {
readingTitle.textContent = "A narrow interruption starts to redirect the route";
statePill.textContent = "Small visible bend";
} else if (percent <= 45) {
readingTitle.textContent = "The interruption produces a clear detour";
statePill.textContent = "Visible path change";
} else {
readingTitle.textContent = "A wide opening creates a pronounced detour";
statePill.textContent = "Strong visible change";
}
}
}
gapRange.addEventListener("input", updateInterface);
updateInterface();
resetViewButton.addEventListener("click", resetCamera);
toggleLabelsButton.addEventListener("click", () => {
labelsVisible = !labelsVisible;
labelRoot.visible = labelsVisible;
toggleLabelsButton.textContent = labelsVisible ? "Labels on" : "Labels off";
toggleLabelsButton.setAttribute("aria-pressed", String(labelsVisible));
});
canvas.addEventListener("pointerdown", (event) => {
orbit.dragging = true;
orbit.pointerX = event.clientX;
orbit.pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!orbit.dragging) return;
const deltaX = event.clientX - orbit.pointerX;
const deltaY = event.clientY - orbit.pointerY;
orbit.pointerX = event.clientX;
orbit.pointerY = event.clientY;
orbit.targetTheta -= deltaX * 0.006;
orbit.targetPhi = THREE.MathUtils.clamp(
orbit.targetPhi - deltaY * 0.005,
0.46,
1.46
);
});
function endPointer(event) {
orbit.dragging = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.targetRadius = THREE.MathUtils.clamp(
orbit.targetRadius * Math.exp(event.deltaY * 0.001),
9,
26
);
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetCamera);
canvas.addEventListener("keydown", (event) => {
const step = 0.08;
if (event.key === "ArrowLeft") orbit.targetTheta += step;
else if (event.key === "ArrowRight") orbit.targetTheta -= step;
else if (event.key === "ArrowUp") orbit.targetPhi = Math.max(0.46, orbit.targetPhi - step);
else if (event.key === "ArrowDown") orbit.targetPhi = Math.min(1.46, orbit.targetPhi + step);
else if (event.key === "+" || event.key === "=") {
orbit.targetRadius = Math.max(9, orbit.targetRadius - 0.8);
} else if (event.key === "-" || event.key === "_") {
orbit.targetRadius = Math.min(26, orbit.targetRadius + 0.8);
} else if (event.key === "Home") {
resetCamera();
} else {
return;
}
event.preventDefault();
});
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
window.addEventListener("resize", resize);
resize();
const clock = new THREE.Clock();
const samplePoint = new THREE.Vector3();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
updateCamera();
paths.forEach((path, pathIndex) => {
if (!path) return;
path.particles.forEach((particle, index) => {
const t = reducedMotion
? index / path.particles.length
: (elapsed * 0.12 + index / path.particles.length + pathIndex * 0.07) % 1;
path.curve.getPointAt(t, samplePoint);
particle.position.copy(samplePoint);
});
});
renderer.render(scene, camera);
}
loading.classList.add("hidden");
animate();
</script>
</body>
</html>
```