Prompt specification
Build or customize the Three.js 3D scene "Solar cell tile with two electrical contacts" 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: Solar cell tile with two electrical contacts
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/solar-cell-tile-with-two-electrical-contacts-x2533
Scene Description Prompt:
Make a voxel Three.js scene in a self-contained HTML file using cdnjs: Solar cell tile with two electrical contacts. Model a single solar cell tile with contacts and incoming light arrows. Keep the physical cell, electrical output, and diagrammatic energy flow visibly distinct.
Working Three.js Starter (solar-cell-tile-with-two-electrical-contacts-x2533):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voxel Solar Cell</title>
<style>
:root {
--ink: #193142;
--muted: #637481;
--panel: rgba(248, 251, 252, 0.88);
--cell: #2e70a3;
--output: #18b978;
--flow: #f2aa22;
--contact: #cc7840;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e5ecee;
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
color: var(--ink);
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.card {
position: fixed;
z-index: 10;
background: var(--panel);
border: 1px solid rgba(25, 49, 66, 0.1);
border-radius: 14px;
box-shadow: 0 12px 35px rgba(35, 58, 72, 0.12);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
#title-card {
top: 22px;
left: 22px;
max-width: 390px;
padding: 17px 19px;
pointer-events: none;
}
#title-card h1 {
margin: 0;
font-size: clamp(18px, 2vw, 25px);
line-height: 1.05;
letter-spacing: -0.04em;
}
#title-card p {
margin: 8px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.45;
}
#legend {
right: 22px;
top: 22px;
width: 245px;
padding: 14px 16px;
pointer-events: none;
}
.legend-title {
margin-bottom: 10px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
margin: 8px 0;
font-size: 12px;
font-weight: 650;
}
.swatch {
width: 12px;
height: 12px;
flex: 0 0 auto;
border-radius: 2px;
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.swatch.cell {
background: var(--cell);
}
.swatch.contact {
background: var(--contact);
}
.swatch.output {
background: var(--output);
}
.swatch.flow {
background: var(--flow);
}
#controls {
left: 22px;
bottom: 22px;
padding: 10px 13px;
color: var(--muted);
font-size: 11px;
pointer-events: none;
}
#reset {
position: fixed;
z-index: 12;
right: 22px;
bottom: 22px;
border: 1px solid rgba(25, 49, 66, 0.14);
border-radius: 10px;
padding: 10px 13px;
background: rgba(255, 255, 255, 0.9);
color: var(--ink);
font: inherit;
font-size: 11px;
font-weight: 750;
cursor: pointer;
box-shadow: 0 8px 25px rgba(35, 58, 72, 0.12);
}
#reset:hover {
background: white;
transform: translateY(-1px);
}
@media (max-width: 720px) {
#title-card {
top: 12px;
left: 12px;
max-width: calc(100vw - 24px);
padding: 13px 15px;
}
#title-card p {
display: none;
}
#legend {
top: auto;
right: 12px;
bottom: 62px;
width: 210px;
}
#controls {
left: 12px;
bottom: 12px;
}
#reset {
right: 12px;
bottom: 12px;
}
}
</style>
</head>
<body>
<div id="title-card" class="card">
<h1>Voxel Solar Cell</h1>
<p>
Solid blue silicon and copper hardware form the physical cell.
Gold arrows are a diagrammatic light-flow overlay; green and teal
voxel conductors show the electrical DC output.
</p>
</div>
<div id="legend" class="card">
<div class="legend-title">Visual key</div>
<div class="legend-row">
<span class="swatch cell"></span>
Physical photovoltaic cell
</div>
<div class="legend-row">
<span class="swatch contact"></span>
Copper electrical contacts
</div>
<div class="legend-row">
<span class="swatch output"></span>
Electrical DC output
</div>
<div class="legend-row">
<span class="swatch flow"></span>
Diagrammatic incoming light
</div>
</div>
<div id="controls" class="card">
Drag to orbit · Scroll or pinch to zoom
</div>
<button id="reset" type="button">Reset view</button>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer, scene, lighting
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe5ecee);
scene.fog = new THREE.Fog(0xe5ecee, 20, 36);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.domElement.setAttribute(
"aria-label",
"Interactive voxel model of a solar cell with contacts, light arrows, and DC output"
);
document.body.prepend(renderer.domElement);
const camera = new THREE.OrthographicCamera(
-10,
10,
6,
-6,
0.1,
100
);
const hemi = new THREE.HemisphereLight(0xf4fbff, 0x73858d, 2.25);
scene.add(hemi);
const key = new THREE.DirectionalLight(0xffffff, 3.4);
key.position.set(5, 14, 7);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -12;
key.shadow.camera.right = 12;
key.shadow.camera.top = 12;
key.shadow.camera.bottom = -12;
key.shadow.camera.near = 1;
key.shadow.camera.far = 35;
key.shadow.normalBias = 0.025;
scene.add(key);
const rim = new THREE.DirectionalLight(0xb8dcff, 1.15);
rim.position.set(-8, 6, -8);
scene.add(rim);
// -------------------------------------------------------------------------
// Shared geometry and materials
// -------------------------------------------------------------------------
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const material = {
ground: new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.94,
metalness: 0
}),
base: new THREE.MeshStandardMaterial({
color: 0xc4c9c6,
roughness: 0.72,
metalness: 0.08
}),
baseSide: new THREE.MeshStandardMaterial({
color: 0x7b898d,
roughness: 0.66,
metalness: 0.18
}),
backing: new THREE.MeshStandardMaterial({
color: 0x102c48,
roughness: 0.68,
metalness: 0.12
}),
frame: new THREE.MeshStandardMaterial({
color: 0xdde2df,
roughness: 0.48,
metalness: 0.42
}),
cellA: new THREE.MeshStandardMaterial({
color: 0x286da7,
roughness: 0.33,
metalness: 0.42
}),
cellB: new THREE.MeshStandardMaterial({
color: 0x347db7,
roughness: 0.3,
metalness: 0.46
}),
cellC: new THREE.MeshStandardMaterial({
color: 0x215b92,
roughness: 0.36,
metalness: 0.38
}),
copper: new THREE.MeshStandardMaterial({
color: 0xc8793f,
roughness: 0.3,
metalness: 0.72
}),
copperBright: new THREE.MeshStandardMaterial({
color: 0xe09a59,
roughness: 0.24,
metalness: 0.68
}),
darkMetal: new THREE.MeshStandardMaterial({
color: 0x3d4a52,
roughness: 0.4,
metalness: 0.62
}),
output: new THREE.MeshStandardMaterial({
color: 0x18b978,
emissive: 0x075f3b,
emissiveIntensity: 0.55,
roughness: 0.42,
metalness: 0.2
}),
returnPath: new THREE.MeshStandardMaterial({
color: 0x26aebe,
emissive: 0x07515b,
emissiveIntensity: 0.45,
roughness: 0.42,
metalness: 0.2
}),
flow: new THREE.MeshStandardMaterial({
color: 0xf2aa22,
emissive: 0x8a4b00,
emissiveIntensity: 0.65,
roughness: 0.4,
metalness: 0.12
}),
photon: new THREE.MeshBasicMaterial({
color: 0xffc44d
}),
loadBody: new THREE.MeshStandardMaterial({
color: 0x41525d,
roughness: 0.48,
metalness: 0.45
}),
loadFace: new THREE.MeshStandardMaterial({
color: 0x153b32,
emissive: 0x0a4d38,
emissiveIntensity: 0.35,
roughness: 0.36,
metalness: 0.3
})
};
function box(w, h, d, x, y, z, mat, parent = scene) {
const mesh = new THREE.Mesh(unitBox, mat);
mesh.scale.set(w, h, d);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// -------------------------------------------------------------------------
// Label sprites made entirely from in-memory canvas textures
// -------------------------------------------------------------------------
function makeLabel(text, x, y, z, accent = "#2e70a3", width = null) {
const canvas = document.createElement("canvas");
canvas.width = 768;
canvas.height = 144;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = "rgba(250, 252, 253, 0.94)";
ctx.strokeStyle = accent;
ctx.lineWidth = 5;
const r = 18;
const x0 = 8;
const y0 = 8;
const w = canvas.width - 16;
const h = canvas.height - 16;
ctx.beginPath();
ctx.moveTo(x0 + r, y0);
ctx.lineTo(x0 + w - r, y0);
ctx.quadraticCurveTo(x0 + w, y0, x0 + w, y0 + r);
ctx.lineTo(x0 + w, y0 + h - r);
ctx.quadraticCurveTo(x0 + w, y0 + h, x0 + w - r, y0 + h);
ctx.lineTo(x0 + r, y0 + h);
ctx.quadraticCurveTo(x0, y0 + h, x0, y0 + h - r);
ctx.lineTo(x0, y0 + r);
ctx.quadraticCurveTo(x0, y0, x0 + r, y0);
ctx.closePath();
ctx.fill();
ctx.stroke();
ctx.fillStyle = accent;
ctx.font = "800 50px ui-monospace, SFMono-Regular, Menlo, monospace";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, canvas.width / 2, canvas.height / 2 + 2);
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,
depthTest: false,
depthWrite: false
})
);
sprite.position.set(x, y, z);
sprite.renderOrder = 20;
const labelWidth = width ?? Math.max(0.65, text.length * 0.115);
sprite.scale.set(labelWidth, labelWidth * 0.1875, 1);
scene.add(sprite);
return sprite;
}
// -------------------------------------------------------------------------
// Voxel ground: one instanced mesh with alternating square tiles
// -------------------------------------------------------------------------
const groundCols = 17;
const groundRows = 13;
const groundTiles = new THREE.InstancedMesh(
unitBox,
material.ground,
groundCols * groundRows
);
const matrix = new THREE.Matrix4();
const groundColor = new THREE.Color();
let groundIndex = 0;
for (let z = 0; z < groundRows; z++) {
for (let x = 0; x < groundCols; x++) {
matrix.makeScale(0.96, 0.1, 0.96);
matrix.setPosition(x - 8, -0.48, z - 6);
groundTiles.setMatrixAt(groundIndex, matrix);
const shade = (x + z) % 3 === 0 ? 0xd9e1e2 : 0xe3e9e9;
groundColor.setHex(shade);
groundTiles.setColorAt(groundIndex, groundColor);
groundIndex++;
}
}
groundTiles.instanceMatrix.needsUpdate = true;
groundTiles.instanceColor.needsUpdate = true;
groundTiles.receiveShadow = true;
scene.add(groundTiles);
// -------------------------------------------------------------------------
// Physical photovoltaic tile
// -------------------------------------------------------------------------
const panelX = -1.4;
const panelZ = 0;
// Ceramic/glass substrate and darker lower chassis.
box(
6.4, 0.5, 6.2,
panelX, -0.08, panelZ,
material.base
);
box(
6.15, 0.13, 5.95,
panelX, 0.205, panelZ,
material.baseSide
);
// Dark silicon backing visible in the tiny grid gaps.
box(
5.82, 0.12, 5.82,
panelX, 0.30, panelZ,
material.backing
);
// Chunky photovoltaic cells.
const cellCount = 12;
const cellPitch = 0.47;
const cellSize = 0.425;
const cellMaterials = [
material.cellA,
material.cellB,
material.cellC
];
for (let row = 0; row < cellCount; row++) {
for (let col = 0; col < cellCount; col++) {
const x = panelX + (col - (cellCount - 1) / 2) * cellPitch;
const z = panelZ + (row - (cellCount - 1) / 2) * cellPitch;
const variant = (col * 7 + row * 11 + col * row) % 3;
box(
cellSize,
0.25,
cellSize,
x,
0.39,
z,
cellMaterials[variant]
);
}
}
// Pale metal frame around the physical cell.
box(0.28, 0.3, 6.12, panelX - 3.02, 0.38, panelZ, material.frame);
box(0.28, 0.3, 6.12, panelX + 3.02, 0.38, panelZ, material.frame);
box(6.3, 0.3, 0.28, panelX, 0.38, panelZ - 2.94, material.frame);
box(6.3, 0.3, 0.28, panelX, 0.38, panelZ + 2.94, material.frame);
// Four blocky corner fasteners.
for (const sx of [-1, 1]) {
for (const sz of [-1, 1]) {
box(
0.17, 0.12, 0.17,
panelX + sx * 2.99,
0.58,
panelZ + sz * 2.85,
material.darkMetal
);
}
}
// -------------------------------------------------------------------------
// Two copper busbar contacts and front-edge terminals
// -------------------------------------------------------------------------
const contactXs = [panelX - 1.55, panelX + 1.55];
for (const contactX of contactXs) {
// Segmented copper busbar.
for (let i = 0; i < 12; i++) {
const z = -2.18 + i * 0.39;
box(
0.18, 0.15, 0.37,
contactX,
0.61,
z,
material.copper
);
}
// Neck and larger contact terminal.
box(
0.18, 0.15, 0.42,
contactX,
0.61,
2.56,
material.copper
);
box(
0.52, 0.27, 0.50,
contactX,
0.65,
2.82,
material.copperBright
);
}
// -------------------------------------------------------------------------
// Blocky electrical output paths
// -------------------------------------------------------------------------
function voxelPath(points, mat, spacing = 0.24, size = 0.16) {
for (let segment = 0; segment < points.length - 1; segment++) {
const a = points[segment];
const b = points[segment + 1];
const dx = b[0] - a[0];
const dy = b[1] - a[1];
const dz = b[2] - a[2];
const length = Math.hypot(dx, dy, dz);
const count = Math.max(1, Math.ceil(length / spacing));
for (let i = 0; i <= count; i++) {
const t = i / count;
box(
size,
size,
size,
a[0] + dx * t,
a[1] + dy * t,
a[2] + dz * t,
mat
);
}
}
// Slightly larger blocks make the corners read as junctions.
for (const point of points) {
box(
size * 1.3,
size * 1.3,
size * 1.3,
point[0],
point[1],
point[2],
mat
);
}
}
const positivePath = [
[contactXs[1], 0.66, 3.06],
[contactXs[1], 0.66, 3.55],
[4.15, 0.66, 3.55],
[4.15, 0.66, 1.48]
];
const negativePath = [
[contactXs[0], 0.66, 3.06],
[contactXs[0], 0.66, 4.05],
[5.15, 0.66, 4.05],
[5.15, 0.66, 1.48]
];
voxelPath(positivePath, material.output);
voxelPath(negativePath, material.returnPath);
// External DC load: a compact voxel block, not another solar cell.
box(
1.9, 0.78, 1.45,
4.65, 0.02, 0.55,
material.loadBody
);
box(
1.62, 0.12, 1.18,
4.65, 0.46, 0.55,
material.output
);
box(
1.18, 0.34, 0.07,
4.65, 0.18, 1.30,
material.loadFace
);
// Small illuminated load indicators.
for (let i = 0; i < 3; i++) {
box(
0.18, 0.13, 0.05,
4.28 + i * 0.37,
0.19,
1.35,
material.output
);
}
box(
0.28, 0.26, 0.28,
4.15, 0.60, 1.48,
material.output
);
box(
0.28, 0.26, 0.28,
5.15, 0.60, 1.48,
material.returnPath
);
// -------------------------------------------------------------------------
// Diagrammatic incoming light arrows
// -------------------------------------------------------------------------
function createDownArrow(x, z, topY, scale = 1) {
const shaftWidth = 0.46 * scale;
const shaftStep = 0.5 * scale;
const shaftHeight = 0.48 * scale;
for (let i = 0; i < 4; i++) {
box(
shaftWidth,
shaftHeight,
shaftWidth,
x,
topY - i * shaftStep,
z,
material.flow
);
}
// Stepped triangular arrowhead.
const headRows = [
{ y: topY - 1.92 * scale, width: 1.7 * scale },
{ y: topY - 2.32 * scale, width: 1.12 * scale },
{ y: topY - 2.72 * scale, width: 0.55 * scale }
];
for (const row of headRows) {
box(
row.width,
0.43 * scale,
shaftWidth,
x,
row.y,
z,
material.flow
);
}
}
createDownArrow(-3.15, -0.95, 6.05, 0.96);
createDownArrow(-1.25, 0.85, 6.72, 0.92);
createDownArrow(0.55, -0.65, 5.95, 0.82);
// Animated falling light markers emphasize that the gold layer is a diagram.
const photonMarkers = [];
const photonLocations = [
[-3.15, -0.95],
[-2.55, -1.25],
[-1.25, 0.85],
[-0.72, 1.12],
[0.55, -0.65],
[0.96, -0.92]
];
photonLocations.forEach(([x, z], index) => {
const marker = box(
0.13,
0.13,
0.13,
x,
6.4,
z,
material.photon
);
marker.castShadow = false;
photonMarkers.push({
mesh: marker,
phase: index / photonLocations.length,
baseX: x,
baseZ: z
});
});
// Animated output pulses travel from the copper contacts to the load.
function samplePath(points, t) {
const vectors = points.map(p => new THREE.Vector3(...p));
const lengths = [];
let total = 0;
for (let i = 0; i < vectors.length - 1; i++) {
const length = vectors[i].distanceTo(vectors[i + 1]);
lengths.push(length);
total += length;
}
let distance = t * total;
for (let i = 0; i < lengths.length; i++) {
if (distance <= lengths[i] || i === lengths.length - 1) {
const segmentT = Math.min(1, distance / lengths[i]);
return vectors[i].clone().lerp(vectors[i + 1], segmentT);
}
distance -= lengths[i];
}
return vectors[0].clone();
}
const positivePulse = box(
0.29, 0.29, 0.29,
0, 0.66, 0,
material.photon
);
positivePulse.material = material.output;
positivePulse.castShadow = false;
const negativePulse = box(
0.27, 0.27, 0.27,
0, 0.66, 0,
material.returnPath
);
negativePulse.castShadow = false;
// -------------------------------------------------------------------------
// Scene labels
// -------------------------------------------------------------------------
makeLabel(
"PHYSICAL PV CELL",
panelX,
1.15,
-3.15,
"#2e70a3"
);
makeLabel(
"CONTACT +",
contactXs[1],
1.08,
2.92,
"#cc7840"
);
makeLabel(
"CONTACT -",
contactXs[0],
1.08,
2.92,
"#cc7840"
);
makeLabel(
"INCOMING LIGHT / FLOW",
-1.25,
7.75,
0.1,
"#b77700"
);
makeLabel(
"ELECTRICAL DC OUTPUT",
4.65,
1.55,
0.25,
"#13885a"
);
makeLabel(
"DC LOAD",
4.65,
0.88,
-0.3,
"#13885a",
1.2
);
// -------------------------------------------------------------------------
// Direct camera controls: orbit, zoom, reset
// -------------------------------------------------------------------------
const target = new THREE.Vector3(-0.15, 1.8, 0);
const cameraRadius = 15;
let azimuth = 0.69;
let polar = 0.73;
let zoom = 1;
let dragging = false;
let previousX = 0;
let previousY = 0;
function updateCamera() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const halfHeight = Math.max(5.55, 6.35 / aspect) / zoom;
camera.left = -halfHeight * aspect;
camera.right = halfHeight * aspect;
camera.top = halfHeight;
camera.bottom = -halfHeight;
camera.position.set(
target.x +
Math.sin(azimuth) *
Math.cos(polar) *
cameraRadius,
target.y + Math.sin(polar) * cameraRadius,
target.z +
Math.cos(azimuth) *
Math.cos(polar) *
cameraRadius
);
camera.lookAt(target);
camera.updateProjectionMatrix();
}
function resetView() {
azimuth = 0.69;
polar = 0.73;
zoom = 1;
updateCamera();
}
renderer.domElement.addEventListener("pointerdown", event => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (!dragging) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
azimuth -= deltaX * 0.006;
polar = THREE.MathUtils.clamp(polar - deltaY * 0.005, 0.38, 1.34);
previousX = event.clientX;
previousY = event.clientY;
updateCamera();
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined) {
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("contextmenu", event => event.preventDefault());
renderer.domElement.addEventListener(
"wheel",
event => {
event.preventDefault();
zoom = THREE.MathUtils.clamp(
zoom * Math.exp(-event.deltaY * 0.001),
0.72,
1.75
);
updateCamera();
},
{ passive: false }
);
document.getElementById("reset").addEventListener("click", resetView);
window.addEventListener("resize", () => {
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
updateCamera();
});
updateCamera();
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
renderer.setAnimationLoop(() => {
const elapsed = clock.getElapsedTime();
// Falling photon markers.
photonMarkers.forEach(marker => {
const cycle = (elapsed * 0.31 + marker.phase) % 1;
marker.mesh.position.y = 6.65 - cycle * 5.85;
marker.mesh.position.x =
marker.baseX + Math.sin(elapsed * 1.7 + marker.phase * 9) * 0.06;
marker.mesh.rotation.y = elapsed * 0.7 + marker.phase * 5;
});
// DC output pulses.
const positivePoint = samplePath(positivePath, (elapsed * 0.17) % 1);
const negativePoint = samplePath(negativePath, (elapsed * 0.14 + 0.12) % 1);
positivePulse.position.copy(positivePoint);
negativePulse.position.copy(negativePoint);
positivePulse.rotation.set(
elapsed * 1.6,
elapsed * 2,
elapsed * 1.2
);
negativePulse.rotation.set(
-elapsed * 1.4,
elapsed * 1.7,
elapsed * 1.1
);
material.flow.emissiveIntensity =
0.57 + Math.sin(elapsed * 2.4) * 0.12;
renderer.render(scene, camera);
});
</script>
</body>
</html>
```