Prompt specification
Build or customize the Three.js 3D scene "Foot arch bone-block model" 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: Foot arch bone-block model
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/foot-arch-bone-block-model-x0981
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts the human foot arch. Arrange simplified foot bones into a visible longitudinal arch above a baseline; mark heel and forefoot contacts while labeling the anatomy as a structural abstraction. A 3D cutaway view.
Working Three.js Starter (foot-arch-bone-block-model-x0981):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>The Longitudinal Foot Arch — Structural Abstraction</title>
<style>
:root {
--ink: #17343b;
--muted: #587078;
--teal: #159b98;
--teal-soft: rgba(21, 155, 152, 0.12);
--coral: #e7785f;
--paper: rgba(247, 250, 249, 0.86);
--line: rgba(34, 74, 81, 0.2);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #edf3f2;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
outline: none;
touch-action: none;
cursor: grab;
}
#scene.dragging {
cursor: grabbing;
}
.panel {
position: fixed;
z-index: 10;
top: 28px;
left: 30px;
width: min(390px, calc(100vw - 60px));
padding: 20px 22px 18px;
border: 1px solid rgba(38, 78, 84, 0.14);
border-radius: 16px;
background: var(--paper);
box-shadow: 0 16px 50px rgba(43, 76, 80, 0.09);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 9px;
color: var(--teal);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 24px;
height: 2px;
border-radius: 2px;
background: var(--teal);
}
h1 {
margin: 0;
max-width: 340px;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(30px, 3.2vw, 47px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
.subtitle {
margin: 14px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.abstraction-note {
display: flex;
gap: 10px;
align-items: flex-start;
margin-top: 16px;
padding-top: 13px;
border-top: 1px solid var(--line);
color: #49666c;
font-size: 10px;
font-weight: 700;
line-height: 1.45;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.abstraction-note .mark {
flex: 0 0 auto;
width: 8px;
height: 8px;
margin-top: 3px;
border: 2px solid var(--teal);
border-radius: 50%;
}
.view-badge {
position: fixed;
z-index: 10;
top: 30px;
right: 30px;
padding: 10px 13px;
border: 1px solid rgba(38, 78, 84, 0.16);
border-radius: 999px;
background: rgba(247, 250, 249, 0.8);
color: #31575e;
box-shadow: 0 8px 28px rgba(43, 76, 80, 0.08);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
pointer-events: none;
}
.legend {
position: fixed;
z-index: 10;
left: 30px;
bottom: 27px;
display: flex;
flex-wrap: wrap;
gap: 9px 17px;
max-width: 560px;
padding: 11px 14px;
border: 1px solid rgba(38, 78, 84, 0.12);
border-radius: 12px;
background: rgba(247, 250, 249, 0.78);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
color: #506c72;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.055em;
text-transform: uppercase;
pointer-events: none;
}
.legend-item {
display: flex;
align-items: center;
gap: 7px;
white-space: nowrap;
}
.swatch {
width: 17px;
height: 5px;
border-radius: 10px;
background: #e6d3ae;
}
.swatch.arch {
background: var(--teal);
}
.swatch.contact {
background: var(--coral);
}
.swatch.baseline {
height: 2px;
background: #557078;
}
.controls {
position: fixed;
z-index: 20;
right: 28px;
bottom: 27px;
display: flex;
align-items: center;
gap: 7px;
}
.controls button {
width: 38px;
height: 38px;
padding: 0;
border: 1px solid rgba(38, 78, 84, 0.16);
border-radius: 11px;
background: rgba(250, 252, 251, 0.9);
color: var(--ink);
box-shadow: 0 7px 22px rgba(43, 76, 80, 0.08);
cursor: pointer;
font-size: 18px;
font-weight: 500;
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
}
.controls button:hover {
color: var(--teal);
border-color: rgba(21, 155, 152, 0.45);
transform: translateY(-1px);
}
.controls button:active {
transform: translateY(0);
}
.controls .reset {
width: auto;
padding: 0 13px;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
#leaders {
position: fixed;
z-index: 4;
inset: 0;
width: 100%;
height: 100%;
overflow: visible;
pointer-events: none;
}
#labels {
position: fixed;
z-index: 5;
inset: 0;
pointer-events: none;
}
.label {
position: absolute;
min-width: 112px;
padding: 7px 9px;
transform: translate(-50%, -50%);
border: 1px solid rgba(35, 72, 78, 0.17);
border-radius: 8px;
background: rgba(249, 252, 251, 0.86);
box-shadow: 0 6px 18px rgba(40, 71, 75, 0.06);
color: #25474d;
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
white-space: nowrap;
}
.label .name {
display: block;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.085em;
line-height: 1.15;
text-transform: uppercase;
}
.label .detail {
display: block;
margin-top: 3px;
color: #70858a;
font-size: 8px;
font-weight: 600;
letter-spacing: 0.045em;
text-transform: uppercase;
}
.label.arch-label {
border-color: rgba(21, 155, 152, 0.28);
color: #087b79;
}
.label.contact-label {
border-color: rgba(231, 120, 95, 0.34);
color: #b5523e;
}
.leader {
fill: none;
stroke: rgba(40, 77, 83, 0.48);
stroke-width: 1;
vector-effect: non-scaling-stroke;
}
.leader.arch {
stroke: rgba(21, 155, 152, 0.72);
}
.leader.contact {
stroke: rgba(231, 120, 95, 0.74);
}
.anchor-dot {
fill: #f7faf9;
stroke: rgba(40, 77, 83, 0.72);
stroke-width: 1.25;
vector-effect: non-scaling-stroke;
}
.anchor-dot.arch {
fill: #dff7f4;
stroke: var(--teal);
}
.anchor-dot.contact {
fill: #fff0ec;
stroke: var(--coral);
}
.scale-note {
position: fixed;
z-index: 10;
right: 30px;
bottom: 80px;
color: rgba(41, 75, 81, 0.62);
font-size: 8px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
pointer-events: none;
}
@media (max-width: 760px) {
.panel {
top: 16px;
left: 16px;
width: calc(100vw - 32px);
padding: 16px 17px 14px;
}
h1 {
max-width: 280px;
font-size: 31px;
}
.subtitle {
max-width: 360px;
margin-top: 10px;
font-size: 11px;
}
.abstraction-note {
margin-top: 11px;
padding-top: 10px;
font-size: 8px;
}
.view-badge {
top: auto;
right: 16px;
bottom: 76px;
font-size: 8px;
}
.legend,
.scale-note {
display: none;
}
.controls {
right: 16px;
bottom: 17px;
}
.label {
min-width: 92px;
padding: 5px 7px;
}
.label .name {
font-size: 8px;
}
.label .detail {
font-size: 7px;
}
.minor {
display: none !important;
}
}
</style>
</head>
<body>
<div
class="panel"
role="heading"
aria-label="Scene description: the longitudinal foot arch, shown as a structural abstraction"
>
<div class="eyebrow">Biomechanics / Plate 01</div>
<h1>The longitudinal arch</h1>
<p class="subtitle">
A cutaway arrangement of simplified foot bones. The curved load path spans
the heel and forefoot, revealing the space beneath the medial arch.
</p>
<div class="abstraction-note">
<span class="mark"></span>
<span>Anatomy as a structural abstraction — schematic, not diagnostic or to scale</span>
</div>
</div>
<div class="view-badge">3D cutaway / medial–lateral</div>
<svg id="leaders" aria-hidden="true"></svg>
<div id="labels" aria-hidden="true"></div>
<div class="legend" aria-hidden="true">
<div class="legend-item"><span class="swatch"></span> Simplified bone</div>
<div class="legend-item"><span class="swatch arch"></span> Arch load path</div>
<div class="legend-item"><span class="swatch contact"></span> Ground contact</div>
<div class="legend-item"><span class="swatch baseline"></span> Reference baseline</div>
</div>
<div class="scale-note">Simplified osseous geometry / not to scale</div>
<div class="controls" aria-label="Camera controls">
<button id="zoomOut" type="button" aria-label="Zoom out">−</button>
<button id="zoomIn" type="button" aria-label="Zoom in">+</button>
<button id="reset" class="reset" type="button">Reset view</button>
</div>
<noscript>This scene requires JavaScript and WebGL.</noscript>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xedf3f2);
scene.fog = new THREE.Fog(0xedf3f2, 13, 27);
const camera = new THREE.PerspectiveCamera(
36,
window.innerWidth / window.innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.04;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.localClippingEnabled = true;
renderer.domElement.id = "scene";
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute(
"aria-label",
"Interactive three-dimensional cutaway of simplified foot bones forming a longitudinal arch."
);
document.body.prepend(renderer.domElement);
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xf9fffe, 0x8ea1a1, 2.1));
const keyLight = new THREE.DirectionalLight(0xfff7e7, 3.0);
keyLight.position.set(-3.8, 7.5, 6.2);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -6;
keyLight.shadow.camera.right = 6;
keyLight.shadow.camera.top = 5;
keyLight.shadow.camera.bottom = -3;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 22;
keyLight.shadow.bias = -0.00035;
keyLight.shadow.normalBias = 0.025;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xc5f1f1, 1.35);
fillLight.position.set(5, 3, -5);
scene.add(fillLight);
const rimLight = new THREE.PointLight(0xffffff, 0.8, 16);
rimLight.position.set(2.5, 4.5, 4.5);
scene.add(rimLight);
// -------------------------------------------------------------------------
// Shared geometry and materials
// -------------------------------------------------------------------------
const boneMaterial = new THREE.MeshStandardMaterial({
color: 0xf0dfbd,
roughness: 0.43,
metalness: 0.015
});
const jointMaterial = new THREE.MeshStandardMaterial({
color: 0xd8c39c,
roughness: 0.5,
metalness: 0.01
});
const archMaterial = new THREE.MeshStandardMaterial({
color: 0x19aaa5,
emissive: 0x075d5b,
emissiveIntensity: 0.22,
roughness: 0.35,
metalness: 0.03
});
const groundMaterial = new THREE.MeshStandardMaterial({
color: 0xe8efee,
roughness: 0.97,
metalness: 0
});
const bonesGroup = new THREE.Group();
bonesGroup.name = "Simplified foot bones";
scene.add(bonesGroup);
const unitSphere = new THREE.SphereGeometry(1, 16, 12);
// -------------------------------------------------------------------------
// Bone construction helpers
// -------------------------------------------------------------------------
function addBone(start, end, startRadius = 0.1, endRadius = 0.085) {
const a = new THREE.Vector3(...start);
const b = new THREE.Vector3(...end);
const direction = b.clone().sub(a);
const length = direction.length();
const midpoint = a.clone().add(b).multiplyScalar(0.5);
const shaftGeometry = new THREE.CylinderGeometry(
endRadius,
startRadius,
length,
16,
1,
false
);
const shaft = new THREE.Mesh(shaftGeometry, boneMaterial);
shaft.position.copy(midpoint);
shaft.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.clone().normalize()
);
shaft.castShadow = true;
shaft.receiveShadow = true;
bonesGroup.add(shaft);
const startCap = new THREE.Mesh(unitSphere, boneMaterial);
startCap.position.copy(a);
startCap.scale.setScalar(startRadius * 1.08);
startCap.castShadow = true;
startCap.receiveShadow = true;
bonesGroup.add(startCap);
const endCap = new THREE.Mesh(unitSphere, boneMaterial);
endCap.position.copy(b);
endCap.scale.setScalar(endRadius * 1.12);
endCap.castShadow = true;
endCap.receiveShadow = true;
bonesGroup.add(endCap);
return { shaft, startCap, endCap };
}
function makeIrregularTarsalGeometry() {
const geometry = new THREE.IcosahedronGeometry(1, 2);
const positions = geometry.attributes.position;
for (let i = 0; i < positions.count; i++) {
const x = positions.getX(i);
const y = positions.getY(i);
const z = positions.getZ(i);
const variation =
1 +
0.055 *
Math.sin(x * 12.7 + y * 8.3 + z * 6.1) +
0.022 * Math.cos(x * 19.1 - z * 10.7);
positions.setXYZ(i, x * variation, y * variation, z * variation);
}
geometry.computeVertexNormals();
return geometry;
}
const tarsalGeometry = makeIrregularTarsalGeometry();
function addTarsal(position, scale, rotation = [0, 0, 0], material = boneMaterial) {
const mesh = new THREE.Mesh(tarsalGeometry, material);
mesh.position.set(...position);
mesh.scale.set(...scale);
mesh.rotation.set(...rotation);
mesh.castShadow = true;
mesh.receiveShadow = true;
bonesGroup.add(mesh);
return mesh;
}
// Hindfoot
addTarsal(
[-2.28, 0.35, 0.03],
[0.72, 0.35, 0.43],
[0.02, -0.05, -0.11]
);
addTarsal(
[-1.37, 0.98, 0.02],
[0.48, 0.37, 0.39],
[0.06, 0.05, 0.16]
);
// Midfoot
addTarsal(
[-0.67, 1.11, 0.08],
[0.39, 0.28, 0.33],
[0.02, -0.08, 0.08]
);
addTarsal(
[-0.19, 0.91, 0.27],
[0.29, 0.23, 0.24],
[0.01, 0.04, -0.06]
);
addTarsal(
[-0.15, 0.75, -0.02],
[0.26, 0.21, 0.23],
[-0.03, 0.08, 0.03]
);
addTarsal(
[-0.28, 0.61, -0.31],
[0.27, 0.21, 0.23],
[0.04, -0.02, -0.08]
);
addTarsal(
[-0.76, 0.52, -0.35],
[0.39, 0.28, 0.31],
[0.04, 0.11, 0.02]
);
// Small joint transitions help the bones read as a connected structure.
[
[-1.0, 1.01, 0.08],
[-0.42, 0.96, 0.18],
[-0.44, 0.65, -0.10],
[-0.51, 0.56, -0.31]
].forEach((position) => {
const joint = new THREE.Mesh(unitSphere, jointMaterial);
joint.position.set(...position);
joint.scale.set(0.16, 0.13, 0.15);
joint.castShadow = true;
bonesGroup.add(joint);
});
// Metatarsals, fanning from the midfoot toward the forefoot.
const metatarsals = [
{ a: [0.22, 0.79, 0.30], b: [1.27, 0.11, 0.40], r: 0.095 },
{ a: [0.27, 0.68, 0.08], b: [1.52, 0.11, 0.16], r: 0.092 },
{ a: [0.17, 0.57, -0.13], b: [1.58, 0.10, -0.08], r: 0.089 },
{ a: [-0.02, 0.49, -0.34], b: [1.44, 0.11, -0.31], r: 0.083 },
{ a: [-0.45, 0.43, -0.50], b: [1.16, 0.11, -0.53], r: 0.077 }
];
metatarsals.forEach(({ a, b, r }) => {
addBone(a, b, r * 1.08, r);
});
// Simplified phalanges.
addBone([1.27, 0.11, 0.40], [1.74, 0.12, 0.42], 0.105, 0.083);
addBone([1.74, 0.12, 0.42], [2.19, 0.10, 0.44], 0.083, 0.064);
addBone([1.52, 0.11, 0.16], [1.82, 0.11, 0.17], 0.094, 0.072);
addBone([1.82, 0.11, 0.17], [2.05, 0.10, 0.18], 0.072, 0.055);
addBone([1.58, 0.10, -0.08], [1.87, 0.10, -0.08], 0.09, 0.068);
addBone([1.87, 0.10, -0.08], [2.08, 0.09, -0.08], 0.068, 0.052);
addBone([1.44, 0.11, -0.31], [1.68, 0.10, -0.32], 0.082, 0.062);
addBone([1.68, 0.10, -0.32], [1.87, 0.09, -0.33], 0.062, 0.048);
addBone([1.16, 0.11, -0.53], [1.36, 0.10, -0.54], 0.075, 0.056);
addBone([1.36, 0.10, -0.54], [1.52, 0.09, -0.55], 0.056, 0.043);
// -------------------------------------------------------------------------
// Longitudinal arch and structural load path
// -------------------------------------------------------------------------
const archCurve = new THREE.CatmullRomCurve3(
[
new THREE.Vector3(-2.28, 0.17, 0),
new THREE.Vector3(-1.79, 0.41, 0),
new THREE.Vector3(-1.28, 0.72, 0),
new THREE.Vector3(-0.69, 0.89, 0),
new THREE.Vector3(-0.14, 0.80, 0),
new THREE.Vector3(0.43, 0.56, 0),
new THREE.Vector3(0.97, 0.25, 0),
new THREE.Vector3(1.55, 0.075, 0)
],
false,
"catmullrom",
0.35
);
const archTube = new THREE.Mesh(
new THREE.TubeGeometry(archCurve, 72, 0.038, 10, false),
archMaterial
);
archTube.castShadow = true;
scene.add(archTube);
// A faint field beneath the curve makes the arch void immediately legible.
const archPoints = archCurve.getPoints(72);
const archFieldShape = new THREE.Shape();
archFieldShape.moveTo(archPoints[0].x, 0);
archPoints.forEach((point) => archFieldShape.lineTo(point.x, point.y));
archFieldShape.lineTo(archPoints[archPoints.length - 1].x, 0);
archFieldShape.closePath();
const archField = new THREE.Mesh(
new THREE.ShapeGeometry(archFieldShape),
new THREE.MeshBasicMaterial({
color: 0x1aa7a2,
transparent: true,
opacity: 0.085,
side: THREE.DoubleSide,
depthWrite: false
})
);
archField.position.z = -0.74;
scene.add(archField);
// A subtle spring-ligament cue beneath the talus/navicular region.
const springCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-1.92, 0.28, -0.09),
new THREE.Vector3(-1.48, 0.46, 0.04),
new THREE.Vector3(-1.05, 0.66, 0.09),
new THREE.Vector3(-0.68, 0.86, 0.08)
]);
const springLigament = new THREE.Mesh(
new THREE.TubeGeometry(springCurve, 32, 0.021, 8, false),
new THREE.MeshStandardMaterial({
color: 0x5f9f9b,
roughness: 0.62
})
);
scene.add(springLigament);
// -------------------------------------------------------------------------
// Translucent cutaway envelope
// -------------------------------------------------------------------------
const footEnvelope = new THREE.Shape();
footEnvelope.moveTo(-3.05, 0.01);
footEnvelope.bezierCurveTo(-3.18, 0.34, -2.91, 0.88, -2.32, 1.14);
footEnvelope.bezierCurveTo(-1.89, 1.34, -1.31, 1.44, -0.76, 1.32);
footEnvelope.bezierCurveTo(-0.26, 1.22, 0.18, 0.91, 0.81, 0.62);
footEnvelope.bezierCurveTo(1.28, 0.41, 1.71, 0.19, 2.12, 0.14);
footEnvelope.bezierCurveTo(2.58, 0.12, 3.08, 0.11, 3.46, 0.03);
footEnvelope.lineTo(3.46, -0.025);
footEnvelope.lineTo(-3.05, -0.025);
footEnvelope.closePath();
// This plane removes the near half of the envelope, producing a true
// sagittal cutaway while leaving the bones exposed.
const cutPlane = new THREE.Plane(new THREE.Vector3(0, 0, -1), 0);
const envelopeMaterial = new THREE.MeshPhysicalMaterial({
color: 0x70b9c2,
transparent: true,
opacity: 0.085,
roughness: 0.72,
metalness: 0,
side: THREE.DoubleSide,
depthWrite: false,
clippingPlanes: [cutPlane]
});
const envelope = new THREE.Mesh(
new THREE.ExtrudeGeometry(footEnvelope, {
depth: 1.35,
bevelEnabled: true,
bevelSegments: 2,
bevelSize: 0.045,
bevelThickness: 0.035,
curveSegments: 28
}),
envelopeMaterial
);
envelope.position.z = -0.69;
scene.add(envelope);
const envelopeContour = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(
footEnvelope.getPoints(90).map((p) => new THREE.Vector3(p.x, p.y, 0.005))
),
new THREE.LineBasicMaterial({
color: 0x5a9da7,
transparent: true,
opacity: 0.32
})
);
scene.add(envelopeContour);
// -------------------------------------------------------------------------
// Ground, baseline, and heel/forefoot contacts
// -------------------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(34, 22),
groundMaterial
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.035;
ground.receiveShadow = true;
scene.add(ground);
const baselinePoints = [
new THREE.Vector3(-3.65, 0, 0),
new THREE.Vector3(3.7, 0, 0)
];
const baseline = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(baselinePoints),
new THREE.LineBasicMaterial({
color: 0x4e6b72,
transparent: true,
opacity: 0.82
})
);
scene.add(baseline);
const tickPositions = [];
for (let x = -3.5; x <= 3.51; x += 0.5) {
const size = Number.isInteger(x) ? 0.09 : 0.05;
tickPositions.push(
x, 0, -size,
x, 0, size
);
}
const tickGeometry = new THREE.BufferGeometry();
tickGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(tickPositions, 3)
);
const baselineTicks = new THREE.LineSegments(
tickGeometry,
new THREE.LineBasicMaterial({
color: 0x648087,
transparent: true,
opacity: 0.55
})
);
scene.add(baselineTicks);
const contactRings = [];
function addContact(x, z = 0.08) {
const group = new THREE.Group();
group.position.set(x, 0.012, z);
const disc = new THREE.Mesh(
new THREE.CylinderGeometry(0.205, 0.205, 0.025, 48),
new THREE.MeshBasicMaterial({
color: 0xe7785f,
transparent: true,
opacity: 0.27
})
);
group.add(disc);
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.255, 0.025, 12, 56),
new THREE.MeshBasicMaterial({
color: 0xe7785f,
transparent: true,
opacity: 0.92
})
);
ring.rotation.x = Math.PI / 2;
group.add(ring);
const guide = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(0, 0.04, 0),
new THREE.Vector3(0, 0.27, 0)
]),
new THREE.LineDashedMaterial({
color: 0xe7785f,
dashSize: 0.055,
gapSize: 0.045,
transparent: true,
opacity: 0.68
})
);
guide.computeLineDistances();
group.add(guide);
scene.add(group);
contactRings.push(ring);
}
addContact(-2.3, 0.03);
addContact(1.55, 0.08);
// -------------------------------------------------------------------------
// DOM annotations with projected 3D anchors
// -------------------------------------------------------------------------
const labelsElement = document.getElementById("labels");
const leadersElement = document.getElementById("leaders");
const SVG_NS = "http://www.w3.org/2000/svg";
const annotationDefinitions = [
{
name: "Calcaneus",
detail: "heel bone",
anchor: new THREE.Vector3(-2.28, 0.39, 0.34),
offset: [-112, -45],
type: "bone"
},
{
name: "Talus",
detail: "ankle pivot",
anchor: new THREE.Vector3(-1.37, 1.04, 0.26),
offset: [-68, -77],
type: "bone",
minor: true
},
{
name: "Navicular",
detail: "midfoot link",
anchor: new THREE.Vector3(-0.67, 1.16, 0.19),
offset: [33, -92],
type: "bone",
minor: true
},
{
name: "Metatarsals",
detail: "forefoot rays",
anchor: new THREE.Vector3(0.91, 0.50, 0.22),
offset: [83, 43],
type: "bone"
},
{
name: "Phalanges",
detail: "toe bones",
anchor: new THREE.Vector3(2.10, 0.17, 0.42),
offset: [72, -35],
type: "bone",
minor: true
},
{
name: "Medial longitudinal arch",
detail: "structural load path",
anchor: new THREE.Vector3(-0.18, 0.72, 0.02),
offset: [-112, 100],
type: "arch"
},
{
name: "Heel contact",
detail: "ground reaction",
anchor: new THREE.Vector3(-2.3, 0.03, 0.03),
offset: [-57, 55],
type: "contact"
},
{
name: "Forefoot contact",
detail: "ground reaction",
anchor: new THREE.Vector3(1.55, 0.03, 0.08),
offset: [62, 55],
type: "contact"
}
];
const annotations = annotationDefinitions.map((definition) => {
const label = document.createElement("div");
label.className = "label";
if (definition.type === "arch") {
label.classList.add("arch-label");
}
if (definition.type === "contact") {
label.classList.add("contact-label");
}
if (definition.minor) {
label.classList.add("minor");
}
const name = document.createElement("span");
name.className = "name";
name.textContent = definition.name;
const detail = document.createElement("span");
detail.className = "detail";
detail.textContent = definition.detail;
label.append(name, detail);
labelsElement.appendChild(label);
const line = document.createElementNS(SVG_NS, "line");
line.setAttribute("class", `leader ${definition.type}`);
if (definition.minor) {
line.classList.add("minor");
}
const dot = document.createElementNS(SVG_NS, "circle");
dot.setAttribute("r", "3.3");
dot.setAttribute("class", `anchor-dot ${definition.type}`);
if (definition.minor) {
dot.classList.add("minor");
}
leadersElement.append(line, dot);
return { ...definition, label, line, dot };
});
function updateAnnotations() {
const width = window.innerWidth;
const height = window.innerHeight;
const offsetScale = Math.min(1, Math.max(0.72, width / 1180));
annotations.forEach((annotation) => {
const projected = annotation.anchor.clone().project(camera);
const anchorX = (projected.x * 0.5 + 0.5) * width;
const anchorY = (-projected.y * 0.5 + 0.5) * height;
const labelX = anchorX + annotation.offset[0] * offsetScale;
const labelY = anchorY + annotation.offset[1] * offsetScale;
annotation.label.style.left = `${labelX}px`;
annotation.label.style.top = `${labelY}px`;
annotation.line.setAttribute("x1", anchorX);
annotation.line.setAttribute("y1", anchorY);
annotation.line.setAttribute("x2", labelX);
annotation.line.setAttribute("y2", labelY);
annotation.dot.setAttribute("cx", anchorX);
annotation.dot.setAttribute("cy", anchorY);
const visible = projected.z > -1 && projected.z < 1;
annotation.label.style.visibility = visible ? "visible" : "hidden";
annotation.line.style.visibility = visible ? "visible" : "hidden";
annotation.dot.style.visibility = visible ? "visible" : "hidden";
});
}
// -------------------------------------------------------------------------
// Direct camera controls: no examples/addons dependencies
// -------------------------------------------------------------------------
const target = new THREE.Vector3(0.12, 0.67, 0);
let theta = 0.11;
let phi = 1.34;
let distance = 8.2;
let dragging = false;
let previousX = 0;
let previousY = 0;
let cameraHasMoved = false;
function fittedDistance() {
const aspect = window.innerWidth / window.innerHeight;
const horizontalWorldSize = 7.6;
const verticalWorldSize = horizontalWorldSize / aspect;
const fovRadians = THREE.MathUtils.degToRad(camera.fov);
return Math.max(
7.7,
verticalWorldSize / (2 * Math.tan(fovRadians * 0.5))
);
}
function updateCamera() {
const sinPhi = Math.sin(phi);
camera.position.set(
target.x + distance * sinPhi * Math.sin(theta),
target.y + distance * Math.cos(phi),
target.z + distance * sinPhi * Math.cos(theta)
);
camera.lookAt(target);
camera.updateMatrixWorld();
}
function resetCamera() {
theta = 0.11;
phi = 1.34;
distance = fittedDistance();
cameraHasMoved = false;
updateCamera();
}
function zoomBy(factor) {
distance = THREE.MathUtils.clamp(
distance * factor,
fittedDistance() * 0.62,
fittedDistance() * 1.85
);
cameraHasMoved = true;
updateCamera();
}
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.classList.add("dragging");
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
theta -= dx * 0.0052;
phi = THREE.MathUtils.clamp(phi - dy * 0.0047, 0.52, 1.72);
cameraHasMoved = true;
updateCamera();
});
function endDrag(event) {
dragging = false;
renderer.domElement.classList.remove("dragging");
if (
event.pointerId !== undefined &&
renderer.domElement.hasPointerCapture(event.pointerId)
) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
zoomBy(Math.exp(event.deltaY * 0.001));
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
renderer.domElement.addEventListener("keydown", (event) => {
const step = 0.07;
if (event.key === "ArrowLeft") theta += step;
else if (event.key === "ArrowRight") theta -= step;
else if (event.key === "ArrowUp") phi -= step;
else if (event.key === "ArrowDown") phi += step;
else if (event.key === "+" || event.key === "=") zoomBy(0.9);
else if (event.key === "-" || event.key === "_") zoomBy(1.1);
else if (event.key.toLowerCase() === "r") resetCamera();
else return;
phi = THREE.MathUtils.clamp(phi, 0.52, 1.72);
cameraHasMoved = true;
updateCamera();
event.preventDefault();
});
document.getElementById("zoomIn").addEventListener("click", () => zoomBy(0.88));
document.getElementById("zoomOut").addEventListener("click", () => zoomBy(1.14));
document.getElementById("reset").addEventListener("click", resetCamera);
// -------------------------------------------------------------------------
// Resize and animation
// -------------------------------------------------------------------------
function onResize() {
const oldFit = fittedDistance();
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
if (!cameraHasMoved) {
distance = fittedDistance();
} else {
distance *= fittedDistance() / oldFit;
}
updateCamera();
}
window.addEventListener("resize", onResize);
resetCamera();
const clock = new THREE.Clock();
const reduceMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
renderer.setAnimationLoop(() => {
const elapsed = clock.getElapsedTime();
if (!reduceMotion) {
contactRings.forEach((ring, index) => {
const pulse = 1 + 0.055 * Math.sin(elapsed * 2.1 + index * 1.4);
ring.scale.setScalar(pulse);
});
}
updateAnnotations();
renderer.render(scene, camera);
});
</script>
</body>
</html>
```