Prompt specification
Build or customize the Three.js 3D scene "Laminate orientation exploration board" 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: Laminate orientation exploration board
Category: Science & Physics · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/laminate-orientation-exploration-board-x1940
Scene Description Prompt:
I'd like to see this as a low-poly Three.js scene: laminate orientation exploration board. Let users rotate a small number of schematic plies and inspect directional stiffness indicators from an explicitly simplified model; distinguish model output from engineering certification. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (laminate-orientation-exploration-board-x1940):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>PLYSCAPE — Laminate Orientation Explorer</title>
<style>
:root {
--paper: #f3f0e8;
--paper-deep: #e9e5da;
--panel: rgba(255, 255, 255, 0.72);
--ink: #18333b;
--muted: #68777a;
--line: #d8d4c9;
--teal: #2a9d8f;
--coral: #e76f51;
--yellow: #e9c46a;
--blue: #457b9d;
--warning: #a44725;
--warning-bg: #fff1e7;
--mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
--sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
min-height: 100%;
background: var(--paper);
color: var(--ink);
font-family: var(--sans);
}
body {
overflow: hidden;
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
button:focus-visible,
input:focus-visible,
summary:focus-visible {
outline: 2px solid var(--teal);
outline-offset: 2px;
}
#app {
display: grid;
grid-template-rows: 66px minmax(0, 1fr) 34px;
height: 100vh;
min-height: 620px;
}
.topbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
padding: 0 22px;
border-bottom: 1px solid var(--line);
background: rgba(248, 246, 240, 0.94);
z-index: 20;
}
.brand {
display: flex;
align-items: center;
gap: 12px;
min-width: 260px;
}
.brand-mark {
position: relative;
width: 34px;
height: 34px;
}
.brand-mark span {
position: absolute;
left: 3px;
width: 28px;
height: 6px;
border: 1px solid var(--ink);
transform: skewY(-15deg);
}
.brand-mark span:nth-child(1) {
top: 4px;
background: var(--teal);
}
.brand-mark span:nth-child(2) {
top: 12px;
background: var(--coral);
}
.brand-mark span:nth-child(3) {
top: 20px;
background: var(--yellow);
}
.brand-name {
font-size: 16px;
font-weight: 850;
letter-spacing: 0.13em;
}
.brand-sub {
margin-top: 2px;
color: var(--muted);
font-family: var(--mono);
font-size: 9px;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.top-context {
display: flex;
align-items: center;
gap: 12px;
color: var(--muted);
font-family: var(--mono);
font-size: 10px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.top-context b {
color: var(--ink);
font-weight: 700;
}
.top-context .slash {
opacity: 0.35;
}
.status-pill {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 8px 11px;
border: 1px solid #dfb59f;
border-radius: 999px;
color: var(--warning);
background: var(--warning-bg);
font-family: var(--mono);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.07em;
text-transform: uppercase;
white-space: nowrap;
}
.status-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--warning);
box-shadow: 0 0 0 3px rgba(164, 71, 37, 0.12);
}
main {
display: grid;
grid-template-columns: 270px minmax(390px, 1fr) 334px;
min-height: 0;
}
.side-panel {
min-height: 0;
overflow-y: auto;
background: rgba(247, 245, 239, 0.86);
scrollbar-width: thin;
scrollbar-color: #bbb7ad transparent;
}
.left-panel {
border-right: 1px solid var(--line);
}
.right-panel {
border-left: 1px solid var(--line);
}
.panel-header {
display: flex;
align-items: center;
gap: 10px;
min-height: 58px;
padding: 14px 18px;
border-bottom: 1px solid var(--line);
}
.panel-index {
color: var(--teal);
font-family: var(--mono);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.08em;
}
.panel-header h2 {
margin: 0;
font-size: 14px;
font-weight: 780;
letter-spacing: -0.01em;
}
.panel-body {
padding: 17px;
}
.section-kicker {
margin-bottom: 10px;
color: var(--muted);
font-family: var(--mono);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.stack-summary {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 14px;
padding-bottom: 12px;
border-bottom: 1px dashed var(--line);
color: var(--muted);
font-family: var(--mono);
font-size: 9px;
line-height: 1.5;
}
.stack-summary strong {
color: var(--ink);
font-weight: 700;
}
.ply-list {
display: grid;
gap: 8px;
}
.ply-row {
--ply-color: var(--teal);
--fill: 50%;
position: relative;
padding: 11px 10px 10px 13px;
border: 1px solid var(--line);
border-left: 3px solid var(--ply-color);
border-radius: 7px;
background: rgba(255, 255, 255, 0.58);
transition: border-color 150ms ease, background 150ms ease,
transform 150ms ease;
}
.ply-row:hover {
border-color: #bdb8ad;
border-left-color: var(--ply-color);
}
.ply-row.selected {
border-color: var(--ply-color);
border-left-color: var(--ply-color);
background: rgba(255, 255, 255, 0.94);
box-shadow: 0 5px 16px rgba(37, 52, 51, 0.06);
transform: translateX(2px);
}
.ply-head {
display: grid;
grid-template-columns: 1fr 58px;
align-items: center;
gap: 8px;
}
.ply-pick {
display: grid;
grid-template-columns: 10px 31px 1fr;
align-items: center;
gap: 8px;
min-width: 0;
padding: 0;
border: 0;
background: transparent;
text-align: left;
cursor: pointer;
}
.ply-swatch {
width: 9px;
height: 9px;
background: var(--ply-color);
transform: rotate(45deg);
}
.ply-code {
font-size: 12px;
font-weight: 850;
letter-spacing: 0.04em;
}
.ply-direction {
overflow: hidden;
color: var(--muted);
font-family: var(--mono);
font-size: 9px;
text-overflow: ellipsis;
white-space: nowrap;
}
.angle-box {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 2px;
color: var(--muted);
font-family: var(--mono);
font-size: 10px;
}
.angle-box input {
width: 40px;
padding: 4px 2px;
border: 0;
border-bottom: 1px solid var(--line);
color: var(--ink);
background: transparent;
font-family: var(--mono);
font-size: 12px;
font-weight: 700;
text-align: right;
appearance: textfield;
}
.angle-box input::-webkit-inner-spin-button,
.angle-box input::-webkit-outer-spin-button {
margin: 0;
appearance: none;
}
.angle-range {
width: 100%;
height: 14px;
margin: 9px 0 0;
background: transparent;
cursor: ew-resize;
appearance: none;
}
.angle-range::-webkit-slider-runnable-track {
height: 3px;
border-radius: 4px;
background: linear-gradient(
to right,
var(--ply-color) 0 var(--fill),
#dedbd2 var(--fill) 100%
);
}
.angle-range::-moz-range-track {
height: 3px;
border-radius: 4px;
background: #dedbd2;
}
.angle-range::-moz-range-progress {
height: 3px;
background: var(--ply-color);
}
.angle-range::-webkit-slider-thumb {
width: 11px;
height: 11px;
margin-top: -4px;
border: 2px solid var(--paper);
border-radius: 50%;
background: var(--ply-color);
box-shadow: 0 0 0 1px var(--ply-color);
appearance: none;
}
.angle-range::-moz-range-thumb {
width: 9px;
height: 9px;
border: 2px solid var(--paper);
border-radius: 50%;
background: var(--ply-color);
box-shadow: 0 0 0 1px var(--ply-color);
}
.preset-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
margin-top: 16px;
}
.small-button {
min-height: 34px;
padding: 7px 9px;
border: 1px solid var(--line);
border-radius: 5px;
background: rgba(255, 255, 255, 0.65);
font-family: var(--mono);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.04em;
cursor: pointer;
}
.small-button:hover {
border-color: #a8aaa3;
background: #fff;
}
.small-button.primary {
grid-column: 1 / -1;
border-color: var(--ink);
color: #fff;
background: var(--ink);
}
.assumptions {
margin-top: 20px;
padding-top: 17px;
border-top: 1px solid var(--line);
}
.property-list {
display: grid;
gap: 0;
border-top: 1px solid #e1ded5;
}
.property-row {
display: flex;
align-items: center;
justify-content: space-between;
min-height: 33px;
border-bottom: 1px solid #e1ded5;
color: var(--muted);
font-family: var(--mono);
font-size: 9px;
}
.property-row strong {
color: var(--ink);
font-weight: 700;
}
.model-chip {
display: inline-flex;
align-items: center;
gap: 7px;
margin-bottom: 12px;
padding: 6px 8px;
border: 1px solid #b9d7d1;
border-radius: 4px;
color: #1e746a;
background: #e9f5f2;
font-family: var(--mono);
font-size: 8px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.model-chip::before {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--teal);
content: "";
}
.chart-wrap {
position: relative;
display: grid;
place-items: center;
margin: 0 -4px 6px;
}
#stiffnessChart {
display: block;
width: 100%;
max-width: 282px;
overflow: visible;
cursor: crosshair;
touch-action: none;
}
.chart-ring {
fill: none;
stroke: #d9d6cd;
stroke-width: 1;
stroke-dasharray: 2 4;
}
.chart-axis {
stroke: #c7c5bc;
stroke-width: 1;
}
.chart-response {
fill: rgba(42, 157, 143, 0.18);
stroke: var(--teal);
stroke-width: 2.2;
stroke-linejoin: bevel;
}
.chart-probe-line {
stroke: var(--coral);
stroke-width: 1.5;
stroke-dasharray: 4 3;
}
.chart-probe-dot {
fill: var(--coral);
stroke: #fff;
stroke-width: 2;
}
.chart-text {
fill: #6c797a;
font-family: var(--mono);
font-size: 8px;
font-weight: 600;
}
.chart-axis-label {
fill: var(--ink);
font-family: var(--mono);
font-size: 9px;
font-weight: 800;
}
.probe-readout {
display: grid;
grid-template-columns: 1fr auto;
align-items: end;
gap: 10px;
margin-top: 2px;
padding: 11px 0 12px;
border-top: 1px solid var(--line);
border-bottom: 1px solid var(--line);
}
.probe-label {
color: var(--muted);
font-family: var(--mono);
font-size: 8px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.probe-angle {
margin-top: 3px;
font-family: var(--mono);
font-size: 11px;
font-weight: 700;
}
.probe-value {
font-family: var(--mono);
font-size: 24px;
font-weight: 800;
letter-spacing: -0.05em;
}
.probe-value small {
margin-left: 3px;
color: var(--muted);
font-size: 9px;
font-weight: 700;
letter-spacing: 0;
}
.probe-slider {
width: 100%;
height: 16px;
margin: 11px 0 4px;
background: transparent;
cursor: ew-resize;
appearance: none;
}
.probe-slider::-webkit-slider-runnable-track {
height: 3px;
border-radius: 4px;
background: linear-gradient(
to right,
var(--coral) 0 var(--probe-fill),
#dedbd2 var(--probe-fill) 100%
);
}
.probe-slider::-webkit-slider-thumb {
width: 12px;
height: 12px;
margin-top: -4.5px;
border: 2px solid var(--paper);
border-radius: 50%;
background: var(--coral);
box-shadow: 0 0 0 1px var(--coral);
appearance: none;
}
.probe-slider::-moz-range-track {
height: 3px;
background: #dedbd2;
}
.probe-slider::-moz-range-progress {
height: 3px;
background: var(--coral);
}
.probe-slider::-moz-range-thumb {
width: 9px;
height: 9px;
border: 2px solid var(--paper);
border-radius: 50%;
background: var(--coral);
box-shadow: 0 0 0 1px var(--coral);
}
.metric-heading {
display: flex;
align-items: center;
justify-content: space-between;
margin: 18px 0 9px;
}
.metric-heading h3 {
margin: 0;
font-size: 11px;
font-weight: 800;
}
.metric-heading span {
color: var(--muted);
font-family: var(--mono);
font-size: 8px;
}
.metric-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
}
.metric-card {
min-height: 67px;
padding: 10px;
border: 1px solid var(--line);
border-radius: 5px;
background: rgba(255, 255, 255, 0.58);
}
.metric-name {
color: var(--muted);
font-family: var(--mono);
font-size: 8px;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.metric-number {
margin-top: 8px;
font-family: var(--mono);
font-size: 17px;
font-weight: 800;
letter-spacing: -0.04em;
}
.metric-number small {
margin-left: 3px;
color: var(--muted);
font-size: 8px;
letter-spacing: 0;
}
.matrix-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
margin-top: 8px;
border: 1px solid var(--line);
border-radius: 5px;
overflow: hidden;
background: rgba(255, 255, 255, 0.56);
}
.matrix-cell {
padding: 9px 5px;
border-right: 1px solid var(--line);
text-align: center;
}
.matrix-cell:last-child {
border-right: 0;
}
.matrix-symbol {
color: var(--muted);
font-family: var(--mono);
font-size: 8px;
}
.matrix-value {
margin-top: 4px;
font-family: var(--mono);
font-size: 10px;
font-weight: 800;
}
.cert-boundary {
margin-top: 18px;
padding: 13px;
border: 1px solid #e3bda9;
border-left: 3px solid var(--coral);
border-radius: 5px;
background: var(--warning-bg);
}
.cert-title {
display: flex;
align-items: center;
gap: 8px;
color: var(--warning);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.03em;
text-transform: uppercase;
}
.cert-title::before {
display: grid;
width: 17px;
height: 17px;
place-items: center;
border: 1px solid #d99775;
border-radius: 50%;
content: "!";
font-family: var(--mono);
font-size: 10px;
}
.cert-boundary p {
margin: 8px 0 0;
color: #754a39;
font-size: 10px;
line-height: 1.55;
}
.cert-boundary strong {
color: #673d2c;
}
.method {
margin-top: 12px;
border-top: 1px solid var(--line);
}
.method summary {
padding: 12px 0;
color: var(--ink);
font-family: var(--mono);
font-size: 9px;
font-weight: 700;
cursor: pointer;
}
.method p,
.method li {
color: var(--muted);
font-size: 10px;
line-height: 1.55;
}
.method ul {
padding-left: 17px;
}
.method code {
color: var(--ink);
font-family: var(--mono);
font-size: 9px;
}
#viewport {
position: relative;
min-width: 0;
min-height: 0;
overflow: hidden;
background: #ece9e0;
isolation: isolate;
}
#canvasHost,
#canvasHost canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
}
#canvasHost canvas {
display: block;
cursor: grab;
touch-action: none;
}
.scene-heading {
position: absolute;
top: 18px;
left: 20px;
z-index: 5;
pointer-events: none;
}
.scene-kicker {
color: var(--teal);
font-family: var(--mono);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.scene-heading h1 {
margin: 5px 0 0;
font-size: clamp(18px, 2vw, 26px);
font-weight: 780;
letter-spacing: -0.035em;
}
.scene-subtitle {
margin-top: 5px;
color: var(--muted);
font-family: var(--mono);
font-size: 8px;
letter-spacing: 0.04em;
}
.scene-tools {
position: absolute;
top: 18px;
right: 18px;
z-index: 8;
display: flex;
gap: 6px;
}
.tool-button {
min-height: 31px;
padding: 6px 10px;
border: 1px solid rgba(24, 51, 59, 0.18);
border-radius: 4px;
background: rgba(250, 248, 242, 0.82);
box-shadow: 0 3px 12px rgba(31, 43, 41, 0.05);
font-family: var(--mono);
font-size: 8px;
font-weight: 700;
letter-spacing: 0.04em;
text-transform: uppercase;
cursor: pointer;
}
.tool-button:hover {
background: #fff;
}
#labels {
position: absolute;
inset: 0;
z-index: 6;
overflow: hidden;
pointer-events: none;
}
.ply-label {
position: absolute;
display: inline-flex;
align-items: center;
gap: 7px;
padding: 6px 8px;
border: 1px solid rgba(24, 51, 59, 0.18);
border-radius: 4px;
background: rgba(250, 248, 242, 0.9);
box-shadow: 0 4px 14px rgba(24, 51, 59, 0.07);
font-family: var(--mono);
font-size: 9px;
font-weight: 800;
pointer-events: auto;
cursor: pointer;
transform: translate(calc(-100% - 22px), -50%);
transition: border-color 150ms ease, background 150ms ease;
}
.ply-label::after {
position: absolute;
right: -22px;
width: 22px;
height: 1px;
background: rgba(24, 51, 59, 0.4);
content: "";
}
.ply-label.selected {
border-color: var(--ink);
background: #fff;
}
.ply-label i {
width: 7px;
height: 7px;
background: var(--label-color);
transform: rotate(45deg);
}
.ply-label span:last-child {
color: var(--muted);
font-weight: 500;
}
.scene-bottom {
position: absolute;
right: 18px;
bottom: 17px;
left: 18px;
z-index: 7;
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 18px;
pointer-events: none;
}
.scene-readout {
max-width: 310px;
padding: 9px 11px;
border: 1px solid rgba(24, 51, 59, 0.14);
border-radius: 5px;
background: rgba(250, 248, 242, 0.82);
backdrop-filter: blur(6px);
}
.scene-readout strong {
display: block;
font-family: var(--mono);
font-size: 10px;
}
.scene-readout span {
display: block;
margin-top: 3px;
color: var(--muted);
font-family: var(--mono);
font-size: 8px;
line-height: 1.4;
}
.axis-key {
display: flex;
gap: 12px;
padding: 8px 10px;
border: 1px solid rgba(24, 51, 59, 0.12);
border-radius: 4px;
background: rgba(250, 248, 242, 0.78);
font-family: var(--mono);
font-size: 8px;
white-space: nowrap;
}
.axis-key span {
display: flex;
align-items: center;
gap: 5px;
color: var(--muted);
}
.axis-key i {
width: 12px;
height: 2px;
background: var(--axis-color);
}
#hoverTip {
position: absolute;
z-index: 12;
display: none;
padding: 6px 8px;
border: 1px solid rgba(24, 51, 59, 0.16);
border-radius: 4px;
color: #fff;
background: rgba(24, 51, 59, 0.9);
font-family: var(--mono);
font-size: 8px;
pointer-events: none;
}
#loading {
position: absolute;
inset: 0;
z-index: 15;
display: grid;
place-items: center;
color: var(--muted);
background: #ece9e0;
font-family: var(--mono);
font-size: 10px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.statusbar {
display: grid;
grid-template-columns: 1fr auto 1fr;
align-items: center;
gap: 18px;
padding: 0 17px;
border-top: 1px solid var(--line);
color: var(--muted);
background: #e8e5dc;
font-family: var(--mono);
font-size: 8px;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.statusbar .left {
color: var(--teal);
font-weight: 700;
}
.statusbar .right {
color: var(--warning);
font-weight: 800;
text-align: right;
}
@media (max-width: 1120px) {
main {
grid-template-columns: 238px minmax(360px, 1fr) 300px;
}
.panel-body {
padding: 13px;
}
.top-context {
display: none;
}
}
@media (max-width: 900px) {
body {
overflow: auto;
}
#app {
display: block;
height: auto;
min-height: 100vh;
}
.topbar {
height: 64px;
}
main {
display: block;
}
#viewport {
height: 64vh;
min-height: 480px;
}
.side-panel {
overflow: visible;
border: 0;
border-top: 1px solid var(--line);
}
.panel-body {
padding: 18px;
}
.ply-list {
grid-template-columns: 1fr 1fr;
}
.statusbar {
min-height: 40px;
grid-template-columns: 1fr auto;
}
.statusbar > :nth-child(2) {
display: none;
}
}
@media (max-width: 580px) {
.brand-sub {
display: none;
}
.status-pill {
padding: 7px 8px;
font-size: 7px;
}
.ply-list {
grid-template-columns: 1fr;
}
.scene-tools {
top: auto;
right: 12px;
bottom: 76px;
}
.scene-heading {
top: 14px;
left: 14px;
}
.axis-key {
display: none;
}
}
</style>
</head>
<body>
<div id="app">
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true">
<span></span><span></span><span></span>
</div>
<div>
<div class="brand-name">PLYSCAPE</div>
<div class="brand-sub">Laminate orientation lab</div>
</div>
</div>
<div class="top-context">
<span>Composites</span>
<span class="slash">/</span>
<b>Exploration board</b>
<span class="slash">/</span>
<span>4-ply schematic</span>
</div>
<div class="status-pill">
<span class="status-dot"></span>
Exploratory model · not certification
</div>
</header>
<main>
<aside class="side-panel left-panel" aria-label="Layup editor">
<div class="panel-header">
<span class="panel-index">01</span>
<h2>Layup editor</h2>
</div>
<div class="panel-body">
<div class="section-kicker">Through-thickness sequence</div>
<div class="stack-summary">
<span><strong>4</strong> schematic plies</span>
<span><strong>0.125 mm</strong> each · <strong>0.50 mm</strong> total</span>
</div>
<div id="plyList" class="ply-list"></div>
<div class="preset-grid">
<button class="small-button primary" data-preset="default">Restore schematic layup</button>
<button class="small-button" data-preset="cross">Cross-ply 0 / 90</button>
<button class="small-button" data-preset="diagonal">±45° schematic</button>
<button class="small-button" data-preset="zero">All fibers at 0°</button>
</div>
<section class="assumptions">
<div class="section-kicker">Nominal material constants</div>
<div class="property-list">
<div class="property-row"><span>E₁ / longitudinal</span><strong>40 GPa</strong></div>
<div class="property-row"><span>E₂ / transverse</span><strong>10 GPa</strong></div>
<div class="property-row"><span>G₁₂ / in-plane shear</span><strong>4 GPa</strong></div>
<div class="property-row"><span>ν₁₂ / major Poisson</span><strong>0.25</strong></div>
<div class="property-row"><span>Nominal ply thickness</span><strong>0.125 mm</strong></div>
</div>
</section>
</div>
</aside>
<section id="viewport" aria-label="Interactive low-poly laminate scene">
<div id="canvasHost"></div>
<div class="scene-heading">
<div class="scene-kicker">Exploded orthotropic stack</div>
<h1>Explore fiber direction</h1>
<div class="scene-subtitle">P1 → P4 through thickness · spacing exaggerated</div>
</div>
<div class="scene-tools">
<button id="frontView" class="tool-button" type="button">Front</button>
<button id="homeView" class="tool-button" type="button">Reset view</button>
<button id="labelsToggle" class="tool-button" type="button">Labels on</button>
</div>
<div id="labels"></div>
<div id="hoverTip"></div>
<div class="scene-bottom">
<div class="scene-readout">
<strong id="selectedReadout">P3 selected · 45°</strong>
<span>Drag a ply sideways to rotate · drag background to orbit · scroll to zoom</span>
</div>
<div class="axis-key" aria-label="Global reference axes">
<span><i style="--axis-color:#2a9d8f"></i>X1 / 0°</span>
<span><i style="--axis-color:#e76f51"></i>X2 / 90°</span>
</div>
</div>
<div id="loading">Initializing simplified laminate model…</div>
</section>
<aside class="side-panel right-panel" aria-label="Directional response inspector">
<div class="panel-header">
<span class="panel-index">02</span>
<h2>Directional response</h2>
</div>
<div class="panel-body">
<div class="model-chip">Model output · indicative only</div>
<div class="chart-wrap">
<svg
id="stiffnessChart"
viewBox="0 0 280 280"
role="img"
aria-label="Polar chart of estimated directional axial modulus"
></svg>
</div>
<div class="probe-readout">
<div>
<div class="probe-label">Eθ at probe direction</div>
<div id="probeAngle" class="probe-angle">30° from X1</div>
</div>
<div class="probe-value">
<span id="probeValue">—</span><small>GPa</small>
</div>
</div>
<input
id="probeSlider"
class="probe-slider"
type="range"
min="0"
max="179"
value="30"
aria-label="Directional probe angle"
>
<div class="metric-heading">
<h3>Directional extrema</h3>
<span>0°–180° sweep</span>
</div>
<div class="metric-grid">
<div class="metric-card">
<div class="metric-name">Maximum Eθ</div>
<div class="metric-number"><span id="metricMax">—</span><small>GPa</small></div>
<div class="metric-name" id="metricMaxDir" style="margin-top:5px">—</div>
</div>
<div class="metric-card">
<div class="metric-name">Minimum Eθ</div>
<div class="metric-number"><span id="metricMin">—</span><small>GPa</small></div>
<div class="metric-name" id="metricMinDir" style="margin-top:5px">—</div>
</div>
</div>
<div class="metric-heading">
<h3>Membrane stiffness matrix</h3>
<span>Aᵢⱼ · kN/mm</span>
</div>
<div class="matrix-grid">
<div class="matrix-cell">
<div class="matrix-symbol">A₁₁</div>
<div class="matrix-value" id="matrixA11">—</div>
</div>
<div class="matrix-cell">
<div class="matrix-symbol">A₁₂</div>
<div class="matrix-value" id="matrixA12">—</div>
</div>
<div class="matrix-cell">
<div class="matrix-symbol">A₂₂</div>
<div class="matrix-value" id="matrixA22">—</div>
</div>
<div class="matrix-cell">
<div class="matrix-symbol">A₆₆</div>
<div class="matrix-value" id="matrixA66">—</div>
</div>
</div>
<div class="cert-boundary">
<div class="cert-title">Certification boundary</div>
<p>
<strong>These are simplified model indicators, not an engineering
certification.</strong> No FEA, code compliance, failure criterion,
test correlation, or design approval has been performed.
</p>
</div>
<details class="method">
<summary>How the simplified model works</summary>
<p>
Each schematic ply is transformed into global axes using the
standard transformed reduced-stiffness equations. The membrane
stiffness is <code>A = Σ tₖQ̄ₖ</code>.
</p>
<p>
For a unit direction <code>n = [cos θ, sin θ]ᵀ</code>, the plotted
indicator is the estimated axial modulus
<code>Eθ = 1 / (nᵀA⁻¹n)</code> under uniaxial stress in direction θ.
</p>
<ul>
<li>Linear elastic and small-strain assumptions.</li>
<li>Homogeneous nominal 0° unidirectional ply.</li>
<li>Perfect bonding and constant ply thickness.</li>
<li>No knockdown, defects, fatigue, moisture, creep, or manufacturing tolerances.</li>
<li>No laminate failure theory, buckling, fracture, or certification check.</li>
</ul>
</details>
</div>
</aside>
</main>
<footer class="statusbar">
<span class="left">● Model output / directional modulus estimates</span>
<span>4 nominal plies · 0.50 mm total · linear reduced-stiffness model</span>
<span class="right">Engineering certification: not performed</span>
</footer>
</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 clamp = THREE.MathUtils.clamp;
const rad = THREE.MathUtils.degToRad;
const deg = THREE.MathUtils.radToDeg;
const COLORS = {
teal: "#2a9d8f",
coral: "#e76f51",
yellow: "#e9c46a",
blue: "#457b9d"
};
const plies = [
{ id: "P1", color: COLORS.teal, angle: 0, fiber: "#173f43" },
{ id: "P2", color: COLORS.coral, angle: 90, fiber: "#4d211b" },
{ id: "P3", color: COLORS.yellow, angle: 45, fiber: "#493b18" },
{ id: "P4", color: COLORS.blue, angle: -45, fiber: "#173448" }
];
const PLY_THICKNESS = 0.125;
const BOARD_W = 4.2;
const BOARD_H = 3.05;
const BOARD_T = 0.12;
let selectedPly = 2;
let probeAngle = 30;
let labelsVisible = true;
let currentModel = null;
function normalizeAngle(value) {
let a = ((Number(value) + 180) % 180 + 180) % 180 - 180;
if (Math.abs(a + 180) < 0.001) a = 0;
return a;
}
function angleDescription(angle) {
if (angle === 0) return "X1 · 0°";
if (angle === 90 || angle === -90) return "X2 · 90°";
return angle > 0 ? `+${angle}° mixed` : `${angle}° mixed`;
}
// ---------------------------------------------------------------------
// Left-side layup controls
// ---------------------------------------------------------------------
const plyList = $("#plyList");
plies.forEach((ply, index) => {
const row = document.createElement("div");
row.className = "ply-row";
row.dataset.index = index;
row.style.setProperty("--ply-color", ply.color);
row.innerHTML = `
<div class="ply-head">
<button class="ply-pick" type="button" aria-label="Select ${ply.id}">
<span class="ply-swatch"></span>
<span class="ply-code">${ply.id}</span>
<span class="ply-direction"></span>
</button>
<label class="angle-box">
<input class="angle-number" type="number" min="-90" max="90"
step="1" value="${ply.angle}" aria-label="${ply.id} fiber angle">
<span>°</span>
</label>
</div>
<input class="angle-range" type="range" min="-90" max="90" step="1"
value="${ply.angle}" aria-label="Rotate ${ply.id} fiber direction">
`;
plyList.appendChild(row);
row.querySelector(".ply-pick").addEventListener("click", () => selectPly(index));
row.querySelector(".angle-range").addEventListener("input", (event) => {
setPlyAngle(index, Number(event.target.value));
});
row.querySelector(".angle-number").addEventListener("change", (event) => {
const value = Number(event.target.value);
if (Number.isFinite(value)) setPlyAngle(index, value);
else updatePlyControls();
});
});
function updatePlyControls() {
plies.forEach((ply, index) => {
const row = plyList.children[index];
const range = row.querySelector(".angle-range");
const number = row.querySelector(".angle-number");
range.value = ply.angle;
number.value = ply.angle;
row.querySelector(".ply-direction").textContent = angleDescription(ply.angle);
const fill = ((ply.angle + 90) / 180) * 100;
range.style.setProperty("--fill", `${fill}%`);
});
}
function selectPly(index) {
selectedPly = index;
[...plyList.children].forEach((row, i) => {
row.classList.toggle("selected", i === selectedPly);
});
layerGroups.forEach((group, i) => {
const active = i === selectedPly;
const mesh = plyMeshes[i];
mesh.material[4].emissive.setHex(active ? 0x173f46 : 0x000000);
mesh.material[4].emissiveIntensity = active ? 0.18 : 0;
mesh.material[5].emissive.setHex(active ? 0x173f46 : 0x000000);
mesh.material[5].emissiveIntensity = active ? 0.12 : 0;
group.userData.edgeMaterial.color.setHex(
active ? 0x173f46 : 0x52656a
);
group.userData.edgeMaterial.opacity = active ? 0.95 : 0.38;
});
labelButtons.forEach((button, i) => {
button.classList.toggle("selected", i === selectedPly);
});
updateSelectedReadout();
}
function updateSelectedReadout() {
const ply = plies[selectedPly];
const sign = ply.angle > 0 ? "+" : "";
$("#selectedReadout").textContent =
`${ply.id} selected · ${sign}${ply.angle}°`;
}
function setPlyAngle(index, value) {
plies[index].angle = normalizeAngle(value);
if (layerGroups[index]) {
layerGroups[index].rotation.z = rad(plies[index].angle);
}
updatePlyControls();
updateSelectedReadout();
computeModel();
renderChart();
updateProbeGraphic();
}
const presets = {
default: [0, 90, 45, -45],
cross: [0, 90, 0, 90],
diagonal: [45, -45, 45, -45],
zero: [0, 0, 0, 0]
};
$$("[data-preset]").forEach((button) => {
button.addEventListener("click", () => {
const values = presets[button.dataset.preset];
values.forEach((value, index) => {
plies[index].angle = value;
layerGroups[index].rotation.z = rad(value);
});
updatePlyControls();
updateSelectedReadout();
computeModel();
renderChart();
updateProbeGraphic();
});
});
// ---------------------------------------------------------------------
// Simplified transformed reduced-stiffness model
// ---------------------------------------------------------------------
const MATERIAL = {
E1: 40000, // MPa
E2: 10000, // MPa
G12: 4000, // MPa
v12: 0.25
};
function computeModel() {
const v21 = MATERIAL.v12 * MATERIAL.E2 / MATERIAL.E1;
const denominator = 1 - MATERIAL.v12 * v21;
const Q11 = MATERIAL.E1 / denominator;
const Q22 = MATERIAL.E2 / denominator;
const Q12 = MATERIAL.v12 * MATERIAL.E2 / denominator;
const Q66 = MATERIAL.G12;
let A11 = 0;
let A12 = 0;
let A22 = 0;
let A66 = 0;
plies.forEach((ply) => {
const theta = rad(ply.angle);
const c = Math.cos(theta);
const s = Math.sin(theta);
const c2 = c * c;
const s2 = s * s;
const s2c2 = s2 * c2;
const Q11b =
Q11 * c2 * c2 +
2 * (Q12 + 2 * Q66) * s2c2 +
Q22 * s2 * s2;
const Q22b =
Q11 * s2 * s2 +
2 * (Q12 + 2 * Q66) * s2c2 +
Q22 * c2 * c2;
const Q12b =
(Q11 + Q22 - 4 * Q66) * s2c2 +
Q12 * (s2 * s2 + c2 * c2);
const Q66b =
(Q11 + Q22 - 2 * Q12 - 2 * Q66) * s2c2 +
Q66 * (s2 * s2 + c2 * c2);
A11 += PLY_THICKNESS * Q11b;
A12 += PLY_THICKNESS * Q12b;
A22 += PLY_THICKNESS * Q22b;
A66 += PLY_THICKNESS * Q66b;
});
const determinant = A11 * A22 - A12 * A12;
const inv11 = A22 / determinant;
const inv12 = -A12 / determinant;
const inv22 = A11 / determinant;
const effectiveModulus = (angle) => {
const theta = rad(angle);
const c = Math.cos(theta);
const s = Math.sin(theta);
const compliance =
inv11 * c * c +
2 * inv12 * c * s +
inv22 * s * s;
return 1 / compliance;
};
let maxE = -Infinity;
let minE = Infinity;
let maxAngle = 0;
let minAngle = 0;
for (let angle = 0; angle < 180; angle += 0.5) {
const value = effectiveModulus(angle);
if (value > maxE) {
maxE = value;
maxAngle = angle;
}
if (value < minE) {
minE = value;
minAngle = angle;
}
}
currentModel = {
A11,
A12,
A22,
A66,
effectiveModulus,
maxE,
minE,
maxAngle,
minAngle
};
$("#metricMax").textContent = (maxE / 1000).toFixed(1);
$("#metricMin").textContent = (minE / 1000).toFixed(1);
$("#metricMaxDir").textContent = `${Math.round(maxAngle)}° from X1`;
$("#metricMinDir").textContent = `${Math.round(minAngle)}° from X1`;
$("#matrixA11").textContent = (A11 / 1000).toFixed(2);
$("#matrixA12").textContent = (A12 / 1000).toFixed(2);
$("#matrixA22").textContent = (A22 / 1000).toFixed(2);
$("#matrixA66").textContent = (A66 / 1000).toFixed(2);
}
// ---------------------------------------------------------------------
// Directional polar chart
// ---------------------------------------------------------------------
const chart = $("#stiffnessChart");
const CHART_CX = 140;
const CHART_CY = 140;
const CHART_R = 105;
const CHART_MAX_MPA = 45000;
function chartPoint(angle, value = currentModel.effectiveModulus(angle)) {
const radius = clamp(value / CHART_MAX_MPA, 0, 1) * CHART_R;
const theta = rad(angle);
return {
x: CHART_CX + radius * Math.cos(theta),
y: CHART_CY - radius * Math.sin(theta),
radius
};
}
function renderChart() {
const rings = [15, 30, 45];
let markup = "";
rings.forEach((gpa) => {
const radius = (gpa / 45) * CHART_R;
markup += `
<circle class="chart-ring" cx="${CHART_CX}" cy="${CHART_CY}" r="${radius}"></circle>
<text class="chart-text" x="${CHART_CX + 3}" y="${CHART_CY - radius - 3}">${gpa}</text>
`;
});
markup += `
<line class="chart-axis" x1="${CHART_CX - CHART_R - 5}" y1="${CHART_CY}"
x2="${CHART_CX + CHART_R + 5}" y2="${CHART_CY}"></line>
<line class="chart-axis" x1="${CHART_CX}" y1="${CHART_CY - CHART_R - 5}"
x2="${CHART_CX}" y2="${CHART_CY + CHART_R + 5}"></line>
`;
let path = "";
for (let angle = 0; angle <= 180; angle += 2) {
const point = chartPoint(angle);
path += `${angle === 0 ? "M" : "L"}${point.x.toFixed(2)},${point.y.toFixed(2)} `;
}
path += "Z";
markup += `
<path class="chart-response" d="${path}"></path>
<line id="probeLine" class="chart-probe-line"></line>
<circle id="probeDot" class="chart-probe-dot" r="5"></circle>
<text class="chart-axis-label" x="${CHART_CX + CHART_R + 8}" y="${CHART_CY + 3}">X1</text>
<text class="chart-axis-label" x="${CHART_CX}" y="${CHART_CY - CHART_R - 10}"
text-anchor="middle">X2</text>
<text class="chart-text" x="12" y="18">GPa</text>
`;
chart.innerHTML = markup;
updateProbeGraphic();
}
function updateProbeGraphic() {
if (!currentModel) return;
const value = currentModel.effectiveModulus(probeAngle);
const point = chartPoint(probeAngle, value);
const probeLine = chart.querySelector("#probeLine");
const probeDot = chart.querySelector("#probeDot");
if (probeLine && probeDot) {
probeLine.setAttribute("x1", CHART_CX);
probeLine.setAttribute("y1", CHART_CY);
probeLine.setAttribute("x2", point.x);
probeLine.setAttribute("y2", point.y);
probeDot.setAttribute("cx", point.x);
probeDot.setAttribute("cy", point.y);
}
$("#probeValue").textContent = (value / 1000).toFixed(1);
$("#probeAngle").textContent = `${probeAngle}° from X1`;
$("#probeSlider").value = probeAngle;
$("#probeSlider").style.setProperty(
"--probe-fill",
`${(probeAngle / 179) * 100}%`
);
}
function setProbe(angle) {
probeAngle = ((angle % 180) + 180) % 180;
updateProbeGraphic();
}
$("#probeSlider").addEventListener("input", (event) => {
setProbe(Number(event.target.value));
});
function probeFromPointer(event) {
const point = chart.createSVGPoint();
point.x = event.clientX;
point.y = event.clientY;
const matrix = chart.getScreenCTM();
if (!matrix) return;
const local = point.matrixTransform(matrix.inverse());
const angle = deg(Math.atan2(CHART_CY - local.y, local.x - CHART_CX));
setProbe(angle);
}
chart.addEventListener("pointermove", probeFromPointer);
chart.addEventListener("pointerdown", (event) => {
chart.setPointerCapture(event.pointerId);
probeFromPointer(event);
});
// ---------------------------------------------------------------------
// Three.js low-poly scene
// ---------------------------------------------------------------------
const viewport = $("#viewport");
const canvasHost = $("#canvasHost");
const labelsHost = $("#labels");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xece9e0);
scene.fog = new THREE.Fog(0xece9e0, 13, 24);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
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;
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute(
"aria-label",
"Interactive exploded laminate. Drag a ply to rotate it, or drag the background to orbit."
);
canvasHost.appendChild(renderer.domElement);
const camera = new THREE.PerspectiveCamera(34, 1, 0.1, 100);
const cameraState = {
theta: 0.48,
phi: 1.18,
radius: 9.45,
target: new THREE.Vector3(0, 0, 0.1)
};
const desiredCamera = {
theta: cameraState.theta,
phi: cameraState.phi,
radius: cameraState.radius,
target: cameraState.target.clone()
};
function updateCamera(dt = 1) {
const smoothing = 1 - Math.exp(-10 * dt);
cameraState.theta += (desiredCamera.theta - cameraState.theta) * smoothing;
cameraState.phi += (desiredCamera.phi - cameraState.phi) * smoothing;
cameraState.radius += (desiredCamera.radius - cameraState.radius) * smoothing;
cameraState.target.lerp(desiredCamera.target, smoothing);
const spherical = new THREE.Spherical(
cameraState.radius,
cameraState.phi,
cameraState.theta
);
camera.position.setFromSpherical(spherical).add(cameraState.target);
camera.lookAt(cameraState.target);
}
const hemisphere = new THREE.HemisphereLight(0xfffdf5, 0x8b8174, 2.2);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff4dc, 4.1);
keyLight.position.set(4.5, 6.5, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1024, 1024);
keyLight.shadow.camera.left = -6;
keyLight.shadow.camera.right = 6;
keyLight.shadow.camera.top = 6;
keyLight.shadow.camera.bottom = -6;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 20;
keyLight.shadow.bias = -0.0004;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0x9bc8d2, 1.55);
fillLight.position.set(-5, 1.5, 4);
scene.add(fillLight);
const rimLight = new THREE.DirectionalLight(0xffd6b5, 1.2);
rimLight.position.set(1, -4, -2);
scene.add(rimLight);
const backdrop = new THREE.Mesh(
new THREE.PlaneGeometry(30, 20),
new THREE.MeshStandardMaterial({
color: 0xe9e5db,
roughness: 1,
metalness: 0
})
);
backdrop.position.z = -1.45;
backdrop.receiveShadow = true;
scene.add(backdrop);
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(30, 30),
new THREE.MeshStandardMaterial({
color: 0xe4e0d6,
roughness: 1,
metalness: 0
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -2.22;
floor.receiveShadow = true;
scene.add(floor);
const framePoints = [
new THREE.Vector3(-BOARD_W / 2 - 0.3, -BOARD_H / 2 - 0.28, -1.42),
new THREE.Vector3(BOARD_W / 2 + 0.3, -BOARD_H / 2 - 0.28, -1.42),
new THREE.Vector3(BOARD_W / 2 + 0.3, BOARD_H / 2 + 0.28, -1.42),
new THREE.Vector3(-BOARD_W / 2 - 0.3, BOARD_H / 2 + 0.28, -1.42),
new THREE.Vector3(-BOARD_W / 2 - 0.3, -BOARD_H / 2 - 0.28, -1.42)
];
const frame = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(framePoints),
new THREE.LineDashedMaterial({
color: 0x879497,
dashSize: 0.12,
gapSize: 0.08,
transparent: true,
opacity: 0.5
})
);
frame.computeLineDistances();
scene.add(frame);
function createFiberGeometry(width, height, angle) {
const positions = [];
const theta = rad(angle);
const direction = { x: Math.cos(theta), y: Math.sin(theta) };
const normal = { x: -Math.sin(theta), y: Math.cos(theta) };
for (let offset = -height / 2; offset <= height / 2 + 0.001; offset += 0.16) {
const xLimit = Math.abs(direction.x) > 0.0001
? (width / 2 - Math.abs(normal.x * offset)) / Math.abs(direction.x)
: Infinity;
const yLimit = Math.abs(direction.y) > 0.0001
? (height / 2 - Math.abs(normal.y * offset)) / Math.abs(direction.y)
: Infinity;
const tMax = Math.min(xLimit, yLimit);
if (tMax <= 0) continue;
const x1 = normal.x * offset - direction.x * tMax;
const y1 = normal.y * offset - direction.y * tMax;
const x2 = normal.x * offset + direction.x * tMax;
const y2 = normal.y * offset + direction.y * tMax;
const z = BOARD_T / 2 + 0.006;
positions.push(x1, y1, z, x2, y2, z);
}
return new THREE.BufferGeometry().setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
}
function createArrowGeometry(angle) {
const theta = rad(angle);
const d = { x: Math.cos(theta), y: Math.sin(theta) };
const n = { x: -Math.sin(theta), y: Math.cos(theta) };
const z = BOARD_T / 2 + 0.012;
const shaftStart = -0.58;
const shaftEnd = 0.36;
const tip = 0.55;
const wing = 0.17;
const points = [
[shaftStart, shaftEnd],
[tip, tip - 0.2 * d.x + wing * n.x, tip - 0.2 * d.y + wing * n.y],
[tip, tip - 0.2 * d.x - wing * n.x, tip - 0.2 * d.y - wing * n.y]
];
const positions = [];
points.forEach(([x1, y1], index) => {
if (index === 0) {
positions.push(
x1 * d.x, x1 * d.y, z,
y1 * d.x, y1 * d.y, z
);
} else {
positions.push(
y1 * d.x, y1 * d.y, z,
x1 * d.x, x1 * d.y, z
);
}
});
return new THREE.BufferGeometry().setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
}
const layerGroups = [];
const plyMeshes = [];
const labelButtons = [];
plies.forEach((ply, index) => {
const group = new THREE.Group();
group.position.z = (index - 1.5) * 0.48;
group.rotation.z = rad(ply.angle);
const sideMaterial = new THREE.MeshStandardMaterial({
color: new THREE.Color(ply.color).multiplyScalar(0.68),
roughness: 0.9,
metalness: 0,
flatShading: true
});
const broadMaterial = new THREE.MeshStandardMaterial({
color: ply.color,
roughness: 0.76,
metalness: 0,
flatShading: true,
emissive: 0x000000,
emissiveIntensity: 0
});
const backMaterial = broadMaterial.clone();
const edgeMaterial = new THREE.MeshStandardMaterial({
color: new THREE.Color(ply.color).multiplyScalar(0.72),
roughness: 0.94,
metalness: 0,
flatShading: true
});
const slabGeometry = new THREE.BoxGeometry(
BOARD_W,
BOARD_H,
BOARD_T
);
const slab = new THREE.Mesh(
slabGeometry,
[edgeMaterial, edgeMaterial, edgeMaterial, edgeMaterial, broadMaterial, backMaterial]
);
slab.castShadow = true;
slab.receiveShadow = true;
slab.userData.plyIndex = index;
group.add(slab);
plyMeshes.push(slab);
const fiberMaterial = new THREE.LineBasicMaterial({
color: ply.fiber,
transparent: true,
opacity: 0.65
});
const fibers = new THREE.LineSegments(
createFiberGeometry(BOARD_W - 0.12, BOARD_H - 0.12, ply.angle),
fiberMaterial
);
group.add(fibers);
const arrow = new THREE.LineSegments(
createArrowGeometry(ply.angle),
new THREE.LineBasicMaterial({
color: ply.fiber,
transparent: true,
opacity: 0.95
})
);
group.add(arrow);
const edgeLineMaterial = new THREE.LineBasicMaterial({
color: 0x52656a,
transparent: true,
opacity: 0.38
});
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(slabGeometry, 20),
edgeLineMaterial
);
group.add(edges);
group.userData.edgeMaterial = edgeLineMaterial;
scene.add(group);
layerGroups.push(group);
const label = document.createElement("button");
label.type = "button";
label.className = "ply-label";
label.style.setProperty("--label-color", ply.color);
label.innerHTML = `<i></i>${ply.id}<span>0°</span>`;
label.addEventListener("click", () => selectPly(index));
labelsHost.appendChild(label);
labelButtons.push(label);
});
const axisOrigin = new THREE.Vector3(-2.55, -1.92, 0.95);
const axisX = new THREE.ArrowHelper(
new THREE.Vector3(1, 0, 0),
axisOrigin,
1.22,
0x2a9d8f,
0.18,
0.11
);
const axisY = new THREE.ArrowHelper(
new THREE.Vector3(0, 1, 0),
axisOrigin,
0.92,
0xe76f51,
0.18,
0.11
);
const axisZ = new THREE.ArrowHelper(
new THREE.Vector3(0, 0, 1),
axisOrigin,
0.62,
0xe9c46a,
0.15,
0.09
);
scene.add(axisX, axisY, axisZ);
// ---------------------------------------------------------------------
// Direct camera and object controls implemented here, without addons
// ---------------------------------------------------------------------
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const hoverTip = $("#hoverTip");
let drag = null;
function raycastPly(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);
const hits = raycaster.intersectObjects(plyMeshes, false);
return hits.length ? hits[0] : null;
}
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.focus({ preventScroll: true });
renderer.domElement.setPointerCapture(event.pointerId);
const hit = raycastPly(event);
if (event.button === 0 && hit) {
const index = hit.object.userData.plyIndex;
selectPly(index);
drag = {
mode: "ply",
index,
startX: event.clientX,
startAngle: plies[index].angle,
moved: false
};
renderer.domElement.style.cursor = "ew-resize";
hoverTip.style.display = "none";
} else {
drag = {
mode: event.button === 2 || event.shiftKey ? "pan" : "orbit",
lastX: event.clientX,
lastY: event.clientY,
moved: false
};
renderer.domElement.style.cursor = drag.mode === "pan" ? "move" : "grabbing";
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (drag) {
const dx = event.clientX - drag.lastX;
const dy = event.clientY - drag.lastY;
if (drag.mode === "ply") {
const totalDx = event.clientX - drag.startX;
if (Math.abs(totalDx) > 1) drag.moved = true;
setPlyAngle(drag.index, drag.startAngle + totalDx * 0.48);
} else if (drag.mode === "orbit") {
desiredCamera.theta -= dx * 0.006;
desiredCamera.phi = clamp(desiredCamera.phi - dy * 0.006, 0.45, 2.25);
drag.lastX = event.clientX;
drag.lastY = event.clientY;
drag.moved = true;
} else if (drag.mode === "pan") {
const direction = new THREE.Vector3();
camera.getWorldDirection(direction);
const right = new THREE.Vector3().crossVectors(direction, camera.up).normalize();
const up = new THREE.Vector3().crossVectors(right, direction).normalize();
const scale = cameraState.radius * 0.0017;
desiredCamera.target.addScaledVector(right, -dx * scale);
desiredCamera.target.addScaledVector(up, dy * scale);
desiredCamera.target.x = clamp(desiredCamera.target.x, -2.5, 2.5);
desiredCamera.target.y = clamp(desiredCamera.target.y, -1.7, 1.7);
drag.lastX = event.clientX;
drag.lastY = event.clientY;
drag.moved = true;
}
return;
}
const hit = raycastPly(event);
if (hit) {
const index = hit.object.userData.plyIndex;
const ply = plies[index];
const rect = viewport.getBoundingClientRect();
hoverTip.textContent = `${ply.id} · ${ply.angle}° · drag to rotate`;
hoverTip.style.left = `${event.clientX - rect.left + 12}px`;
hoverTip.style.top = `${event.clientY - rect.top + 12}px`;
hoverTip.style.display = "block";
renderer.domElement.style.cursor = "ew-resize";
} else {
hoverTip.style.display = "none";
renderer.domElement.style.cursor = "grab";
}
});
function endDrag(event) {
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
drag = null;
renderer.domElement.style.cursor = "grab";
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("pointerleave", () => {
if (!drag) hoverTip.style.display = "none";
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desiredCamera.radius = clamp(
desiredCamera.radius * Math.exp(event.deltaY * 0.001),
5.4,
13.5
);
},
{ passive: false }
);
function homeView() {
desiredCamera.theta = 0.48;
desiredCamera.phi = 1.18;
desiredCamera.radius = 9.45;
desiredCamera.target.set(0, 0, 0.1);
}
$("#homeView").addEventListener("click", homeView);
$("#frontView").addEventListener("click", () => {
desiredCamera.theta = 0;
desiredCamera.phi = Math.PI / 2;
desiredCamera.radius = 8.7;
desiredCamera.target.set(0, 0, 0.1);
});
$("#labelsToggle").addEventListener("click", (event) => {
labelsVisible = !labelsVisible;
labelsHost.style.display = labelsVisible ? "block" : "none";
event.currentTarget.textContent = labelsVisible ? "Labels on" : "Labels off";
});
window.addEventListener("keydown", (event) => {
if (["INPUT", "TEXTAREA", "SELECT"].includes(document.activeElement.tagName)) {
return;
}
if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
event.preventDefault();
const direction = event.key === "ArrowRight" ? 1 : -1;
const increment = event.shiftKey ? 5 : 1;
setPlyAngle(selectedPly, plies[selectedPly].angle + direction * increment);
}
});
// ---------------------------------------------------------------------
// Labels, resizing, and render loop
// ---------------------------------------------------------------------
function updateLabels() {
if (!labelsVisible) return;
const width = viewport.clientWidth;
const height = viewport.clientHeight;
layerGroups.forEach((group, index) => {
const anchor = new THREE.Vector3(
-BOARD_W / 2 - 0.27,
BOARD_H / 2 - 0.24,
group.position.z + 0.08
);
anchor.project(camera);
const x = (anchor.x * 0.5 + 0.5) * width;
const y = (-anchor.y * 0.5 + 0.5) * height;
const button = labelButtons[index];
button.style.left = `${x}px`;
button.style.top = `${y}px`;
button.style.zIndex = String(20 + index);
button.style.opacity = anchor.z > -1 && anchor.z < 1 ? "1" : "0";
button.querySelector("span:last-child").textContent = `${plies[index].angle}°`;
});
}
function resize() {
const width = viewport.clientWidth;
const height = viewport.clientHeight;
if (!width || !height) return;
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
const resizeObserver = new ResizeObserver(resize);
resizeObserver.observe(viewport);
updatePlyControls();
computeModel();
renderChart();
selectPly(selectedPly);
resize();
updateCamera(1);
let previousTime = performance.now();
function animate(now) {
const dt = Math.min((now - previousTime) / 1000, 0.05);
previousTime = now;
updateCamera(dt);
updateLabels();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
$("#loading").remove();
</script>
</body>
</html>
```