Prompt specification
Build or customize the Three.js 3D scene "Three-variable causal block model" inside the active workspace.
Engineering Constraints:
1. Runtime & Orbit: Use Three.js r160 with OrbitControls (damping enabled) and ACESFilmicToneMapping.
2. Frame Timing: Drive all motion strictly with clock.getDelta() so animation speed is FPS-independent.
3. Viewport Hygiene: Handle window resize cleanly, cap DPR at Math.min(window.devicePixelRatio, 2), and dispose geometries/materials/renderer on unmount.
Scene Metadata:
Scene: Three-variable causal block model
Category: Algorithms & Systems · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/three-variable-causal-block-model-x1781
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows confounding by a common causal variable. Build a simple directed graph with a common-cause node feeding two measured variables; distinguish causal arrows from an undirected correlation display. Low-poly.
Working Three.js Starter (three-variable-causal-block-model-x1781):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Confounding by a Common Cause</title>
<style>
:root {
color-scheme: dark;
--bg: #07111f;
--panel: rgba(10, 20, 36, 0.78);
--border: rgba(148, 163, 184, 0.2);
--text: #eef6ff;
--muted: #94a9c1;
--causal: #ffc857;
--association: #5eead4;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 48% 38%, #10243d 0%, #091728 42%, #050b14 100%);
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#stage {
position: fixed;
inset: 0;
}
#stage canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#stage canvas:active {
cursor: grabbing;
}
.title-block {
position: fixed;
top: 28px;
left: 30px;
z-index: 10;
width: min(520px, calc(100vw - 390px));
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 10px;
color: #b8c9da;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--causal);
box-shadow: 0 0 16px rgba(255, 200, 87, 0.7);
content: "";
}
h1 {
margin: 0;
font-size: clamp(27px, 3.2vw, 46px);
font-weight: 760;
letter-spacing: -0.045em;
line-height: 1.03;
}
.subtitle {
max-width: 490px;
margin: 12px 0 0;
color: var(--muted);
font-size: 14px;
line-height: 1.55;
}
.controls {
position: fixed;
top: 26px;
right: 26px;
z-index: 20;
width: 250px;
padding: 16px;
border: 1px solid var(--border);
border-radius: 18px;
background: var(--panel);
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
backdrop-filter: blur(14px);
}
.controls-heading {
margin-bottom: 13px;
color: #d9e7f5;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.switch-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
padding: 8px 0;
cursor: pointer;
}
.switch-copy {
display: flex;
align-items: center;
gap: 9px;
color: #dce8f5;
font-size: 13px;
font-weight: 650;
}
.switch-copy::before {
width: 10px;
height: 10px;
border-radius: 3px;
content: "";
}
.switch-copy.causal::before {
background: var(--causal);
box-shadow: 0 0 12px rgba(255, 200, 87, 0.35);
}
.switch-copy.association::before {
background: var(--association);
box-shadow: 0 0 12px rgba(94, 234, 212, 0.35);
}
.switch {
position: relative;
width: 36px;
height: 20px;
flex: 0 0 auto;
}
.switch input {
position: absolute;
width: 1px;
height: 1px;
opacity: 0;
}
.switch-track {
position: absolute;
inset: 0;
border: 1px solid #40536a;
border-radius: 999px;
background: #17263a;
transition: 160ms ease;
}
.switch-track::after {
position: absolute;
top: 3px;
left: 3px;
width: 12px;
height: 12px;
border-radius: 50%;
background: #8192a6;
content: "";
transition: 160ms ease;
}
.switch input:checked + .switch-track {
border-color: #5eead4;
background: rgba(94, 234, 212, 0.18);
}
.switch input:checked + .switch-track::after {
left: 19px;
background: #d9fff8;
box-shadow: 0 0 10px rgba(94, 234, 212, 0.55);
}
.reset-button {
width: 100%;
margin-top: 11px;
padding: 9px 12px;
border: 1px solid rgba(148, 163, 184, 0.22);
border-radius: 10px;
background: rgba(148, 163, 184, 0.08);
color: #cbd8e7;
font: inherit;
font-size: 12px;
font-weight: 700;
cursor: pointer;
transition: 150ms ease;
}
.reset-button:hover {
border-color: rgba(148, 163, 184, 0.42);
background: rgba(148, 163, 184, 0.14);
color: white;
}
.legend {
position: fixed;
bottom: 27px;
left: 50%;
z-index: 15;
display: flex;
align-items: center;
gap: 24px;
padding: 12px 17px;
border: 1px solid var(--border);
border-radius: 14px;
background: rgba(8, 17, 31, 0.76);
box-shadow: 0 15px 40px rgba(0, 0, 0, 0.22);
backdrop-filter: blur(12px);
transform: translateX(-50%);
pointer-events: none;
}
.legend-item {
display: flex;
align-items: center;
gap: 10px;
color: #c6d4e3;
font-size: 12px;
font-weight: 650;
white-space: nowrap;
}
.sample {
position: relative;
display: inline-block;
width: 43px;
height: 18px;
}
.sample.causal {
height: 3px;
margin-top: 7px;
background: var(--causal);
box-shadow: 0 0 10px rgba(255, 200, 87, 0.35);
}
.sample.causal::after {
position: absolute;
top: -5px;
right: -2px;
width: 0;
height: 0;
border-top: 6px solid transparent;
border-bottom: 6px solid transparent;
border-left: 10px solid var(--causal);
content: "";
}
.sample.association {
height: 0;
border-top: 3px dashed var(--association);
}
.insight {
position: fixed;
right: 26px;
bottom: 27px;
z-index: 12;
width: 285px;
padding: 16px 17px;
border: 1px solid var(--border);
border-radius: 16px;
background: rgba(10, 20, 36, 0.72);
backdrop-filter: blur(12px);
pointer-events: none;
}
.insight-label {
margin-bottom: 7px;
color: var(--association);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.backdoor {
margin-bottom: 8px;
color: #f1f7fd;
font-size: 17px;
font-weight: 750;
letter-spacing: 0.08em;
}
.insight p {
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.5;
}
.hint {
position: fixed;
bottom: 30px;
left: 30px;
z-index: 11;
color: rgba(180, 199, 218, 0.68);
font-size: 11px;
pointer-events: none;
}
@media (max-width: 1050px) {
.insight {
display: none;
}
}
@media (max-width: 760px) {
.title-block {
top: 19px;
left: 18px;
width: calc(100vw - 36px);
}
.subtitle {
max-width: 360px;
font-size: 12px;
}
.controls {
top: auto;
right: 14px;
bottom: 72px;
width: 205px;
padding: 12px;
}
.controls-heading,
.hint {
display: none;
}
.legend {
bottom: 14px;
gap: 13px;
width: calc(100vw - 28px);
justify-content: center;
padding: 10px 12px;
}
.legend-item {
gap: 7px;
font-size: 10px;
}
.sample {
width: 29px;
}
}
</style>
</head>
<body>
<main id="stage" aria-label="Interactive three-dimensional causal graph"></main>
<header class="title-block">
<div class="eyebrow">Causal structure / low-poly diagram</div>
<h1>Confounding by a common cause</h1>
<p class="subtitle">
The solid arrows show directed causal effects. The dashed connection shows
an observed association with no implied direction of causation.
</p>
</header>
<aside class="controls" aria-label="Diagram controls">
<div class="controls-heading">Visible layers</div>
<label class="switch-row">
<span class="switch-copy causal">Causal arrows</span>
<span class="switch">
<input id="causalToggle" type="checkbox" checked />
<span class="switch-track"></span>
</span>
</label>
<label class="switch-row">
<span class="switch-copy association">Observed correlation</span>
<span class="switch">
<input id="associationToggle" type="checkbox" checked />
<span class="switch-track"></span>
</span>
</label>
<button id="resetView" class="reset-button" type="button">
Reset camera
</button>
</aside>
<section class="legend" aria-label="Edge legend">
<div class="legend-item">
<span class="sample causal"></span>
Directed causal effect
</div>
<div class="legend-item">
<span class="sample association"></span>
Undirected observed correlation
</div>
</section>
<aside class="insight">
<div class="insight-label">Why this is confounding</div>
<div class="backdoor">X ← C → Y</div>
<p>
C drives both measured variables. Their correlation does not imply a
direct effect from X to Y. Adjusting for C blocks this backdoor path.
</p>
</aside>
<div class="hint">Drag to orbit · Scroll to zoom · Double-click to reset</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stage = document.getElementById("stage");
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0x000000, 0);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
stage.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0x07111f, 13, 27);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const cameraState = {
radius: 11.7,
theta: 0.04,
phi: 1.34
};
const cameraTarget = new THREE.Vector3(0, 0.05, 0);
function updateCamera() {
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraTarget.x +
cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraTarget.y + cameraState.radius * Math.cos(cameraState.phi),
cameraTarget.z +
cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraTarget);
}
updateCamera();
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
scene.add(
new THREE.HemisphereLight(0xc8e5ff, 0x101827, 2.15)
);
const keyLight = new THREE.DirectionalLight(0xfff0c4, 3.2);
keyLight.position.set(4.5, 7, 6);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1024, 1024);
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 24;
keyLight.shadow.camera.left = -8;
keyLight.shadow.camera.right = 8;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -8;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x62b5ff, 1.35);
rimLight.position.set(-5, 2, 4);
scene.add(rimLight);
const fillLight = new THREE.PointLight(0xa78bfa, 0.65, 15);
fillLight.position.set(4, -1, 5);
scene.add(fillLight);
// -------------------------------------------------------------------------
// Ground plane and grid
// -------------------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(30, 30),
new THREE.MeshStandardMaterial({
color: 0x07111f,
roughness: 1,
metalness: 0,
transparent: true,
opacity: 0.72
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -3.05;
ground.receiveShadow = true;
scene.add(ground);
const grid = new THREE.GridHelper(
18,
18,
0x2e5275,
0x18334d
);
grid.position.y = -3.02;
const gridMaterials = Array.isArray(grid.material)
? grid.material
: [grid.material];
gridMaterials.forEach((material) => {
material.transparent = true;
material.opacity = 0.24;
material.depthWrite = false;
});
scene.add(grid);
// Subtle low-poly particles for depth.
const particlePositions = [];
let seed = 731;
function random() {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
}
for (let i = 0; i < 90; i++) {
particlePositions.push(
(random() - 0.5) * 18,
random() * 10 - 2.5,
(random() - 0.5) * 14 - 2
);
}
const particleGeometry = new THREE.BufferGeometry();
particleGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(particlePositions, 3)
);
const particles = new THREE.Points(
particleGeometry,
new THREE.PointsMaterial({
color: 0x7dd3fc,
size: 0.035,
transparent: true,
opacity: 0.38,
depthWrite: false
})
);
scene.add(particles);
// -------------------------------------------------------------------------
// Node and label helpers
// -------------------------------------------------------------------------
function roundedRect(ctx, x, y, width, height, radius) {
const r = Math.min(radius, width / 2, height / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.arcTo(x + width, y, x + width, y + height, r);
ctx.arcTo(x + width, y + height, x, y + height, r);
ctx.arcTo(x, y + height, x, y, r);
ctx.arcTo(x, y, x + width, y, r);
ctx.closePath();
}
function makeLabel(title, subtitle, accent) {
const canvas = document.createElement("canvas");
canvas.width = 768;
canvas.height = 192;
const ctx = canvas.getContext("2d");
roundedRect(ctx, 4, 4, 760, 184, 28);
ctx.fillStyle = "rgba(7, 17, 31, 0.90)";
ctx.fill();
ctx.strokeStyle = accent;
ctx.globalAlpha = 0.65;
ctx.lineWidth = 4;
ctx.stroke();
ctx.globalAlpha = 1;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = "#f3f8ff";
ctx.font = "750 51px Inter, system-ui, sans-serif";
ctx.fillText(title, 384, 72);
ctx.fillStyle = accent;
ctx.font = "700 27px Inter, system-ui, sans-serif";
ctx.fillText(subtitle, 384, 132);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(2.7, 0.675, 1);
sprite.renderOrder = 20;
return sprite;
}
function makeGlyph(letter, accent) {
const canvas = document.createElement("canvas");
canvas.width = 256;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.beginPath();
ctx.arc(128, 128, 91, 0, Math.PI * 2);
ctx.fillStyle = "rgba(5, 12, 23, 0.86)";
ctx.fill();
ctx.strokeStyle = accent;
ctx.lineWidth = 10;
ctx.stroke();
ctx.fillStyle = "#ffffff";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "800 104px Inter, system-ui, sans-serif";
ctx.fillText(letter, 128, 137);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(0.82, 0.82, 1);
sprite.renderOrder = 21;
return sprite;
}
function createNode(position, radius, color, emissive, letter, label) {
const group = new THREE.Group();
group.position.copy(position);
const geometry = new THREE.OctahedronGeometry(radius, 0);
const material = new THREE.MeshStandardMaterial({
color,
emissive,
emissiveIntensity: 0.19,
roughness: 0.42,
metalness: 0.14,
flatShading: true
});
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(geometry, 1),
new THREE.LineBasicMaterial({
color: 0xffffff,
transparent: true,
opacity: 0.24
})
);
edges.scale.setScalar(1.012);
mesh.add(edges);
group.add(mesh);
const glyph = makeGlyph(letter, color);
glyph.position.set(0, 0, radius + 0.09);
group.add(glyph);
group.userData.mesh = mesh;
group.userData.glyph = glyph;
scene.add(group);
return group;
}
const commonCausePosition = new THREE.Vector3(0, 1.72, 0);
const xPosition = new THREE.Vector3(-2.65, -1.18, 0);
const yPosition = new THREE.Vector3(2.65, -1.18, 0);
const commonCause = createNode(
commonCausePosition,
0.88,
0xf59e0b,
0x7c2d12,
"C",
null
);
const measuredX = createNode(
xPosition,
0.78,
0x2dd4bf,
0x064e3b,
"X",
null
);
const measuredY = createNode(
yPosition,
0.78,
0x8b5cf6,
0x312e81,
"Y",
null
);
const commonLabel = makeLabel(
"COMMON CAUSE",
"C • drives both variables",
"#ffc857"
);
commonLabel.position.set(0, 2.92, 0.2);
scene.add(commonLabel);
const xLabel = makeLabel(
"MEASURED VARIABLE",
"X",
"#5eead4"
);
xLabel.position.set(-2.65, -2.32, 0.2);
scene.add(xLabel);
const yLabel = makeLabel(
"MEASURED VARIABLE",
"Y",
"#c4b5fd"
);
yLabel.position.set(2.65, -2.32, 0.2);
scene.add(yLabel);
// -------------------------------------------------------------------------
// Directed causal arrows: solid shafts with arrowheads
// -------------------------------------------------------------------------
const causalGroup = new THREE.Group();
scene.add(causalGroup);
const arrowMaterial = new THREE.MeshStandardMaterial({
color: 0xffc857,
emissive: 0xff8a00,
emissiveIntensity: 0.58,
roughness: 0.34,
metalness: 0.16,
flatShading: true
});
function makeArrow(source, target, sourceRadius, targetRadius) {
const direction = target.clone().sub(source).normalize();
const start = source.clone().addScaledVector(
direction,
sourceRadius + 0.13
);
const end = target.clone().addScaledVector(
direction,
-(targetRadius + 0.14)
);
const totalLength = start.distanceTo(end);
const headLength = 0.36;
const shaftLength = Math.max(0.1, totalLength - headLength);
const shaftCenter = start.clone().addScaledVector(
direction,
shaftLength / 2
);
const headCenter = end.clone().addScaledVector(
direction,
-headLength / 2
);
const up = new THREE.Vector3(0, 1, 0);
const orientation = new THREE.Quaternion().setFromUnitVectors(
up,
direction
);
const shaft = new THREE.Mesh(
new THREE.CylinderGeometry(0.035, 0.035, shaftLength, 6, 1),
arrowMaterial
);
shaft.position.copy(shaftCenter);
shaft.quaternion.copy(orientation);
shaft.castShadow = true;
const head = new THREE.Mesh(
new THREE.ConeGeometry(0.145, headLength, 6, 1),
arrowMaterial
);
head.position.copy(headCenter);
head.quaternion.copy(orientation);
head.castShadow = true;
const arrow = new THREE.Group();
arrow.add(shaft, head);
return arrow;
}
causalGroup.add(
makeArrow(
commonCausePosition,
xPosition,
0.88,
0.78
),
makeArrow(
commonCausePosition,
yPosition,
0.88,
0.78
)
);
// -------------------------------------------------------------------------
// Undirected observed correlation: dashed line, no arrowheads
// -------------------------------------------------------------------------
const associationGroup = new THREE.Group();
scene.add(associationGroup);
const associationDirection = yPosition
.clone()
.sub(xPosition)
.normalize();
const associationStart = xPosition.clone().addScaledVector(
associationDirection,
0.91
);
const associationEnd = yPosition.clone().addScaledVector(
associationDirection,
-0.91
);
const associationGeometry = new THREE.BufferGeometry().setFromPoints([
associationStart,
associationEnd
]);
const associationLine = new THREE.Line(
associationGeometry,
new THREE.LineDashedMaterial({
color: 0x5eead4,
dashSize: 0.24,
gapSize: 0.17,
transparent: true,
opacity: 0.92,
linewidth: 1
})
);
associationLine.computeLineDistances();
associationLine.renderOrder = 5;
associationGroup.add(associationLine);
const associationLabel = makeLabel(
"OBSERVED CORRELATION",
"undirected • no causal direction",
"#5eead4"
);
associationLabel.position.set(0, -1.72, 0.42);
associationLabel.scale.set(3.15, 0.79, 1);
associationGroup.add(associationLabel);
// -------------------------------------------------------------------------
// Layer toggles
// -------------------------------------------------------------------------
document.getElementById("causalToggle").addEventListener("change", (event) => {
causalGroup.visible = event.target.checked;
});
document
.getElementById("associationToggle")
.addEventListener("change", (event) => {
associationGroup.visible = event.target.checked;
});
// -------------------------------------------------------------------------
// Direct camera controls — no addons
// -------------------------------------------------------------------------
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - pointerX;
const deltaY = event.clientY - pointerY;
cameraState.theta -= deltaX * 0.005;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - deltaY * 0.005,
0.82,
1.57
);
pointerX = event.clientX;
pointerY = event.clientY;
updateCamera();
});
function stopDragging(event) {
dragging = false;
if (
event.pointerId !== undefined &&
renderer.domElement.hasPointerCapture(event.pointerId)
) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.008,
7.4,
16.5
);
updateCamera();
},
{ passive: false }
);
function resetCamera() {
cameraState.radius = 11.7;
cameraState.theta = 0.04;
cameraState.phi = 1.34;
updateCamera();
}
document
.getElementById("resetView")
.addEventListener("click", resetCamera);
renderer.domElement.addEventListener("dblclick", resetCamera);
// -------------------------------------------------------------------------
// Resize and animation
// -------------------------------------------------------------------------
window.addEventListener("resize", () => {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
const reduceMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
const clock = new THREE.Clock();
const animatedNodes = [commonCause, measuredX, measuredY];
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
if (!reduceMotion) {
animatedNodes.forEach((node, index) => {
const mesh = node.userData.mesh;
mesh.rotation.y += delta * (0.14 + index * 0.025);
mesh.rotation.x =
Math.sin(elapsed * 0.42 + index * 1.7) * 0.045;
});
particles.rotation.y += delta * 0.012;
}
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```