Prompt specification
Build or customize the Three.js 3D scene "Resize an overhang across sun angles" 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: Resize an overhang across sun angles
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/resize-an-overhang-across-sun-angles-x2240
Scene Description Prompt:
Adjust a voxel overhang above a Northern Hemisphere south-facing window, comparing seasonal sun angles and light penetration. Three.js from cdnjs, one HTML file.
Working Three.js Starter (resize-an-overhang-across-sun-angles-x2240):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Solstice — Voxel Overhang Study</title>
<style>
:root {
--ink: #18302e;
--muted: #6e7c78;
--paper: #f4f5ef;
--panel: #fbfcf7;
--line: #dfe4dc;
--accent: #e99345;
--winter: #6c9fc7;
--equinox: #dda846;
--summer: #d96f52;
--shadow: 0 12px 36px rgba(28, 48, 44, 0.12);
}
* { box-sizing: border-box; }
html, body {
margin: 0;
width: 100%;
height: 100%;
overflow: hidden;
color: var(--ink);
background: var(--paper);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button, input { font: inherit; }
button { color: inherit; }
.app {
height: 100%;
display: grid;
grid-template-rows: 64px minmax(0, 1fr);
}
.topbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
padding: 0 24px;
color: #f4f8f3;
background: var(--ink);
border-bottom: 1px solid rgba(255,255,255,0.08);
z-index: 5;
}
.brand {
display: flex;
align-items: center;
gap: 13px;
min-width: 0;
}
.brand-mark {
width: 30px;
height: 30px;
position: relative;
flex: 0 0 auto;
}
.brand-mark i {
position: absolute;
width: 12px;
height: 12px;
border-radius: 2px;
background: var(--accent);
box-shadow: inset 0 -2px 0 rgba(0,0,0,0.13);
}
.brand-mark i:nth-child(1) { left: 0; top: 9px; opacity: .58; }
.brand-mark i:nth-child(2) { left: 9px; top: 0; }
.brand-mark i:nth-child(3) { left: 9px; top: 12px; opacity: .78; }
.brand-copy { min-width: 0; }
.brand-title {
font-size: 14px;
font-weight: 750;
letter-spacing: .14em;
text-transform: uppercase;
white-space: nowrap;
}
.brand-subtitle {
margin-top: 2px;
color: #aebdb8;
font-size: 11px;
letter-spacing: .03em;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.top-meta {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
justify-content: flex-end;
}
.meta-pill {
padding: 7px 10px;
border: 1px solid rgba(255,255,255,.14);
border-radius: 999px;
color: #c8d3ce;
font-size: 11px;
white-space: nowrap;
}
.meta-pill strong {
color: #fff;
font-weight: 650;
}
.workspace {
min-height: 0;
display: grid;
grid-template-columns: minmax(0, 1fr) 380px;
}
.viewport {
position: relative;
min-width: 0;
min-height: 0;
overflow: hidden;
background: #dce3df;
}
canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
outline: none;
}
.scene-header {
position: absolute;
z-index: 2;
top: 20px;
left: 20px;
right: 20px;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 18px;
pointer-events: none;
}
.scene-title {
padding: 13px 15px;
background: rgba(250,252,247,.88);
border: 1px solid rgba(255,255,255,.75);
border-radius: 13px;
box-shadow: var(--shadow);
backdrop-filter: blur(12px);
}
.eyebrow {
margin-bottom: 5px;
color: var(--muted);
font-size: 10px;
font-weight: 750;
letter-spacing: .14em;
text-transform: uppercase;
}
.scene-title h1 {
margin: 0;
font-size: 16px;
line-height: 1.2;
font-weight: 720;
}
.scene-title p {
margin: 5px 0 0;
color: var(--muted);
font-size: 11px;
}
.scene-actions {
display: flex;
gap: 7px;
pointer-events: auto;
}
.view-button {
border: 1px solid rgba(255,255,255,.82);
border-radius: 10px;
padding: 9px 11px;
background: rgba(250,252,247,.88);
box-shadow: 0 7px 20px rgba(28,48,44,.10);
backdrop-filter: blur(12px);
cursor: pointer;
font-size: 11px;
font-weight: 650;
transition: background .15s, transform .15s;
}
.view-button:hover {
background: #fff;
transform: translateY(-1px);
}
.orientation {
position: absolute;
z-index: 2;
left: 20px;
bottom: 20px;
width: 155px;
padding: 13px;
border-radius: 13px;
color: #eaf0eb;
background: rgba(24,48,46,.88);
box-shadow: var(--shadow);
backdrop-filter: blur(12px);
pointer-events: none;
}
.orientation-row {
display: flex;
align-items: center;
gap: 12px;
}
.compass {
position: relative;
width: 38px;
height: 38px;
flex: 0 0 auto;
border: 1px solid rgba(255,255,255,.23);
border-radius: 50%;
}
.compass::before {
content: "";
position: absolute;
left: 18px;
top: 6px;
width: 1px;
height: 25px;
background: rgba(255,255,255,.45);
}
.compass::after {
content: "";
position: absolute;
left: 14px;
top: 7px;
width: 9px;
height: 9px;
border-top: 2px solid var(--accent);
border-right: 2px solid var(--accent);
transform: rotate(-45deg);
}
.compass-n {
position: absolute;
top: -12px;
left: 14px;
font-size: 9px;
font-weight: 800;
}
.orientation strong {
display: block;
font-size: 12px;
letter-spacing: .04em;
}
.orientation span {
display: block;
margin-top: 3px;
color: #aebdb8;
font-size: 10px;
}
.legend {
position: absolute;
z-index: 2;
right: 20px;
bottom: 20px;
display: flex;
gap: 13px;
padding: 10px 12px;
border: 1px solid rgba(255,255,255,.75);
border-radius: 11px;
background: rgba(250,252,247,.84);
box-shadow: 0 7px 20px rgba(28,48,44,.09);
backdrop-filter: blur(12px);
pointer-events: none;
}
.legend-item {
display: flex;
align-items: center;
gap: 6px;
color: #52635e;
font-size: 10px;
}
.legend-line {
width: 18px;
height: 2px;
background: var(--accent);
}
.legend-block {
width: 10px;
height: 10px;
border-radius: 2px;
background: #dc7548;
}
.legend-patch {
width: 13px;
height: 8px;
border: 1px solid #e5ad42;
background: rgba(242,186,61,.32);
}
#labels {
position: absolute;
inset: 0;
z-index: 3;
pointer-events: none;
overflow: hidden;
}
.world-label {
position: absolute;
left: 0;
top: 0;
padding: 5px 7px;
border-radius: 6px;
color: #29403c;
background: rgba(250,252,247,.92);
border: 1px solid rgba(255,255,255,.8);
box-shadow: 0 4px 14px rgba(24,48,46,.12);
font-size: 10px;
font-weight: 700;
white-space: nowrap;
transform: translate(-50%, -50%);
opacity: 0;
transition: opacity .15s;
}
.world-label.warm {
color: #9a572b;
border-color: rgba(233,147,69,.36);
}
.world-label.south {
color: #fff;
background: var(--ink);
border-color: var(--ink);
padding: 4px 7px;
}
.panel {
min-height: 0;
overflow-y: auto;
padding: 22px 22px 30px;
background: var(--panel);
border-left: 1px solid var(--line);
scrollbar-width: thin;
scrollbar-color: #bac5bf transparent;
}
.panel-heading {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 15px;
margin-bottom: 18px;
}
.panel-heading h2 {
margin: 0;
font-size: 17px;
letter-spacing: -.02em;
}
.panel-heading p {
margin: 5px 0 0;
color: var(--muted);
font-size: 11px;
line-height: 1.45;
}
.projection-badge {
min-width: 76px;
padding: 9px 10px;
border-radius: 10px;
text-align: right;
color: #9a572b;
background: #fff0e2;
border: 1px solid #f1d4b8;
}
.projection-badge span {
display: block;
font-size: 17px;
font-weight: 780;
line-height: 1;
}
.projection-badge small {
display: block;
margin-top: 4px;
font-size: 9px;
font-weight: 700;
letter-spacing: .08em;
text-transform: uppercase;
}
.section {
margin-top: 20px;
padding-top: 19px;
border-top: 1px solid var(--line);
}
.section-title {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-bottom: 15px;
}
.section-title h3 {
margin: 0;
font-size: 12px;
font-weight: 780;
letter-spacing: .08em;
text-transform: uppercase;
}
.section-title span {
color: var(--muted);
font-size: 10px;
}
.control {
margin-bottom: 17px;
}
.control-head {
display: flex;
justify-content: space-between;
align-items: baseline;
gap: 12px;
margin-bottom: 8px;
}
.control-head label {
font-size: 12px;
font-weight: 650;
}
.control-value {
color: #7a8783;
font-size: 11px;
font-variant-numeric: tabular-nums;
}
input[type="range"] {
width: 100%;
height: 18px;
margin: 0;
appearance: none;
background: transparent;
cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
height: 4px;
border-radius: 999px;
background: linear-gradient(to right, var(--accent) var(--fill, 50%), #dfe5de var(--fill, 50%));
}
input[type="range"]::-moz-range-track {
height: 4px;
border-radius: 999px;
background: #dfe5de;
}
input[type="range"]::-moz-range-progress {
height: 4px;
border-radius: 999px;
background: var(--accent);
}
input[type="range"]::-webkit-slider-thumb {
width: 15px;
height: 15px;
margin-top: -5.5px;
appearance: none;
border-radius: 50%;
border: 3px solid #fff;
background: var(--accent);
box-shadow: 0 1px 5px rgba(30,45,40,.26);
}
input[type="range"]::-moz-range-thumb {
width: 10px;
height: 10px;
border-radius: 50%;
border: 3px solid #fff;
background: var(--accent);
box-shadow: 0 1px 5px rgba(30,45,40,.26);
}
.metric-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 9px;
}
.metric {
min-height: 83px;
padding: 13px;
border: 1px solid var(--line);
border-radius: 12px;
background: #fff;
}
.metric-label {
color: var(--muted);
font-size: 9px;
font-weight: 750;
letter-spacing: .08em;
text-transform: uppercase;
}
.metric-value {
display: block;
margin-top: 7px;
font-size: 21px;
line-height: 1;
font-weight: 760;
letter-spacing: -.03em;
font-variant-numeric: tabular-nums;
}
.metric-note {
display: block;
margin-top: 6px;
color: #84908c;
font-size: 10px;
}
.status-row {
display: flex;
align-items: center;
gap: 9px;
margin-top: 10px;
padding: 10px 11px;
border-radius: 10px;
background: #f0f3ed;
}
.status-dot {
width: 8px;
height: 8px;
flex: 0 0 auto;
border-radius: 50%;
background: var(--equinox);
box-shadow: 0 0 0 4px rgba(221,168,70,.14);
}
.status-text {
color: #53635e;
font-size: 11px;
line-height: 1.35;
}
.season-list {
display: grid;
gap: 8px;
}
.season-card {
width: 100%;
padding: 12px;
display: grid;
grid-template-columns: 12px minmax(0, 1fr) auto;
gap: 10px;
align-items: center;
text-align: left;
border: 1px solid var(--line);
border-radius: 11px;
background: #fff;
cursor: pointer;
transition: border-color .15s, box-shadow .15s, transform .15s;
}
.season-card:hover {
transform: translateY(-1px);
border-color: #bcc8c1;
box-shadow: 0 5px 15px rgba(25,48,44,.07);
}
.season-card.active {
border-color: var(--season-color);
box-shadow: 0 0 0 2px color-mix(in srgb, var(--season-color) 17%, transparent);
}
.season-swatch {
width: 9px;
height: 30px;
border-radius: 99px;
background: var(--season-color);
}
.season-name {
display: flex;
align-items: center;
gap: 7px;
font-size: 12px;
font-weight: 720;
}
.season-name small {
color: #9aa49f;
font-size: 9px;
font-weight: 700;
letter-spacing: .06em;
}
.mini-track {
height: 4px;
margin-top: 7px;
overflow: hidden;
border-radius: 999px;
background: #e8ece7;
}
.mini-track span {
display: block;
width: 0;
height: 100%;
border-radius: inherit;
background: var(--season-color);
transition: width .2s ease;
}
.season-card-right {
text-align: right;
}
.season-alt {
display: block;
font-size: 14px;
font-weight: 780;
font-variant-numeric: tabular-nums;
}
.season-reach {
display: block;
margin-top: 4px;
color: var(--muted);
font-size: 9px;
}
.insight {
margin-top: 11px;
padding: 12px 13px;
border-left: 3px solid var(--accent);
border-radius: 0 9px 9px 0;
color: #5c6c67;
background: #fff4e9;
font-size: 11px;
line-height: 1.5;
}
.toggle-list {
display: grid;
gap: 11px;
}
.toggle {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
cursor: pointer;
font-size: 12px;
}
.toggle-copy {
display: flex;
flex-direction: column;
gap: 3px;
}
.toggle-copy small {
color: #8b9692;
font-size: 10px;
}
.switch {
position: relative;
width: 37px;
height: 21px;
flex: 0 0 auto;
}
.switch input {
position: absolute;
opacity: 0;
pointer-events: none;
}
.switch-track {
position: absolute;
inset: 0;
border-radius: 99px;
background: #d8dfd9;
transition: background .18s;
}
.switch-track::after {
content: "";
position: absolute;
width: 15px;
height: 15px;
left: 3px;
top: 3px;
border-radius: 50%;
background: #fff;
box-shadow: 0 1px 4px rgba(0,0,0,.18);
transition: transform .18s;
}
.switch input:checked + .switch-track {
background: var(--accent);
}
.switch input:checked + .switch-track::after {
transform: translateX(16px);
}
.fine-print {
margin-top: 18px;
color: #98a29e;
font-size: 9px;
line-height: 1.55;
}
@media (max-width: 900px) {
html, body { overflow: auto; }
.app {
height: auto;
min-height: 100%;
grid-template-rows: 64px auto;
}
.workspace {
grid-template-columns: 1fr;
}
.viewport {
height: 65vh;
min-height: 480px;
}
.panel {
overflow: visible;
border-left: 0;
border-top: 1px solid var(--line);
}
.top-meta .meta-pill:first-child { display: none; }
}
@media (max-width: 560px) {
.topbar { padding: 0 14px; }
.brand-subtitle { display: none; }
.top-meta .meta-pill:not(:last-child) { display: none; }
.scene-header { left: 12px; right: 12px; top: 12px; }
.scene-title { padding: 10px 12px; }
.scene-title p { display: none; }
.scene-actions { flex-direction: column; }
.view-button { padding: 7px 9px; }
.orientation { left: 12px; bottom: 12px; transform: scale(.9); transform-origin: left bottom; }
.legend { right: 12px; bottom: 12px; flex-direction: column; gap: 7px; }
.panel { padding: 20px 16px 30px; }
}
</style>
</head>
<body>
<div class="app">
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true"><i></i><i></i><i></i></div>
<div class="brand-copy">
<div class="brand-title">Solstice / Voxel Shade Lab</div>
<div class="brand-subtitle">Solar-noon study for a Northern Hemisphere, south-facing window</div>
</div>
</div>
<div class="top-meta">
<div class="meta-pill"><strong id="headerLatitude">40° N</strong></div>
<div class="meta-pill">Solar noon · azimuth <strong>180°</strong></div>
<div class="meta-pill">North Hemisphere</div>
</div>
</header>
<main class="workspace">
<section class="viewport" id="viewport" aria-label="Interactive 3D overhang study">
<div class="scene-header">
<div class="scene-title">
<div class="eyebrow">South elevation / live section</div>
<h1 id="sceneSeasonTitle">March equinox · 50.0° altitude</h1>
<p>Drag to orbit · scroll to zoom · select a season below</p>
</div>
<div class="scene-actions">
<button class="view-button" id="frontView" type="button">Front</button>
<button class="view-button" id="planView" type="button">Plan</button>
<button class="view-button" id="resetView" type="button">Reset</button>
</div>
</div>
<div id="labels" aria-hidden="true">
<div class="world-label" id="depthLabel"></div>
<div class="world-label warm" id="reachLabel"></div>
<div class="world-label south" id="southLabel">S · 180°</div>
</div>
<div class="orientation">
<div class="orientation-row">
<div class="compass"><span class="compass-n">N</span></div>
<div>
<strong>South-facing façade</strong>
<span>Exterior +Z · interior −Z</span>
</div>
</div>
</div>
<div class="legend">
<div class="legend-item"><span class="legend-line"></span>Sun rays</div>
<div class="legend-item"><span class="legend-block"></span>Voxel overhang</div>
<div class="legend-item"><span class="legend-patch"></span>Floor light</div>
</div>
</section>
<aside class="panel">
<div class="panel-heading">
<div>
<div class="eyebrow">Overhang controls</div>
<h2>Shape the solar shadow</h2>
<p>Projection is assembled from square voxel blocks. All angles refer to local solar noon.</p>
</div>
<div class="projection-badge">
<span id="projectionValue">1.50 m</span>
<small>Projection</small>
</div>
</div>
<section class="section">
<div class="section-title">
<h3>Voxel assembly</h3>
<span id="blockCount">60 blocks</span>
</div>
<div class="control">
<div class="control-head">
<label for="layers">Depth layers</label>
<span class="control-value" id="layersValue">5 layers</span>
</div>
<input id="layers" data-control="layers" type="range" min="1" max="8" step="1" value="5" />
</div>
<div class="control">
<div class="control-head">
<label for="voxel">Voxel size</label>
<span class="control-value" id="voxelValue">0.30 m</span>
</div>
<input id="voxel" data-control="voxel" type="range" min="0.20" max="0.45" step="0.05" value="0.30" />
</div>
<div class="control">
<div class="control-head">
<label for="clearance">Clearance above window</label>
<span class="control-value" id="clearanceValue">0.20 m</span>
</div>
<input id="clearance" data-control="clearance" type="range" min="0.05" max="0.60" step="0.05" value="0.20" />
</div>
<div class="control">
<div class="control-head">
<label for="margin">Wing margin</label>
<span class="control-value" id="marginValue">0.55 m each side</span>
</div>
<input id="margin" data-control="margin" type="range" min="0.20" max="1.00" step="0.05" value="0.55" />
</div>
</section>
<section class="section">
<div class="section-title">
<h3>Selected condition</h3>
<span id="selectedSeasonName">Equinox</span>
</div>
<div class="metric-grid">
<div class="metric">
<span class="metric-label">Sun altitude</span>
<strong class="metric-value" id="altitudeValue">50.0°</strong>
<span class="metric-note">above the horizon</span>
</div>
<div class="metric">
<span class="metric-label">Window exposed</span>
<strong class="metric-value" id="exposureValue">73%</strong>
<span class="metric-note">direct vertical opening</span>
</div>
<div class="metric">
<span class="metric-label">Direct reach</span>
<strong class="metric-value" id="reachValue">2.10 m</strong>
<span class="metric-note" id="reachNote">into the room</span>
</div>
<div class="metric">
<span class="metric-label">Voxel depth</span>
<strong class="metric-value" id="voxelDepthValue">5 × 0.30</strong>
<span class="metric-note">layers × block size</span>
</div>
</div>
<div class="status-row">
<span class="status-dot" id="statusDot"></span>
<span class="status-text" id="statusText">Partially shaded window; direct light reaches the floor.</span>
</div>
</section>
<section class="section">
<div class="section-title">
<h3>Seasonal comparison</h3>
<span>Click to select</span>
</div>
<div class="season-list">
<button class="season-card" data-season="winter" style="--season-color: var(--winter)" type="button">
<span class="season-swatch"></span>
<span>
<span class="season-name">Winter solstice <small>21 DEC</small></span>
<span class="mini-track"><span></span></span>
</span>
<span class="season-card-right">
<span class="season-alt">26.6°</span>
<span class="season-reach">0.00 m reach</span>
</span>
</button>
<button class="season-card active" data-season="equinox" style="--season-color: var(--equinox)" type="button">
<span class="season-swatch"></span>
<span>
<span class="season-name">March equinox <small>20 MAR</small></span>
<span class="mini-track"><span></span></span>
</span>
<span class="season-card-right">
<span class="season-alt">50.0°</span>
<span class="season-reach">0.00 m reach</span>
</span>
</button>
<button class="season-card" data-season="summer" style="--season-color: var(--summer)" type="button">
<span class="season-swatch"></span>
<span>
<span class="season-name">Summer solstice <small>21 JUN</small></span>
<span class="mini-track"><span></span></span>
</span>
<span class="season-card-right">
<span class="season-alt">73.4°</span>
<span class="season-reach">0.00 m reach</span>
</span>
</button>
</div>
<div class="insight" id="insightText"></div>
</section>
<section class="section">
<div class="section-title">
<h3>Site & display</h3>
<span>Solar noon</span>
</div>
<div class="control">
<div class="control-head">
<label for="latitude">Reference latitude</label>
<span class="control-value" id="latitudeValue">40° N</span>
</div>
<input id="latitude" data-control="latitude" type="range" min="25" max="60" step="1" value="40" />
</div>
<div class="toggle-list">
<label class="toggle">
<span class="toggle-copy">
<span>Sun-ray bundles</span>
<small>Show direct and comparative seasonal rays</small>
</span>
<span class="switch">
<input id="showRays" type="checkbox" checked />
<span class="switch-track"></span>
</span>
</label>
<label class="toggle">
<span class="toggle-copy">
<span>Overlay other seasons</span>
<small>Compare all three noon conditions</small>
</span>
<span class="switch">
<input id="compareSeasons" type="checkbox" checked />
<span class="switch-track"></span>
</span>
</label>
<label class="toggle">
<span class="toggle-copy">
<span>Room section</span>
<small>Remove the near wall and ceiling</small>
</span>
<span class="switch">
<input id="sectionView" type="checkbox" checked />
<span class="switch-track"></span>
</span>
</label>
</div>
<div class="fine-print">
Noon solar altitude is calculated as 90° − latitude + solar declination.
Light penetration assumes clear direct sun, a level horizon, and an unobstructed
rectangular window. The room is 4.8 m deep.
</div>
</section>
</aside>
</main>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const $ = (selector) => document.querySelector(selector);
const $$ = (selector) => [...document.querySelectorAll(selector)];
const VIEWPORT = $("#viewport");
const LABEL_LAYER = $("#labels");
const WIN = {
width: 2.40,
sill: 0.90,
top: 2.50,
get height() { return this.top - this.sill; }
};
const ROOM = {
depth: 4.80,
floor: 0.00,
facadeWidth: 7.20,
facadeHeight: 5.60
};
const SEASONS = {
winter: { name: "Winter solstice", short: "Winter", date: "21 DEC", declination: -23.44, color: 0x6c9fc7 },
equinox: { name: "March equinox", short: "Equinox", date: "20 MAR", declination: 0, color: 0xdda846 },
summer: { name: "Summer solstice", short: "Summer", date: "21 JUN", declination: 23.44, color: 0xd96f52 }
};
const state = {
season: "equinox",
layers: 5,
voxel: 0.30,
clearance: 0.20,
margin: 0.55,
latitude: 40,
showRays: true,
compareSeasons: true,
sectionView: true
};
let overhangWidth = 0;
let overhangBottom = 0;
let projection = 0;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce3df);
scene.fog = new THREE.Fog(0xdce3df, 19, 38);
const camera = new THREE.PerspectiveCamera(42, 1, 0.05, 100);
const renderer = new THREE.WebGLRenderer({ antialias: true, powerPreference: "high-performance" });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
renderer.domElement.setAttribute("aria-label", "Three-dimensional south-facing window and voxel overhang");
VIEWPORT.prepend(renderer.domElement);
const cameraState = {
target: new THREE.Vector3(0, 1.65, -0.45),
radius: 11.8,
theta: 0.66,
phi: 1.19
};
function applyCamera() {
const { target, radius, theta, phi } = cameraState;
camera.position.set(
target.x + radius * Math.sin(phi) * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + radius * Math.sin(phi) * Math.cos(theta)
);
camera.lookAt(target);
}
const hemisphere = new THREE.HemisphereLight(0xe9f3ff, 0x8d7962, 1.75);
scene.add(hemisphere);
const ambient = new THREE.AmbientLight(0xffffff, 0.20);
scene.add(ambient);
const sunLight = new THREE.DirectionalLight(0xffedc7, 3.5);
sunLight.castShadow = true;
sunLight.shadow.mapSize.set(2048, 2048);
sunLight.shadow.camera.left = -7;
sunLight.shadow.camera.right = 7;
sunLight.shadow.camera.top = 8;
sunLight.shadow.camera.bottom = -5;
sunLight.shadow.camera.near = 0.1;
sunLight.shadow.camera.far = 35;
sunLight.shadow.bias = -0.00035;
sunLight.shadow.normalBias = 0.025;
scene.add(sunLight);
scene.add(sunLight.target);
const sunGroup = new THREE.Group();
const sunCore = new THREE.Mesh(
new THREE.SphereGeometry(0.31, 24, 16),
new THREE.MeshBasicMaterial({ color: 0xffc85c, fog: false })
);
const sunHalo = new THREE.Mesh(
new THREE.SphereGeometry(0.52, 24, 16),
new THREE.MeshBasicMaterial({
color: 0xffd782,
transparent: true,
opacity: 0.12,
side: THREE.BackSide,
depthWrite: false,
fog: false
})
);
sunGroup.add(sunHalo, sunCore);
scene.add(sunGroup);
const materials = {
wall: new THREE.MeshStandardMaterial({ color: 0xd9d3c4, roughness: 0.88 }),
wallSide: new THREE.MeshStandardMaterial({ color: 0xcec8b9, roughness: 0.9 }),
floor: new THREE.MeshStandardMaterial({ color: 0xb9a78b, roughness: 0.82 }),
frame: new THREE.MeshStandardMaterial({ color: 0x2d403d, roughness: 0.35, metalness: 0.55 }),
interior: new THREE.MeshStandardMaterial({ color: 0xe5dfd1, roughness: 0.95 }),
wood: new THREE.MeshStandardMaterial({ color: 0x9d7551, roughness: 0.72 }),
pot: new THREE.MeshStandardMaterial({ color: 0xb96e4d, roughness: 0.9 }),
leaf: new THREE.MeshStandardMaterial({ color: 0x58785c, roughness: 0.85 })
};
function addBox(width, height, depth, material, x, y, z, castShadow = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(width, height, depth), material);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
// Ground and coordinate grid.
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(32, 32),
new THREE.MeshStandardMaterial({ color: 0xcdd5cf, roughness: 1 })
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.13;
ground.receiveShadow = true;
scene.add(ground);
const grid = new THREE.GridHelper(30, 30, 0xaab7af, 0xbcc7c0);
grid.position.y = -0.115;
grid.material.transparent = true;
grid.material.opacity = 0.48;
scene.add(grid);
// Façade assembled around a real opening so shadows can pass through it.
const facadeZ = 0;
const wallDepth = 0.28;
const sideWidth = (ROOM.facadeWidth - WIN.width) / 2;
addBox(sideWidth, ROOM.facadeHeight, wallDepth, materials.wall,
-(WIN.width / 2 + sideWidth / 2), ROOM.facadeHeight / 2, facadeZ);
addBox(sideWidth, ROOM.facadeHeight, wallDepth, materials.wall,
WIN.width / 2 + sideWidth / 2, ROOM.facadeHeight / 2, facadeZ);
addBox(WIN.width, WIN.sill, wallDepth, materials.wall,
0, WIN.sill / 2, facadeZ);
addBox(WIN.width, ROOM.facadeHeight - WIN.top, wallDepth, materials.wall,
0, (ROOM.facadeHeight + WIN.top) / 2, facadeZ);
// Interior floor, back wall and far side wall.
addBox(ROOM.facadeWidth, 0.12, ROOM.depth, materials.floor,
0, -0.06, -ROOM.depth / 2, false);
addBox(ROOM.facadeWidth, ROOM.facadeHeight, 0.16, materials.interior,
0, ROOM.facadeHeight / 2, -ROOM.depth - 0.08);
addBox(0.16, ROOM.facadeHeight, ROOM.depth, materials.wallSide,
-ROOM.facadeWidth / 2 + 0.08, ROOM.facadeHeight / 2, -ROOM.depth / 2);
// Near wall and ceiling form the optional closed-room section.
const sectionShell = new THREE.Group();
const nearWall = new THREE.Mesh(
new THREE.BoxGeometry(0.16, ROOM.facadeHeight, ROOM.depth),
materials.wallSide
);
nearWall.position.set(ROOM.facadeWidth / 2 - 0.08, ROOM.facadeHeight / 2, -ROOM.depth / 2);
nearWall.castShadow = true;
nearWall.receiveShadow = true;
const ceiling = new THREE.Mesh(
new THREE.BoxGeometry(ROOM.facadeWidth, 0.16, ROOM.depth),
materials.interior
);
ceiling.position.set(0, ROOM.facadeHeight - 0.08, -ROOM.depth / 2);
ceiling.castShadow = true;
ceiling.receiveShadow = true;
sectionShell.add(nearWall, ceiling);
scene.add(sectionShell);
// Window frame and glazing.
const frameZ = 0.16;
addBox(0.09, WIN.height + 0.12, 0.12, materials.frame,
-WIN.width / 2, (WIN.sill + WIN.top) / 2, frameZ);
addBox(0.09, WIN.height + 0.12, 0.12, materials.frame,
WIN.width / 2, (WIN.sill + WIN.top) / 2, frameZ);
addBox(WIN.width + 0.09, 0.09, 0.12, materials.frame,
0, WIN.sill, frameZ);
addBox(WIN.width + 0.09, 0.09, 0.12, materials.frame,
0, WIN.top, frameZ);
addBox(0.045, WIN.height, 0.09, materials.frame,
0, (WIN.sill + WIN.top) / 2, frameZ);
const glass = new THREE.Mesh(
new THREE.BoxGeometry(WIN.width - 0.06, WIN.height - 0.06, 0.018),
new THREE.MeshPhysicalMaterial({
color: 0xb6d9df,
transparent: true,
opacity: 0.13,
roughness: 0.12,
metalness: 0,
depthWrite: false,
side: THREE.DoubleSide
})
);
glass.position.set(0, (WIN.sill + WIN.top) / 2, 0.025);
scene.add(glass);
// Quiet interior reference objects.
addBox(1.45, 0.10, 0.58, materials.wood, -1.55, 0.70, -2.75);
addBox(0.09, 0.68, 0.09, materials.frame, -2.10, 0.34, -2.50);
addBox(0.09, 0.68, 0.09, materials.frame, -1.00, 0.34, -2.50);
const pot = new THREE.Mesh(new THREE.CylinderGeometry(0.18, 0.14, 0.28, 18), materials.pot);
pot.position.set(1.72, 0.14, -1.72);
pot.castShadow = true;
scene.add(pot);
for (let i = 0; i < 6; i++) {
const leaf = new THREE.Mesh(new THREE.SphereGeometry(0.17, 12, 8), materials.leaf);
leaf.scale.set(0.72, 1.6, 0.55);
leaf.position.set(
1.72 + Math.sin(i * 2.1) * 0.10,
0.42 + i * 0.045,
-1.72 + Math.cos(i * 1.7) * 0.10
);
leaf.rotation.z = Math.sin(i) * 0.38;
leaf.castShadow = true;
scene.add(leaf);
}
// Overhang instances.
const overhangMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
vertexColors: true,
roughness: 0.68,
metalness: 0.02
});
let overhangMesh = null;
function buildOverhang() {
if (overhangMesh) {
scene.remove(overhangMesh);
overhangMesh.geometry.dispose();
}
projection = state.layers * state.voxel;
overhangBottom = WIN.top + state.clearance;
const columns = Math.max(1, Math.round((WIN.width + state.margin * 2) / state.voxel));
overhangWidth = columns * state.voxel;
const count = columns * state.layers;
overhangMesh = new THREE.InstancedMesh(
new THREE.BoxGeometry(1, 1, 1),
overhangMaterial,
count
);
overhangMesh.castShadow = true;
overhangMesh.receiveShadow = true;
overhangMesh.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
const dummy = new THREE.Object3D();
const color = new THREE.Color();
let index = 0;
for (let layer = 0; layer < state.layers; layer++) {
for (let column = 0; column < columns; column++) {
dummy.position.set(
-overhangWidth / 2 + (column + 0.5) * state.voxel,
overhangBottom + state.voxel / 2,
(layer + 0.5) * state.voxel
);
dummy.scale.set(state.voxel, state.voxel, state.voxel);
dummy.updateMatrix();
overhangMesh.setMatrixAt(index, dummy.matrix);
const lightness = 0.49 + ((column * 7 + layer * 3) % 5) * 0.025;
color.setHSL(0.065 + ((column + layer) % 3) * 0.006, 0.49, lightness);
overhangMesh.setColorAt(index, color);
index++;
}
}
overhangMesh.instanceMatrix.needsUpdate = true;
if (overhangMesh.instanceColor) overhangMesh.instanceColor.needsUpdate = true;
scene.add(overhangMesh);
$("#blockCount").textContent = `${count} blocks`;
}
// A geometric sunlight patch supplements the renderer shadows.
const sunPatch = new THREE.Mesh(
new THREE.PlaneGeometry(1, 1),
new THREE.MeshBasicMaterial({
color: 0xf4b840,
transparent: true,
opacity: 0.19,
depthWrite: false,
side: THREE.DoubleSide,
polygonOffset: true,
polygonOffsetFactor: -1
})
);
sunPatch.rotation.x = -Math.PI / 2;
sunPatch.renderOrder = 2;
scene.add(sunPatch);
const rayGroup = new THREE.Group();
scene.add(rayGroup);
const dimensionGroup = new THREE.Group();
scene.add(dimensionGroup);
const dimensionMaterial = new THREE.LineBasicMaterial({
color: 0x3c514d,
transparent: true,
opacity: 0.62
});
const reachDimensionMaterial = new THREE.LineBasicMaterial({
color: 0xd7923f,
transparent: true,
opacity: 0.86
});
function clearGeometryGroup(group) {
group.traverse((object) => {
if (object.geometry) object.geometry.dispose();
});
group.clear();
}
function solarAltitude(seasonKey) {
return 90 - state.latitude + SEASONS[seasonKey].declination;
}
function seasonData(seasonKey) {
const altitude = solarAltitude(seasonKey);
const tangent = Math.tan(THREE.MathUtils.degToRad(altitude));
const shadowY = overhangBottom - projection * tangent;
let highestLit = 0;
if (shadowY > WIN.sill) {
highestLit = Math.min(WIN.top, shadowY);
}
const exposure = Math.max(0, (highestLit - WIN.sill) / WIN.height);
const rawReach = highestLit > WIN.sill
? (highestLit - ROOM.floor) / tangent
: 0;
const reach = Math.min(ROOM.depth, rawReach);
const reachesBackWall = rawReach >= ROOM.depth - 0.001;
return {
altitude,
tangent,
shadowY,
highestLit,
exposure,
reach,
reachesBackWall
};
}
function updateLighting() {
const altitude = solarAltitude(state.season);
const radians = THREE.MathUtils.degToRad(altitude);
const target = new THREE.Vector3(0, 1, -0.8);
sunLight.position.set(
target.x,
target.y + Math.sin(radians) * 14,
target.z + Math.cos(radians) * 14
);
sunLight.target.position.copy(target);
sunLight.target.updateMatrixWorld();
const visualRadius = 7.8;
sunGroup.position.set(
0,
target.y + Math.sin(radians) * visualRadius,
target.z + Math.cos(radians) * visualRadius
);
}
function clearRayGeometry() {
rayGroup.traverse((object) => {
if (object.geometry) object.geometry.dispose();
if (object.material) object.material.dispose();
});
rayGroup.clear();
}
function rebuildRays() {
clearRayGeometry();
if (!state.showRays) return;
const keys = state.compareSeasons
? Object.keys(SEASONS)
: [state.season];
const outsideZ = 4.25;
for (const key of keys) {
const data = seasonData(key);
if (data.exposure <= 0) continue;
const points = [];
const entries = [
WIN.sill + 0.07,
WIN.sill + WIN.height * 0.48,
Math.max(WIN.sill + 0.12, data.highestLit - 0.06)
];
const uniqueEntries = [...new Set(entries.map((v) => Number(v.toFixed(3))))];
for (const x of [-0.88, 0, 0.88]) {
for (const entryY of uniqueEntries) {
if (entryY < WIN.sill || entryY > data.highestLit + 0.001) continue;
const start = new THREE.Vector3(
x,
entryY + outsideZ * data.tangent,
outsideZ
);
const floorDepth = (entryY - ROOM.floor) / data.tangent;
let end;
if (floorDepth <= ROOM.depth) {
end = new THREE.Vector3(x, 0.012, -floorDepth);
} else {
end = new THREE.Vector3(
x,
entryY - ROOM.depth * data.tangent,
-ROOM.depth
);
}
points.push(start, end);
}
}
if (!points.length) continue;
const geometry = new THREE.BufferGeometry().setFromPoints(points);
const material = new THREE.LineBasicMaterial({
color: SEASONS[key].color,
transparent: true,
opacity: key === state.season ? 0.82 : 0.20,
depthWrite: false
});
const lines = new THREE.LineSegments(geometry, material);
rayGroup.add(lines);
}
}
function updateSunPatch() {
const data = seasonData(state.season);
if (data.exposure <= 0) {
sunPatch.visible = false;
return;
}
const minimumFloorDepth = (WIN.sill - ROOM.floor) / data.tangent;
const maximumFloorDepth = Math.min(
(data.highestLit - ROOM.floor) / data.tangent,
ROOM.depth
);
if (maximumFloorDepth <= minimumFloorDepth) {
sunPatch.visible = false;
return;
}
sunPatch.visible = true;
const depth = maximumFloorDepth - minimumFloorDepth;
sunPatch.scale.set(WIN.width - 0.15, depth, 1);
sunPatch.position.set(
0,
0.012,
-(maximumFloorDepth + minimumFloorDepth) / 2
);
}
function addDimensionLine(a, b, tickA, tickB, material) {
const geometry = new THREE.BufferGeometry().setFromPoints([a, b, tickA, tickB]);
const line = new THREE.LineSegments(geometry, material);
dimensionGroup.add(line);
}
function updateDimensions() {
clearGeometryGroup(dimensionGroup);
const projectionX = overhangWidth / 2 + 0.20;
const y = overhangBottom - 0.10;
addDimensionLine(
new THREE.Vector3(projectionX, y, 0),
new THREE.Vector3(projectionX, y, projection),
new THREE.Vector3(projectionX - 0.09, y, 0),
new THREE.Vector3(projectionX - 0.09, y, projection),
dimensionMaterial
);
const data = seasonData(state.season);
if (data.exposure > 0) {
const reachX = WIN.width / 2 + 0.42;
addDimensionLine(
new THREE.Vector3(reachX, 0.025, 0),
new THREE.Vector3(reachX, 0.025, -data.reach),
new THREE.Vector3(reachX - 0.08, 0.025, 0),
new THREE.Vector3(reachX - 0.08, 0.025, -data.reach),
reachDimensionMaterial
);
}
// Ground compass pointing toward south (+Z).
addDimensionLine(
new THREE.Vector3(-3.45, 0.015, 2.15),
new THREE.Vector3(-3.45, 0.015, 3.25),
new THREE.Vector3(-3.60, 0.015, 2.95),
new THREE.Vector3(-3.30, 0.015, 2.95),
reachDimensionMaterial
);
}
function formatReach(value) {
return `${value.toFixed(2)} m`;
}
function updateUI() {
const selected = seasonData(state.season);
const season = SEASONS[state.season];
$("#layersValue").textContent = `${state.layers} ${state.layers === 1 ? "layer" : "layers"}`;
$("#voxelValue").textContent = `${state.voxel.toFixed(2)} m`;
$("#clearanceValue").textContent = `${state.clearance.toFixed(2)} m`;
$("#marginValue").textContent = `${state.margin.toFixed(2)} m each side`;
$("#latitudeValue").textContent = `${state.latitude}° N`;
$("#headerLatitude").textContent = `${state.latitude}° N`;
$("#projectionValue").textContent = `${projection.toFixed(2)} m`;
$("#altitudeValue").textContent = `${selected.altitude.toFixed(1)}°`;
$("#exposureValue").textContent = `${Math.round(selected.exposure * 100)}%`;
$("#reachValue").textContent = formatReach(selected.reach);
$("#reachNote").textContent = selected.reachesBackWall ? "reaches the back wall" : "into the room";
$("#voxelDepthValue").textContent = `${state.layers} × ${state.voxel.toFixed(2)}`;
$("#selectedSeasonName").textContent = season.short;
$("#sceneSeasonTitle").textContent = `${season.name} · ${selected.altitude.toFixed(1)}° altitude`;
let status;
let statusColor;
if (selected.exposure <= 0.001) {
status = "The overhang fully shades the glazing at this sun altitude.";
statusColor = "#d96f52";
} else if (selected.exposure > 0.995) {
status = "No overhang shadow reaches the glazing at this sun altitude.";
statusColor = "#6c9fc7";
} else {
status = `${Math.round(selected.exposure * 100)}% of the glazing remains sunlit; direct light reaches ${formatReach(selected.reach)} into the room.`;
statusColor = "#dda846";
}
$("#statusText").textContent = status;
$("#statusDot").style.background = statusColor;
$("#statusDot").style.boxShadow = `0 0 0 4px ${statusColor}24`;
$$(".season-card").forEach((card) => {
const key = card.dataset.season;
const data = seasonData(key);
card.classList.toggle("active", key === state.season);
card.querySelector(".season-alt").textContent = `${data.altitude.toFixed(1)}°`;
card.querySelector(".season-reach").textContent = `${formatReach(data.reach)} reach`;
card.querySelector(".mini-track span").style.width = `${data.exposure * 100}%`;
});
const summer = seasonData("summer");
const winter = seasonData("winter");
if (summer.exposure <= 0.001) {
$("#insightText").textContent =
`At ${state.latitude}° N, the ${projection.toFixed(2)} m projection blocks summer-solstice sun at the glazing while retaining ${Math.round(winter.exposure * 100)}% winter exposure.`;
} else if (summer.exposure < 0.995) {
$("#insightText").textContent =
`Summer keeps ${Math.round(summer.exposure * 100)}% of the glazing exposed. The selected ${state.layers}-layer projection allows direct summer light ${formatReach(summer.reach)} into the room.`;
} else {
$("#insightText").textContent =
`The glazing remains fully exposed at summer noon. Increase the projection or lower the overhang to introduce stronger seasonal shade.`;
}
$$('input[type="range"]').forEach((input) => {
const percent = ((input.value - input.min) / (input.max - input.min)) * 100;
input.style.setProperty("--fill", `${percent}%`);
});
}
function refresh() {
buildOverhang();
updateLighting();
rebuildRays();
updateSunPatch();
updateDimensions();
updateUI();
}
// Direct, dependency-free camera controls.
const pointers = new Map();
let previousPinchDistance = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 2) {
const points = [...pointers.values()];
previousPinchDistance = Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 1) {
cameraState.theta -= dx * 0.005;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - dy * 0.004,
0.12,
1.53
);
} else if (pointers.size === 2) {
const points = [...pointers.values()];
const distance = Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
if (previousPinchDistance > 0) {
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * (previousPinchDistance / distance),
5.2,
22
);
}
previousPinchDistance = distance;
}
applyCamera();
});
function endPointer(event) {
pointers.delete(event.pointerId);
if (pointers.size < 2) previousPinchDistance = 0;
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener("contextmenu", (event) => event.preventDefault());
renderer.domElement.addEventListener("wheel", (event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * Math.exp(event.deltaY * 0.001),
5.2,
22
);
applyCamera();
}, { passive: false });
renderer.domElement.addEventListener("dblclick", resetCamera);
function resetCamera() {
cameraState.target.set(0, 1.65, -0.45);
cameraState.radius = 11.8;
cameraState.theta = 0.66;
cameraState.phi = 1.19;
applyCamera();
}
$("#resetView").addEventListener("click", resetCamera);
$("#frontView").addEventListener("click", () => {
cameraState.target.set(0, 1.75, -0.55);
cameraState.radius = 10.8;
cameraState.theta = 0;
cameraState.phi = 1.47;
applyCamera();
});
$("#planView").addEventListener("click", () => {
cameraState.target.set(0, 0.6, -1.25);
cameraState.radius = 11.5;
cameraState.theta = 0;
cameraState.phi = 0.13;
applyCamera();
});
$$('input[data-control]').forEach((input) => {
input.addEventListener("input", () => {
state[input.dataset.control] = Number(input.value);
refresh();
});
});
$$(".season-card").forEach((card) => {
card.addEventListener("click", () => {
state.season = card.dataset.season;
refresh();
});
});
$("#showRays").addEventListener("change", (event) => {
state.showRays = event.target.checked;
rebuildRays();
});
$("#compareSeasons").addEventListener("change", (event) => {
state.compareSeasons = event.target.checked;
rebuildRays();
});
$("#sectionView").addEventListener("change", (event) => {
state.sectionView = event.target.checked;
sectionShell.visible = !state.sectionView;
});
function placeLabel(element, position) {
const projected = position.clone().project(camera);
const visible = projected.z > -1 && projected.z < 1 &&
projected.x > -1.15 && projected.x < 1.15 &&
projected.y > -1.15 && projected.y < 1.15;
if (!visible) {
element.style.opacity = "0";
return;
}
const x = (projected.x * 0.5 + 0.5) * VIEWPORT.clientWidth;
const y = (-projected.y * 0.5 + 0.5) * VIEWPORT.clientHeight;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
element.style.opacity = "1";
}
function updateLabels() {
const selected = seasonData(state.season);
$("#depthLabel").textContent = `D ${projection.toFixed(2)} m`;
placeLabel(
$("#depthLabel"),
new THREE.Vector3(overhangWidth / 2 + 0.26, overhangBottom - 0.05, projection / 2)
);
const reachLabel = $("#reachLabel");
if (selected.exposure > 0) {
reachLabel.textContent = `${formatReach(selected.reach)} direct reach`;
placeLabel(
reachLabel,
new THREE.Vector3(WIN.width / 2 + 0.55, 0.10, -selected.reach / 2)
);
} else {
reachLabel.style.opacity = "0";
}
placeLabel(
$("#southLabel"),
new THREE.Vector3(-3.45, 0.12, 3.48)
);
}
function resize() {
const width = VIEWPORT.clientWidth;
const height = VIEWPORT.clientHeight;
renderer.setSize(width, height, false);
camera.aspect = width / Math.max(1, height);
camera.updateProjectionMatrix();
}
new ResizeObserver(resize).observe(VIEWPORT);
sectionShell.visible = !state.sectionView;
applyCamera();
resize();
refresh();
function animate(time) {
requestAnimationFrame(animate);
const pulse = 1 + Math.sin(time * 0.0018) * 0.045;
sunHalo.scale.setScalar(pulse);
renderer.render(scene, camera);
updateLabels();
}
requestAnimationFrame(animate);
</script>
</body>
</html>
```