Prompt specification
Build or customize the Three.js 3D scene "Suspender strap junction geometry" 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: Suspender strap junction geometry
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/suspender-strap-junction-geometry-x0625
Scene Description Prompt:
I'd like to see this as a stylized Three.js scene: suspender strap junction geometry. Display Y-shaped suspenders on a simple torso frame with visible clips and back junction; separate the three attachment paths so the load-sharing arrangement is readable. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (suspender-strap-junction-geometry-x0625):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Y-Junction Suspender Study</title>
<style>
:root {
--ink: #25303a;
--muted: #6d746f;
--paper: #f3f0e9;
--panel: rgba(250, 248, 243, 0.82);
--border: rgba(37, 48, 58, 0.14);
--left: #3b82f6;
--right: #f59e0b;
--rear: #8b5cf6;
--junction: #e76f51;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--paper);
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
outline: none;
}
.panel {
position: fixed;
z-index: 5;
border: 1px solid var(--border);
background: var(--panel);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
box-shadow: 0 18px 45px rgba(46, 39, 28, 0.08);
}
.intro {
top: 28px;
left: 28px;
width: min(390px, calc(100vw - 56px));
padding: 22px 24px 20px;
border-radius: 18px;
}
.eyebrow {
margin-bottom: 10px;
color: var(--junction);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(25px, 3vw, 37px);
font-weight: 650;
line-height: 1.03;
letter-spacing: -0.045em;
}
.intro p {
margin: 12px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.legend {
top: 28px;
right: 28px;
width: 230px;
padding: 17px 18px;
border-radius: 16px;
}
.legend-title {
margin-bottom: 12px;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.legend-item {
display: grid;
grid-template-columns: 24px 1fr;
gap: 9px;
align-items: start;
margin-top: 10px;
}
.swatch {
width: 20px;
height: 4px;
margin-top: 5px;
border-radius: 99px;
background: var(--color);
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.legend-item strong {
display: block;
font-size: 11px;
font-weight: 750;
}
.legend-item span:last-child {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 10px;
line-height: 1.35;
}
.controls {
left: 50%;
bottom: 25px;
width: min(760px, calc(100vw - 40px));
padding: 13px 16px;
border-radius: 16px;
transform: translateX(-50%);
display: grid;
grid-template-columns: minmax(220px, 1.5fr) repeat(3, auto) auto;
align-items: center;
gap: 17px;
}
.range-wrap {
min-width: 0;
}
.range-label {
display: flex;
justify-content: space-between;
margin-bottom: 7px;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.range-label output {
color: var(--muted);
font-variant-numeric: tabular-nums;
}
input[type="range"] {
width: 100%;
height: 4px;
margin: 0;
appearance: none;
border-radius: 99px;
background: linear-gradient(
to right,
var(--junction) 0%,
var(--junction) var(--value, 22%),
rgba(37, 48, 58, 0.13) var(--value, 22%)
);
cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
width: 15px;
height: 15px;
appearance: none;
border: 3px solid var(--panel);
border-radius: 50%;
background: var(--junction);
box-shadow: 0 0 0 1px rgba(37, 48, 58, 0.25);
}
input[type="range"]::-moz-range-thumb {
width: 11px;
height: 11px;
border: 3px solid var(--panel);
border-radius: 50%;
background: var(--junction);
box-shadow: 0 0 0 1px rgba(37, 48, 58, 0.25);
}
.toggle {
display: flex;
align-items: center;
gap: 7px;
color: #505954;
font-size: 11px;
white-space: nowrap;
cursor: pointer;
user-select: none;
}
.toggle input {
width: 14px;
height: 14px;
margin: 0;
accent-color: var(--junction);
}
.reset {
height: 32px;
padding: 0 12px;
border: 1px solid var(--border);
border-radius: 9px;
color: var(--ink);
background: rgba(255, 255, 255, 0.48);
font-size: 11px;
font-weight: 700;
cursor: pointer;
transition: background 150ms ease, transform 150ms ease;
}
.reset:hover {
background: white;
transform: translateY(-1px);
}
.hint {
position: fixed;
right: 30px;
bottom: 28px;
z-index: 4;
color: rgba(37, 48, 58, 0.56);
font-size: 10px;
letter-spacing: 0.06em;
pointer-events: none;
}
#leaders {
position: fixed;
inset: 0;
z-index: 3;
width: 100%;
height: 100%;
overflow: visible;
pointer-events: none;
}
#leaders line {
stroke-width: 1.2;
stroke-dasharray: 3 4;
opacity: 0.62;
}
.annotation {
position: fixed;
top: 0;
left: 0;
z-index: 4;
min-width: 138px;
padding: 8px 10px 8px 12px;
border: 1px solid rgba(37, 48, 58, 0.11);
border-left: 3px solid var(--accent);
border-radius: 8px;
background: rgba(250, 248, 243, 0.9);
box-shadow: 0 8px 24px rgba(48, 41, 30, 0.08);
pointer-events: none;
will-change: transform;
}
.annotation strong {
display: block;
color: var(--ink);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.annotation span {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 9px;
white-space: nowrap;
}
@media (max-width: 900px) {
.legend {
display: none;
}
.hint {
display: none;
}
.controls {
grid-template-columns: 1fr auto auto;
}
.toggle:nth-of-type(3) {
display: none;
}
}
@media (max-width: 620px) {
.intro {
top: 14px;
left: 14px;
width: calc(100vw - 28px);
padding: 16px 18px;
}
.intro p {
display: none;
}
.controls {
bottom: 12px;
width: calc(100vw - 24px);
grid-template-columns: 1fr auto;
gap: 12px;
}
.toggle {
display: none;
}
.annotation {
min-width: 112px;
padding: 7px 8px;
}
.annotation span {
display: none;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive 3D model of Y-shaped suspenders"></canvas>
<section class="panel intro">
<div class="eyebrow">Load path study / 01</div>
<h1>Y-junction<br>suspender system</h1>
<p>
Three distinct attachment paths meet at a reinforced rear junction.
Orbit the frame or increase separation to inspect the load-sharing geometry.
</p>
</section>
<aside class="panel legend" aria-label="Path legend">
<div class="legend-title">Attachment paths</div>
<div class="legend-item" style="--color: var(--left)">
<i class="swatch"></i>
<div>
<strong>Left shoulder</strong>
<span>Front clip to shared junction</span>
</div>
</div>
<div class="legend-item" style="--color: var(--right)">
<i class="swatch"></i>
<div>
<strong>Right shoulder</strong>
<span>Front clip to shared junction</span>
</div>
</div>
<div class="legend-item" style="--color: var(--rear)">
<i class="swatch"></i>
<div>
<strong>Center rear</strong>
<span>Junction to rear waist clip</span>
</div>
</div>
</aside>
<svg id="leaders" aria-hidden="true"></svg>
<div class="annotation" id="label-junction" style="--accent: var(--junction)">
<strong>Y-junction</strong>
<span>Shared load node</span>
</div>
<div class="annotation" id="label-left" style="--accent: var(--left)">
<strong>01 · Left shoulder</strong>
<span>Front clip → junction</span>
</div>
<div class="annotation" id="label-right" style="--accent: var(--right)">
<strong>02 · Right shoulder</strong>
<span>Front clip → junction</span>
</div>
<div class="annotation" id="label-rear" style="--accent: var(--rear)">
<strong>03 · Center rear</strong>
<span>Junction → rear clip</span>
</div>
<section class="panel controls" aria-label="Scene controls">
<div class="range-wrap">
<label class="range-label" for="separation">
<span>Path separation</span>
<output id="separation-value">22%</output>
</label>
<input
id="separation"
type="range"
min="0"
max="100"
value="22"
aria-label="Separate the three attachment paths"
>
</div>
<label class="toggle">
<input id="show-labels" type="checkbox" checked>
Labels
</label>
<label class="toggle">
<input id="show-arrows" type="checkbox" checked>
Load arrows
</label>
<label class="toggle">
<input id="auto-rotate" type="checkbox" checked>
Auto orbit
</label>
<button class="reset" id="reset-view" type="button">Reset view</button>
</section>
<div class="hint">DRAG TO ORBIT · SCROLL TO ZOOM · DOUBLE-CLICK TO RESET</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Scene setup
// -------------------------------------------------------------------------
const canvas = document.querySelector("#scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xf3f0e9);
scene.fog = new THREE.Fog(0xf3f0e9, 11, 23);
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
60
);
const target = new THREE.Vector3(0, 2.45, 0);
const orbit = {
theta: 0.58,
phi: 1.20,
radius: 10.0
};
function updateCamera() {
const sinPhi = Math.sin(orbit.phi);
camera.position.set(
target.x + orbit.radius * sinPhi * Math.sin(orbit.theta),
target.y + orbit.radius * Math.cos(orbit.phi),
target.z + orbit.radius * sinPhi * Math.cos(orbit.theta)
);
camera.lookAt(target);
}
updateCamera();
const hemi = new THREE.HemisphereLight(0xfffbf2, 0x8b918c, 2.15);
scene.add(hemi);
const key = new THREE.DirectionalLight(0xfff4dc, 3.15);
key.position.set(5, 8, 6);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -5;
key.shadow.camera.right = 5;
key.shadow.camera.top = 6;
key.shadow.camera.bottom = -3;
key.shadow.bias = -0.0008;
scene.add(key);
const rim = new THREE.DirectionalLight(0xb9d8ff, 2.1);
rim.position.set(-4, 5, -6);
scene.add(rim);
const fill = new THREE.DirectionalLight(0xffd7b6, 0.8);
fill.position.set(-5, 3, 4);
scene.add(fill);
// -------------------------------------------------------------------------
// Materials
// -------------------------------------------------------------------------
const strapMaterial = new THREE.MeshStandardMaterial({
color: 0x29343d,
roughness: 0.58,
metalness: 0.05,
side: THREE.DoubleSide
});
const frameMaterial = new THREE.MeshStandardMaterial({
color: 0xa9a296,
roughness: 0.8,
metalness: 0.03,
transparent: true,
opacity: 0.5,
depthWrite: false
});
const torsoMaterial = new THREE.MeshPhysicalMaterial({
color: 0xcac3b7,
roughness: 0.95,
transmission: 0.05,
transparent: true,
opacity: 0.035,
depthWrite: false,
side: THREE.DoubleSide
});
const steelMaterial = new THREE.MeshStandardMaterial({
color: 0xb8bec1,
roughness: 0.24,
metalness: 0.88
});
const darkSteelMaterial = new THREE.MeshStandardMaterial({
color: 0x4e565a,
roughness: 0.35,
metalness: 0.72
});
const leatherMaterial = new THREE.MeshStandardMaterial({
color: 0x805e48,
roughness: 0.78,
metalness: 0.02
});
const rivetMaterial = new THREE.MeshStandardMaterial({
color: 0xd2b17c,
roughness: 0.27,
metalness: 0.78
});
const pathColors = {
left: 0x3b82f6,
right: 0xf59e0b,
rear: 0x8b5cf6,
junction: 0xe76f51
};
function pathMaterial(color) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.45,
metalness: 0.04,
emissive: color,
emissiveIntensity: 0.15
});
}
// -------------------------------------------------------------------------
// Helpers
// -------------------------------------------------------------------------
function vectorArray(points) {
return points.map((point) =>
point.isVector3 ? point.clone() : new THREE.Vector3(...point)
);
}
function tube(points, radius, material, closed = false, segments = 72) {
const curve = new THREE.CatmullRomCurve3(
vectorArray(points),
closed,
"centripetal",
0.5
);
const mesh = new THREE.Mesh(
new THREE.TubeGeometry(curve, segments, radius, 8, closed),
material
);
mesh.castShadow = false;
mesh.receiveShadow = true;
return mesh;
}
function ellipsePoints(y, radiusX, radiusZ, count = 72) {
const points = [];
for (let i = 0; i < count; i++) {
const angle = (i / count) * Math.PI * 2;
points.push(
new THREE.Vector3(
Math.cos(angle) * radiusX,
y,
Math.sin(angle) * radiusZ
)
);
}
return points;
}
function sampleFrames(curve, count) {
const frames = [];
for (let i = 0; i <= count; i++) {
const t = i / count;
const point = curve.getPoint(t);
const tangent = curve.getTangent(t).normalize();
let side = new THREE.Vector3(1, 0, 0);
side.addScaledVector(tangent, -side.dot(tangent));
if (side.lengthSq() < 0.0001) {
side = new THREE.Vector3(0, 0, 1);
side.addScaledVector(tangent, -side.dot(tangent));
}
side.normalize();
const normal = new THREE.Vector3()
.crossVectors(tangent, side)
.normalize();
frames.push({ point, tangent, side, normal });
}
return frames;
}
function ribbonGeometry(curve, width, thickness, segments = 120) {
const frames = sampleFrames(curve, segments);
const positions = [];
const indices = [];
const halfWidth = width * 0.5;
const halfThickness = thickness * 0.5;
for (const frame of frames) {
const left = frame.point
.clone()
.addScaledVector(frame.side, -halfWidth);
const right = frame.point
.clone()
.addScaledVector(frame.side, halfWidth);
const topLeft = left.clone().addScaledVector(frame.normal, halfThickness);
const topRight = right.clone().addScaledVector(frame.normal, halfThickness);
const bottomLeft = left.clone().addScaledVector(frame.normal, -halfThickness);
const bottomRight = right.clone().addScaledVector(frame.normal, -halfThickness);
positions.push(
topLeft.x, topLeft.y, topLeft.z,
topRight.x, topRight.y, topRight.z,
bottomLeft.x, bottomLeft.y, bottomLeft.z,
bottomRight.x, bottomRight.y, bottomRight.z
);
}
for (let i = 0; i < segments; i++) {
const a = i * 4;
const b = (i + 1) * 4;
indices.push(
a, b, a + 1,
a + 1, b, b + 1,
a + 2, a + 3, b + 2,
a + 3, b + 3, b + 2,
a, a + 2, b,
a + 2, b + 2, b,
a + 1, b + 1, a + 3,
a + 3, b + 1, b + 3
);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
geometry.computeBoundingSphere();
return geometry;
}
function makeStitches(curve, width, color) {
const frames = sampleFrames(curve, 100);
const material = new THREE.LineDashedMaterial({
color,
dashSize: 0.065,
gapSize: 0.05,
transparent: true,
opacity: 0.58
});
const lines = [];
for (const sign of [-1, 1]) {
const points = frames.map((frame) =>
frame.point
.clone()
.addScaledVector(frame.side, sign * width * 0.36)
.addScaledVector(frame.normal, 0.025)
);
const line = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(points),
material
);
line.computeLineDistances();
lines.push(line);
}
return lines;
}
function makeAdjuster() {
const group = new THREE.Group();
const horizontalGeometry = new THREE.BoxGeometry(0.31, 0.045, 0.085);
const verticalGeometry = new THREE.BoxGeometry(0.045, 0.27, 0.085);
for (const y of [-0.115, 0.115]) {
const bar = new THREE.Mesh(horizontalGeometry, steelMaterial);
bar.position.y = y;
group.add(bar);
}
for (const x of [-0.132, 0.132]) {
const rail = new THREE.Mesh(verticalGeometry, steelMaterial);
rail.position.x = x;
group.add(rail);
}
const center = new THREE.Mesh(
new THREE.BoxGeometry(0.045, 0.26, 0.11),
darkSteelMaterial
);
group.add(center);
return group;
}
function makeClip(accentColor) {
const group = new THREE.Group();
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.105, 0.027, 10, 30),
steelMaterial
);
group.add(ring);
const body = new THREE.Mesh(
new THREE.BoxGeometry(0.265, 0.34, 0.105),
steelMaterial
);
body.position.y = -0.245;
body.castShadow = true;
group.add(body);
const lever = new THREE.Mesh(
new THREE.BoxGeometry(0.205, 0.13, 0.075),
new THREE.MeshStandardMaterial({
color: accentColor,
roughness: 0.38,
metalness: 0.55
})
);
lever.position.set(0, -0.115, 0.071);
lever.rotation.z = -0.12;
lever.castShadow = true;
group.add(lever);
const hinge = new THREE.Mesh(
new THREE.CylinderGeometry(0.028, 0.028, 0.31, 12),
darkSteelMaterial
);
hinge.rotation.z = Math.PI * 0.5;
hinge.position.set(0, -0.19, 0.067);
group.add(hinge);
for (let i = 0; i < 3; i++) {
const tooth = new THREE.Mesh(
new THREE.BoxGeometry(0.038, 0.055, 0.13),
darkSteelMaterial
);
tooth.position.set(-0.065 + i * 0.065, -0.43, 0.01);
group.add(tooth);
}
return group;
}
function makeStrap(points, color, options = {}) {
const group = new THREE.Group();
const curve = new THREE.CatmullRomCurve3(
vectorArray(points),
false,
"centripetal",
0.5
);
const width = options.width ?? 0.235;
const ribbon = new THREE.Mesh(
ribbonGeometry(curve, width, 0.035),
strapMaterial
);
ribbon.castShadow = true;
ribbon.receiveShadow = true;
group.add(ribbon);
// A slightly proud central cord keeps all three paths readable.
const accent = new THREE.Mesh(
new THREE.TubeGeometry(curve, 120, 0.026, 8, false),
pathMaterial(color)
);
group.add(accent);
const stitches = makeStitches(curve, width, 0xc9bda7);
stitches.forEach((line) => group.add(line));
if (options.clip) {
const clip = makeClip(color);
clip.position.copy(curve.getPoint(1));
group.add(clip);
}
if (options.adjuster) {
const adjuster = makeAdjuster();
adjuster.position.copy(options.adjuster);
group.add(adjuster);
}
return {
group,
curve,
points: vectorArray(points),
color
};
}
// -------------------------------------------------------------------------
// Ground and torso frame
// -------------------------------------------------------------------------
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(40, 40),
new THREE.MeshStandardMaterial({
color: 0xe9e5dc,
roughness: 0.95,
metalness: 0
})
);
floor.rotation.x = -Math.PI * 0.5;
floor.position.y = 0.42;
floor.receiveShadow = true;
scene.add(floor);
const platform = new THREE.Mesh(
new THREE.CylinderGeometry(2.55, 2.72, 0.13, 96),
new THREE.MeshStandardMaterial({
color: 0xd9d4c8,
roughness: 0.82,
metalness: 0.03
})
);
platform.position.y = 0.49;
platform.receiveShadow = true;
platform.castShadow = true;
scene.add(platform);
const platformRing = new THREE.Mesh(
new THREE.TorusGeometry(2.38, 0.012, 8, 120),
new THREE.MeshBasicMaterial({
color: 0xb9afa0,
transparent: true,
opacity: 0.55
})
);
platformRing.rotation.x = Math.PI * 0.5;
platformRing.position.y = 0.56;
scene.add(platformRing);
const torsoProfile = [
new THREE.Vector2(0.68, 0.84),
new THREE.Vector2(1.00, 1.08),
new THREE.Vector2(1.17, 1.65),
new THREE.Vector2(1.22, 2.42),
new THREE.Vector2(1.39, 3.18),
new THREE.Vector2(1.47, 3.53),
new THREE.Vector2(1.15, 3.86),
new THREE.Vector2(0.62, 4.05)
];
const torsoVolume = new THREE.Mesh(
new THREE.LatheGeometry(torsoProfile, 72),
torsoMaterial
);
torsoVolume.renderOrder = 1;
scene.add(torsoVolume);
const torsoFrame = new THREE.Group();
scene.add(torsoFrame);
torsoFrame.add(
tube(ellipsePoints(1.10, 1.03, 0.57), 0.026, frameMaterial, true)
);
torsoFrame.add(
tube(ellipsePoints(2.47, 1.23, 0.63), 0.021, frameMaterial, true)
);
torsoFrame.add(
tube(ellipsePoints(3.54, 1.44, 0.54), 0.028, frameMaterial, true)
);
for (const side of [-1, 1]) {
torsoFrame.add(
tube(
[
[side * 1.02, 1.10, 0.02],
[side * 1.19, 1.82, 0.0],
[side * 1.27, 2.52, 0.0],
[side * 1.43, 3.47, 0.0]
],
0.022,
frameMaterial
)
);
}
torsoFrame.add(
tube(
[
[0, 1.08, -0.65],
[0, 1.62, -0.69],
[0, 2.25, -0.69],
[0, 2.92, -0.69],
[0, 3.60, -0.64]
],
0.017,
frameMaterial
)
);
for (const y of [1.48, 1.88, 2.28, 2.68, 3.08]) {
const points = [];
for (let i = 0; i <= 24; i++) {
const t = i / 24;
const angle = t * Math.PI;
points.push(
new THREE.Vector3(
Math.cos(angle) * (0.83 - (y - 1.48) * 0.055),
y,
-0.60 - Math.sin(angle) * 0.14
)
);
}
torsoFrame.add(tube(points, 0.012, frameMaterial));
}
// -------------------------------------------------------------------------
// Three attachment paths
// -------------------------------------------------------------------------
const junctionPoint = new THREE.Vector3(0, 2.86, -0.76);
const leftStrap = makeStrap(
[
[0, 2.86, -0.76],
[-0.55, 3.15, -0.69],
[-0.96, 3.57, -0.55],
[-1.12, 3.87, -0.12],
[-1.05, 3.78, 0.30],
[-0.84, 3.35, 0.58],
[-0.78, 2.45, 0.72],
[-0.78, 1.52, 0.74]
],
pathColors.left,
{
clip: true,
adjuster: new THREE.Vector3(-0.78, 2.30, 0.765)
}
);
const rightStrap = makeStrap(
[
[0, 2.86, -0.76],
[0.55, 3.15, -0.69],
[0.96, 3.57, -0.55],
[1.12, 3.87, -0.12],
[1.05, 3.78, 0.30],
[0.84, 3.35, 0.58],
[0.78, 2.45, 0.72],
[0.78, 1.52, 0.74]
],
pathColors.right,
{
clip: true,
adjuster: new THREE.Vector3(0.78, 2.30, 0.765)
}
);
const rearStrap = makeStrap(
[
[0, 2.86, -0.76],
[0, 2.45, -0.77],
[0, 1.93, -0.75],
[0, 1.40, -0.72]
],
pathColors.rear,
{
clip: true,
width: 0.25
}
);
scene.add(leftStrap.group, rightStrap.group, rearStrap.group);
// -------------------------------------------------------------------------
// Back junction plate
// -------------------------------------------------------------------------
const junctionGroup = new THREE.Group();
junctionGroup.position.set(0, 2.86, -0.82);
const plateShape = new THREE.Shape();
plateShape.moveTo(-0.34, 0.26);
plateShape.lineTo(0.34, 0.26);
plateShape.lineTo(0.27, -0.08);
plateShape.lineTo(0.13, -0.34);
plateShape.lineTo(0, -0.42);
plateShape.lineTo(-0.13, -0.34);
plateShape.lineTo(-0.27, -0.08);
plateShape.closePath();
const plate = new THREE.Mesh(
new THREE.ExtrudeGeometry(plateShape, {
depth: 0.09,
bevelEnabled: true,
bevelSegments: 3,
bevelSize: 0.025,
bevelThickness: 0.025,
curveSegments: 8
}),
leatherMaterial
);
plate.castShadow = true;
junctionGroup.add(plate);
const rivetPositions = [
[-0.19, 0.14],
[0.19, 0.14],
[0, -0.25]
];
for (const [x, y] of rivetPositions) {
const rivet = new THREE.Mesh(
new THREE.SphereGeometry(0.045, 16, 10),
rivetMaterial
);
rivet.position.set(x, y, 0.125);
junctionGroup.add(rivet);
}
const stitchPoints = [
new THREE.Vector3(-0.28, 0.20, 0.125),
new THREE.Vector3(0.28, 0.20, 0.125),
new THREE.Vector3(0.22, -0.06, 0.125),
new THREE.Vector3(0.09, -0.28, 0.125),
new THREE.Vector3(0, -0.34, 0.125),
new THREE.Vector3(-0.09, -0.28, 0.125),
new THREE.Vector3(-0.22, -0.06, 0.125)
];
const stitchLine = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(stitchPoints),
new THREE.LineDashedMaterial({
color: 0xd8bd91,
dashSize: 0.045,
gapSize: 0.035,
transparent: true,
opacity: 0.9
})
);
stitchLine.computeLineDistances();
junctionGroup.add(stitchLine);
scene.add(junctionGroup);
const junctionHalo = new THREE.Mesh(
new THREE.TorusGeometry(0.43, 0.012, 8, 72),
new THREE.MeshBasicMaterial({
color: pathColors.junction,
transparent: true,
opacity: 0.64,
depthWrite: false
})
);
junctionHalo.position.set(0, 2.86, -0.93);
scene.add(junctionHalo);
// -------------------------------------------------------------------------
// Load-direction arrows
// -------------------------------------------------------------------------
function makeArrow(origin, direction, color, length) {
const arrow = new THREE.ArrowHelper(
direction,
origin,
length,
color,
0.12,
0.075
);
arrow.line.material.transparent = true;
arrow.line.material.opacity = 0.88;
arrow.line.material.depthTest = false;
arrow.cone.material.transparent = true;
arrow.cone.material.opacity = 0.92;
arrow.cone.material.depthTest = false;
arrow.line.renderOrder = 20;
arrow.cone.renderOrder = 20;
scene.add(arrow);
return arrow;
}
const arrows = [
makeArrow(
new THREE.Vector3(-0.58, 2.88, -0.70),
new THREE.Vector3(1, 0, 0),
pathColors.left,
0.43
),
makeArrow(
new THREE.Vector3(0.58, 2.88, -0.70),
new THREE.Vector3(-1, 0, 0),
pathColors.right,
0.43
),
makeArrow(
new THREE.Vector3(0, 2.69, -0.70),
new THREE.Vector3(0, -1, 0),
pathColors.rear,
0.40
)
];
// -------------------------------------------------------------------------
// Exploded-view guide lines
// -------------------------------------------------------------------------
function makeGuide(color) {
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(new Float32Array(6), 3)
);
const line = new THREE.Line(
geometry,
new THREE.LineDashedMaterial({
color,
dashSize: 0.06,
gapSize: 0.045,
transparent: true,
opacity: 0
})
);
line.frustumCulled = false;
scene.add(line);
return line;
}
const guides = {
left: makeGuide(pathColors.left),
right: makeGuide(pathColors.right),
rear: makeGuide(pathColors.rear)
};
function updateGuide(line, end) {
const attribute = line.geometry.attributes.position;
attribute.setXYZ(0, junctionPoint.x, junctionPoint.y, junctionPoint.z);
attribute.setXYZ(1, end.x, end.y, end.z);
attribute.needsUpdate = true;
line.computeLineDistances();
}
// -------------------------------------------------------------------------
// Screen-space annotations
// -------------------------------------------------------------------------
const svgNamespace = "http://www.w3.org/2000/svg";
const leaders = document.querySelector("#leaders");
const annotations = [
{
element: document.querySelector("#label-junction"),
lineColor: "#e76f51",
anchor: () => junctionPoint.clone(),
offset: [92, -58]
},
{
element: document.querySelector("#label-left"),
lineColor: "#3b82f6",
anchor: () =>
leftStrap.group.localToWorld(new THREE.Vector3(-0.78, 2.58, 0.73)),
offset: [-158, -28]
},
{
element: document.querySelector("#label-right"),
lineColor: "#f59e0b",
anchor: () =>
rightStrap.group.localToWorld(new THREE.Vector3(0.78, 2.83, 0.66)),
offset: [76, -12]
},
{
element: document.querySelector("#label-rear"),
lineColor: "#8b5cf6",
anchor: () =>
rearStrap.group.localToWorld(new THREE.Vector3(0, 1.91, -0.76)),
offset: [75, 6]
}
];
for (const annotation of annotations) {
const line = document.createElementNS(svgNamespace, "line");
line.setAttribute("stroke", annotation.lineColor);
leaders.appendChild(line);
annotation.line = line;
}
const projected = new THREE.Vector3();
const cameraDirection = new THREE.Vector3();
function updateAnnotations(showLabels) {
camera.getWorldDirection(cameraDirection);
for (const annotation of annotations) {
const anchor = annotation.anchor();
const towardPoint = anchor.clone().sub(camera.position);
projected.copy(anchor).project(camera);
const visible =
showLabels &&
towardPoint.dot(cameraDirection) > 0 &&
projected.z > -1 &&
projected.z < 1;
annotation.element.style.display = visible ? "block" : "none";
annotation.line.style.display = visible ? "block" : "none";
if (!visible) continue;
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
const labelX = x + annotation.offset[0];
const labelY = y + annotation.offset[1];
annotation.element.style.transform =
`translate(${labelX}px, ${labelY}px)`;
const labelWidth = annotation.element.offsetWidth;
const labelHeight = annotation.element.offsetHeight;
const lineX = annotation.offset[0] < 0
? labelX + labelWidth
: labelX;
annotation.line.setAttribute("x1", x);
annotation.line.setAttribute("y1", y);
annotation.line.setAttribute("x2", lineX);
annotation.line.setAttribute("y2", labelY + labelHeight * 0.5);
}
}
// -------------------------------------------------------------------------
// UI
// -------------------------------------------------------------------------
const separationInput = document.querySelector("#separation");
const separationValue = document.querySelector("#separation-value");
const showLabelsInput = document.querySelector("#show-labels");
const showArrowsInput = document.querySelector("#show-arrows");
const autoRotateInput = document.querySelector("#auto-rotate");
const resetButton = document.querySelector("#reset-view");
let targetSpread = Number(separationInput.value) / 100;
let currentSpread = targetSpread;
function updateRangeFill() {
const value = Number(separationInput.value);
separationInput.style.setProperty("--value", `${value}%`);
separationValue.textContent = `${value}%`;
}
updateRangeFill();
separationInput.addEventListener("input", () => {
targetSpread = Number(separationInput.value) / 100;
updateRangeFill();
});
function resetView() {
orbit.theta = 0.58;
orbit.phi = 1.20;
orbit.radius = 10.0;
lastInteraction = performance.now();
}
resetButton.addEventListener("click", resetView);
canvas.addEventListener("dblclick", resetView);
// -------------------------------------------------------------------------
// Custom pointer orbit controls — no camera-control addons
// -------------------------------------------------------------------------
let dragging = false;
let pointerId = null;
let previousX = 0;
let previousY = 0;
let lastInteraction = performance.now();
canvas.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
dragging = true;
pointerId = event.pointerId;
previousX = event.clientX;
previousY = event.clientY;
lastInteraction = performance.now();
canvas.setPointerCapture(pointerId);
canvas.style.cursor = "grabbing";
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging || event.pointerId !== pointerId) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
orbit.theta -= deltaX * 0.006;
orbit.phi = THREE.MathUtils.clamp(
orbit.phi + deltaY * 0.005,
0.52,
1.48
);
lastInteraction = performance.now();
});
function stopDragging(event) {
if (!dragging || event.pointerId !== pointerId) return;
dragging = false;
canvas.style.cursor = "grab";
if (canvas.hasPointerCapture(pointerId)) {
canvas.releasePointerCapture(pointerId);
}
pointerId = null;
lastInteraction = performance.now();
}
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
canvas.addEventListener("lostpointercapture", () => {
dragging = false;
canvas.style.cursor = "grab";
});
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius * Math.exp(event.deltaY * 0.001),
6.3,
16
);
lastInteraction = performance.now();
},
{ passive: false }
);
canvas.style.cursor = "grab";
// -------------------------------------------------------------------------
// Resize and animation
// -------------------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
const clock = new THREE.Clock();
function animate() {
const dt = Math.min(clock.getDelta(), 0.05);
if (
autoRotateInput.checked &&
!dragging &&
performance.now() - lastInteraction > 1600
) {
orbit.theta += dt * 0.075;
}
currentSpread = THREE.MathUtils.lerp(
currentSpread,
targetSpread,
1 - Math.exp(-dt * 7)
);
const spread = currentSpread;
leftStrap.group.position.set(
-0.24 * spread,
0,
0.10 * spread
);
rightStrap.group.position.set(
0.24 * spread,
0,
0.10 * spread
);
rearStrap.group.position.set(
0,
0,
-0.24 * spread
);
leftStrap.group.updateMatrixWorld(true);
rightStrap.group.updateMatrixWorld(true);
rearStrap.group.updateMatrixWorld(true);
updateGuide(
guides.left,
leftStrap.group.localToWorld(leftStrap.points[0].clone())
);
updateGuide(
guides.right,
rightStrap.group.localToWorld(rightStrap.points[0].clone())
);
updateGuide(
guides.rear,
rearStrap.group.localToWorld(rearStrap.points[0].clone())
);
for (const guide of Object.values(guides)) {
guide.visible = spread > 0.015;
guide.material.opacity = 0.62 * spread;
}
const showArrows = showArrowsInput.checked;
for (const arrow of arrows) {
arrow.visible = showArrows;
}
const pulse = 1 + Math.sin(clock.elapsedTime * 2.1) * 0.035;
junctionHalo.scale.setScalar(pulse);
junctionHalo.material.opacity =
0.54 + Math.sin(clock.elapsedTime * 2.1) * 0.10;
updateCamera();
updateAnnotations(showLabelsInput.checked);
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```