UNPKG

@forbespro/lead-agent

Version:
92 lines (91 loc) 2.94 kB
import { jsx as E } from "react/jsx-runtime"; import { useRef as R, useEffect as D } from "react"; import * as t from "three"; import { EffectComposer as F } from "./index23.js"; import { RenderPass as C } from "./index24.js"; import { AfterimagePass as I } from "./index25.js"; const N = ({ size: n = 40 }) => { const p = R(null); return D(() => { if (!p.current) return; const m = new t.Scene(), f = new t.PerspectiveCamera(75, 1, 0.1, 1e3), s = new t.WebGLRenderer({ canvas: p.current, alpha: !0, antialias: !0, precision: "highp", powerPreference: "high-performance" }); s.setPixelRatio(Math.min(window.devicePixelRatio, 2)), s.setSize(n, n), f.position.z = 2.2; const i = new F(s); i.addPass(new C(m, f)); const x = new I(0.85); i.addPass(x); const h = new t.SphereGeometry(1, 36, 36), w = new t.MeshBasicMaterial({ color: 666974, transparent: !0, opacity: 0.1 }), y = new t.Mesh(h, w); m.add(y); const l = [], c = [4886754, 49919, 26367]; for (let e = 0; e < 11; e++) { const r = new t.EllipseCurve( 0, 0, // Center 1, 1, // X/Y radius 0, Math.PI * 2, // Start/end angle !1, // Clockwise Math.random() * Math.PI * 3 // Rotation ).getPoints(68), o = new t.BufferGeometry().setFromPoints(r), d = new t.LineBasicMaterial({ color: c[e % c.length], transparent: !0, opacity: 0.8, linewidth: 10 }), a = new t.Line(o, d); a.rotation.x = Math.random() * Math.PI, a.rotation.y = Math.random() * Math.PI, a.userData.pulseSpeed = 3e-3 * (e + 1), a.userData.rotationSpeed = { x: 0.18 * (e % 3 + 1), y: 0.12 * (e % 3 + 1), z: 0.06 * (e % 3 + 1) }, l.push(a), m.add(a); } let P = 0; const M = (e) => { const g = e - P; P = e; const r = g * 22e-4; y.rotation.y += 0.6 * r, l.forEach((o, d) => { const a = Math.sin(e * o.userData.pulseSpeed) * 0.5 + 0.5, u = 1 + a * 2; o.rotation.x += o.userData.rotationSpeed.x * r * u, o.rotation.y += o.userData.rotationSpeed.y * r * u, o.rotation.z += o.userData.rotationSpeed.z * r * u; const S = o.material; S.opacity = 0.4 + a * 0.6; const v = new t.Color(c[d % c.length]); v.multiplyScalar(0.8 + a * 0.7), S.color = v; }), i.render(), requestAnimationFrame(M); }, b = requestAnimationFrame(M); return () => { cancelAnimationFrame(b), i.dispose(), l.forEach((e) => { e.geometry.dispose(), e.material.dispose(); }), h.dispose(), w.dispose(), s.dispose(); }; }, [n]), /* @__PURE__ */ E( "canvas", { ref: p, className: "fpl-h-8 fpl-w-8 fpl-mr-2", style: { display: "block", width: n, height: n } } ); }; export { N as default };