Prompt specification
Build or customize the Three.js 3D scene "Pick Fixture Place Fixture and Robot Reach" 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: Pick Fixture Place Fixture and Robot Reach
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/pick-fixture-place-fixture-and-robot-reach-x2061
Scene Description Prompt:
In one HTML file using Three.js from cdnjs, show a cutaway robot arm reaching between two fixtures, with gripper clearance and object supports.
Working Three.js Starter (pick-fixture-place-fixture-and-robot-reach-x2061):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Robotic Arm Cutaway Inspection</title>
<style>
:root {
--cyan: #62e8ff;
--cyan-soft: rgba(98, 232, 255, 0.16);
--orange: #ff8b32;
--text: #eaf7ff;
--muted: #89a9b8;
--panel: rgba(7, 18, 27, 0.82);
--border: rgba(119, 211, 235, 0.24);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #071018;
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#viewport {
position: fixed;
inset: 0;
touch-action: none;
}
canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
#vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
radial-gradient(circle at 52% 46%, transparent 40%, rgba(1, 6, 10, 0.43) 100%),
linear-gradient(180deg, rgba(4, 13, 20, 0.18), transparent 25%);
}
.hud {
position: fixed;
z-index: 5;
pointer-events: none;
}
#title {
top: 26px;
left: 30px;
max-width: 440px;
}
#title .eyebrow {
display: flex;
align-items: center;
gap: 9px;
color: var(--cyan);
font-size: 11px;
font-weight: 750;
letter-spacing: 0.18em;
text-transform: uppercase;
}
#title .eyebrow::before {
content: "";
width: 26px;
height: 2px;
background: var(--cyan);
box-shadow: 0 0 12px var(--cyan);
}
#title h1 {
margin: 9px 0 7px;
font-size: clamp(24px, 3vw, 40px);
line-height: 1.02;
letter-spacing: -0.045em;
font-weight: 720;
}
#title p {
margin: 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
letter-spacing: 0.02em;
}
#status {
top: 28px;
right: 30px;
display: flex;
gap: 9px;
}
.status-chip {
display: flex;
align-items: center;
gap: 8px;
padding: 9px 12px;
border: 1px solid var(--border);
border-radius: 4px;
background: rgba(7, 18, 27, 0.72);
backdrop-filter: blur(12px);
color: #bcd3de;
font-size: 10px;
font-weight: 760;
letter-spacing: 0.13em;
}
.status-chip.active {
color: var(--cyan);
border-color: rgba(98, 232, 255, 0.38);
}
.status-dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--cyan);
box-shadow: 0 0 10px var(--cyan);
animation: pulse 1.9s ease-in-out infinite;
}
@keyframes pulse {
0%, 100% { opacity: 0.45; }
50% { opacity: 1; }
}
#metrics {
left: 30px;
bottom: 28px;
width: 314px;
border: 1px solid var(--border);
border-radius: 7px;
overflow: hidden;
background: var(--panel);
backdrop-filter: blur(15px);
box-shadow: 0 16px 45px rgba(0, 0, 0, 0.25);
}
.panel-head {
display: flex;
align-items: center;
justify-content: space-between;
padding: 13px 15px;
border-bottom: 1px solid var(--border);
color: var(--cyan);
font-size: 10px;
font-weight: 760;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.panel-head span:last-child {
color: var(--muted);
font-size: 9px;
}
.metric-grid {
display: grid;
grid-template-columns: 1fr 1fr;
}
.metric {
min-height: 72px;
padding: 13px 15px;
border-right: 1px solid rgba(119, 211, 235, 0.12);
border-bottom: 1px solid rgba(119, 211, 235, 0.12);
}
.metric:nth-child(even) {
border-right: 0;
}
.metric:nth-last-child(-n + 2) {
border-bottom: 0;
}
.metric .label {
color: var(--muted);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.metric .value {
margin-top: 6px;
color: #f4fbff;
font-size: 21px;
font-weight: 660;
letter-spacing: -0.03em;
}
.metric .value span {
margin-left: 3px;
color: var(--cyan);
font-size: 11px;
font-weight: 750;
letter-spacing: 0.04em;
}
.support-row {
display: flex;
align-items: center;
gap: 10px;
padding: 12px 15px;
border-top: 1px solid var(--border);
color: #bad0db;
font-size: 11px;
}
.support-icon {
position: relative;
width: 30px;
height: 17px;
flex: 0 0 auto;
}
.support-icon::before,
.support-icon::after {
content: "";
position: absolute;
top: 2px;
width: 15px;
height: 13px;
border: 2px solid var(--orange);
}
.support-icon::before {
left: 0;
transform: skewY(24deg);
border-right: 0;
}
.support-icon::after {
right: 0;
transform: skewY(-24deg);
border-left: 0;
}
#controls {
right: 30px;
bottom: 28px;
display: flex;
align-items: flex-end;
gap: 10px;
pointer-events: auto;
}
.control-box {
padding: 12px 14px;
border: 1px solid var(--border);
border-radius: 6px;
background: rgba(7, 18, 27, 0.8);
backdrop-filter: blur(12px);
}
.control-box strong {
display: block;
margin-bottom: 5px;
color: #d8edf6;
font-size: 10px;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.control-box span {
color: var(--muted);
font-size: 10px;
}
.buttons {
display: flex;
flex-direction: column;
gap: 6px;
}
button {
min-width: 104px;
padding: 9px 12px;
border: 1px solid rgba(98, 232, 255, 0.26);
border-radius: 4px;
background: rgba(13, 35, 47, 0.88);
color: var(--cyan);
font: inherit;
font-size: 9px;
font-weight: 760;
letter-spacing: 0.12em;
text-transform: uppercase;
cursor: pointer;
transition: background 140ms ease, border-color 140ms ease;
}
button:hover {
background: rgba(28, 76, 92, 0.9);
border-color: rgba(98, 232, 255, 0.62);
}
#leaders {
position: fixed;
inset: 0;
z-index: 3;
pointer-events: none;
}
#leaders line {
stroke: rgba(98, 232, 255, 0.52);
stroke-width: 1;
}
#leaders circle {
fill: var(--cyan);
stroke: rgba(98, 232, 255, 0.3);
stroke-width: 4;
}
.annotation {
position: fixed;
z-index: 4;
transform: translate(-50%, -100%);
padding: 7px 9px;
border: 1px solid rgba(98, 232, 255, 0.31);
border-radius: 3px;
background: rgba(5, 17, 25, 0.86);
color: #dff7ff;
font-size: 9px;
font-weight: 720;
letter-spacing: 0.1em;
text-transform: uppercase;
white-space: nowrap;
pointer-events: none;
box-shadow: 0 6px 22px rgba(0, 0, 0, 0.25);
}
.annotation .index {
margin-right: 7px;
color: var(--cyan);
}
.annotation.orange {
border-color: rgba(255, 139, 50, 0.4);
}
.annotation.orange .index {
color: var(--orange);
}
@media (max-width: 760px) {
#title {
top: 18px;
left: 18px;
}
#title p,
#status .status-chip:last-child,
.control-box {
display: none;
}
#status {
top: 18px;
right: 18px;
}
#metrics {
left: 18px;
bottom: 18px;
width: 270px;
}
#controls {
right: 18px;
bottom: 18px;
}
.annotation {
font-size: 8px;
}
}
</style>
</head>
<body>
<div id="viewport"></div>
<div id="vignette"></div>
<svg id="leaders" aria-hidden="true"></svg>
<header id="title" class="hud">
<div class="eyebrow">Robotic Handling Cell / Inspection 07</div>
<h1>Cutaway Reach &<br>Support Analysis</h1>
<p>
Open-housing arm geometry, open-jaw clearance, and the two-point support
condition for the transferred workpiece.
</p>
</header>
<div id="status" class="hud">
<div class="status-chip active">
<span class="status-dot"></span>
Cutaway active
</div>
<div class="status-chip">
<span class="status-dot"></span>
Reach verified
</div>
</div>
<section id="metrics" class="hud">
<div class="panel-head">
<span>Clearance Report</span>
<span>Live geometry</span>
</div>
<div class="metric-grid">
<div class="metric">
<div class="label">Vertical clearance</div>
<div class="value">110<span>mm</span></div>
</div>
<div class="metric">
<div class="label">Lateral jaw gap</div>
<div class="value">50<span>mm</span></div>
</div>
<div class="metric">
<div class="label">Articulated span</div>
<div class="value" id="reach-value">5.25<span>m</span></div>
</div>
<div class="metric">
<div class="label">Support contacts</div>
<div class="value">4<span>pads</span></div>
</div>
</div>
<div class="support-row">
<span class="support-icon"></span>
<span>Workpiece seated on two V-block fixtures</span>
</div>
</section>
<aside id="controls" class="hud">
<div class="control-box">
<strong>Camera</strong>
<span>Drag to orbit · Shift-drag to pan · Wheel to zoom</span>
</div>
<div class="buttons">
<button id="reset-view" type="button">Reset view</button>
<button id="top-view" type="button">Top view</button>
</div>
</aside>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const viewport = document.getElementById("viewport");
const leaders = document.getElementById("leaders");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x071018);
scene.fog = new THREE.Fog(0x071018, 13, 29);
const camera = new THREE.PerspectiveCamera(
42,
innerWidth / innerHeight,
0.1,
60
);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.18;
viewport.appendChild(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xa6dcff, 0x142028, 2.15);
scene.add(hemisphere);
const key = new THREE.DirectionalLight(0xe9f7ff, 3.2);
key.position.set(4.5, 8.5, 6.5);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -8;
key.shadow.camera.right = 8;
key.shadow.camera.top = 8;
key.shadow.camera.bottom = -8;
key.shadow.camera.near = 0.5;
key.shadow.camera.far = 25;
key.shadow.bias = -0.00015;
scene.add(key);
const rim = new THREE.DirectionalLight(0x36bfff, 2.0);
rim.position.set(-5, 4, -6);
scene.add(rim);
const warmFill = new THREE.PointLight(0xff8b32, 12, 8, 2);
warmFill.position.set(-2.5, 3.4, 2.0);
scene.add(warmFill);
const materials = {
orange: new THREE.MeshStandardMaterial({
color: 0xf47b25,
metalness: 0.42,
roughness: 0.34
}),
orangeDark: new THREE.MeshStandardMaterial({
color: 0xa84414,
metalness: 0.5,
roughness: 0.42
}),
cutEdge: new THREE.MeshStandardMaterial({
color: 0xffc16b,
emissive: 0x5d2605,
emissiveIntensity: 0.22,
metalness: 0.45,
roughness: 0.32
}),
steel: new THREE.MeshStandardMaterial({
color: 0x91a8b4,
metalness: 0.86,
roughness: 0.26
}),
chrome: new THREE.MeshStandardMaterial({
color: 0xe4f5ff,
metalness: 0.96,
roughness: 0.12
}),
darkSteel: new THREE.MeshStandardMaterial({
color: 0x172630,
metalness: 0.76,
roughness: 0.32
}),
black: new THREE.MeshStandardMaterial({
color: 0x081015,
metalness: 0.35,
roughness: 0.55
}),
cyan: new THREE.MeshStandardMaterial({
color: 0x28c6e8,
emissive: 0x0b7190,
emissiveIntensity: 1.0,
metalness: 0.42,
roughness: 0.28
}),
cyanDark: new THREE.MeshStandardMaterial({
color: 0x08738c,
emissive: 0x063849,
emissiveIntensity: 0.8,
metalness: 0.38,
roughness: 0.38
}),
blueMetal: new THREE.MeshStandardMaterial({
color: 0x287895,
metalness: 0.76,
roughness: 0.24
}),
blueBand: new THREE.MeshStandardMaterial({
color: 0x55d4e7,
emissive: 0x0b5264,
emissiveIntensity: 0.55,
metalness: 0.7,
roughness: 0.22
}),
bronze: new THREE.MeshStandardMaterial({
color: 0xc98d43,
metalness: 0.82,
roughness: 0.3
}),
green: new THREE.MeshStandardMaterial({
color: 0x2a9b65,
emissive: 0x0a3b22,
emissiveIntensity: 0.7,
metalness: 0.35,
roughness: 0.42
}),
floor: new THREE.MeshStandardMaterial({
color: 0x0c1820,
metalness: 0.18,
roughness: 0.76
})
};
function box(parent, w, h, d, material, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), material);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(
parent,
rTop,
rBottom,
height,
material,
x = 0,
y = 0,
z = 0,
axis = "y",
segments = 32
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(rTop, rBottom, height, segments),
material
);
mesh.position.set(x, y, z);
if (axis === "x") mesh.rotation.z = -Math.PI / 2;
if (axis === "z") mesh.rotation.x = Math.PI / 2;
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function torus(
parent,
radius,
tube,
material,
x = 0,
y = 0,
z = 0,
axis = "z"
) {
const mesh = new THREE.Mesh(
new THREE.TorusGeometry(radius, tube, 12, 56),
material
);
mesh.position.set(x, y, z);
if (axis === "x") mesh.rotation.y = Math.PI / 2;
if (axis === "y") mesh.rotation.x = Math.PI / 2;
mesh.castShadow = true;
parent.add(mesh);
return mesh;
}
// Floor and cell platform.
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(36, 36),
materials.floor
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.075;
ground.receiveShadow = true;
scene.add(ground);
const grid = new THREE.GridHelper(28, 56, 0x2b6475, 0x18313d);
grid.position.y = -0.065;
grid.material.transparent = true;
grid.material.opacity = 0.48;
scene.add(grid);
const platform = box(
scene,
10.2,
0.1,
5.0,
new THREE.MeshStandardMaterial({
color: 0x0e1c25,
metalness: 0.42,
roughness: 0.58
}),
-1.0,
-0.02,
-0.25
);
platform.receiveShadow = true;
const platformOutline = new THREE.LineLoop(
new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-6.1, 0.035, -2.75),
new THREE.Vector3(4.1, 0.035, -2.75),
new THREE.Vector3(4.1, 0.035, 2.25),
new THREE.Vector3(-6.1, 0.035, 2.25)
]),
new THREE.LineBasicMaterial({
color: 0x2c7c91,
transparent: true,
opacity: 0.42
})
);
scene.add(platformOutline);
// Robot pedestal.
const baseX = -3.35;
const baseZ = -0.65;
cylinder(scene, 0.72, 0.76, 0.18, materials.darkSteel, baseX, 0.09, baseZ);
cylinder(scene, 0.58, 0.64, 0.08, materials.orangeDark, baseX, 0.20, baseZ);
cylinder(scene, 0.34, 0.41, 0.74, materials.darkSteel, baseX, 0.56, baseZ);
cylinder(scene, 0.38, 0.38, 0.10, materials.orange, baseX, 0.92, baseZ);
torus(scene, 0.63, 0.035, materials.steel, baseX, 0.19, baseZ, "y");
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2;
cylinder(
scene,
0.045,
0.045,
0.05,
materials.chrome,
baseX + Math.cos(angle) * 0.60,
0.29,
baseZ + Math.sin(angle) * 0.60,
"y",
16
);
}
const shoulder = new THREE.Vector3(-3.35, 1.25, -0.65);
const elbow = new THREE.Vector3(-1.50, 3.30, -0.55);
const wrist = new THREE.Vector3(0.78, 2.28, -0.18);
const reachLength = shoulder.distanceTo(elbow) + elbow.distanceTo(wrist);
document.getElementById("reach-value").innerHTML =
`${reachLength.toFixed(2)}<span>m</span>`;
const animatedCables = [];
function makeCutawayLink(start, end, width, depth, accentMaterial) {
const direction = new THREE.Vector3().subVectors(end, start);
const length = direction.length();
const group = new THREE.Group();
group.position.copy(start).add(end).multiplyScalar(0.5);
group.quaternion.setFromUnitVectors(
new THREE.Vector3(1, 0, 0),
direction.clone().normalize()
);
scene.add(group);
// Rear shell and perimeter rails form an open front cutaway.
box(
group,
length - 0.14,
width - 0.08,
0.12,
accentMaterial,
0,
0,
-depth * 0.35
);
box(
group,
length,
0.13,
depth,
accentMaterial,
0,
width * 0.5 - 0.065,
0
);
box(
group,
length,
0.13,
depth,
accentMaterial,
0,
-width * 0.5 + 0.065,
0
);
box(
group,
0.14,
width,
depth,
accentMaterial,
-length * 0.5 + 0.07,
0,
0
);
box(
group,
0.14,
width,
depth,
accentMaterial,
length * 0.5 - 0.07,
0,
0
);
// Bright cut edges around the missing front cover.
box(
group,
length - 0.16,
0.035,
0.035,
materials.cutEdge,
0,
width * 0.5 - 0.025,
depth * 0.5 - 0.015
);
box(
group,
length - 0.16,
0.035,
0.035,
materials.cutEdge,
0,
-width * 0.5 + 0.025,
depth * 0.5 - 0.015
);
// Exposed linear actuator.
cylinder(
group,
0.115,
0.115,
length * 0.48,
materials.black,
-length * 0.17,
-0.02,
-0.01,
"x"
);
cylinder(
group,
0.057,
0.057,
length * 0.47,
materials.chrome,
length * 0.16,
-0.02,
-0.01,
"x"
);
cylinder(
group,
0.14,
0.14,
0.11,
accentMaterial,
-length * 0.38,
-0.02,
-0.01,
"x"
);
// Exposed controller and small drive blocks.
box(
group,
Math.min(0.35, length * 0.28),
0.09,
0.25,
materials.green,
-length * 0.05,
width * 0.27,
0.055
);
box(
group,
0.18,
0.15,
0.15,
materials.darkSteel,
length * 0.30,
width * 0.25,
0.03
);
// Hydraulic / signal cable loop.
const cableCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-length * 0.43, -0.09, 0.075),
new THREE.Vector3(-length * 0.25, -0.15, 0.15),
new THREE.Vector3(0, -0.04, 0.17),
new THREE.Vector3(length * 0.23, 0.08, 0.13),
new THREE.Vector3(length * 0.42, 0.035, 0.08)
]);
const cable = new THREE.Mesh(
new THREE.TubeGeometry(cableCurve, 44, 0.027, 8, false),
materials.cyanDark
);
cable.castShadow = true;
group.add(cable);
const pulse = new THREE.Mesh(
new THREE.SphereGeometry(0.038, 12, 12),
materials.cyan
);
group.add(pulse);
animatedCables.push({ curve: cableCurve, pulse });
// Frame bolts.
for (const x of [-length * 0.5 + 0.07, length * 0.5 - 0.07]) {
for (const y of [-width * 0.27, width * 0.27]) {
cylinder(
group,
0.037,
0.037,
0.045,
materials.chrome,
x,
y,
depth * 0.5 + 0.015,
"z",
16
);
}
}
return group;
}
function makeJoint(position, radius) {
const group = new THREE.Group();
group.position.copy(position);
scene.add(group);
cylinder(
group,
radius,
radius,
0.50,
materials.orangeDark,
0,
0,
0,
"z",
48
);
torus(group, radius * 0.79, radius * 0.085, materials.steel, 0, 0, 0.265);
cylinder(
group,
radius * 0.58,
radius * 0.58,
0.13,
materials.darkSteel,
0,
0,
0.28,
"z",
40
);
cylinder(
group,
radius * 0.28,
radius * 0.28,
0.16,
materials.orange,
0,
0,
0.32,
"z",
36
);
cylinder(
group,
radius * 0.12,
radius * 0.12,
0.18,
materials.chrome,
0,
0,
0.34,
"z",
24
);
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2;
cylinder(
group,
0.028,
0.028,
0.04,
materials.chrome,
Math.cos(angle) * radius * 0.73,
Math.sin(angle) * radius * 0.73,
0.285,
"z",
12
);
}
const indicator = new THREE.Mesh(
new THREE.SphereGeometry(radius * 0.07, 12, 12),
materials.cyan
);
indicator.position.set(radius * 0.46, radius * 0.39, 0.37);
group.add(indicator);
}
makeJoint(shoulder, 0.47);
makeJoint(elbow, 0.43);
makeJoint(wrist, 0.32);
makeCutawayLink(shoulder, elbow, 0.52, 0.58, materials.orange);
makeCutawayLink(elbow, wrist, 0.43, 0.48, materials.orange);
// Wrist transition and gripper.
cylinder(scene, 0.18, 0.18, 0.36, materials.chrome, 0.78, 2.03, -0.14);
cylinder(scene, 0.22, 0.22, 0.12, materials.darkSteel, 0.78, 1.87, -0.10);
box(scene, 0.46, 0.25, 0.54, materials.orange, 0.78, 1.87, -0.04);
const gripper = new THREE.Group();
gripper.position.set(0.78, 0, 0.05);
scene.add(gripper);
box(gripper, 0.62, 0.16, 0.98, materials.darkSteel, 0, 1.80, 0);
box(gripper, 0.54, 0.055, 0.86, materials.orange, 0, 1.90, 0);
// Two open fingers with a 50 mm lateral gap to the cylinder.
for (const side of [-1, 1]) {
box(
gripper,
0.17,
0.24,
0.15,
materials.steel,
0,
1.60,
side * 0.455
);
box(
gripper,
0.13,
0.16,
0.012,
materials.black,
0,
1.59,
side * 0.374
);
box(
gripper,
0.23,
0.07,
0.18,
materials.orangeDark,
0,
1.70,
side * 0.44
);
cylinder(
gripper,
0.045,
0.045,
0.26,
materials.chrome,
-0.18,
1.80,
side * 0.30,
"z",
20
);
}
// Workpiece: a machined cylinder supported between two V-block fixtures.
const objectY = 1.05;
const objectZ = 0.05;
const objectRadius = 0.32;
const workpiece = cylinder(
scene,
objectRadius,
objectRadius,
1.60,
materials.blueMetal,
0.80,
objectY,
objectZ,
"x",
64
);
cylinder(
scene,
0.327,
0.327,
0.18,
materials.blueBand,
0.80,
objectY,
objectZ,
"x",
64
);
torus(scene, 0.307, 0.026, materials.chrome, 0.01, objectY, objectZ, "x");
torus(scene, 0.307, 0.026, materials.chrome, 1.59, objectY, objectZ, "x");
// Top fiducial on the workpiece.
cylinder(
scene,
0.047,
0.047,
0.009,
materials.bronze,
0.80,
1.374,
objectZ,
"y",
24
);
// V-block geometry is an extruded notched profile.
const vShape = new THREE.Shape();
vShape.moveTo(-0.55, 0);
vShape.lineTo(0.55, 0);
vShape.lineTo(0.55, 0.724);
vShape.lineTo(0.30, 0.724);
vShape.lineTo(0, 0.394);
vShape.lineTo(-0.30, 0.724);
vShape.lineTo(-0.55, 0.724);
vShape.closePath();
const vGeometry = new THREE.ExtrudeGeometry(vShape, {
depth: 0.48,
bevelEnabled: false,
curveSegments: 1
});
vGeometry.rotateY(Math.PI / 2);
vGeometry.translate(-0.24, 0, 0);
function makeFixture(x, name) {
const group = new THREE.Group();
group.position.set(x, 0, objectZ);
scene.add(group);
box(group, 0.72, 0.16, 1.44, materials.darkSteel, 0, 0.08, 0);
box(group, 0.64, 0.045, 1.34, materials.steel, 0, 0.18, 0);
for (const dx of [-0.25, 0.25]) {
for (const dz of [-0.56, 0.56]) {
cylinder(group, 0.07, 0.08, 0.055, materials.black, dx, 0.027, dz, "y", 20);
cylinder(
group,
0.028,
0.028,
0.025,
materials.chrome,
dx,
0.18,
dz,
"y",
16
);
}
}
const vBlock = new THREE.Mesh(vGeometry, materials.steel);
vBlock.position.y = 0.18;
vBlock.castShadow = true;
vBlock.receiveShadow = true;
group.add(vBlock);
// Four bronze contact pads across the two V-blocks.
for (const side of [-1, 1]) {
const pad = box(
group,
0.44,
0.036,
0.14,
materials.bronze,
0,
0.903,
side * 0.30
);
pad.rotation.x = side > 0 ? -0.832 : 0.832;
const contact = new THREE.Mesh(
new THREE.SphereGeometry(0.027, 12, 12),
materials.cutEdge
);
contact.position.set(0, 0.913, side * 0.30);
group.add(contact);
}
// Rear locating post and fixture hardware.
cylinder(
group,
0.047,
0.047,
0.74,
materials.steel,
0,
0.59,
-0.64,
"y",
24
);
box(group, 0.26, 0.11, 0.25, materials.orangeDark, 0, 0.28, -0.64);
cylinder(
group,
0.035,
0.035,
0.42,
materials.chrome,
0,
0.89,
-0.43,
"z",
20
);
return group;
}
makeFixture(0.05, "A");
makeFixture(1.55, "B");
// Transparent clearance volume between jaw tips and workpiece top.
const clearanceHeight = 0.11;
const clearanceMaterial = new THREE.MeshBasicMaterial({
color: 0x49dcff,
transparent: true,
opacity: 0.07,
depthWrite: false,
side: THREE.DoubleSide
});
const clearanceVolume = new THREE.Mesh(
new THREE.BoxGeometry(0.72, clearanceHeight, 0.80),
clearanceMaterial
);
clearanceVolume.position.set(0.78, 1.425, objectZ);
scene.add(clearanceVolume);
const clearanceEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(clearanceVolume.geometry),
new THREE.LineBasicMaterial({
color: 0x62e8ff,
transparent: true,
opacity: 0.58
})
);
clearanceEdges.position.copy(clearanceVolume.position);
scene.add(clearanceEdges);
// 110 mm vertical dimension line.
const dimensionMaterial = new THREE.LineBasicMaterial({
color: 0x62e8ff,
transparent: true,
opacity: 0.95
});
const dimensionGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(1.19, 1.37, 0.58),
new THREE.Vector3(1.19, 1.48, 0.58),
new THREE.Vector3(1.13, 1.37, 0.58),
new THREE.Vector3(1.25, 1.37, 0.58),
new THREE.Vector3(1.13, 1.48, 0.58),
new THREE.Vector3(1.25, 1.48, 0.58)
]);
const dimensionLines = new THREE.LineSegments(
dimensionGeometry,
dimensionMaterial
);
scene.add(dimensionLines);
// Small fixed camera/inspection markers.
const markerMaterial = new THREE.MeshBasicMaterial({ color: 0x62e8ff });
for (const marker of [
new THREE.Vector3(1.19, 1.37, 0.58),
new THREE.Vector3(1.19, 1.48, 0.58)
]) {
const marker = new THREE.Mesh(
new THREE.SphereGeometry(0.025, 12, 12),
markerMaterial
);
marker.position.copy(marker);
scene.add(marker);
}
// Direct camera controls: orbit, pan, and zoom without addons.
const target = new THREE.Vector3(-0.65, 1.65, -0.05);
const spherical = new THREE.Spherical(11.25, 1.18, 0.59);
const defaultView = {
target: target.clone(),
spherical: spherical.clone()
};
const pointers = new Map();
let dragPrevious = null;
let pinchPrevious = null;
const canvas = renderer.domElement;
const cameraRight = new THREE.Vector3();
const cameraUp = new THREE.Vector3();
function updateCamera() {
camera.position.setFromSpherical(spherical).add(target);
camera.lookAt(target);
camera.updateMatrixWorld();
}
function panCamera(dx, dy) {
cameraRight.setFromMatrixColumn(camera.matrix, 0);
cameraUp.setFromMatrixColumn(camera.matrix, 1);
const panScale = spherical.radius * 0.00155;
target.addScaledVector(cameraRight, -dx * panScale);
target.addScaledVector(cameraUp, dy * panScale);
target.x = THREE.MathUtils.clamp(target.x, -5.5, 4.0);
target.y = THREE.MathUtils.clamp(target.y, 0.3, 4.5);
target.z = THREE.MathUtils.clamp(target.z, -3.0, 3.0);
}
function pinchState() {
const values = [...pointers.values()];
if (values.length < 2) return null;
const dx = values[0].x - values[1].x;
const dy = values[0].y - values[1].y;
const distance = Math.hypot(dx, dy);
return {
distance,
centerX: (values[0].x + values[1].x) * 0.5,
centerY: (values[0].y + values[1].y) * 0.5
};
}
canvas.addEventListener("contextmenu", event => event.preventDefault());
canvas.addEventListener("pointerdown", event => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 1) {
dragPrevious = {
x: event.clientX,
y: event.clientY,
pan: event.shiftKey || event.button === 2
};
} else {
dragPrevious = null;
pinchPrevious = pinchState();
}
});
canvas.addEventListener("pointermove", event => {
if (!pointers.has(event.pointerId)) return;
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 1 && dragPrevious) {
const dx = event.clientX - dragPrevious.x;
const dy = event.clientY - dragPrevious.y;
if (dragPrevious.pan || event.shiftKey) {
panCamera(dx, dy);
} else {
spherical.theta -= dx * 0.006;
spherical.phi = THREE.MathUtils.clamp(
spherical.phi - dy * 0.006,
0.22,
1.48
);
}
dragPrevious = {
x: event.clientX,
y: event.clientY,
pan: dragPrevious.pan || event.shiftKey
};
} else if (pointers.size === 2) {
const current = pinchState();
if (current && pinchPrevious) {
spherical.radius = THREE.MathUtils.clamp(
spherical.radius * (pinchPrevious.distance / current.distance),
5.8,
18
);
panCamera(
current.centerX - pinchPrevious.centerX,
current.centerY - pinchPrevious.centerY
);
}
pinchPrevious = current;
}
});
function releasePointer(event) {
pointers.delete(event.pointerId);
if (pointers.size === 1) {
const remaining = [...pointers.values()][0];
dragPrevious = {
x: remaining.x,
y: remaining.y,
pan: false
};
} else {
dragPrevious = null;
pinchPrevious = null;
}
}
canvas.addEventListener("pointerup", releasePointer);
canvas.addEventListener("pointercancel", releasePointer);
canvas.addEventListener(
"wheel",
event => {
event.preventDefault();
spherical.radius = THREE.MathUtils.clamp(
spherical.radius * Math.exp(event.deltaY * 0.001),
5.8,
18
);
},
{ passive: false }
);
document.getElementById("reset-view").addEventListener("click", () => {
target.copy(defaultView.target);
spherical.copy(defaultView.spherical);
});
document.getElementById("top-view").addEventListener("click", () => {
target.set(0.05, 0.85, 0.0);
spherical.set(9.4, 0.18, 0.001);
});
// Projected HTML annotations with SVG leader lines.
const annotations = [
{
text: "Open housing / exposed drive",
index: "01",
anchor: new THREE.Vector3(-2.25, 2.42, -0.10),
offset: [-28, -72],
orange: false
},
{
text: "Fixture A / V-block",
index: "02",
anchor: new THREE.Vector3(0.05, 0.31, 0.72),
offset: [-76, 32],
orange: true
},
{
text: "Fixture B / V-block",
index: "03",
anchor: new THREE.Vector3(1.55, 0.31, 0.72),
offset: [76, 32],
orange: true
},
{
text: "110 mm vertical clearance",
index: "04",
anchor: new THREE.Vector3(1.19, 1.425, 0.58),
offset: [118, -6],
orange: false
},
{
text: "Workpiece seated on two supports",
index: "05",
anchor: new THREE.Vector3(0.80, 0.73, 0.31),
offset: [0, 72],
orange: true
}
];
const svgNS = "http://www.w3.org/2000/svg";
for (const annotation of annotations) {
const element = document.createElement("div");
element.className = `annotation${annotation.orange ? " orange" : ""}`;
element.innerHTML = `<span class="index">${annotation.index}</span>${annotation.text}`;
document.body.appendChild(element);
const line = document.createElementNS(svgNS, "line");
const dot = document.createElementNS(svgNS, "circle");
dot.setAttribute("r", "3");
leaders.appendChild(line);
leaders.appendChild(dot);
annotation.element = element;
annotation.line = line;
annotation.dot = dot;
}
const projected = new THREE.Vector3();
function updateAnnotations() {
for (const annotation of annotations) {
projected.copy(annotation.anchor).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.25 &&
Math.abs(projected.y) < 1.25;
annotation.element.style.display = visible ? "block" : "none";
annotation.line.style.display = visible ? "block" : "none";
annotation.dot.style.display = visible ? "block" : "none";
if (!visible) continue;
const anchorX = (projected.x * 0.5 + 0.5) * innerWidth;
const anchorY = (-projected.y * 0.5 + 0.5) * innerHeight;
const labelX = THREE.MathUtils.clamp(
anchorX + annotation.offset[0],
75,
innerWidth - 75
);
const labelY = THREE.MathUtils.clamp(
anchorY + annotation.offset[1],
80,
innerHeight - 65
);
annotation.element.style.left = `${labelX}px`;
annotation.element.style.top = `${labelY}px`;
annotation.line.setAttribute("x1", anchorX);
annotation.line.setAttribute("y1", anchorY);
annotation.line.setAttribute("x2", labelX);
annotation.line.setAttribute("y2", labelY + 2);
annotation.dot.setAttribute("cx", anchorX);
annotation.dot.setAttribute("cy", anchorY);
}
}
function resize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
leaders.setAttribute("width", innerWidth);
leaders.setAttribute("height", innerHeight);
leaders.setAttribute("viewBox", `0 0 ${innerWidth} ${innerHeight}`);
}
addEventListener("resize", resize);
resize();
updateCamera();
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
for (let i = 0; i < animatedCables.length; i++) {
const { curve, pulse } = animatedCables[i];
const t = (elapsed * 0.14 + i * 0.37) % 1;
pulse.position.copy(curve.getPoint(t));
}
updateCamera();
updateAnnotations();
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```