Loading…
← All components

Background · Network

Plexus Network

Drifting nodes linked by proximity: hovering repels them, holding the button attracts them.

<PlexusNetworkBackground />Live

Customize

Nodes#e0f2fe
Links#38bdf8

Installation

Use it in your project

Or skip the copy-paste

One command: writes the file and installs the dependencies.

$ npx deepui-cli add plexus-network
01

Install

The 3D packages this component is built on.

$ npm install three @react-three/fiber @react-three/postprocessing postprocessing && npm install -D @types/three
02

Add the component

One self-contained file: create components/PlexusNetworkBackground.tsx and paste it in.

components/PlexusNetworkBackground.tsx
1"use client";
2
3import {
4 memo,
5 useEffect,
6 useMemo,
7 useRef,
8 useState,
9 type CSSProperties,
10 type ReactNode,
11 type RefObject,
12} from "react";
13import * as THREE from "three";
14import { Canvas, useFrame, useThree, type CanvasProps } from "@react-three/fiber";
15import { Bloom, EffectComposer, Vignette } from "@react-three/postprocessing";
16
17/**
18 * The shared props API of DeepUI's individual 3D components (not the full-page templates, which keep
19 * their own tailored scenes).
20 *
21 * The props are grouped by concern. A component extends ONLY the groups it really applies, so its
22 * type never advertises a knob that does nothing (a card has no particles, a background has no tilt):
23 *
24 * interface MyCardProps extends CursorProps, TiltProps, MaterialProps, PerformanceProps { … }
25 *
26 * `Base3DComponentProps` is every group at once, for tooling that handles any component. Same name,
27 * same unit and same meaning everywhere; the default values live in DEFAULT_3D_PROPS. These files are
28 * inlined into each component's single-file bundle (lib/bundle-source.mjs), only what it uses.
29 */
30
31/** Which rotation axes follow the pointer. "x-only": the object nods (up / down); "y-only": it turns (left / right). */
32export type TiltAxis = "both" | "x-only" | "y-only" | "none";
33
34/** 1. Cursor: how the pointer pulls, pushes and drags the object. */
35interface CursorProps {
36 /** Reach of the pointer's influence, in the component's own space: CSS pixels for pixel-laid-out widgets, world units for 3D scenes (each component says which). Default 220 (px). */
37 cursorRadius?: number;
38 /** Positive pulls things towards the pointer, negative pushes them away (repulsion, shockwave). Default 1. */
39 cursorForce?: number;
40 /** How far the object slides towards the pointer, 0 (stays put) to 1 (follows closely). Default 0. */
41 magneticStrength?: number;
42 /** Share of the remaining distance the motion closes each frame (at 60 fps), 0.01 (heavy, slow) to 1 (instant). Default 0.1. */
43 cursorDamping?: number;
44}
45
46/** 2. Tilt and parallax: the object leans towards the pointer, its layers slide against each other. */
47interface TiltProps {
48 /** Largest lean towards the pointer, in degrees. Default 15. */
49 maxTiltAngle?: number;
50 /** Axes that follow the pointer. Default "both". */
51 tiltAxis?: TiltAxis;
52 /** Lean away from the pointer instead of towards it. Default false. */
53 invertTilt?: boolean;
54 /** How far apart the depth layers slide when the object tilts, 0 (flat) to 2. Default 1. */
55 parallaxOffset?: number;
56}
57
58/** 3. Text and 3D typography, for components that draw a label. */
59interface Text3DProps {
60 /** The label drawn by the component. */
61 text?: string;
62 /** Scale of the lettering. Default 1. */
63 fontSize?: number;
64 /** Extrusion depth of 3D letters. Default 0.2. */
65 textDepth?: number;
66 /** Bevelled, light-catching edges on 3D letters. Default true. */
67 bevelEnabled?: boolean;
68 /** Custom font: a .woff / .ttf (flat text) or a typeface .json (extruded text). */
69 fontUrl?: string;
70}
71
72/** 4. Rendering, materials and glow. */
73interface MaterialProps {
74 /** Main color of the object. Default "#6366f1". */
75 primaryColor?: string;
76 /** Color of the glow. Default "#00f0ff". */
77 emissiveColor?: string;
78 /** Strength of the glow, 0 (none) to 3. Default 1. */
79 emissiveIntensity?: number;
80 /** 0 (mirror, glass) to 1 (matte). Default 0.3. */
81 roughness?: number;
82 /** 0 (plastic, organic) to 1 (metal). Default 0.5. */
83 metalness?: number;
84 /** 0 (opaque) to 1 (clear glass): see-through, refracting surfaces. Default 0. */
85 transmission?: number;
86 /** Technical wireframe rendering. Default false. */
87 wireframe?: boolean;
88}
89
90/** 5. Particles, idle motion and shader animation. */
91interface MotionProps {
92 /** Number of instanced elements. Default depends on the component. */
93 particleCount?: number;
94 /** Spin on its own, in radians per second (negative: the other way; 0.5 ≈ one turn in 12 s). Default 0. */
95 autoRotateSpeed?: number;
96 /** Pulses or ripples per second. Default 1. */
97 pulseRate?: number;
98 /** Amplitude of the noise deformation, 0 (none) to 2. Default 1. */
99 displacementScale?: number;
100}
101
102/** 6. Environment and camera. */
103interface EnvironmentProps {
104 /** Camera field of view, in degrees. Default depends on the component. */
105 cameraFov?: number;
106 /** Color of the depth fog. Default "#0a0a0a". */
107 fogColor?: string;
108 /** Thickness of the fog, 0 (none) to 0.2. Default 0. */
109 fogDensity?: number;
110}
111
112/** 7. Performance and accessibility. */
113interface PerformanceProps {
114 /** Lighter rendering for weak devices: pixel ratio 1, fewer instances, smaller environment maps. Default false. */
115 lowPowerMode?: boolean;
116 /** Under the OS "reduce motion" setting, stop idle spin, pulses and deformation (pointer feedback stays). Default true. */
117 respectReducedMotion?: boolean;
118 /** Stop the render loop while the component is scrolled out of view. Default true. */
119 pauseWhenOffscreen?: boolean;
120}
121
122/** Every group at once. Components extend only the groups they apply (see the top of this file). */
123interface Base3DComponentProps
124 extends CursorProps,
125 TiltProps,
126 Text3DProps,
127 MaterialProps,
128 MotionProps,
129 EnvironmentProps,
130 PerformanceProps {}
131
132type Defaults = Required<Omit<Base3DComponentProps, "text" | "fontUrl" | "particleCount" | "cameraFov">>;
133
134/** The values a prop takes when it is left out. A component may override one, and then documents it. */
135const DEFAULT_3D_PROPS: Defaults = {
136 cursorRadius: 220,
137 cursorForce: 1,
138 magneticStrength: 0,
139 cursorDamping: 0.1,
140 maxTiltAngle: 15,
141 tiltAxis: "both",
142 invertTilt: false,
143 parallaxOffset: 1,
144 fontSize: 1,
145 textDepth: 0.2,
146 bevelEnabled: true,
147 primaryColor: "#6366f1",
148 emissiveColor: "#00f0ff",
149 emissiveIntensity: 1,
150 roughness: 0.3,
151 metalness: 0.5,
152 transmission: 0,
153 wireframe: false,
154 autoRotateSpeed: 0,
155 pulseRate: 1,
156 displacementScale: 1,
157 fogColor: "#0a0a0a",
158 fogDensity: 0,
159 lowPowerMode: false,
160 respectReducedMotion: true,
161 pauseWhenOffscreen: true,
162};
163
164/** Fills the positioned parent; never intercepts clicks meant for the page content above it. */
165const FILL_STYLE: CSSProperties = {
166 position: "absolute",
167 top: 0,
168 left: 0,
169 width: "100%",
170 height: "100%",
171 pointerEvents: "none",
172};
173
174interface BackgroundCanvasProps extends Omit<CanvasProps, "children" | "style" | "frameloop" | "gl">, Pick<PerformanceProps, "pauseWhenOffscreen" | "lowPowerMode"> {
175 children: ReactNode;
176}
177
178/**
179 * Ready-to-use <Canvas> shared by every background.
180 * - Pauses the render loop while the canvas is scrolled out of view.
181 * - Renders a single still frame when the user prefers reduced motion.
182 * - Caps the pixel ratio; R3F disposes the renderer and releases the WebGL
183 * context (forceContextLoss) when the Canvas unmounts.
184 */
185function BackgroundCanvas({ children, dpr = [1, 1.75], pauseWhenOffscreen = DEFAULT_3D_PROPS.pauseWhenOffscreen, lowPowerMode = DEFAULT_3D_PROPS.lowPowerMode, ...canvasProps }: BackgroundCanvasProps) {
186 const containerRef = useRef<HTMLDivElement>(null);
187 // Starts "in view" so the first frame is always drawn before the loop can be paused
188 const [inView, setInView] = useState(true);
189 const [reducedMotion, setReducedMotion] = useState(false);
190
191 useEffect(() => {
192 const el = containerRef.current;
193 if (!el) return undefined;
194 const observer = new IntersectionObserver(([entry]) => setInView(entry.isIntersecting));
195 observer.observe(el);
196
197 const query = window.matchMedia("(prefers-reduced-motion: reduce)");
198 const sync = () => setReducedMotion(query.matches);
199 sync();
200 query.addEventListener("change", sync);
201
202 return () => {
203 observer.disconnect();
204 query.removeEventListener("change", sync);
205 };
206 }, []);
207
208 return (
209 <div ref={containerRef} style={FILL_STYLE} aria-hidden="true">
210 <Canvas
211 dpr={lowPowerMode ? 1 : dpr}
212 frameloop={!inView && pauseWhenOffscreen ? "never" : reducedMotion ? "demand" : "always"}
213 gl={{ antialias: true, alpha: true, powerPreference: "high-performance" }}
214 style={{ pointerEvents: "none" }}
215 {...canvasProps}
216 >
217 {children}
218 </Canvas>
219 </div>
220 );
221}
222
223interface CanvasPointer {
224 /** Pointer position in normalized device coordinates of the canvas (-1..1). */
225 ndc: THREE.Vector2;
226 /** True while the pointer is over the canvas area. */
227 inside: boolean;
228 /** True while a button is held down. */
229 pressed: boolean;
230}
231
232/**
233 * Tracks the pointer relative to the canvas through window listeners: the
234 * canvas itself has `pointer-events: none`, so R3F's own events never fire.
235 * Returns a ref read inside useFrame — pointer moves never re-render React.
236 */
237function useCanvasPointer(onDown?: (ndc: THREE.Vector2) => void): RefObject<CanvasPointer> {
238 const gl = useThree((state) => state.gl);
239 const pointer = useRef<CanvasPointer>({ ndc: new THREE.Vector2(), inside: false, pressed: false });
240 const onDownRef = useRef(onDown);
241
242 useEffect(() => {
243 onDownRef.current = onDown;
244 }, [onDown]);
245
246 useEffect(() => {
247 const el = gl.domElement;
248 const update = (event: PointerEvent) => {
249 const rect = el.getBoundingClientRect();
250 const p = pointer.current;
251 p.ndc.set(((event.clientX - rect.left) / rect.width) * 2 - 1, -((event.clientY - rect.top) / rect.height) * 2 + 1);
252 p.inside = Math.abs(p.ndc.x) <= 1 && Math.abs(p.ndc.y) <= 1;
253 };
254 const down = (event: PointerEvent) => {
255 update(event);
256 pointer.current.pressed = true;
257 if (pointer.current.inside) onDownRef.current?.(pointer.current.ndc);
258 };
259 const up = () => {
260 pointer.current.pressed = false;
261 };
262 const leave = () => {
263 pointer.current.inside = false;
264 pointer.current.pressed = false;
265 };
266
267 window.addEventListener("pointermove", update, { passive: true });
268 window.addEventListener("pointerdown", down, { passive: true });
269 window.addEventListener("pointerup", up, { passive: true });
270 document.documentElement.addEventListener("pointerleave", leave);
271 window.addEventListener("blur", leave);
272 return () => {
273 window.removeEventListener("pointermove", update);
274 window.removeEventListener("pointerdown", down);
275 window.removeEventListener("pointerup", up);
276 document.documentElement.removeEventListener("pointerleave", leave);
277 window.removeEventListener("blur", leave);
278 };
279 }, [gl]);
280
281 return pointer;
282}
283
284const unprojected = new THREE.Vector3();
285
286const rayDirection = new THREE.Vector3();
287
288/** Screen (NDC) → world space: intersects the camera ray with the plane z = planeZ. */
289function ndcToWorldOnPlane(ndc: THREE.Vector2, camera: THREE.Camera, planeZ: number, target: THREE.Vector3) {
290 unprojected.set(ndc.x, ndc.y, 0.5).unproject(camera);
291 rayDirection.copy(unprojected).sub(camera.position).normalize();
292 const distance = (planeZ - camera.position.z) / rayDirection.z;
293 return target.copy(camera.position).addScaledVector(rayDirection, distance);
294}
295
296export interface PlexusNetworkProps extends Pick<MotionProps, "particleCount">, Pick<MaterialProps, "primaryColor">, Pick<PerformanceProps, "pauseWhenOffscreen" | "lowPowerMode"> {
297 /** Default 100. */
298 particleCount?: number;
299 /** @deprecated Use `particleCount`. */
300 nodeCount?: number;
301 /** Two nodes closer than this (world units) are linked. Default 2.6. */
302 maxDistance?: number;
303 primaryColor?: string;
304 /** @deprecated Use `primaryColor`. */
305 nodeColor?: string;
306 lineColor?: string;
307 /** Node size in pixels, 10 units from the camera. Default 9. */
308 nodeSize?: number;
309 /** Drift speed multiplier. Default 1. */
310 speed?: number;
311}
312
313const DEPTH = 3; // nodes spread over z in [-DEPTH, DEPTH]
314const CURSOR_LINK_FACTOR = 1.4; // the cursor links to nodes a bit further away than nodes link to each other
315
316const nodeVertexShader = /* glsl */ `
317uniform float uSize;
318uniform float uPixelRatio;
319attribute float aGlow;
320varying float vGlow;
321
322void main() {
323 vec4 mv = modelViewMatrix * vec4(position, 1.0);
324 gl_Position = projectionMatrix * mv;
325 // Hubs (many links) are drawn bigger
326 gl_PointSize = uSize * uPixelRatio * (0.8 + min(aGlow, 4.0) * 0.18) * (10.0 / -mv.z);
327 vGlow = aGlow;
328}
329`;
330
331const nodeFragmentShader = /* glsl */ `
332uniform vec3 uColor;
333varying float vGlow;
334
335void main() {
336 float d = length(gl_PointCoord - 0.5);
337 float core = 1.0 - smoothstep(0.06, 0.14, d);
338 float halo = 1.0 - smoothstep(0.0, 0.5, d);
339 float alpha = core + halo * halo * 0.7;
340 if (alpha < 0.01) discard;
341 gl_FragColor = vec4(uColor * (1.6 + min(vGlow, 4.0) * 0.45), alpha);
342 #include <colorspace_fragment>
343}
344`;
345
346const Network = memo(function Network({ nodeCount, maxDistance, nodeColor, lineColor, nodeSize, speed }: Required<Omit<PlexusNetworkProps, "particleCount" | "primaryColor" | "pauseWhenOffscreen" | "lowPowerMode">>) {
347 const groupRef = useRef<THREE.Group>(null);
348 const pointer = useCanvasPointer();
349 const count = Math.max(2, Math.round(nodeCount));
350 // Every possible pair, plus one link per node to the cursor
351 const maxSegments = (count * (count - 1)) / 2 + count;
352
353 const nodeGeometry = useMemo(() => {
354 const g = new THREE.BufferGeometry();
355 g.setAttribute("position", new THREE.BufferAttribute(new Float32Array(count * 3), 3).setUsage(THREE.DynamicDrawUsage));
356 g.setAttribute("aGlow", new THREE.BufferAttribute(new Float32Array(count), 1).setUsage(THREE.DynamicDrawUsage));
357 return g;
358 }, [count]);
359
360 const lineGeometry = useMemo(() => {
361 const g = new THREE.BufferGeometry();
362 g.setAttribute("position", new THREE.BufferAttribute(new Float32Array(maxSegments * 6), 3).setUsage(THREE.DynamicDrawUsage));
363 g.setAttribute("color", new THREE.BufferAttribute(new Float32Array(maxSegments * 6), 3).setUsage(THREE.DynamicDrawUsage));
364 g.setDrawRange(0, 0);
365 return g;
366 }, [maxSegments]);
367
368 const nodeMaterial = useMemo(
369 () =>
370 new THREE.ShaderMaterial({
371 uniforms: { uSize: { value: 9 }, uPixelRatio: { value: 1 }, uColor: { value: new THREE.Color() } },
372 vertexShader: nodeVertexShader,
373 fragmentShader: nodeFragmentShader,
374 transparent: true,
375 depthWrite: false,
376 blending: THREE.AdditiveBlending,
377 }),
378 []
379 );
380 // Additive lines: the color already carries the link strength, overlaps add up into light
381 const lineMaterial = useMemo(
382 () => new THREE.LineBasicMaterial({ vertexColors: true, transparent: true, depthWrite: false, blending: THREE.AdditiveBlending }),
383 []
384 );
385
386 // Node state: position (local space of the group) and velocity
387 const nodes = useMemo(() => {
388 const position = new Float32Array(count * 3);
389 const velocity = new Float32Array(count * 3);
390 for (let i = 0; i < count; i++) {
391 position[i * 3] = (Math.random() * 2 - 1) * 8;
392 position[i * 3 + 1] = (Math.random() * 2 - 1) * 5;
393 position[i * 3 + 2] = (Math.random() * 2 - 1) * DEPTH;
394 const v = new THREE.Vector3(Math.random() - 0.5, Math.random() - 0.5, (Math.random() - 0.5) * 0.4).normalize();
395 velocity[i * 3] = v.x;
396 velocity[i * 3 + 1] = v.y;
397 velocity[i * 3 + 2] = v.z;
398 }
399 return { position, velocity, glow: new Float32Array(count) };
400 }, [count]);
401
402 const scratch = useMemo(() => ({ cursor: new THREE.Vector3(), lineColor: new THREE.Color() }), []);
403
404 useEffect(() => {
405 nodeMaterial.uniforms.uSize.value = nodeSize;
406 (nodeMaterial.uniforms.uColor.value as THREE.Color).set(nodeColor);
407 scratch.lineColor.set(lineColor);
408 }, [nodeMaterial, nodeSize, nodeColor, lineColor, scratch]);
409
410 useEffect(
411 () => () => {
412 nodeGeometry.dispose();
413 lineGeometry.dispose();
414 },
415 [nodeGeometry, lineGeometry]
416 );
417 useEffect(
418 () => () => {
419 nodeMaterial.dispose();
420 lineMaterial.dispose();
421 },
422 [nodeMaterial, lineMaterial]
423 );
424
425 useFrame((state, delta) => {
426 const group = groupRef.current;
427 if (!group) return;
428 const dt = Math.min(delta, 1 / 30);
429 const t = state.clock.elapsedTime;
430 nodeMaterial.uniforms.uPixelRatio.value = state.viewport.dpr;
431
432 // Gentle sway of the whole network: its depth reads through parallax
433 group.rotation.y = Math.sin(t * 0.15) * 0.25;
434 group.rotation.x = Math.sin(t * 0.11) * 0.1;
435 group.updateMatrixWorld();
436
437 // Bounds follow the visible area at z = 0
438 const halfW = state.viewport.width * 0.55;
439 const halfH = state.viewport.height * 0.55;
440
441 // Cursor in the group's local space; hover repels, a held button attracts
442 const p = pointer.current;
443 const cursor = scratch.cursor;
444 const hasCursor = p.inside;
445 if (hasCursor) {
446 ndcToWorldOnPlane(p.ndc, state.camera, 0, cursor);
447 group.worldToLocal(cursor);
448 }
449 const cursorRadius = maxDistance * CURSOR_LINK_FACTOR;
450 const force = p.pressed ? -1 : 1;
451
452 const { position: pos, velocity: vel, glow } = nodes;
453 const baseSpeed = 0.35 * speed;
454 const limits = [halfW, halfH, DEPTH];
455 for (let i = 0; i < count; i++) {
456 const i3 = i * 3;
457 if (hasCursor) {
458 const dx = pos[i3] - cursor.x;
459 const dy = pos[i3 + 1] - cursor.y;
460 const dz = pos[i3 + 2] - cursor.z;
461 const d = Math.sqrt(dx * dx + dy * dy + dz * dz);
462 if (d < cursorRadius && d > 1e-4) {
463 const strength = (1 - d / cursorRadius) * 6 * force * dt;
464 vel[i3] += (dx / d) * strength;
465 vel[i3 + 1] += (dy / d) * strength;
466 vel[i3 + 2] += (dz / d) * strength;
467 }
468 }
469 // Speed relaxes back towards the cruise speed after a push
470 const v = Math.hypot(vel[i3], vel[i3 + 1], vel[i3 + 2]) || 1;
471 const relaxed = v + (1 - v) * Math.min(1, dt * 1.5);
472 for (let k = 0; k < 3; k++) {
473 vel[i3 + k] *= relaxed / v;
474 pos[i3 + k] += vel[i3 + k] * baseSpeed * dt;
475 }
476 // Bounce on the bounds
477 for (let k = 0; k < 3; k++) {
478 if (pos[i3 + k] > limits[k]) {
479 pos[i3 + k] = limits[k];
480 vel[i3 + k] = -Math.abs(vel[i3 + k]);
481 } else if (pos[i3 + k] < -limits[k]) {
482 pos[i3 + k] = -limits[k];
483 vel[i3 + k] = Math.abs(vel[i3 + k]);
484 }
485 }
486 glow[i] = 0;
487 }
488
489 // Links: every pair under the threshold, faded by distance
490 const linePos = (lineGeometry.attributes.position as THREE.BufferAttribute).array as Float32Array;
491 const lineCol = (lineGeometry.attributes.color as THREE.BufferAttribute).array as Float32Array;
492 const { r, g, b } = scratch.lineColor;
493 const maxSq = maxDistance * maxDistance;
494 let segments = 0;
495 const writeSegment = (ax: number, ay: number, az: number, bx: number, by: number, bz: number, strength: number) => {
496 const o = segments * 6;
497 linePos[o] = ax;
498 linePos[o + 1] = ay;
499 linePos[o + 2] = az;
500 linePos[o + 3] = bx;
501 linePos[o + 4] = by;
502 linePos[o + 5] = bz;
503 lineCol[o] = lineCol[o + 3] = r * strength;
504 lineCol[o + 1] = lineCol[o + 4] = g * strength;
505 lineCol[o + 2] = lineCol[o + 5] = b * strength;
506 segments++;
507 };
508
509 for (let i = 0; i < count; i++) {
510 const i3 = i * 3;
511 for (let j = i + 1; j < count; j++) {
512 const j3 = j * 3;
513 const dx = pos[i3] - pos[j3];
514 const dy = pos[i3 + 1] - pos[j3 + 1];
515 const dz = pos[i3 + 2] - pos[j3 + 2];
516 const dSq = dx * dx + dy * dy + dz * dz;
517 if (dSq < maxSq) {
518 const strength = 1 - Math.sqrt(dSq) / maxDistance;
519 writeSegment(pos[i3], pos[i3 + 1], pos[i3 + 2], pos[j3], pos[j3 + 1], pos[j3 + 2], strength * (0.35 + strength * 1.6));
520 glow[i] += strength;
521 glow[j] += strength;
522 }
523 }
524 // The cursor is a node too: brighter links to everything within reach
525 if (hasCursor) {
526 const d = Math.hypot(pos[i3] - cursor.x, pos[i3 + 1] - cursor.y, pos[i3 + 2] - cursor.z);
527 if (d < cursorRadius) {
528 const strength = 1 - d / cursorRadius;
529 writeSegment(cursor.x, cursor.y, cursor.z, pos[i3], pos[i3 + 1], pos[i3 + 2], strength * 2.6);
530 glow[i] += strength * 2;
531 }
532 }
533 }
534
535 lineGeometry.setDrawRange(0, segments * 2);
536 (lineGeometry.attributes.position as THREE.BufferAttribute).needsUpdate = true;
537 (lineGeometry.attributes.color as THREE.BufferAttribute).needsUpdate = true;
538 (nodeGeometry.attributes.position as THREE.BufferAttribute).copyArray(pos).needsUpdate = true;
539 (nodeGeometry.attributes.aGlow as THREE.BufferAttribute).copyArray(glow).needsUpdate = true;
540 });
541
542 return (
543 <group ref={groupRef}>
544 <lineSegments geometry={lineGeometry} material={lineMaterial} frustumCulled={false} />
545 <points geometry={nodeGeometry} material={nodeMaterial} frustumCulled={false} />
546 </group>
547 );
548});
549
550function PlexusNetworkBackground({
551 particleCount,
552 nodeCount = particleCount ?? 100,
553 maxDistance = 2.6,
554 primaryColor,
555 nodeColor = primaryColor ?? "#e0f2fe",
556 lineColor = "#38bdf8",
557 nodeSize = 9,
558 speed = 1,
559 pauseWhenOffscreen,
560 lowPowerMode,
561}: PlexusNetworkProps) {
562 return (
563 <BackgroundCanvas pauseWhenOffscreen={pauseWhenOffscreen} lowPowerMode={lowPowerMode} camera={{ position: [0, 0, 12], fov: 50 }}>
564 <Network
565 nodeCount={nodeCount}
566 maxDistance={maxDistance}
567 nodeColor={nodeColor}
568 lineColor={lineColor}
569 nodeSize={nodeSize}
570 speed={speed}
571 />
572 <EffectComposer multisampling={0}>
573 <Bloom mipmapBlur intensity={1.2} luminanceThreshold={0.35} luminanceSmoothing={0.3} />
574 <Vignette offset={0.3} darkness={0.7} />
575 </EffectComposer>
576 </BackgroundCanvas>
577 );
578}
579
580export default memo(PlexusNetworkBackground);
03

Drop it in a page

Updated live with the settings above.

app/page.tsx
1import PlexusNetworkBackground from "@/components/PlexusNetworkBackground";
2
3export default function Section() {
4 return (
5 // The component fills this box: give it a position and a height
6 <div style={{ position: "relative", width: "100%", height: "100vh" }}>
7 <PlexusNetworkBackground
8 particleCount={100}
9 maxDistance={2.6}
10 nodeSize={9}
11 speed={1}
12 primaryColor="#e0f2fe"
13 lineColor="#38bdf8"
14 />
15 </div>
16 );
17}
Next componentChrome Field→