Prompt specification
Build or customize the Three.js 3D scene "Robot Tool Swap Changes Reachable Tasks" 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: Robot Tool Swap Changes Reachable Tasks
Category: Games & Play · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/robot-tool-swap-changes-reachable-tasks-x3744
Scene Description Prompt:
Swap a low-poly robot’s end effectors to reveal which tasks each tool can perform. Keep its arm unchanged. Three.js from cdnjs, standalone HTML.
Working Three.js Starter (robot-tool-swap-changes-reachable-tasks-x3744):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#0b1220" />
<title>Tool Lab — Modular End Effectors</title>
<style>
:root {
--accent: #ff8a3d;
--accent-rgb: 255, 138, 61;
--ink: #eef4fb;
--muted: #8e9bad;
--panel: rgba(14, 23, 38, 0.82);
--border: rgba(189, 210, 233, 0.14);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #0b1220;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
#stage {
position: fixed;
inset: 0;
}
#stage canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
}
.topbar {
position: absolute;
top: 24px;
left: 28px;
right: 28px;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 20px;
}
.brand {
display: flex;
align-items: center;
gap: 13px;
}
.brand-mark {
width: 42px;
height: 42px;
display: grid;
grid-template-columns: repeat(3, 1fr);
align-items: end;
gap: 3px;
padding: 8px;
border: 1px solid var(--border);
border-radius: 11px;
background: rgba(13, 22, 37, 0.74);
box-shadow: 0 12px 35px rgba(0, 0, 0, 0.22);
}
.brand-mark span {
display: block;
border-radius: 2px;
background: var(--accent);
box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.35);
transition: background 250ms ease;
}
.brand-mark span:nth-child(1) {
height: 45%;
opacity: 0.55;
}
.brand-mark span:nth-child(2) {
height: 72%;
opacity: 0.78;
}
.brand-mark span:nth-child(3) {
height: 100%;
}
.eyebrow {
margin: 0 0 3px;
color: var(--accent);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
.brand h1 {
margin: 0;
font-size: clamp(18px, 2vw, 25px);
font-weight: 750;
letter-spacing: -0.035em;
}
.brand-subtitle {
margin: 5px 0 0;
color: var(--muted);
font-size: 12px;
}
.status {
display: flex;
align-items: center;
gap: 9px;
padding: 10px 13px;
border: 1px solid var(--border);
border-radius: 999px;
background: rgba(13, 22, 37, 0.72);
color: #b6c4d3;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
backdrop-filter: blur(14px);
}
.status-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: #5ee7aa;
box-shadow: 0 0 0 4px rgba(94, 231, 170, 0.11),
0 0 16px rgba(94, 231, 170, 0.45);
}
.capability-panel {
position: absolute;
top: 104px;
right: 28px;
width: min(350px, calc(100vw - 40px));
padding: 23px;
overflow: hidden;
border: 1px solid var(--border);
border-radius: 18px;
background:
linear-gradient(145deg, rgba(var(--accent-rgb), 0.08), transparent 42%),
var(--panel);
box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
backdrop-filter: blur(18px);
pointer-events: auto;
transition: background 250ms ease;
}
.capability-panel::before {
content: "";
position: absolute;
top: 0;
left: 23px;
right: 23px;
height: 1px;
background: linear-gradient(
90deg,
transparent,
rgba(var(--accent-rgb), 0.9),
transparent
);
}
.panel-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 14px;
}
.tool-index {
margin-bottom: 10px;
color: var(--accent);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.capability-panel h2 {
margin: 0;
font-size: 28px;
line-height: 1.05;
letter-spacing: -0.045em;
}
.mounted-badge {
flex: none;
display: flex;
align-items: center;
gap: 6px;
padding: 7px 9px;
border: 1px solid rgba(var(--accent-rgb), 0.26);
border-radius: 8px;
color: var(--accent);
background: rgba(var(--accent-rgb), 0.08);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.mounted-badge::before {
content: "";
width: 5px;
height: 5px;
border-radius: 50%;
background: currentColor;
}
.description {
min-height: 54px;
margin: 14px 0 20px;
color: #aab7c6;
font-size: 13px;
line-height: 1.55;
}
.section-title {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
color: #dbe5ef;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.section-title span:last-child {
color: var(--muted);
font-weight: 650;
letter-spacing: 0.06em;
}
.task-list {
display: grid;
gap: 8px;
margin: 0;
padding: 0;
list-style: none;
}
.task-list li {
display: grid;
grid-template-columns: 26px 1fr;
gap: 10px;
align-items: start;
padding: 11px 12px;
border: 1px solid rgba(189, 210, 233, 0.09);
border-radius: 11px;
background: rgba(255, 255, 255, 0.025);
animation: reveal-task 420ms both;
animation-delay: calc(var(--i) * 65ms);
}
@keyframes reveal-task {
from {
opacity: 0;
transform: translateY(7px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.task-check {
width: 24px;
height: 24px;
display: grid;
place-items: center;
border-radius: 7px;
color: var(--accent);
background: rgba(var(--accent-rgb), 0.1);
font-size: 12px;
font-weight: 900;
}
.task-name {
margin: 1px 0 3px;
color: #eef4fb;
font-size: 12px;
font-weight: 750;
}
.task-detail {
color: #8796a8;
font-size: 11px;
line-height: 1.4;
}
.match {
display: flex;
align-items: center;
gap: 12px;
margin-top: 16px;
padding: 12px;
border: 1px solid rgba(var(--accent-rgb), 0.2);
border-radius: 11px;
background: rgba(var(--accent-rgb), 0.065);
}
.match-icon {
width: 31px;
height: 31px;
display: grid;
place-items: center;
flex: none;
border-radius: 8px;
color: var(--accent);
background: rgba(var(--accent-rgb), 0.11);
}
.match-label {
margin-bottom: 2px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.match-value {
color: #e9f1f8;
font-size: 12px;
font-weight: 650;
}
.tool-dock {
position: absolute;
left: 28px;
bottom: 27px;
width: min(760px, calc(100vw - 56px));
pointer-events: auto;
}
.dock-heading {
display: flex;
align-items: center;
gap: 10px;
margin: 0 0 10px 2px;
color: #aebdcc;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.dock-heading::after {
content: "";
width: 34px;
height: 1px;
background: rgba(190, 208, 228, 0.25);
}
.tool-list {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
}
.tool-card {
position: relative;
min-width: 0;
display: grid;
grid-template-columns: 43px 1fr auto;
align-items: center;
gap: 11px;
padding: 12px;
overflow: hidden;
border: 1px solid var(--border);
border-radius: 14px;
color: var(--ink);
text-align: left;
background: rgba(13, 22, 37, 0.78);
box-shadow: 0 15px 42px rgba(0, 0, 0, 0.2);
backdrop-filter: blur(15px);
cursor: pointer;
transition:
transform 180ms ease,
border-color 180ms ease,
background 180ms ease;
}
.tool-card::after {
content: "";
position: absolute;
inset: auto 0 0;
height: 2px;
background: var(--card-accent);
transform: scaleX(0);
transform-origin: left;
transition: transform 220ms ease;
}
.tool-card:hover {
transform: translateY(-3px);
border-color: rgba(205, 224, 244, 0.27);
background: rgba(19, 31, 49, 0.9);
}
.tool-card.active {
border-color: rgba(var(--card-accent-rgb), 0.52);
background:
linear-gradient(
120deg,
rgba(var(--card-accent-rgb), 0.12),
transparent 55%
),
rgba(13, 22, 37, 0.9);
}
.tool-card.active::after {
transform: scaleX(1);
}
.tool-icon {
width: 43px;
height: 43px;
display: grid;
place-items: center;
border: 1px solid rgba(var(--card-accent-rgb), 0.25);
border-radius: 11px;
color: var(--card-accent);
background: rgba(var(--card-accent-rgb), 0.08);
}
.tool-icon svg {
width: 25px;
height: 25px;
fill: none;
stroke: currentColor;
stroke-width: 1.7;
stroke-linecap: round;
stroke-linejoin: round;
}
.tool-copy {
min-width: 0;
}
.tool-number {
display: block;
margin-bottom: 3px;
color: var(--muted);
font-size: 8px;
font-weight: 800;
letter-spacing: 0.12em;
}
.tool-name {
display: block;
overflow: hidden;
color: #eff5fb;
font-size: 12px;
font-weight: 780;
text-overflow: ellipsis;
white-space: nowrap;
}
.tool-tagline {
display: block;
margin-top: 3px;
overflow: hidden;
color: #8797a9;
font-size: 10px;
text-overflow: ellipsis;
white-space: nowrap;
}
.tool-key {
align-self: start;
min-width: 20px;
padding: 4px 5px;
border: 1px solid rgba(190, 210, 232, 0.13);
border-radius: 5px;
color: #8797a9;
font-size: 9px;
text-align: center;
}
.camera-help {
position: absolute;
right: 29px;
bottom: 29px;
display: flex;
align-items: center;
gap: 9px;
color: rgba(195, 209, 225, 0.62);
font-size: 9px;
font-weight: 750;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.camera-help svg {
width: 17px;
height: 17px;
fill: none;
stroke: currentColor;
stroke-width: 1.5;
}
@media (max-width: 1000px) {
.capability-panel {
width: 315px;
}
.camera-help {
display: none;
}
.tool-card {
grid-template-columns: 38px 1fr;
}
.tool-icon {
width: 38px;
height: 38px;
}
.tool-key {
display: none;
}
}
@media (max-width: 720px) {
.topbar {
top: 15px;
left: 15px;
right: 15px;
}
.brand-subtitle,
.status {
display: none;
}
.brand-mark {
width: 36px;
height: 36px;
}
.capability-panel {
top: 72px;
left: 15px;
right: 15px;
width: auto;
padding: 16px;
border-radius: 14px;
}
.capability-panel h2 {
font-size: 22px;
}
.description {
display: none;
}
.tool-list {
grid-template-columns: repeat(3, 1fr);
gap: 6px;
}
.tool-card {
display: flex;
justify-content: center;
padding: 9px;
}
.tool-copy,
.tool-key {
display: none;
}
.tool-icon {
width: 36px;
height: 36px;
}
.tool-dock {
left: 15px;
bottom: 15px;
width: calc(100vw - 30px);
}
.match {
margin-top: 10px;
padding: 9px;
}
}
@media (max-height: 650px) {
.description,
.match,
.dock-heading {
display: none;
}
.capability-panel {
top: 78px;
padding: 15px;
}
.task-list {
gap: 5px;
}
.task-list li {
padding: 7px 9px;
}
.tool-dock {
bottom: 15px;
}
}
</style>
</head>
<body>
<div id="stage"></div>
<main class="hud">
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true">
<span></span><span></span><span></span>
</div>
<div>
<p class="eyebrow">Tool Lab / Modular Robotics</p>
<h1>End Effector Configurator</h1>
<p class="brand-subtitle">Change the hand. Keep the arm locked.</p>
</div>
</div>
<div class="status">
<span class="status-dot"></span>
Arm system locked
</div>
</header>
<aside class="capability-panel" aria-live="polite">
<div class="panel-header">
<div>
<div class="tool-index" id="toolIndex">Tool 01 / 03</div>
<h2 id="toolName">Parallel Gripper</h2>
</div>
<div class="mounted-badge">Mounted</div>
</div>
<p class="description" id="toolDescription"></p>
<div class="section-title">
<span>Can perform</span>
<span id="taskCount">03 capabilities</span>
</div>
<ul class="task-list" id="taskList"></ul>
<div class="match">
<div class="match-icon" aria-hidden="true">◎</div>
<div>
<div class="match-label">Workpiece match</div>
<div class="match-value" id="matchValue"></div>
</div>
</div>
</aside>
<nav class="tool-dock" aria-label="End effector selection">
<div class="dock-heading">Choose end effector</div>
<div class="tool-list" role="tablist">
<button
class="tool-card active"
data-tool="gripper"
role="tab"
aria-selected="true"
style="
--card-accent: #ff8a3d;
--card-accent-rgb: 255, 138, 61;
"
>
<div class="tool-icon" aria-hidden="true">
<svg viewBox="0 0 32 32">
<path d="M16 3v7M11 10h10v4H11z" />
<path d="M11 14 7 17v8l4 2V15M21 14l4 3v8l-4 2V15" />
<path d="M7 22h4M21 22h4" />
</svg>
</div>
<div class="tool-copy">
<span class="tool-number">01 / PINCH</span>
<span class="tool-name">Parallel Gripper</span>
<span class="tool-tagline">Rigid parts and controls</span>
</div>
<span class="tool-key">1</span>
</button>
<button
class="tool-card"
data-tool="vacuum"
role="tab"
aria-selected="false"
style="
--card-accent: #2ec7d9;
--card-accent-rgb: 46, 199, 217;
"
>
<div class="tool-icon" aria-hidden="true">
<svg viewBox="0 0 32 32">
<path d="M12 3h8v7h-8zM14 10v6h4v-6" />
<path d="M10 16h12l-3 5v5c0 2-1.5 3-3 3s-3-1-3-3v-5l-3-5Z" />
<path d="M12 20h8" />
</svg>
</div>
<div class="tool-copy">
<span class="tool-number">02 / VACUUM</span>
<span class="tool-name">Vacuum Cup</span>
<span class="tool-tagline">Smooth, flat surfaces</span>
</div>
<span class="tool-key">2</span>
</button>
<button
class="tool-card"
data-tool="magnet"
role="tab"
aria-selected="false"
style="
--card-accent: #ad8cff;
--card-accent-rgb: 173, 140, 255;
"
>
<div class="tool-icon" aria-hidden="true">
<svg viewBox="0 0 32 32">
<path d="M13 3h6v12h3v5h-5v-4h-2v4H10v-5h3V3Z" />
<path d="M10 20h12M12 24h8M14 28h4" />
</svg>
</div>
<div class="tool-copy">
<span class="tool-number">03 / MAGNET</span>
<span class="tool-name">Magnetic Gripper</span>
<span class="tool-tagline">Ferrous metal stock</span>
</div>
<span class="tool-key">3</span>
</button>
</div>
</nav>
<div class="camera-help" aria-hidden="true">
<svg viewBox="0 0 24 24">
<path d="M8 3H5a2 2 0 0 0-2 2v3M16 3h3a2 2 0 0 1 2 2v3M8 21H5a2 2 0 0 1-2-2v-3M16 21h3a2 2 0 0 0 2-2v-3" />
<circle cx="12" cy="12" r="4" />
</svg>
Drag to orbit · Scroll to zoom
</div>
</main>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Scene
// -------------------------------------------------------------------------
const stage = document.querySelector("#stage");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x0b1220);
scene.fog = new THREE.Fog(0x0b1220, 13, 27);
const camera = new THREE.PerspectiveCamera(
43,
window.innerWidth / window.innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
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.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Interactive 3D low-poly robot with swappable end effectors"
);
stage.appendChild(renderer.domElement);
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0xc4dcff, 0x111827, 2.15);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffffff, 3.4);
keyLight.position.set(5, 9, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -7;
keyLight.shadow.camera.right = 7;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -6;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 25;
keyLight.shadow.bias = -0.0008;
scene.add(keyLight);
const coolRim = new THREE.PointLight(0x4bbdff, 34, 14, 2);
coolRim.position.set(4.5, 5.5, -4.5);
scene.add(coolRim);
const warmRim = new THREE.PointLight(0xff7a32, 25, 11, 2);
warmRim.position.set(-4, 3.7, -2.8);
scene.add(warmRim);
// -------------------------------------------------------------------------
// Materials and geometry helpers
// -------------------------------------------------------------------------
const standard = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.67,
metalness: 0.08,
flatShading: true,
...options
});
const materials = {
platform: standard(0x172335),
platformTop: standard(0x1b2a3e),
navy: standard(0x172333),
dark: standard(0x0c1420),
steel: standard(0x718197, { metalness: 0.58, roughness: 0.36 }),
lightSteel: standard(0xa7b5c3, { metalness: 0.42, roughness: 0.42 }),
orange: standard(0xff7a32, { metalness: 0.16, roughness: 0.48 }),
orangeDark: standard(0xba4c22),
rubber: standard(0x101720, { roughness: 0.94, metalness: 0 }),
cyan: standard(0x2ec7d9, { metalness: 0.25, roughness: 0.4 }),
violet: standard(0xad8cff, { metalness: 0.28, roughness: 0.38 }),
greenLight: standard(0x61f0b0, {
emissive: 0x24c981,
emissiveIntensity: 1.1,
roughness: 0.3
}),
amberLight: standard(0xffbe64, {
emissive: 0xff7a26,
emissiveIntensity: 0.9
})
};
function mesh(geometry, material, position, parent = scene) {
const object = new THREE.Mesh(geometry, material);
if (position) object.position.copy(position);
object.castShadow = true;
object.receiveShadow = true;
parent.add(object);
return object;
}
function box(width, height, depth, material, position, parent = scene) {
return mesh(
new THREE.BoxGeometry(width, height, depth),
material,
position,
parent
);
}
function cylinder(
topRadius,
bottomRadius,
height,
material,
position,
segments = 10,
parent = scene
) {
return mesh(
new THREE.CylinderGeometry(topRadius, bottomRadius, height, segments),
material,
position,
parent
);
}
function makeBeam(a, b, width, depth, material, stripeMaterial) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(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(0, 1, 0),
direction.clone().normalize()
);
box(width, length, depth, material, new THREE.Vector3(), group);
if (stripeMaterial) {
box(
width * 0.34,
length * 0.72,
0.025,
stripeMaterial,
new THREE.Vector3(0, 0, depth / 2 + 0.016),
group
);
}
scene.add(group);
return group;
}
function makeJoint(position, radius, width, material) {
const joint = cylinder(
radius,
radius,
width,
material,
new THREE.Vector3(...position),
12
);
joint.rotation.x = Math.PI / 2;
return joint;
}
// -------------------------------------------------------------------------
// Display platform
// -------------------------------------------------------------------------
const platform = cylinder(
4.75,
4.95,
0.18,
materials.platform,
new THREE.Vector3(0, -0.12, 0),
64
);
platform.receiveShadow = true;
cylinder(
4.55,
4.55,
0.035,
materials.platformTop,
new THREE.Vector3(0, -0.012, 0),
64
);
const grid = new THREE.GridHelper(9, 18, 0x4d647d, 0x33475d);
grid.position.y = 0.012;
grid.material.transparent = true;
grid.material.opacity = 0.14;
scene.add(grid);
const platformRing = mesh(
new THREE.TorusGeometry(4.58, 0.025, 6, 96),
new THREE.MeshBasicMaterial({
color: 0x47708c,
transparent: true,
opacity: 0.45
}),
new THREE.Vector3(0, 0.025, 0)
);
platformRing.rotation.x = Math.PI / 2;
// -------------------------------------------------------------------------
// Static robot arm — this group is never modified by tool selection.
// -------------------------------------------------------------------------
const armGroup = new THREE.Group();
armGroup.name = "Static robot arm";
scene.add(armGroup);
const baseX = -1.65;
cylinder(
0.78,
0.87,
0.25,
materials.dark,
new THREE.Vector3(baseX, 0.08, 0),
12,
armGroup
);
cylinder(
0.64,
0.75,
0.35,
materials.navy,
new THREE.Vector3(baseX, 0.35, 0),
10,
armGroup
);
cylinder(
0.48,
0.57,
0.58,
materials.steel,
new THREE.Vector3(baseX, 0.78, 0),
10,
armGroup
);
box(
0.92,
0.38,
0.9,
materials.orange,
new THREE.Vector3(baseX, 1.04, 0),
armGroup
);
const shoulder = new THREE.Vector3(baseX, 1.2, 0);
const elbow = new THREE.Vector3(-1.42, 2.88, 0.06);
const wrist = new THREE.Vector3(-0.18, 4.05, 0.12);
makeJoint([shoulder.x, shoulder.y, shoulder.z], 0.43, 0.9, materials.navy);
makeJoint([elbow.x, elbow.y, elbow.z], 0.42, 0.86, materials.navy);
makeJoint([wrist.x, wrist.y, wrist.z], 0.33, 0.64, materials.lightSteel);
makeBeam(
[shoulder.x, shoulder.y, shoulder.z],
[elbow.x, elbow.y, elbow.z],
0.62,
0.68,
materials.orange,
materials.orangeDark
);
makeBeam(
[elbow.x, elbow.y, elbow.z],
[wrist.x, wrist.y, wrist.z],
0.5,
0.55,
materials.lightSteel,
materials.orange
);
// Shoulder accent and status strip.
box(
0.48,
0.09,
0.03,
materials.greenLight,
new THREE.Vector3(baseX, 1.1, 0.466),
armGroup
);
// Fixed wrist flange. Only the tool below this flange is swapped.
cylinder(
0.29,
0.29,
0.2,
materials.steel,
new THREE.Vector3(wrist.x, wrist.y - 0.16, wrist.z),
12,
armGroup
);
const effectorMount = new THREE.Group();
effectorMount.name = "End effector mount";
effectorMount.position.copy(wrist);
effectorMount.position.y -= 0.25;
scene.add(effectorMount);
// -------------------------------------------------------------------------
// End effectors
// -------------------------------------------------------------------------
function createGripper() {
const group = new THREE.Group();
group.name = "Parallel gripper";
cylinder(
0.27,
0.27,
0.18,
materials.steel,
new THREE.Vector3(0, -0.09, 0),
12,
group
);
cylinder(
0.14,
0.17,
0.31,
materials.navy,
new THREE.Vector3(0, -0.31, 0),
10,
group
);
box(
0.7,
0.36,
0.38,
materials.orange,
new THREE.Vector3(0, -0.57, 0),
group
);
box(
0.92,
0.1,
0.14,
materials.dark,
new THREE.Vector3(0, -0.77, 0),
group
);
for (const side of [-1, 1]) {
const finger = new THREE.Group();
finger.position.x = side * 0.32;
group.add(finger);
box(
0.13,
0.49,
0.2,
materials.lightSteel,
new THREE.Vector3(0, -0.96, 0),
finger
);
box(
0.19,
0.17,
0.24,
materials.rubber,
new THREE.Vector3(-side * 0.035, -1.18, 0),
finger
);
box(
0.18,
0.13,
0.25,
materials.orange,
new THREE.Vector3(0, -0.79, 0),
finger
);
}
box(
0.19,
0.06,
0.03,
materials.amberLight,
new THREE.Vector3(0, -0.55, 0.198),
group
);
return group;
}
function createVacuum() {
const group = new THREE.Group();
group.name = "Vacuum cup";
cylinder(
0.27,
0.27,
0.18,
materials.steel,
new THREE.Vector3(0, -0.09, 0),
12,
group
);
cylinder(
0.14,
0.14,
0.34,
materials.navy,
new THREE.Vector3(0, -0.32, 0),
10,
group
);
cylinder(
0.21,
0.19,
0.19,
materials.cyan,
new THREE.Vector3(0, -0.55, 0),
12,
group
);
cylinder(
0.16,
0.16,
0.26,
materials.dark,
new THREE.Vector3(0, -0.72, 0),
10,
group
);
cylinder(
0.18,
0.43,
0.31,
materials.cyan,
new THREE.Vector3(0, -0.98, 0),
12,
group
);
const lip = mesh(
new THREE.TorusGeometry(0.39, 0.055, 6, 24),
materials.rubber,
new THREE.Vector3(0, -1.13, 0),
group
);
lip.rotation.x = Math.PI / 2;
box(
0.13,
0.05,
0.025,
materials.greenLight,
new THREE.Vector3(0.1, -0.53, 0.15),
group
);
return group;
}
function createMagnet() {
const group = new THREE.Group();
group.name = "Magnetic gripper";
cylinder(
0.27,
0.27,
0.18,
materials.steel,
new THREE.Vector3(0, -0.09, 0),
12,
group
);
cylinder(
0.15,
0.15,
0.28,
materials.navy,
new THREE.Vector3(0, -0.31, 0),
10,
group
);
box(
0.78,
0.34,
0.47,
materials.violet,
new THREE.Vector3(0, -0.57, 0),
group
);
box(
0.68,
0.11,
0.39,
materials.dark,
new THREE.Vector3(0, -0.8, 0),
group
);
box(
0.61,
0.13,
0.34,
materials.steel,
new THREE.Vector3(0, -0.91, 0),
group
);
for (const side of [-1, 1]) {
cylinder(
0.12,
0.12,
0.08,
materials.rubber,
new THREE.Vector3(side * 0.23, -1.0, 0),
10,
group
);
}
box(
0.24,
0.06,
0.025,
materials.greenLight,
new THREE.Vector3(0, -0.54, 0.245),
group
);
return group;
}
const toolFactories = {
gripper: createGripper,
vacuum: createVacuum,
magnet: createMagnet
};
// -------------------------------------------------------------------------
// Workstation and representative workpieces
// -------------------------------------------------------------------------
const bench = new THREE.Group();
scene.add(bench);
box(
2.65,
0.18,
1.55,
materials.navy,
new THREE.Vector3(0.95, 0.88, 0.02),
bench
);
box(
2.35,
0.035,
1.28,
materials.steel,
new THREE.Vector3(0.95, 0.985, 0.02),
bench
);
for (const x of [-0.15, 2.05]) {
for (const z of [-0.55, 0.58]) {
box(
0.12,
0.82,
0.12,
materials.dark,
new THREE.Vector3(x, 0.42, z),
bench
);
}
}
const cubeMaterial = standard(0xff7138, {
metalness: 0.12,
roughness: 0.45
});
const panelMaterial = standard(0x29b9d1, {
metalness: 0.25,
roughness: 0.25,
transparent: true,
opacity: 0.88
});
const steelBarMaterial = standard(0x8e9cad, {
metalness: 0.78,
roughness: 0.3
});
const cube = box(
0.46,
0.38,
0.46,
cubeMaterial,
new THREE.Vector3(0.16, 1.19, 0.24),
bench
);
cube.rotation.y = -0.18;
const buttonBase = cylinder(
0.16,
0.18,
0.12,
materials.dark,
new THREE.Vector3(0.72, 1.05, -0.27),
10,
bench
);
cylinder(
0.1,
0.1,
0.1,
materials.greenLight,
new THREE.Vector3(0.72, 1.15, -0.27),
10,
bench
);
const panel = box(
0.72,
0.73,
0.065,
panelMaterial,
new THREE.Vector3(1.55, 1.38, -0.32),
bench
);
panel.rotation.y = -0.16;
panel.rotation.z = -0.08;
const steelBar = box(
0.77,
0.16,
0.2,
steelBarMaterial,
new THREE.Vector3(1.48, 1.08, 0.36),
bench
);
steelBar.rotation.y = 0.14;
// Small connector part used as a second gripper target.
const connector = new THREE.Group();
connector.position.set(0.58, 1.11, 0.47);
connector.rotation.y = 0.42;
bench.add(connector);
box(0.18, 0.17, 0.2, materials.dark, new THREE.Vector3(), connector);
box(0.14, 0.14, 0.14, materials.orange, new THREE.Vector3(0, 0, 0.14), connector);
// -------------------------------------------------------------------------
// Scene labels
// -------------------------------------------------------------------------
function makeLabel(text, color = "#91a5ba") {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 128;
const context = canvas.getContext("2d");
context.clearRect(0, 0, canvas.width, canvas.height);
context.fillStyle = "rgba(8, 16, 27, 0.84)";
context.fillRect(0, 0, canvas.width, canvas.height);
context.strokeStyle = "rgba(171, 195, 219, 0.23)";
context.strokeRect(2, 2, canvas.width - 4, canvas.height - 4);
context.fillStyle = color;
context.font = "700 31px system-ui, sans-serif";
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(text.toUpperCase(), 256, 66);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false,
depthTest: true
})
);
sprite.scale.set(1.32, 0.33, 1);
return sprite;
}
const cubeLabel = makeLabel("Rigid part", "#ff9a61");
cubeLabel.position.set(0.16, 1.69, 0.24);
scene.add(cubeLabel);
const panelLabel = makeLabel("Smooth panel", "#62d8e7");
panelLabel.position.set(1.55, 1.96, -0.32);
scene.add(panelLabel);
const steelLabel = makeLabel("Ferrous stock", "#c0a7ff");
steelLabel.position.set(1.48, 1.5, 0.36);
scene.add(steelLabel);
// -------------------------------------------------------------------------
// Active workpiece highlighting
// -------------------------------------------------------------------------
const targetRing = mesh(
new THREE.TorusGeometry(0.34, 0.023, 6, 32),
new THREE.MeshBasicMaterial({
color: 0xff8a3d,
transparent: true,
opacity: 0.85,
depthWrite: false
}),
new THREE.Vector3(0.16, 1.02, 0.24)
);
targetRing.rotation.x = Math.PI / 2;
targetRing.castShadow = false;
targetRing.receiveShadow = false;
const targetConfigurations = {
gripper: {
position: new THREE.Vector3(0.16, 1.02, 0.24),
radius: 0.34,
materials: [cubeMaterial],
color: 0xff8a3d
},
vacuum: {
position: new THREE.Vector3(1.55, 1.02, -0.32),
radius: 0.5,
materials: [panelMaterial],
color: 0x2ec7d9
},
magnet: {
position: new THREE.Vector3(1.48, 1.02, 0.36),
radius: 0.43,
materials: [steelBarMaterial],
color: 0xad8cff
}
};
function resetTargetMaterials() {
cubeMaterial.emissive.setHex(0x000000);
panelMaterial.emissive.setHex(0x000000);
steelBarMaterial.emissive.setHex(0x000000);
cubeMaterial.emissiveIntensity = 0;
panelMaterial.emissiveIntensity = 0;
steelBarMaterial.emissiveIntensity = 0;
}
// -------------------------------------------------------------------------
// Tool data and interface
// -------------------------------------------------------------------------
const tools = {
gripper: {
index: "Tool 01 / 03",
name: "Parallel Gripper",
description:
"A two-finger mechanical hand for controlled contact with rigid components, controls, and connectors.",
accent: "#ff8a3d",
accentRgb: "255, 138, 61",
match: "Orange housing + green button",
tasks: [
{
name: "Pick & place",
detail: "Molded housings, blocks and small fixtures"
},
{
name: "Button pressing",
detail: "Control panels, switches and toggles"
},
{
name: "Connector handling",
detail: "Plugs, caps and cable-end components"
}
]
},
vacuum: {
index: "Tool 02 / 03",
name: "Vacuum Cup",
description:
"A non-contact suction hand optimized for broad, smooth surfaces where a mechanical grip would scratch the workpiece.",
accent: "#2ec7d9",
accentRgb: "46, 199, 217",
match: "Blue acrylic panel",
tasks: [
{
name: "Sheet transfer",
detail: "Glass, acrylic, labels and flexible film"
},
{
name: "Flat-part handling",
detail: "Panels, lenses and shallow trays"
},
{
name: "Packaging support",
detail: "Cartons, film and lightweight packages"
}
]
},
magnet: {
index: "Tool 03 / 03",
name: "Magnetic Gripper",
description:
"An electromagnetic hold-down for ferrous stock, providing rapid tool-free contact without mechanical fingers.",
accent: "#ad8cff",
accentRgb: "173, 140, 255",
match: "Galvanized steel bar",
tasks: [
{
name: "Steel pick-up",
detail: "Brackets, plates and stock offcuts"
},
{
name: "Machine tending",
detail: "Ferrous blanks, billets and metal stock"
},
{
name: "Tool-free holding",
detail: "Stable, contactless grip on metal"
}
]
}
};
const toolName = document.querySelector("#toolName");
const toolIndex = document.querySelector("#toolIndex");
const toolDescription = document.querySelector("#toolDescription");
const taskList = document.querySelector("#taskList");
const taskCount = document.querySelector("#taskCount");
const matchValue = document.querySelector("#matchValue");
const toolButtons = [...document.querySelectorAll(".tool-card")];
let activeTool = "gripper";
let activeEffect = null;
function updateInterface(id) {
const tool = tools[id];
document.documentElement.style.setProperty("--accent", tool.accent);
document.documentElement.style.setProperty("--accent-rgb", tool.accentRgb);
toolIndex.textContent = tool.index;
toolName.textContent = tool.name;
toolDescription.textContent = tool.description;
taskCount.textContent = `0${tool.tasks.length} capabilities`;
matchValue.textContent = tool.match;
taskList.innerHTML = tool.tasks
.map(
(task, index) => `
<li style="--i: ${index}">
<div class="task-check" aria-hidden="true">✓</div>
<div>
<div class="task-name">${task.name}</div>
<div class="task-detail">${task.detail}</div>
</div>
</li>
`
)
.join("");
toolButtons.forEach((button) => {
const selected = button.dataset.tool === id;
button.classList.toggle("active", selected);
button.setAttribute("aria-selected", String(selected));
});
resetTargetMaterials();
const target = targetConfigurations[id];
target.materials.forEach((material) => {
material.emissive.setHex(target.color);
material.emissiveIntensity = 0.28;
});
targetRing.position.set(
target.position.x,
target.position.y,
target.position.z
);
targetRing.material.color.setHex(target.color);
targetRing.scale.setScalar(target.radius / 0.34);
}
// -------------------------------------------------------------------------
// Tool swap animation — only the effector group is changed.
// -------------------------------------------------------------------------
function easeOutBack(value) {
const c1 = 1.70158;
const c3 = c1 + 1;
return 1 + c3 * Math.pow(value - 1, 3) + c1 * Math.pow(value - 1, 2);
}
function installTool(id, animate = true) {
if (activeEffect) {
activeEffect.userData.outStart = performance.now();
}
const next = toolFactories[id]();
next.userData.inStart = performance.now();
next.scale.setScalar(animate ? 0.001 : 1);
next.position.y = animate ? -0.16 : 0;
effectorMount.add(next);
activeEffect = next;
activeTool = id;
updateInterface(id);
}
function updateToolTransitions(now) {
for (const child of [...effectorMount.children]) {
if (child.userData.outStart !== undefined) {
const progress = Math.min((now - child.userData.outStart) / 260, 1);
const scale = Math.max(0.001, 1 - progress * progress);
child.scale.setScalar(scale);
child.position.y = -0.16 * progress;
if (progress >= 1) {
effectorMount.remove(child);
}
} else if (child === activeEffect && child.userData.inStart !== undefined) {
const progress = Math.min((now - child.userData.inStart) / 480, 1);
const scale = Math.max(0.001, easeOutBack(progress));
child.scale.setScalar(scale);
child.position.y = -0.16 * (1 - progress);
if (progress >= 1) {
child.userData.inStart = undefined;
child.scale.setScalar(1);
child.position.y = 0;
}
}
}
}
toolButtons.forEach((button) => {
button.addEventListener("click", () => {
const id = button.dataset.tool;
if (id !== activeTool) installTool(id);
});
});
window.addEventListener("keydown", (event) => {
if (event.key === "1") installTool("gripper");
if (event.key === "2") installTool("vacuum");
if (event.key === "3") installTool("magnet");
});
installTool("gripper", false);
// -------------------------------------------------------------------------
// Custom camera controls — no addons or example modules.
// -------------------------------------------------------------------------
const cameraTarget = new THREE.Vector3(-0.05, 2.05, 0);
const desiredTarget = cameraTarget.clone();
let desiredTheta = 0.65;
let desiredPhi = 1.11;
let desiredRadius = 9.8;
let currentTheta = desiredTheta;
let currentPhi = desiredPhi;
let currentRadius = desiredRadius;
const pointers = new Map();
let dragPointerId = null;
let lastPinchDistance = 0;
function pointerDistance() {
const values = [...pointers.values()];
if (values.length < 2) return 0;
return Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
}
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 1) {
dragPointerId = event.pointerId;
} else if (pointers.size === 2) {
lastPinchDistance = pointerDistance();
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
const deltaX = event.clientX - previous.x;
const deltaY = event.clientY - previous.y;
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 1 && dragPointerId === event.pointerId) {
desiredTheta -= deltaX * 0.006;
desiredPhi = THREE.MathUtils.clamp(
desiredPhi - deltaY * 0.005,
0.55,
1.43
);
} else if (pointers.size === 2) {
const distance = pointerDistance();
if (lastPinchDistance > 0 && distance > 0) {
desiredRadius = THREE.MathUtils.clamp(
desiredRadius * (lastPinchDistance / distance),
5.8,
14.5
);
}
lastPinchDistance = distance;
}
});
function releasePointer(event) {
pointers.delete(event.pointerId);
if (pointers.size === 1) {
dragPointerId = [...pointers.keys()][0];
} else {
dragPointerId = null;
}
lastPinchDistance = pointerDistance();
}
renderer.domElement.addEventListener("pointerup", releasePointer);
renderer.domElement.addEventListener("pointercancel", releasePointer);
renderer.domElement.addEventListener("lostpointercapture", releasePointer);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desiredRadius = THREE.MathUtils.clamp(
desiredRadius + event.deltaY * 0.008,
5.8,
14.5
);
},
{ passive: false }
);
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
function updateCamera() {
currentTheta += (desiredTheta - currentTheta) * 0.085;
currentPhi += (desiredPhi - currentPhi) * 0.085;
currentRadius += (desiredRadius - currentRadius) * 0.085;
const sinPhi = Math.sin(currentPhi);
camera.position.set(
desiredTarget.x + currentRadius * sinPhi * Math.sin(currentTheta),
desiredTarget.y + currentRadius * Math.cos(currentPhi),
desiredTarget.z + currentRadius * sinPhi * Math.cos(currentTheta)
);
camera.lookAt(desiredTarget);
}
// -------------------------------------------------------------------------
// Resize and render loop
// -------------------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
const clock = new THREE.Clock();
function animate(now) {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
updateCamera();
updateToolTransitions(now);
const pulse = 0.22 + Math.sin(elapsed * 3.2) * 0.08;
const activeMaterials = targetConfigurations[activeTool].materials;
activeMaterials.forEach((material) => {
material.emissiveIntensity = pulse;
});
const ringPulse = 1 + Math.sin(elapsed * 3.5) * 0.08;
targetRing.scale.x =
(targetConfigurations[activeTool].radius / 0.34) * ringPulse;
targetRing.scale.z = targetRing.scale.x;
targetRing.material.opacity = 0.62 + Math.sin(elapsed * 3.5) * 0.16;
renderer.render(scene, camera);
}
requestAnimationFrame(animate);
</script>
</body>
</html>
```