Prompt specification
Build or customize the Three.js 3D scene "Industrial catalyst teaching cutaway" 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: Industrial catalyst teaching cutaway
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/industrial-catalyst-teaching-cutaway-x1927
Scene Description Prompt:
Make a voxel Three.js scene in a self-contained HTML file using cdnjs: industrial catalyst teaching cutaway. Compose a porous support with schematic active sites and a separate energy diagram; label geometry illustrative and omit real reactor operating conditions or production instructions.
Working Three.js Starter (industrial-catalyst-teaching-cutaway-x1927):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Industrial Catalyst Teaching Cutaway</title>
<style>
:root {
color-scheme: dark;
--bg: #071117;
--panel: #0d1a22;
--panel-2: #11242e;
--line: rgba(151, 196, 211, 0.18);
--text: #eaf4f5;
--muted: #91aab3;
--cyan: #65e2d3;
--amber: #f3ba62;
--coral: #ef765e;
--green: #8edb8a;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
background: var(--bg);
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
body {
overflow: hidden;
}
button {
font: inherit;
}
#app {
display: grid;
grid-template-columns: minmax(0, 1fr) 390px;
width: 100%;
height: 100%;
}
#stage {
position: relative;
min-width: 0;
min-height: 0;
overflow: hidden;
background:
radial-gradient(circle at 48% 42%, rgba(40, 91, 104, 0.2), transparent 38%),
#071117;
}
#stage > canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
outline: none;
}
.hero {
position: absolute;
z-index: 5;
top: 26px;
left: 28px;
max-width: 510px;
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
color: var(--cyan);
font-size: 11px;
font-weight: 750;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 24px;
height: 1px;
background: currentColor;
box-shadow: 0 0 8px rgba(101, 226, 211, 0.6);
}
h1 {
margin: 10px 0 9px;
max-width: 470px;
font-size: clamp(26px, 3vw, 42px);
line-height: 1.04;
letter-spacing: -0.035em;
font-weight: 760;
}
.hero p {
max-width: 470px;
margin: 0;
color: var(--muted);
font-size: 14px;
line-height: 1.55;
}
.view-controls {
position: absolute;
z-index: 8;
top: 24px;
right: 24px;
display: flex;
gap: 8px;
padding: 6px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(8, 20, 27, 0.76);
backdrop-filter: blur(14px);
}
.view-controls button {
min-height: 34px;
padding: 0 12px;
border: 1px solid transparent;
border-radius: 8px;
background: transparent;
color: var(--muted);
cursor: pointer;
font-size: 12px;
font-weight: 700;
transition: 160ms ease;
}
.view-controls button:hover,
.view-controls button[aria-pressed="true"] {
color: var(--text);
border-color: rgba(101, 226, 211, 0.28);
background: rgba(101, 226, 211, 0.1);
}
.legend {
position: absolute;
z-index: 7;
left: 26px;
bottom: 56px;
display: grid;
gap: 8px;
padding: 13px 15px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(8, 19, 26, 0.78);
backdrop-filter: blur(14px);
pointer-events: none;
}
.legend-row {
display: flex;
align-items: center;
gap: 10px;
color: #b9cbd1;
font-size: 11px;
}
.swatch {
width: 10px;
height: 10px;
border-radius: 2px;
box-shadow: 0 0 10px currentColor;
}
.swatch.support {
color: #b49b7c;
background: #b49b7c;
}
.swatch.site {
color: var(--cyan);
background: var(--cyan);
}
.swatch.ligand {
color: var(--amber);
background: var(--amber);
}
.swatch.reactant {
color: var(--coral);
background: var(--coral);
}
.swatch.product {
color: var(--green);
background: var(--green);
}
.orbit-hint {
position: absolute;
z-index: 6;
right: 25px;
bottom: 58px;
color: #7f9aa4;
font-size: 11px;
letter-spacing: 0.03em;
pointer-events: none;
}
.disclaimer {
position: absolute;
z-index: 6;
left: 26px;
right: 25px;
bottom: 18px;
padding-top: 11px;
border-top: 1px solid var(--line);
color: #728b95;
font-size: 10px;
line-height: 1.45;
pointer-events: none;
}
#labels {
position: absolute;
inset: 0;
z-index: 4;
overflow: hidden;
pointer-events: none;
}
.scene-label {
position: absolute;
display: flex;
align-items: center;
gap: 7px;
padding: 6px 9px;
border: 1px solid rgba(141, 193, 204, 0.22);
border-radius: 6px;
background: rgba(7, 18, 24, 0.84);
color: #dcebed;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.025em;
white-space: nowrap;
transform: translate(-50%, -100%);
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
transition: opacity 120ms ease;
}
.scene-label::after {
content: "";
position: absolute;
left: 50%;
top: 100%;
width: 1px;
height: 14px;
background: linear-gradient(rgba(141, 193, 204, 0.5), transparent);
}
.scene-label::before {
content: "";
width: 6px;
height: 6px;
flex: 0 0 auto;
border-radius: 50%;
background: var(--label-color, #b8c9ce);
box-shadow: 0 0 8px var(--label-color, #b8c9ce);
}
.scene-label.site-label {
--label-color: var(--cyan);
border-color: rgba(101, 226, 211, 0.34);
}
.scene-label.reactant-label {
--label-color: var(--coral);
}
.scene-label.product-label {
--label-color: var(--green);
}
#inspector {
position: relative;
z-index: 10;
min-height: 0;
overflow-y: auto;
padding: 25px 22px 18px;
border-left: 1px solid var(--line);
background:
linear-gradient(180deg, rgba(21, 43, 53, 0.58), transparent 220px),
var(--panel);
scrollbar-width: thin;
scrollbar-color: #284651 transparent;
}
#inspector h2 {
margin: 8px 0 7px;
font-size: 24px;
letter-spacing: -0.03em;
}
#inspector > p {
margin: 0 0 22px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.section {
margin-top: 16px;
padding: 17px;
border: 1px solid var(--line);
border-radius: 14px;
background: linear-gradient(145deg, rgba(255, 255, 255, 0.025), transparent);
}
.section-heading {
display: flex;
justify-content: space-between;
align-items: center;
gap: 12px;
margin-bottom: 13px;
}
.section-heading h3 {
margin: 0;
font-size: 12px;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.concept-chip {
padding: 4px 7px;
border: 1px solid rgba(243, 186, 98, 0.25);
border-radius: 999px;
color: var(--amber);
background: rgba(243, 186, 98, 0.07);
font-size: 9px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
white-space: nowrap;
}
.energy-chart {
display: block;
width: 100%;
height: auto;
border-radius: 9px;
background: #09151c;
}
.chart-legend {
display: flex;
flex-wrap: wrap;
gap: 12px;
margin-top: 11px;
color: var(--muted);
font-size: 10px;
}
.chart-legend span {
display: flex;
align-items: center;
gap: 6px;
}
.chart-legend i {
display: block;
width: 19px;
height: 2px;
background: currentColor;
}
.chart-legend .assisted {
color: var(--cyan);
}
.chart-legend .unassisted {
color: #738994;
}
.chart-legend .axis {
color: #a8bbc2;
}
.site-summary {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 12px;
}
.site-id {
color: var(--cyan);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.site-summary h4 {
margin: 5px 0 0;
font-size: 17px;
}
.site-symbol {
display: grid;
place-items: center;
width: 42px;
height: 42px;
flex: 0 0 auto;
border: 1px solid rgba(101, 226, 211, 0.25);
border-radius: 10px;
color: var(--cyan);
background: rgba(101, 226, 211, 0.07);
font-size: 20px;
box-shadow: inset 0 0 18px rgba(101, 226, 211, 0.05);
}
.site-description {
margin: 13px 0 0;
color: var(--muted);
font-size: 11px;
line-height: 1.55;
}
.site-facts {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-top: 14px;
}
.fact {
padding: 9px;
border: 1px solid var(--line);
border-radius: 8px;
background: rgba(255, 255, 255, 0.018);
}
.fact small {
display: block;
margin-bottom: 4px;
color: #6f8993;
font-size: 8px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.fact strong {
color: #c9d9dd;
font-size: 10px;
font-weight: 650;
}
.teaching-note {
position: relative;
margin-top: 16px;
padding: 15px 15px 15px 38px;
border: 1px solid rgba(101, 226, 211, 0.17);
border-radius: 12px;
background: rgba(101, 226, 211, 0.045);
color: #a9c1c7;
font-size: 11px;
line-height: 1.55;
}
.teaching-note::before {
content: "i";
position: absolute;
top: 14px;
left: 14px;
display: grid;
place-items: center;
width: 16px;
height: 16px;
border: 1px solid rgba(101, 226, 211, 0.45);
border-radius: 50%;
color: var(--cyan);
font-family: Georgia, serif;
font-size: 11px;
font-weight: 700;
}
.side-footer {
margin-top: 17px;
padding-top: 14px;
border-top: 1px solid var(--line);
color: #718a94;
font-size: 9px;
line-height: 1.55;
}
@media (max-width: 900px) {
body {
overflow: auto;
}
#app {
display: grid;
grid-template-columns: 1fr;
grid-template-rows: minmax(560px, 72vh) auto;
height: auto;
min-height: 100%;
}
#inspector {
overflow: visible;
border-top: 1px solid var(--line);
border-left: 0;
}
.hero {
top: 20px;
left: 18px;
right: 18px;
}
.hero p {
max-width: 380px;
}
.view-controls {
top: auto;
right: 16px;
bottom: 54px;
}
.legend {
left: 16px;
bottom: 54px;
}
.orbit-hint {
display: none;
}
.disclaimer {
left: 16px;
right: 16px;
}
}
@media (max-width: 560px) {
.hero h1 {
font-size: 27px;
}
.hero p {
max-width: 300px;
font-size: 12px;
}
.legend {
display: none;
}
.view-controls {
left: 16px;
right: auto;
}
.scene-label {
font-size: 9px;
}
}
</style>
</head>
<body>
<div id="app">
<main id="stage" aria-label="Interactive voxel catalyst cutaway">
<header class="hero">
<div class="eyebrow">Catalyst concepts / interactive cutaway</div>
<h1>Inside a porous catalyst support</h1>
<p>
Explore a voxelized support with cutaway faces, internal voids, and
schematic exposed active sites. Select a teal center to inspect it.
</p>
</header>
<nav class="view-controls" aria-label="Scene view controls">
<button type="button" data-view="overview" aria-pressed="true">
Overview
</button>
<button type="button" data-view="cutaway" aria-pressed="false">
Cutaway
</button>
<button id="toggle-labels" type="button" aria-pressed="true">
Labels
</button>
</nav>
<div id="labels" aria-hidden="true">
<div
class="scene-label"
data-label="support"
style="--label-color:#b49b7c"
>
Porous support
</div>
<div
class="scene-label"
data-label="void"
style="--label-color:#a9c0c8"
>
Pore / channel
</div>
<div
class="scene-label"
data-label="section"
style="--label-color:#f3ba62"
>
Exposed cut face
</div>
<div
class="scene-label site-label"
data-label="site"
>
Active site 01
</div>
<div
class="scene-label reactant-label"
data-label="reactant"
>
Reactant motif
</div>
<div
class="scene-label product-label"
data-label="product"
>
Product motif
</div>
</div>
<aside class="legend" aria-label="Scene legend">
<div class="legend-row">
<span class="swatch support"></span>
Support voxels
</div>
<div class="legend-row">
<span class="swatch site"></span>
Schematic site center
</div>
<div class="legend-row">
<span class="swatch ligand"></span>
Coordination cues
</div>
<div class="legend-row">
<span class="swatch reactant"></span>
Reactant motif
</div>
<div class="legend-row">
<span class="swatch product"></span>
Product motif
</div>
</aside>
<div class="orbit-hint">Drag to orbit · scroll or pinch to zoom · click a teal site</div>
<div class="disclaimer">
Educational schematic only. Geometry is illustrative and not to scale.
Site placement and the energy profile are conceptual; no chemical identities,
reactor conditions, or production guidance are shown.
</div>
</main>
<aside id="inspector">
<div class="eyebrow">Separate conceptual view</div>
<h2>Energy diagram</h2>
<p>
A qualitative pathway compares an assisted route with a higher,
unassisted route. The profile is intentionally not scaled.
</p>
<section class="section">
<div class="section-heading">
<h3>Relative energy</h3>
<span class="concept-chip">Concept only</span>
</div>
<svg
class="energy-chart"
viewBox="0 0 380 260"
role="img"
aria-label="Conceptual energy diagram with reactant and product states and two possible pathways"
>
<defs>
<linearGradient id="energyFill" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stop-color="#65e2d3" stop-opacity="0.2"/>
<stop offset="100%" stop-color="#65e2d3" stop-opacity="0"/>
</linearGradient>
<filter id="softGlow" x="-40%" y="-40%" width="180%" height="180%">
<feGaussianBlur stdDeviation="3" result="blur"/>
<feMerge>
<feMergeNode in="blur"/>
<feMergeNode in="SourceGraphic"/>
</feMerge>
</filter>
</defs>
<g stroke="#20333d" stroke-width="1">
<line x1="54" y1="35" x2="54" y2="220"/>
<line x1="54" y1="220" x2="350" y2="220"/>
</g>
<g fill="none" stroke="#8ba3ad" stroke-width="1.5">
<path d="M54 220 L45 220"/>
<path d="M54 220 L54 211"/>
<path d="M350 220 L340 220"/>
<path d="M350 220 L350 211"/>
</g>
<text x="22" y="119" fill="#78919b" font-size="10"
transform="rotate(-90 22 119)" text-anchor="middle">
Relative energy
</text>
<text x="205" y="244" fill="#78919b" font-size="10" text-anchor="middle">
Reaction coordinate
</text>
<path
d="M96 174 C132 169 150 37 204 34 C258 31 278 165 320 195"
fill="none"
stroke="#71858e"
stroke-width="2"
stroke-dasharray="5 6"
opacity="0.75"
/>
<path
d="M96 174 C139 174 169 94 205 94 C251 94 271 185 320 195 L320 220 L96 220 Z"
fill="url(#energyFill)"
/>
<path
d="M96 174 C139 174 169 94 205 94 C251 94 271 185 320 195"
fill="none"
stroke="#65e2d3"
stroke-width="3"
stroke-linecap="round"
filter="url(#softGlow)"
/>
<g fill="#0b171e" stroke-width="2">
<circle cx="96" cy="174" r="5" stroke="#f0b965"/>
<circle cx="205" cy="94" r="5" stroke="#65e2d3"/>
<circle cx="320" cy="195" r="5" stroke="#8edb8a"/>
</g>
<text x="96" y="158" fill="#d9e6e8" font-size="10" text-anchor="middle">
Reactants
</text>
<text x="205" y="75" fill="#65e2d3" font-size="10" text-anchor="middle">
Transition region
</text>
<text x="320" y="214" fill="#d9e6e8" font-size="10" text-anchor="middle">
Products
</text>
<text x="209" y="44" fill="#879ba4" font-size="9" text-anchor="middle">
higher route
</text>
<text x="253" y="111" fill="#65e2d3" font-size="9">
assisted route
</text>
<g transform="translate(66 247)">
<circle cx="0" cy="0" r="3" fill="#f0b965"/>
<text x="8" y="3" fill="#708994" font-size="9">state</text>
</g>
</svg>
<div class="chart-legend">
<span class="assisted"><i></i>Assisted route</span>
<span class="unassisted"><i></i>Higher route</span>
<span class="axis"><i></i>Axes</span>
</div>
</section>
<section class="section">
<div class="section-heading">
<h3>Selected active site</h3>
<span class="concept-chip">Schematic</span>
</div>
<div class="site-summary">
<div>
<div id="site-id" class="site-id">Site 01 / 06</div>
<h4 id="site-name">Exposed cut-face center</h4>
</div>
<div class="site-symbol" aria-hidden="true">◆</div>
</div>
<p id="site-description" class="site-description"></p>
<div class="site-facts">
<div class="fact">
<small>Teal center</small>
<strong>Generic site center</strong>
</div>
<div class="fact">
<small>Amber voxels</small>
<strong>Coordination cues</strong>
</div>
</div>
</section>
<div class="teaching-note">
The scene emphasizes <strong>surface accessibility</strong>: a site near a
pore or cut face is more readily reached than one buried deep inside
the support. The colors identify concepts, not specific chemistry.
</div>
<footer class="side-footer">
Geometry, site count, and energy differences are illustrative.
This visual is a teaching aid and does not represent a validated
catalyst formulation, reactor configuration, or operating procedure.
</footer>
</aside>
</div>
<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 labelLayer = document.querySelector("#labels");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x071117);
scene.fog = new THREE.FogExp2(0x071117, 0.025);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
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.08;
renderer.domElement.setAttribute(
"aria-label",
"Interactive three-dimensional voxel catalyst support"
);
stage.prepend(renderer.domElement);
const camera = new THREE.PerspectiveCamera(
43,
1,
0.1,
160
);
const cameraState = {
azimuth: 0.72,
elevation: 0.47,
radius: 31,
target: new THREE.Vector3(0, 4.7, 0)
};
const desiredCamera = {
azimuth: cameraState.azimuth,
elevation: cameraState.elevation,
radius: cameraState.radius,
target: cameraState.target.clone()
};
function applyCamera() {
const cosElevation = Math.cos(cameraState.elevation);
camera.position.set(
cameraState.target.x +
cameraState.radius * cosElevation * Math.sin(cameraState.azimuth),
cameraState.target.y +
cameraState.radius * Math.sin(cameraState.elevation),
cameraState.target.z +
cameraState.radius * cosElevation * Math.cos(cameraState.azimuth)
);
camera.lookAt(cameraState.target);
}
applyCamera();
const ambient = new THREE.HemisphereLight(0xb8dce4, 0x20180f, 1.75);
scene.add(ambient);
const keyLight = new THREE.DirectionalLight(0xd9f5ff, 3.1);
keyLight.position.set(-8, 18, 13);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -18;
keyLight.shadow.camera.right = 18;
keyLight.shadow.camera.top = 18;
keyLight.shadow.camera.bottom = -18;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 55;
keyLight.shadow.bias = -0.00035;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x5de2d0, 2.0);
rimLight.position.set(13, 9, -12);
scene.add(rimLight);
const warmLight = new THREE.PointLight(0xf4b45d, 26, 28, 2);
warmLight.position.set(9, 5, 8);
scene.add(warmLight);
const floorMaterial = new THREE.MeshStandardMaterial({
color: 0x0b171d,
roughness: 0.93,
metalness: 0.08
});
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(100, 100),
floorMaterial
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.58;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(70, 70, 0x25424d, 0x142a34);
grid.position.y = -0.56;
grid.material.transparent = true;
grid.material.opacity = 0.42;
scene.add(grid);
const pedestalMaterial = new THREE.MeshStandardMaterial({
color: 0x18272e,
roughness: 0.6,
metalness: 0.48
});
const pedestal = new THREE.Mesh(
new THREE.BoxGeometry(14.6, 0.55, 11.15),
pedestalMaterial
);
pedestal.position.y = -0.28;
pedestal.receiveShadow = true;
pedestal.castShadow = true;
scene.add(pedestal);
const pedestalInset = new THREE.Mesh(
new THREE.BoxGeometry(13.8, 0.12, 10.35),
new THREE.MeshStandardMaterial({
color: 0x28414b,
roughness: 0.5,
metalness: 0.55
})
);
pedestalInset.position.y = 0.04;
pedestalInset.receiveShadow = true;
scene.add(pedestalInset);
const nx = 16;
const ny = 13;
const nz = 12;
const spacing = 0.82;
const voxelSize = 0.745;
function voxelPosition(i, j, k) {
return new THREE.Vector3(
(i - (nx - 1) / 2) * spacing,
0.48 + j * spacing,
(k - (nz - 1) / 2) * spacing
);
}
function hash(i, j, k) {
const value = Math.sin(i * 91.17 + j * 37.41 + k * 17.73) * 43758.5453;
return value - Math.floor(value);
}
const pores = [
{ c: [-4.1, 6.0, 1.7], r: [1.65, 2.1, 1.55] },
{ c: [0.4, 7.4, -1.7], r: [1.75, 1.8, 1.45] },
{ c: [4.4, 4.3, -0.7], r: [1.85, 2.2, 1.7] },
{ c: [-2.0, 2.8, -2.8], r: [1.4, 1.5, 1.45] },
{ c: [1.8, 3.0, 2.6], r: [1.5, 1.35, 1.35] },
{ c: [-5.0, 3.3, -1.3], r: [1.25, 1.55, 1.3] },
{ c: [5.2, 8.1, -2.6], r: [1.35, 1.55, 1.3] },
{ c: [-0.5, 9.0, 3.6], r: [1.2, 1.1, 1.15] },
{ c: [2.0, 1.1, -3.7], r: [1.4, 1.1, 1.2] }
];
function isPore(position) {
return pores.some(({ c, r }) => {
const dx = (position.x - c[0]) / r[0];
const dy = (position.y - c[1]) / r[1];
const dz = (position.z - c[2]) / r[2];
return dx * dx + dy * dy + dz * dz < 1;
});
}
const occupied = new Set();
const keyFor = (i, j, k) => `${i},${j},${k}`;
for (let i = 0; i < nx; i++) {
for (let j = 0; j < ny; j++) {
for (let k = 0; k < nz; k++) {
const position = voxelPosition(i, j, k);
// A stepped quarter-volume is removed to expose internal structure.
const cutAway = i >= 10 && k >= 7;
// A partial horizontal channel connects several voids.
const channel =
j === 6 &&
i >= 3 && i <= 12 &&
k >= 3 && k <= 8;
if (!cutAway && !channel && !isPore(position)) {
occupied.add(keyFor(i, j, k));
}
}
}
}
const supportGeometry = new THREE.BoxGeometry(
voxelSize,
voxelSize,
voxelSize
);
const supportMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.86,
metalness: 0.04,
vertexColors: true
});
const support = new THREE.InstancedMesh(
supportGeometry,
supportMaterial,
occupied.size
);
support.castShadow = true;
support.receiveShadow = true;
const matrix = new THREE.Matrix4();
const color = new THREE.Color();
let instanceIndex = 0;
for (let i = 0; i < nx; i++) {
for (let j = 0; j < ny; j++) {
for (let k = 0; k < nz; k++) {
if (!occupied.has(keyFor(i, j, k))) continue;
const position = voxelPosition(i, j, k);
matrix.makeTranslation(position.x, position.y, position.z);
support.setMatrixAt(instanceIndex, matrix);
const noise = hash(i, j, k);
const onCutFace =
(k === 6 && i >= 10) ||
(i === 9 && k >= 7);
if (onCutFace) {
color.setHSL(0.095, 0.28, 0.48 + noise * 0.055);
} else {
color.setHSL(0.105, 0.14, 0.45 + noise * 0.085);
}
support.setColorAt(instanceIndex, color);
instanceIndex++;
}
}
}
support.instanceMatrix.needsUpdate = true;
if (support.instanceColor) support.instanceColor.needsUpdate = true;
scene.add(support);
// Thin markers make the two principal cut planes easier to read.
const cutPlaneMaterial = new THREE.MeshBasicMaterial({
color: 0xf0b45e,
transparent: true,
opacity: 0.24,
depthWrite: false
});
const frontCutMarker = new THREE.Mesh(
new THREE.PlaneGeometry(5.0, 10.45),
cutPlaneMaterial
);
frontCutMarker.position.set(4.1, 5.6, 0.405);
scene.add(frontCutMarker);
const sideCutMarker = new THREE.Mesh(
new THREE.PlaneGeometry(4.95, 10.45),
cutPlaneMaterial.clone()
);
sideCutMarker.rotation.y = Math.PI / 2;
sideCutMarker.position.set(3.24, 5.6, 3.18);
scene.add(sideCutMarker);
const siteData = [
{
position: new THREE.Vector3(4.25, 3.25, 1.02),
name: "Exposed cut-face center",
description:
"A generic active-site center is positioned at an accessible cut face. The surrounding amber voxels suggest nearby coordination features without identifying a chemical species."
},
{
position: new THREE.Vector3(5.65, 6.55, 0.98),
name: "Pore-rim center",
description:
"This schematic center sits near an open channel. It illustrates how pore geometry can change access to a reactive location."
},
{
position: new THREE.Vector3(0.7, 8.15, -2.7),
name: "Internal pore center",
description:
"The site is shown within a porous region. Its placement is conceptual and is not intended to represent a specific material structure."
},
{
position: new THREE.Vector3(-4.3, 5.0, -3.35),
name: "Embedded surface center",
description:
"A partially surrounded site demonstrates the difference between exposed and embedded locations within the support."
},
{
position: new THREE.Vector3(-6.25, 2.5, 1.6),
name: "Outer surface center",
description:
"This location illustrates a site at the external boundary of the support. The surface itself remains schematic."
},
{
position: new THREE.Vector3(-1.4, 2.5, 2.55),
name: "Channel-edge center",
description:
"Positioned beside a channel opening, this site provides another example of a potentially accessible reactive location."
}
];
const siteGroups = [];
const pickables = [];
const socketGeometry = new THREE.BoxGeometry(0.61, 0.61, 0.61);
const socketMaterial = new THREE.MeshStandardMaterial({
color: 0x142c31,
roughness: 0.55,
metalness: 0.4
});
const centerGeometry = new THREE.BoxGeometry(0.39, 0.39, 0.39);
const ligandGeometry = new THREE.BoxGeometry(0.17, 0.17, 0.17);
const ligandMaterial = new THREE.MeshStandardMaterial({
color: 0xf3ba62,
emissive: 0x7b4310,
emissiveIntensity: 0.45,
roughness: 0.48,
metalness: 0.38
});
siteData.forEach((data, index) => {
const group = new THREE.Group();
group.position.copy(data.position);
const socket = new THREE.Mesh(socketGeometry, socketMaterial);
socket.castShadow = true;
socket.receiveShadow = true;
group.add(socket);
const centerMaterial = new THREE.MeshStandardMaterial({
color: 0x65e2d3,
emissive: 0x1b8f82,
emissiveIntensity: 0.62,
roughness: 0.28,
metalness: 0.46
});
const center = new THREE.Mesh(centerGeometry, centerMaterial);
center.castShadow = true;
center.userData.siteIndex = index;
pickables.push(center);
group.add(center);
const ligandOffsets = [
[0.47, 0, 0],
[-0.47, 0, 0],
[0, 0.47, 0],
[0, -0.47, 0]
];
ligandOffsets.forEach(([x, y, z]) => {
const ligand = new THREE.Mesh(ligandGeometry, ligandMaterial);
ligand.position.set(x, y, z);
ligand.castShadow = true;
group.add(ligand);
});
group.userData.index = index;
siteGroups.push(group);
scene.add(group);
});
// Generic voxel molecule motifs.
function createMoleculeMotif(colors, position, mirror = false) {
const group = new THREE.Group();
group.position.copy(position);
const geometry = new THREE.BoxGeometry(0.52, 0.52, 0.52);
colors.forEach((entry, index) => {
const mesh = new THREE.Mesh(
geometry,
new THREE.MeshStandardMaterial({
color: entry.color,
emissive: entry.color,
emissiveIntensity: entry.glow ?? 0.12,
roughness: 0.38,
metalness: 0.18
})
);
mesh.position.set(
(index - 1) * 0.48 * (mirror ? -1 : 1),
index === 1 ? 0.13 : -0.08,
index === 1 ? 0 : 0.08
);
mesh.rotation.y = index === 1 ? 0.18 : -0.12;
mesh.castShadow = true;
group.add(mesh);
});
scene.add(group);
return group;
}
const reactantMotif = createMoleculeMotif(
[
{ color: 0xef765e, glow: 0.22 },
{ color: 0xe7eef0, glow: 0.04 },
{ color: 0xef765e, glow: 0.18 }
],
new THREE.Vector3(-8.55, 4.0, 3.45)
);
const productMotif = createMoleculeMotif(
[
{ color: 0x8edb8a, glow: 0.18 },
{ color: 0xe7eef0, glow: 0.04 },
{ color: 0x8edb8a, glow: 0.15 }
],
new THREE.Vector3(8.45, 3.65, 2.75),
true
);
function cubicBezier(p0, p1, p2, p3, t) {
const inverse = 1 - t;
const a = inverse * inverse * inverse;
const b = 3 * inverse * inverse * t;
const c = 3 * inverse * t * t;
const d = t * t * t;
return new THREE.Vector3(
a * p0.x + b * p1.x + c * p2.x + d * p3.x,
a * p0.y + b * p1.y + c * p2.y + d * p3.y,
a * p0.z + b * p1.z + c * p2.z + d * p3.z
);
}
const flowPaths = [];
function createFlowPath(points, color) {
const group = new THREE.Group();
const pathMaterial = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.45
});
const dotGeometry = new THREE.BoxGeometry(0.075, 0.075, 0.075);
for (let t = 0.025; t < 0.99; t += 0.047) {
const dot = new THREE.Mesh(dotGeometry, pathMaterial);
dot.position.copy(cubicBezier(...points, t));
dot.rotation.set(t * 3, t * 5, t * 2);
group.add(dot);
}
const tracerMaterial = new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: 0.75,
roughness: 0.25,
metalness: 0.15
});
const tracer = new THREE.Mesh(
new THREE.BoxGeometry(0.19, 0.19, 0.19),
tracerMaterial
);
tracer.castShadow = true;
group.add(tracer);
scene.add(group);
flowPaths.push({ points, tracer, phase: Math.random() * 0.25 });
}
const primarySite = siteData[0].position;
createFlowPath(
[
new THREE.Vector3(-7.25, 4.0, 3.45),
new THREE.Vector3(-3.1, 3.3, 3.15),
new THREE.Vector3(0.7, 4.0, 1.8),
primarySite.clone().add(new THREE.Vector3(0, 0, 0.35))
],
0xf3ba62
);
createFlowPath(
[
primarySite.clone().add(new THREE.Vector3(0, 0, 0.4)),
new THREE.Vector3(5.5, 3.8, 2.0),
new THREE.Vector3(7.1, 3.4, 2.65),
new THREE.Vector3(7.3, 3.65, 2.75)
],
0x65e2d3
);
// Labels are projected from 3D anchors into the HTML overlay.
const labelAnchors = {
support: new THREE.Vector3(-4.9, 8.4, 4.25),
void: new THREE.Vector3(-0.4, 5.55, 4.25),
section: new THREE.Vector3(5.25, 8.2, 0.8),
site: primarySite.clone().add(new THREE.Vector3(0, 0.82, 0)),
reactant: new THREE.Vector3(-8.55, 5.0, 3.45),
product: new THREE.Vector3(8.45, 4.7, 2.75)
};
const labels = Array.from(document.querySelectorAll("[data-label]")).map(
(element) => ({
element,
anchor: labelAnchors[element.dataset.label].clone()
})
);
let labelsVisible = true;
function updateLabels() {
if (!labelsVisible) {
labelLayer.style.opacity = "0";
return;
}
labelLayer.style.opacity = "1";
const width = stage.clientWidth;
const height = stage.clientHeight;
labels.forEach(({ element, anchor }) => {
const projected = anchor.clone().project(camera);
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
const visible =
projected.z > -1 &&
projected.z < 1 &&
x > 8 &&
x < width - 8 &&
y > 8 &&
y < height - 8;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
element.style.opacity = visible ? "1" : "0";
});
}
let selectedSite = 0;
function selectSite(index) {
selectedSite = index;
const data = siteData[index];
document.querySelector("#site-id").textContent =
`Site ${String(index + 1).padStart(2, "0")} / ${String(siteData.length).padStart(2, "0")}`;
document.querySelector("#site-name").textContent = data.name;
document.querySelector("#site-description").textContent = data.description;
const siteLabel = document.querySelector('[data-label="site"]');
siteLabel.textContent = `Active site ${String(index + 1).padStart(2, "0")}`;
labels.find(({ element }) => element.dataset.label === "site").anchor =
data.position.clone().add(new THREE.Vector3(0, 0.82, 0));
}
selectSite(0);
// Direct camera controls; no examples/addons modules are used.
const pointers = new Map();
let activePointer = null;
let lastX = 0;
let lastY = 0;
let pointerDownX = 0;
let pointerDownY = 0;
let dragged = false;
let previousPinchDistance = 0;
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
function pointerDistance() {
const values = [...pointers.values()];
if (values.length < 2) return 0;
return Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
}
function updateRaycast(event) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
return raycaster.intersectObjects(pickables, false);
}
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 1) {
activePointer = event.pointerId;
lastX = event.clientX;
lastY = event.clientY;
pointerDownX = event.clientX;
pointerDownY = event.clientY;
dragged = false;
} else if (pointers.size === 2) {
previousPinchDistance = pointerDistance();
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (pointers.has(event.pointerId)) {
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
}
if (pointers.size === 2) {
const distance = pointerDistance();
if (distance > 0 && previousPinchDistance > 0) {
desiredCamera.radius = THREE.MathUtils.clamp(
desiredCamera.radius * (previousPinchDistance / distance),
17,
46
);
}
previousPinchDistance = distance;
return;
}
if (event.pointerId === activePointer) {
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
if (
Math.abs(event.clientX - pointerDownX) +
Math.abs(event.clientY - pointerDownY) >
4
) {
dragged = true;
}
desiredCamera.azimuth -= dx * 0.005;
desiredCamera.elevation = THREE.MathUtils.clamp(
desiredCamera.elevation + dy * 0.004,
0.16,
1.28
);
lastX = event.clientX;
lastY = event.clientY;
} else if (event.pointerType === "mouse") {
renderer.domElement.style.cursor =
updateRaycast(event).length ? "pointer" : "grab";
}
});
renderer.domElement.addEventListener("pointerup", (event) => {
const wasClick =
!dragged &&
Math.abs(event.clientX - pointerDownX) +
Math.abs(event.clientY - pointerDownY) < 6;
pointers.delete(event.pointerId);
if (activePointer === event.pointerId) {
activePointer = null;
}
if (wasClick && event.pointerType === "mouse") {
const hits = updateRaycast(event);
if (hits.length) selectSite(hits[0].object.userData.siteIndex);
}
if (pointers.size < 2) previousPinchDistance = 0;
});
renderer.domElement.addEventListener("pointercancel", (event) => {
pointers.delete(event.pointerId);
if (activePointer === event.pointerId) activePointer = null;
previousPinchDistance = 0;
});
renderer.domElement.addEventListener("wheel", (event) => {
event.preventDefault();
desiredCamera.radius = THREE.MathUtils.clamp(
desiredCamera.radius * Math.exp(event.deltaY * 0.001),
17,
46
);
}, { passive: false });
const viewButtons = [...document.querySelectorAll("[data-view]")];
viewButtons.forEach((button) => {
button.addEventListener("click", () => {
const view = button.dataset.view;
viewButtons.forEach((other) => {
other.setAttribute("aria-pressed", String(other === button));
});
if (view === "overview") {
desiredCamera.azimuth = 0.72;
desiredCamera.elevation = 0.47;
desiredCamera.radius = 31;
desiredCamera.target.set(0, 4.7, 0);
} else {
desiredCamera.azimuth = 0.39;
desiredCamera.elevation = 0.33;
desiredCamera.radius = 22.5;
desiredCamera.target.set(2.1, 4.7, 0.7);
}
});
});
document.querySelector("#toggle-labels").addEventListener("click", (event) => {
labelsVisible = !labelsVisible;
event.currentTarget.setAttribute("aria-pressed", String(labelsVisible));
});
function resize() {
const width = Math.max(stage.clientWidth, 1);
const height = Math.max(stage.clientHeight, 1);
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setSize(width, height, false);
}
const resizeObserver = new ResizeObserver(resize);
resizeObserver.observe(stage);
resize();
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
// Smooth camera preset transitions while drag remains immediate.
cameraState.azimuth +=
(desiredCamera.azimuth - cameraState.azimuth) * 0.09;
cameraState.elevation +=
(desiredCamera.elevation - cameraState.elevation) * 0.09;
cameraState.radius +=
(desiredCamera.radius - cameraState.radius) * 0.09;
cameraState.target.lerp(desiredCamera.target, 0.09);
applyCamera();
siteGroups.forEach((group, index) => {
const selected = index === selectedSite;
const pulse = selected ? 1 + Math.sin(elapsed * 3.2) * 0.075 : 1;
group.scale.setScalar(pulse);
group.children.forEach((child) => {
if (
child.isMesh &&
child.material?.emissive &&
child.material.color.getHex() === 0x65e2d3
) {
child.material.emissiveIntensity = selected ? 1.05 : 0.62;
}
});
});
reactantMotif.position.y = 4.0 + Math.sin(elapsed * 1.35) * 0.11;
reactantMotif.rotation.y = Math.sin(elapsed * 0.55) * 0.1;
productMotif.position.y = 3.65 + Math.sin(elapsed * 1.35 + 2) * 0.11;
productMotif.rotation.y = -Math.sin(elapsed * 0.55) * 0.1;
flowPaths.forEach(({ points, tracer, phase }) => {
const t = (elapsed * 0.24 + phase) % 1;
tracer.position.copy(cubicBezier(...points, t));
tracer.rotation.set(t * 4, t * 6, t * 3);
});
updateLabels();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```