Prompt specification
Build or customize the Three.js 3D scene "Chip layers and external pin connections" 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: Chip layers and external pin connections
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/chip-layers-and-external-pin-connections-x2494
Scene Description Prompt:
An exploded low-poly microchip with substrate, schematic circuitry, package, pins, and one traced connection; mark differing scales. Three.js from cdnjs, one HTML file.
Working Three.js Starter (chip-layers-and-external-pin-connections-x2494):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Exploded Microchip</title>
<style>
:root {
color-scheme: dark;
--ink: #eaf6ff;
--muted: #91a9bd;
--cyan: #62e7ff;
--gold: #e3b85b;
--panel: rgba(8, 18, 32, 0.78);
--line: rgba(137, 187, 215, 0.22);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 48% 42%, #14283d 0%, #091422 43%, #050a12 100%);
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;
touch-action: none;
outline: none;
}
#leaders {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
pointer-events: none;
overflow: visible;
}
#annotations {
position: fixed;
inset: 0;
pointer-events: none;
}
.annotation {
position: absolute;
min-width: 172px;
max-width: 224px;
padding: 9px 11px 9px 13px;
border: 1px solid var(--line);
border-left: 2px solid var(--cyan);
border-radius: 4px;
background: var(--panel);
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
backdrop-filter: blur(10px);
opacity: 0;
transition: opacity 180ms ease;
}
.annotation.visible {
opacity: 1;
}
.annotation.gold {
border-left-color: var(--gold);
}
.annotation strong {
display: block;
margin-bottom: 3px;
color: #f4fbff;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.annotation span {
display: block;
color: var(--muted);
font-size: 10px;
line-height: 1.35;
letter-spacing: 0.025em;
}
.annotation .dimension {
display: inline-block;
margin-top: 6px;
padding: 2px 6px;
border: 1px solid rgba(98, 231, 255, 0.25);
border-radius: 999px;
color: var(--cyan);
font: 600 9px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.annotation.gold .dimension {
color: var(--gold);
border-color: rgba(227, 184, 91, 0.28);
}
.hud {
position: fixed;
top: 22px;
left: 24px;
z-index: 5;
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 8px;
color: var(--cyan);
font-size: 9px;
font-weight: 750;
letter-spacing: 0.22em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 19px;
height: 1px;
background: var(--cyan);
box-shadow: 0 0 8px var(--cyan);
}
h1 {
margin: 0;
font-size: clamp(25px, 3.3vw, 47px);
font-weight: 680;
letter-spacing: -0.045em;
line-height: 0.98;
}
.subtitle {
margin: 10px 0 0;
max-width: 380px;
color: var(--muted);
font-size: 11px;
line-height: 1.55;
}
.scale-card {
position: fixed;
top: 22px;
right: 24px;
z-index: 5;
width: 228px;
padding: 14px;
border: 1px solid var(--line);
border-radius: 6px;
background: var(--panel);
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
backdrop-filter: blur(12px);
pointer-events: none;
}
.scale-title {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 11px;
color: #e8f7ff;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.scale-title span:last-child {
color: var(--muted);
font-weight: 500;
letter-spacing: 0.06em;
}
.scale-row {
display: grid;
grid-template-columns: 69px 1fr 49px;
gap: 7px;
align-items: center;
margin-top: 8px;
font: 500 9px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.scale-row .name {
color: var(--muted);
text-transform: uppercase;
}
.scale-row .value {
color: #d9efff;
text-align: right;
}
.scale-track {
height: 4px;
overflow: hidden;
border-radius: 2px;
background: rgba(255, 255, 255, 0.07);
}
.scale-fill {
height: 100%;
min-width: 2px;
border-radius: inherit;
background: linear-gradient(90deg, #3d9bb5, var(--cyan));
}
.scale-row.gold .scale-fill {
background: linear-gradient(90deg, #9e7130, var(--gold));
}
.scale-note {
margin: 12px 0 0;
padding-top: 10px;
border-top: 1px solid var(--line);
color: #71899c;
font-size: 9px;
line-height: 1.45;
}
.controls {
position: fixed;
right: 24px;
bottom: 22px;
z-index: 6;
display: flex;
gap: 8px;
align-items: center;
}
.hint {
padding: 8px 10px;
border: 1px solid var(--line);
border-radius: 4px;
background: rgba(8, 18, 32, 0.68);
color: var(--muted);
font-size: 9px;
letter-spacing: 0.035em;
backdrop-filter: blur(8px);
pointer-events: none;
}
button {
border: 1px solid rgba(98, 231, 255, 0.35);
border-radius: 4px;
padding: 9px 12px;
background: rgba(17, 45, 61, 0.86);
color: var(--cyan);
font: 700 9px/1 ui-sans-serif, system-ui, sans-serif;
letter-spacing: 0.12em;
text-transform: uppercase;
cursor: pointer;
transition: background 150ms ease, transform 150ms ease;
}
button:hover {
background: rgba(33, 87, 108, 0.92);
transform: translateY(-1px);
}
button:focus-visible {
outline: 2px solid var(--cyan);
outline-offset: 3px;
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #07101b;
color: var(--cyan);
font-size: 10px;
letter-spacing: 0.18em;
text-transform: uppercase;
transition: opacity 400ms ease;
}
#loading.done {
opacity: 0;
pointer-events: none;
}
@media (max-width: 760px) {
.hud {
top: 16px;
left: 16px;
}
.subtitle {
max-width: 260px;
font-size: 9px;
}
.scale-card {
top: auto;
right: 12px;
bottom: 60px;
width: 190px;
padding: 10px;
}
.scale-row {
grid-template-columns: 59px 1fr 43px;
gap: 5px;
font-size: 8px;
}
.scale-note {
display: none;
}
.controls {
right: 12px;
bottom: 12px;
}
.hint {
display: none;
}
.annotation {
min-width: 145px;
max-width: 165px;
padding: 7px 8px 7px 10px;
}
.annotation strong {
font-size: 9px;
}
.annotation span {
font-size: 8px;
}
.annotation .dimension {
font-size: 8px;
}
}
</style>
</head>
<body>
<div id="loading">Constructing microchip…</div>
<svg id="leaders" aria-hidden="true"></svg>
<div id="annotations" aria-hidden="true"></div>
<header class="hud">
<div class="eyebrow">Low-poly assembly / 04</div>
<h1>Exploded<br />Microchip</h1>
<p class="subtitle">
Substrate, lead frame, ceramic package, silicon circuitry and a single
highlighted signal route. Component dimensions differ by more than 50×.
</p>
</header>
<aside class="scale-card">
<div class="scale-title">
<span>Relative scale</span>
<span>Linear</span>
</div>
<div class="scale-row">
<span class="name">Substrate</span>
<span class="scale-track"><span class="scale-fill" style="width:100%"></span></span>
<span class="value">10.0 mm</span>
</div>
<div class="scale-row gold">
<span class="name">Package</span>
<span class="scale-track"><span class="scale-fill" style="width:62%"></span></span>
<span class="value">6.2 mm</span>
</div>
<div class="scale-row gold">
<span class="name">Die</span>
<span class="scale-track"><span class="scale-fill" style="width:32%"></span></span>
<span class="value">3.2 mm</span>
</div>
<div class="scale-row gold">
<span class="name">Pin pitch</span>
<span class="scale-track"><span class="scale-fill" style="width:6.5%"></span></span>
<span class="value">0.65 mm</span>
</div>
<div class="scale-row">
<span class="name">Trace</span>
<span class="scale-track"><span class="scale-fill" style="width:1.8%"></span></span>
<span class="value">0.18 mm</span>
</div>
<p class="scale-note">
Dimensions describe real components. Exploded gaps and very small
features are enlarged for visibility.
</p>
</aside>
<div class="controls">
<div class="hint">Drag: orbit · Wheel: zoom · Right-drag: pan</div>
<button id="reset" type="button">Reset view</button>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0x07111f, 20, 42);
const camera = new THREE.PerspectiveCamera(
38,
innerWidth / innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.domElement.id = "scene";
renderer.domElement.setAttribute(
"aria-label",
"Interactive exploded low-poly microchip assembly"
);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.setClearColor(0x07111f, 0);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
document.body.prepend(renderer.domElement);
// Materials --------------------------------------------------------------
const materials = {
substrate: new THREE.MeshStandardMaterial({
color: 0x174743,
roughness: 0.8,
metalness: 0.12
}),
substrateEdge: new THREE.MeshStandardMaterial({
color: 0x0c292b,
roughness: 0.7,
metalness: 0.18
}),
ceramic: new THREE.MeshStandardMaterial({
color: 0x29374d,
roughness: 0.72,
metalness: 0.08
}),
ceramicTop: new THREE.MeshStandardMaterial({
color: 0x344760,
roughness: 0.66,
metalness: 0.08
}),
gold: new THREE.MeshStandardMaterial({
color: 0xe0b452,
roughness: 0.25,
metalness: 0.82,
emissive: 0x241500,
emissiveIntensity: 0.25
}),
darkGold: new THREE.MeshStandardMaterial({
color: 0x8b6b2d,
roughness: 0.38,
metalness: 0.72
}),
silicon: new THREE.MeshStandardMaterial({
color: 0x18242e,
roughness: 0.28,
metalness: 0.72
}),
silver: new THREE.MeshStandardMaterial({
color: 0xa9bac4,
roughness: 0.32,
metalness: 0.8
}),
black: new THREE.MeshStandardMaterial({
color: 0x070d13,
roughness: 0.66,
metalness: 0.18
}),
cyan: new THREE.MeshStandardMaterial({
color: 0x62e7ff,
emissive: 0x29c7e6,
emissiveIntensity: 1.7,
roughness: 0.28,
metalness: 0.25
})
};
// Lighting ---------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xb8dfff, 0x10252d, 1.55));
const key = new THREE.DirectionalLight(0xffffff, 3.2);
key.position.set(8, 14, 9);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -13;
key.shadow.camera.right = 13;
key.shadow.camera.top = 13;
key.shadow.camera.bottom = -13;
key.shadow.camera.near = 1;
key.shadow.camera.far = 35;
key.shadow.bias = -0.00025;
scene.add(key);
const rim = new THREE.DirectionalLight(0x58caff, 2.1);
rim.position.set(-10, 7, -8);
scene.add(rim);
const warmFill = new THREE.DirectionalLight(0xffcc78, 0.85);
warmFill.position.set(7, 3, -8);
scene.add(warmFill);
// Ground and technical grid ---------------------------------------------
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(44, 44),
new THREE.MeshStandardMaterial({
color: 0x07111c,
roughness: 0.96,
metalness: 0.02,
transparent: true,
opacity: 0.92
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.38;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(30, 30, 0x31566d, 0x183246);
grid.position.y = -0.365;
grid.material.transparent = true;
grid.material.opacity = 0.28;
scene.add(grid);
// Geometry helpers -------------------------------------------------------
function addEdges(mesh, color = 0x7da0b5, opacity = 0.28) {
const edge = new THREE.LineSegments(
new THREE.EdgesGeometry(mesh.geometry, 22),
new THREE.LineBasicMaterial({
color,
transparent: true,
opacity
})
);
mesh.add(edge);
return mesh;
}
function makeBox(w, h, d, material, x, y, z, parent = scene, edged = true) {
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);
if (edged) addEdges(mesh);
return mesh;
}
function makeChamferedSlab(w, d, h, chamfer, material, y) {
const shape = new THREE.Shape();
shape.moveTo(-w / 2 + chamfer, -d / 2);
shape.lineTo(w / 2 - chamfer, -d / 2);
shape.lineTo(w / 2, -d / 2 + chamfer);
shape.lineTo(w / 2, d / 2 - chamfer);
shape.lineTo(w / 2 - chamfer, d / 2);
shape.lineTo(-w / 2 + chamfer, d / 2);
shape.lineTo(-w / 2, d / 2 - chamfer);
shape.lineTo(-w / 2, -d / 2 + chamfer);
shape.closePath();
const geometry = new THREE.ExtrudeGeometry(shape, {
depth: h,
bevelEnabled: false,
steps: 1
});
geometry.rotateX(-Math.PI / 2);
geometry.translate(0, -h / 2, 0);
const mesh = new THREE.Mesh(geometry, material);
mesh.position.y = y;
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
addEdges(mesh);
return mesh;
}
function addPad(x, z, y, radius = 0.13, material = materials.gold, parent = scene) {
const pad = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, 0.055, 8),
material
);
pad.position.set(x, y, z);
pad.castShadow = true;
parent.add(pad);
return pad;
}
function addHorizontalTrace(points, y, material = materials.gold, width = 0.045) {
for (let i = 0; i < points.length - 1; i++) {
const a = points[i];
const b = points[i + 1];
const dx = b[0] - a[0];
const dz = b[1] - a[1];
const length = Math.hypot(dx, dz);
const segment = new THREE.Mesh(
new THREE.BoxGeometry(length, 0.035, width),
material
);
segment.position.set(
(a[0] + b[0]) / 2,
y,
(a[1] + b[1]) / 2
);
segment.rotation.y = -Math.atan2(dz, dx);
segment.castShadow = true;
scene.add(segment);
}
}
function addCylinderBetween(a, b, radius, material, radialSegments = 6) {
const start = a.clone();
const end = b.clone();
const direction = end.clone().sub(start);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, length, radialSegments),
material
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
scene.add(mesh);
return mesh;
}
// Substrate --------------------------------------------------------------
const substrate = makeChamferedSlab(
10,
7.5,
0.68,
0.38,
materials.substrate,
0
);
// A darker lower edge makes the laminate thickness readable.
makeChamferedSlab(
9.94,
7.44,
0.12,
0.36,
materials.substrateEdge,
-0.29
);
const topY = 0.365;
// Substrate footprint and copper routing.
const boardTraces = [
[[-1.7, 0.65], [-3.35, 0.65], [-3.35, 2.7], [-4.45, 2.7]],
[[-1.7, -0.65], [-3.35, -0.65], [-3.35, -2.7], [-4.45, -2.7]],
[[1.7, 0.65], [2.85, 0.65], [2.85, 3.05], [4.25, 3.05]],
[[1.7, -0.65], [2.85, -0.65], [2.85, -3.05], [4.25, -3.05]],
[[0.65, -1.55], [0.65, -2.6], [3.9, -2.6]],
[[-0.65, 1.55], [-0.65, 2.6], [-3.9, 2.6]]
];
boardTraces.forEach(points => {
addHorizontalTrace(points, topY + 0.028, materials.darkGold, 0.052);
});
// Central package footprint.
const footprint = new THREE.Group();
scene.add(footprint);
const footprintLines = [
[-1.83, -1.53, 1.83, -1.53],
[1.83, -1.53, 1.83, 1.53],
[1.83, 1.53, -1.83, 1.53],
[-1.83, 1.53, -1.83, -1.53]
];
footprintLines.forEach(([x1, z1, x2, z2]) => {
const length = Math.hypot(x2 - x1, z2 - z1);
const line = makeBox(
length,
0.035,
0.045,
materials.silver,
(x1 + x2) / 2,
topY + 0.03,
(z1 + z2) / 2,
footprint,
false
);
line.rotation.y = -Math.atan2(z2 - z1, x2 - x1);
});
// Contact pads and vias.
const pinZ = [-2.1, -1.4, -0.7, 0, 0.7, 1.4, 2.1];
[-3.45, 3.45].forEach(x => {
pinZ.forEach(z => {
addPad(x, z, topY + 0.055, 0.14, materials.gold, footprint);
});
});
[
[-4.05, 2.7],
[4.25, 3.05],
[3.9, -2.6],
[-3.9, 2.6],
[-2.45, -2.55],
[2.45, 2.55]
].forEach(([x, z]) => {
addPad(x, z, topY + 0.055, 0.095, materials.darkGold, footprint);
});
// Pin / lead-frame layer -------------------------------------------------
const pinLayer = new THREE.Group();
scene.add(pinLayer);
[-3.45, 3.45].forEach(x => {
pinZ.forEach(z => {
makeBox(
0.17,
1.12,
0.25,
materials.gold,
x,
1.14,
z,
pinLayer
);
makeBox(
0.29,
0.11,
0.35,
materials.gold,
x,
1.67,
z,
pinLayer
);
makeBox(
0.28,
0.10,
0.35,
materials.gold,
x,
0.61,
z,
pinLayer
);
});
});
// Ceramic package body ---------------------------------------------------
const packageBody = new THREE.Group();
packageBody.position.y = 2.25;
scene.add(packageBody);
const bodyWidth = 6.4;
const bodyDepth = 6.4;
const bodyThickness = 0.64;
const bodyBar = 0.52;
makeBox(
bodyWidth,
bodyThickness,
bodyBar,
materials.ceramic,
0,
0,
-(bodyDepth - bodyBar) / 2,
packageBody
);
makeBox(
bodyWidth,
bodyThickness,
bodyBar,
materials.ceramic,
0,
0,
(bodyDepth - bodyBar) / 2,
packageBody
);
makeBox(
bodyBar,
bodyThickness,
bodyDepth - bodyBar * 2,
materials.ceramic,
-(bodyWidth - bodyBar) / 2,
0,
0,
packageBody
);
makeBox(
bodyBar,
bodyThickness,
bodyDepth - bodyBar * 2,
materials.ceramic,
(bodyWidth - bodyBar) / 2,
0,
0,
packageBody
);
// Thin inner conductor ring.
const ringY = 0.335;
makeBox(5.84, 0.055, 0.065, materials.gold, 0, ringY, -2.68, packageBody);
makeBox(5.84, 0.055, 0.065, materials.gold, 0, ringY, 2.68, packageBody);
makeBox(0.065, 0.055, 5.42, materials.gold, -2.68, ringY, 0, packageBody);
makeBox(0.065, 0.055, 5.42, materials.gold, 2.68, ringY, 0, packageBody);
// Four ceramic corner supports.
[
[-2.85, -2.85],
[2.85, -2.85],
[2.85, 2.85],
[-2.85, 2.85]
].forEach(([x, z]) => {
makeBox(0.48, 0.58, 0.48, materials.ceramicTop, x, 0.03, z, packageBody);
});
// Silicon die and schematic circuitry ----------------------------------
const die = makeChamferedSlab(
3.3,
3.3,
0.18,
0.14,
materials.silicon,
3.5
);
const circuitY = 3.625;
// Orthogonal die traces.
const dieTraces = [
[[-1.35, 0.7], [-0.82, 0.7], [-0.82, 1.25], [-0.42, 1.25]],
[[-1.35, -0.7], [-0.92, -0.7], [-0.92, -1.22], [-0.45, -1.22]],
[[0.42, 1.25], [0.88, 1.25], [0.88, 0.7], [1.35, 0.7]],
[[0.42, -1.25], [0.9, -1.25], [0.9, -0.7], [1.35, -0.7]],
[[-1.2, 0], [-0.82, 0]],
[[1.2, 0], [0.82, 0]],
[[0, -1.35], [0, -0.85]],
[[0, 1.35], [0, 0.85]]
];
dieTraces.forEach(points => {
addHorizontalTrace(points, circuitY, materials.gold, 0.045);
});
// Central processor.
makeBox(
1.08,
0.13,
1.08,
materials.black,
0,
circuitY + 0.075,
0,
scene
);
makeBox(
0.73,
0.055,
0.73,
materials.silver,
0,
circuitY + 0.165,
0,
scene
);
// Capacitor / resistor-like raised schematic components.
const componentPositions = [
[-1.15, -1.02, 0.32, 0.14],
[1.15, 1.02, 0.32, 0.14],
[-1.08, 1.02, 0.14, 0.31],
[1.08, -1.02, 0.14, 0.31],
[0.55, -1.16, 0.28, 0.12]
];
componentPositions.forEach(([x, z, w, d]) => {
makeBox(
w,
0.09,
d,
materials.silver,
x,
circuitY + 0.07,
z,
scene
);
});
// Tiny bond pads around the die.
[
[-1.35, 0.7],
[-1.35, -0.7],
[1.35, 0.7],
[1.35, -0.7],
[0, 1.35],
[0, -1.35]
].forEach(([x, z]) => {
addPad(x, z, circuitY + 0.04, 0.11, materials.gold);
});
// A flat transistor-like schematic mark.
const transistorShape = new THREE.Shape();
transistorShape.moveTo(-0.19, -0.15);
transistorShape.lineTo(0.19, 0);
transistorShape.lineTo(-0.19, 0.15);
transistorShape.closePath();
const transistor = new THREE.Mesh(
new THREE.ShapeGeometry(transistorShape),
new THREE.MeshStandardMaterial({
color: 0x4bb8c7,
emissive: 0x123c40,
emissiveIntensity: 0.5,
side: THREE.DoubleSide,
roughness: 0.5
})
);
transistor.rotation.x = -Math.PI / 2;
transistor.position.set(-0.92, circuitY + 0.035, 0.1);
scene.add(transistor);
// Package lid ------------------------------------------------------------
const lid = makeChamferedSlab(
6.65,
6.65,
0.34,
0.42,
materials.ceramicTop,
5.08
);
// Orientation triangle.
const orientation = new THREE.Mesh(
new THREE.CircleGeometry(0.16, 3),
materials.gold
);
orientation.rotation.x = -Math.PI / 2;
orientation.position.set(-2.55, 5.26, -2.55);
scene.add(orientation);
// Canvas-generated top marking.
const labelCanvas = document.createElement("canvas");
labelCanvas.width = 512;
labelCanvas.height = 160;
const labelContext = labelCanvas.getContext("2d");
labelContext.clearRect(0, 0, 512, 160);
labelContext.fillStyle = "rgba(5, 12, 19, 0.72)";
labelContext.fillRect(22, 18, 468, 124);
labelContext.strokeStyle = "rgba(227, 184, 91, 0.55)";
labelContext.lineWidth = 3;
labelContext.strokeRect(22, 18, 468, 124);
labelContext.fillStyle = "#dceaf0";
labelContext.font = "700 54px monospace";
labelContext.textAlign = "center";
labelContext.textBaseline = "middle";
labelContext.fillText("μCORE / 04", 256, 78);
const labelTexture = new THREE.CanvasTexture(labelCanvas);
labelTexture.colorSpace = THREE.SRGBColorSpace;
const topLabel = new THREE.Mesh(
new THREE.PlaneGeometry(2.65, 0.83),
new THREE.MeshBasicMaterial({
map: labelTexture,
transparent: true,
depthWrite: false
})
);
topLabel.rotation.x = -Math.PI / 2;
topLabel.position.set(0, 5.265, 0);
scene.add(topLabel);
// One highlighted traced connection -------------------------------------
const routePoints = [
new THREE.Vector3(1.15, circuitY + 0.09, 0.7),
new THREE.Vector3(1.9, circuitY + 0.09, 0.7),
new THREE.Vector3(1.9, 2.35, 0.7),
new THREE.Vector3(3.62, 2.35, 0.7),
new THREE.Vector3(3.62, 0.55, 0.7),
new THREE.Vector3(4.18, 0.55, 0.7),
new THREE.Vector3(4.18, topY + 0.075, 2.35)
];
routePoints.slice(0, -1).forEach((point, index) => {
addCylinderBetween(point, routePoints[index + 1], 0.046, materials.cyan, 6);
});
routePoints.slice(1, -1).forEach(point => {
const joint = new THREE.Mesh(
new THREE.SphereGeometry(0.066, 8, 5),
materials.cyan
);
joint.position.copy(point);
scene.add(joint);
});
const routeStart = new THREE.Mesh(
new THREE.SphereGeometry(0.105, 10, 6),
materials.cyan
);
routeStart.position.copy(routePoints[0]);
scene.add(routeStart);
const routeEnd = new THREE.Mesh(
new THREE.SphereGeometry(0.105, 10, 6),
materials.cyan
);
routeEnd.position.copy(routePoints[routePoints.length - 1]);
scene.add(routeEnd);
const movingSignal = new THREE.Mesh(
new THREE.SphereGeometry(0.075, 10, 6),
new THREE.MeshBasicMaterial({ color: 0xffffff })
);
scene.add(movingSignal);
const segmentLengths = [];
let routeLength = 0;
for (let i = 0; i < routePoints.length - 1; i++) {
const length = routePoints[i].distanceTo(routePoints[i + 1]);
segmentLengths.push(length);
routeLength += length;
}
function pointOnRoute(t, target) {
let distance = ((t % 1) + 1) % 1 * routeLength;
for (let i = 0; i < segmentLengths.length; i++) {
if (distance <= segmentLengths[i]) {
const local = distance / segmentLengths[i];
return target.lerpVectors(routePoints[i], routePoints[i + 1], local);
}
distance -= segmentLengths[i];
}
return target.copy(routePoints[routePoints.length - 1]);
}
// Dashed assembly axis.
const axisGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(0, 0.5, 0),
new THREE.Vector3(0, 5.45, 0)
]);
const axis = new THREE.Line(
axisGeometry,
new THREE.LineDashedMaterial({
color: 0x8ab1c5,
dashSize: 0.09,
gapSize: 0.1,
transparent: true,
opacity: 0.25
})
);
axis.computeLineDistances();
scene.add(axis);
// Custom camera controls -------------------------------------------------
const target = new THREE.Vector3(0, 2.25, 0);
const desiredTarget = target.clone();
const spherical = new THREE.Spherical(17.8, 0.87, 0.72);
const desiredSpherical = spherical.clone();
const pointerState = {
pointers: new Map(),
mode: "orbit",
lastX: 0,
lastY: 0,
pinchDistance: 0
};
const canvas = renderer.domElement;
canvas.addEventListener("contextmenu", event => event.preventDefault());
canvas.addEventListener("pointerdown", event => {
canvas.setPointerCapture(event.pointerId);
pointerState.pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointerState.pointers.size === 1) {
pointerState.mode = event.button === 2 || event.shiftKey ? "pan" : "orbit";
pointerState.lastX = event.clientX;
pointerState.lastY = event.clientY;
} else if (pointerState.pointers.size === 2) {
const [a, b] = [...pointerState.pointers.values()];
pointerState.pinchDistance = Math.hypot(a.x - b.x, a.y - b.y);
}
});
canvas.addEventListener("pointermove", event => {
if (!pointerState.pointers.has(event.pointerId)) return;
pointerState.pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointerState.pointers.size === 2) {
const [a, b] = [...pointerState.pointers.values()];
const distance = Math.hypot(a.x - b.x, a.y - b.y);
if (pointerState.pinchDistance > 0) {
desiredSpherical.radius *= pointerState.pinchDistance / distance;
desiredSpherical.radius = THREE.MathUtils.clamp(
desiredSpherical.radius,
9,
31
);
}
pointerState.pinchDistance = distance;
return;
}
const dx = event.clientX - pointerState.lastX;
const dy = event.clientY - pointerState.lastY;
pointerState.lastX = event.clientX;
pointerState.lastY = event.clientY;
if (pointerState.mode === "orbit") {
desiredSpherical.theta -= dx * 0.006;
desiredSpherical.phi = THREE.MathUtils.clamp(
desiredSpherical.phi - dy * 0.006,
0.28,
1.42
);
} else {
const right = new THREE.Vector3().setFromMatrixColumn(camera.matrix, 0);
const up = new THREE.Vector3().setFromMatrixColumn(camera.matrix, 1);
const panScale = desiredSpherical.radius / Math.max(innerHeight, 1);
desiredTarget
.addScaledVector(right, -dx * panScale)
.addScaledVector(up, dy * panScale);
}
});
function endPointer(event) {
pointerState.pointers.delete(event.pointerId);
if (pointerState.pointers.size === 1) {
const remaining = [...pointerState.pointers.values()][0];
pointerState.lastX = remaining.x;
pointerState.lastY = remaining.y;
}
if (pointerState.pointers.size === 0) {
pointerState.pinchDistance = 0;
}
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener(
"wheel",
event => {
event.preventDefault();
desiredSpherical.radius *= Math.exp(event.deltaY * 0.001);
desiredSpherical.radius = THREE.MathUtils.clamp(
desiredSpherical.radius,
9,
31
);
},
{ passive: false }
);
function resetView() {
desiredSpherical.set(17.8, 0.87, 0.72);
desiredTarget.set(0, 2.25, 0);
}
document.getElementById("reset").addEventListener("click", resetView);
canvas.addEventListener("dblclick", resetView);
window.addEventListener("keydown", event => {
if (event.key.toLowerCase() === "r") resetView();
if (event.key === "ArrowLeft") desiredSpherical.theta += 0.08;
if (event.key === "ArrowRight") desiredSpherical.theta -= 0.08;
if (event.key === "ArrowUp") {
desiredSpherical.phi = THREE.MathUtils.clamp(
desiredSpherical.phi - 0.06,
0.28,
1.42
);
}
if (event.key === "ArrowDown") {
desiredSpherical.phi = THREE.MathUtils.clamp(
desiredSpherical.phi + 0.06,
0.28,
1.42
);
}
if (event.key === "+" || event.key === "=") {
desiredSpherical.radius = Math.max(9, desiredSpherical.radius - 0.8);
}
if (event.key === "-") {
desiredSpherical.radius = Math.min(31, desiredSpherical.radius + 0.8);
}
});
// Projected HTML annotations ---------------------------------------------
const annotationRoot = document.getElementById("annotations");
const leaderRoot = document.getElementById("leaders");
const annotationData = [
{
title: "Substrate",
detail: "Ceramic laminate carrier",
dimension: "10.0 × 7.5 mm",
anchor: new THREE.Vector3(-4.25, 0.38, 2.65),
offset: [-225, 48],
side: "left"
},
{
title: "Gold pins",
detail: "Fourteen conductive leads",
dimension: "0.65 mm pitch",
anchor: new THREE.Vector3(3.48, 1.36, 0.7),
offset: [115, 28],
side: "right",
gold: true
},
{
title: "Package body",
detail: "Low-profile ceramic frame",
dimension: "6.2 mm class",
anchor: new THREE.Vector3(2.95, 2.26, -2.95),
offset: [105, -54],
side: "right"
},
{
title: "Die circuitry",
detail: "Silicon die and schematic routing",
dimension: "3.2 × 3.2 mm",
anchor: new THREE.Vector3(-1.3, 3.7, -1.28),
offset: [-225, -50],
side: "left",
gold: true
},
{
title: "Package lid",
detail: "Exploded ceramic cover",
dimension: "6.2 mm class",
anchor: new THREE.Vector3(2.7, 5.1, -2.55),
offset: [100, -38],
side: "right"
},
{
title: "Traced connection",
detail: "Single highlighted signal path",
dimension: "0.18 mm trace",
anchor: new THREE.Vector3(3.62, 2.18, 0.7),
offset: [-230, 100],
side: "left"
}
];
annotationData.forEach(item => {
const element = document.createElement("div");
element.className = `annotation${item.gold ? " gold" : ""}`;
element.innerHTML = `
<strong>${item.title}</strong>
<span>${item.detail}</span>
<span class="dimension">${item.dimension}</span>
`;
annotationRoot.appendChild(element);
item.element = element;
});
const projected = new THREE.Vector3();
function updateAnnotations() {
const width = innerWidth;
const height = innerHeight;
leaderRoot.setAttribute("viewBox", `0 0 ${width} ${height}`);
const leaderMarkup = [];
annotationData.forEach(item => {
projected.copy(item.anchor).project(camera);
const visible = projected.z > -1 && projected.z < 1;
const anchorX = (projected.x * 0.5 + 0.5) * width;
const anchorY = (-projected.y * 0.5 + 0.5) * height;
const mobile = width < 760;
const scale = mobile ? 0.72 : 1;
const offsetX = item.offset[0] * scale;
const offsetY = item.offset[1] * scale;
const labelWidth = item.element.offsetWidth || 190;
const labelHeight = item.element.offsetHeight || 68;
const left = THREE.MathUtils.clamp(
anchorX + offsetX,
10,
Math.max(10, width - labelWidth - 10)
);
const top = THREE.MathUtils.clamp(
anchorY + offsetY,
12,
Math.max(12, height - labelHeight - 12)
);
item.element.style.left = `${left}px`;
item.element.style.top = `${top}px`;
item.element.classList.toggle("visible", visible);
const targetX = item.side === "left" ? left + labelWidth : left;
const targetY = top + labelHeight / 2;
const elbowX = item.side === "left" ? targetX + 18 : targetX - 18;
leaderMarkup.push(`
<path
d="M ${anchorX.toFixed(1)} ${anchorY.toFixed(1)}
L ${elbowX.toFixed(1)} ${targetY.toFixed(1)}
L ${targetX.toFixed(1)} ${targetY.toFixed(1)}"
fill="none"
stroke="rgba(111, 184, 211, 0.55)"
stroke-width="1"
/>
<circle
cx="${anchorX.toFixed(1)}"
cy="${anchorY.toFixed(1)}"
r="3"
fill="#62e7ff"
/>
`);
});
leaderRoot.innerHTML = leaderMarkup.join("");
}
// Resize -----------------------------------------------------------------
function resize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
}
window.addEventListener("resize", resize);
// Animation --------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const damping = 1 - Math.exp(-9 * clock.getDelta());
spherical.radius +=
(desiredSpherical.radius - spherical.radius) * damping;
spherical.theta +=
(desiredSpherical.theta - spherical.theta) * damping;
spherical.phi +=
(desiredSpherical.phi - spherical.phi) * damping;
target.lerp(desiredTarget, damping);
camera.position.setFromSpherical(spherical).add(target);
camera.lookAt(target);
camera.updateMatrixWorld();
const signalTime = clock.elapsedTime * 0.18;
pointOnRoute(signalTime, movingSignal.position);
updateAnnotations();
renderer.render(scene, camera);
}
resize();
animate();
requestAnimationFrame(() => {
document.getElementById("loading").classList.add("done");
});
</script>
</body>
</html>
```