@mrigx/fx 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +32 -0
- package/src/cursors/caustic-cursor.tsx +16 -0
- package/src/cursors/cavitation-cursor.tsx +28 -0
- package/src/cursors/glass-rod-cursor.tsx +20 -0
- package/src/cursors/lens-cursor.tsx +20 -0
- package/src/cursors/magnetic-cursor.tsx +20 -0
- package/src/cursors/prismatic-cursor.tsx +20 -0
- package/src/cursors/tension-cursor.tsx +26 -0
- package/src/effects/optical-abyss.tsx +17 -0
- package/src/index.ts +11 -0
- package/src/materials/abyss-surface.tsx +14 -0
- package/src/materials/glass-surface.tsx +14 -0
- package/src/materials/ripple-surface.tsx +23 -0
- package/tsconfig.json +27 -0
- package/vite.config.ts +40 -0
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mrigx/fx",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/fx.umd.js",
|
|
6
|
+
"module": "./dist/fx.es.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/fx.es.js",
|
|
12
|
+
"require": "./dist/fx.umd.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "vite build"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@mrigx/core": "*",
|
|
20
|
+
"@mrigx/react": "*"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"react": "^19.0.0",
|
|
24
|
+
"react-dom": "^19.0.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"typescript": "~5.7.2",
|
|
28
|
+
"vite": "^6.0.0",
|
|
29
|
+
"vite-plugin-dts": "^4.5.0",
|
|
30
|
+
"@vitejs/plugin-react": "^4.3.4"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
export function CausticCursor() {
|
|
4
|
+
const [pos, setPos] = useState({ x: 0, y: 0 });
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
document.body.style.cursor = 'none';
|
|
7
|
+
const handleMove = (e: MouseEvent) => setPos({ x: e.clientX, y: e.clientY });
|
|
8
|
+
window.addEventListener('mousemove', handleMove);
|
|
9
|
+
return () => { document.body.style.cursor = ''; window.removeEventListener('mousemove', handleMove); };
|
|
10
|
+
}, []);
|
|
11
|
+
return (
|
|
12
|
+
<div className="pointer-events-none fixed top-0 left-0 z-[9999] mix-blend-overlay transition-transform duration-75 ease-out"
|
|
13
|
+
style={{ transform: `translate3d(${pos.x}px, ${pos.y}px, 0) translate(-50%, -50%)`, width: '40px', height: '40px', borderRadius: '50%', background: 'radial-gradient(circle, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 70%)' }}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import { useEngine } from '@mrigx/react';
|
|
4
|
+
export function CavitationCursor() {
|
|
5
|
+
const engine = useEngine();
|
|
6
|
+
const [pos, setPos] = useState({ x: 0, y: 0 });
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
let lastTime = 0;
|
|
9
|
+
document.body.style.cursor = 'none';
|
|
10
|
+
const handleMove = (e: MouseEvent) => {
|
|
11
|
+
setPos({ x: e.clientX, y: e.clientY });
|
|
12
|
+
const now = performance.now();
|
|
13
|
+
if (now - lastTime < 32) return;
|
|
14
|
+
lastTime = now;
|
|
15
|
+
if (engine && engine.triggerDisturbance) {
|
|
16
|
+
// High strength but very small radius mimics a sharp vacuum drop
|
|
17
|
+
engine.triggerDisturbance(e.clientX / window.innerWidth, e.clientY / window.innerHeight, -2.0, 0.02);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
window.addEventListener('mousemove', handleMove);
|
|
21
|
+
return () => { document.body.style.cursor = ''; window.removeEventListener('mousemove', handleMove); };
|
|
22
|
+
}, [engine]);
|
|
23
|
+
return (
|
|
24
|
+
<div className="pointer-events-none fixed top-0 left-0 z-[9999] w-4 h-4 rounded-full bg-black border border-white/20 mix-blend-difference"
|
|
25
|
+
style={{ transform: `translate3d(${pos.x}px, ${pos.y}px, 0) translate(-50%, -50%)` }}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
import React, { useEffect, useRef } from 'react';
|
|
3
|
+
import { useMrigSurface } from '@mrigx/react';
|
|
4
|
+
export function GlassRodCursor() {
|
|
5
|
+
const localRef = useRef<any>(null);
|
|
6
|
+
const mrigRef = useMrigSurface<HTMLDivElement>({ material: 'glass', materialStrength: 1.5, borderRadius: 4 }, localRef);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
document.body.style.cursor = 'none';
|
|
9
|
+
const handleMove = (e: MouseEvent) => {
|
|
10
|
+
if (localRef.current) {
|
|
11
|
+
localRef.current.style.transform = `translate3d(${e.clientX}px, ${e.clientY}px, 0) translate(-50%, -50%)`;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
window.addEventListener('mousemove', handleMove);
|
|
15
|
+
return () => { document.body.style.cursor = ''; window.removeEventListener('mousemove', handleMove); };
|
|
16
|
+
}, [localRef]);
|
|
17
|
+
return (
|
|
18
|
+
<div ref={mrigRef as any} className="pointer-events-none fixed top-0 left-0 z-[9999] w-1.5 h-8 rounded-sm bg-white/30 mix-blend-overlay shadow-[0_0_10px_rgba(255,255,255,0.5)]" />
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
import React, { useEffect, useRef } from 'react';
|
|
3
|
+
import { useMrigSurface } from '@mrigx/react';
|
|
4
|
+
export function LensCursor() {
|
|
5
|
+
const localRef = useRef<any>(null);
|
|
6
|
+
const mrigRef = useMrigSurface<HTMLDivElement>({ material: 'crystal', materialStrength: 2.0, borderRadius: 9999 }, localRef);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
document.body.style.cursor = 'none';
|
|
9
|
+
const handleMove = (e: MouseEvent) => {
|
|
10
|
+
if (localRef.current) {
|
|
11
|
+
localRef.current.style.transform = `translate3d(${e.clientX}px, ${e.clientY}px, 0) translate(-50%, -50%)`;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
window.addEventListener('mousemove', handleMove);
|
|
15
|
+
return () => { document.body.style.cursor = ''; window.removeEventListener('mousemove', handleMove); };
|
|
16
|
+
}, [localRef]);
|
|
17
|
+
return (
|
|
18
|
+
<div ref={mrigRef as any} className="pointer-events-none fixed top-0 left-0 z-[9999] w-16 h-16 rounded-full border border-white/20 bg-white/5" />
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
|
+
import { useEngine } from '@mrigx/react';
|
|
4
|
+
export function MagneticCursor() {
|
|
5
|
+
const engine = useEngine();
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
let lastTime = 0;
|
|
8
|
+
const handleMove = (e: MouseEvent) => {
|
|
9
|
+
const now = performance.now();
|
|
10
|
+
if (now - lastTime < 16) return;
|
|
11
|
+
lastTime = now;
|
|
12
|
+
if (engine && engine.triggerDisturbance) {
|
|
13
|
+
engine.triggerDisturbance(e.clientX / window.innerWidth, e.clientY / window.innerHeight, 1.5, 0.08);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
window.addEventListener('mousemove', handleMove);
|
|
17
|
+
return () => window.removeEventListener('mousemove', handleMove);
|
|
18
|
+
}, [engine]);
|
|
19
|
+
return null; // Invisible, pure fluid interaction
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
import React, { useEffect, useRef } from 'react';
|
|
3
|
+
import { useMrigSurface } from '@mrigx/react';
|
|
4
|
+
export function PrismaticCursor() {
|
|
5
|
+
const localRef = useRef<any>(null);
|
|
6
|
+
const mrigRef = useMrigSurface<HTMLDivElement>({ material: 'glass', materialStrength: 2.5, borderRadius: 4 }, localRef);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
document.body.style.cursor = 'none';
|
|
9
|
+
const handleMove = (e: MouseEvent) => {
|
|
10
|
+
if (localRef.current) {
|
|
11
|
+
localRef.current.style.transform = `translate3d(${e.clientX}px, ${e.clientY}px, 0) translate(-50%, -50%)`;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
window.addEventListener('mousemove', handleMove);
|
|
15
|
+
return () => { document.body.style.cursor = ''; window.removeEventListener('mousemove', handleMove); };
|
|
16
|
+
}, [localRef]);
|
|
17
|
+
return (
|
|
18
|
+
<div ref={mrigRef as any} className="pointer-events-none fixed top-0 left-0 z-[9999] w-8 h-8 rounded border border-white/40 bg-white/10" />
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
|
+
export function TensionCursor() {
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const handleMove = (e: MouseEvent) => {
|
|
6
|
+
const elements = document.querySelectorAll('p, h1, h2, h3, a, button');
|
|
7
|
+
elements.forEach((el) => {
|
|
8
|
+
const rect = el.getBoundingClientRect();
|
|
9
|
+
const centerX = rect.left + rect.width / 2;
|
|
10
|
+
const centerY = rect.top + rect.height / 2;
|
|
11
|
+
const distX = e.clientX - centerX;
|
|
12
|
+
const distY = e.clientY - centerY;
|
|
13
|
+
const distance = Math.sqrt(distX * distX + distY * distY);
|
|
14
|
+
if (distance < 150) {
|
|
15
|
+
const pull = (150 - distance) / 15;
|
|
16
|
+
(el as HTMLElement).style.transform = `translate(${distX > 0 ? pull : -pull}px, ${distY > 0 ? pull : -pull}px)`;
|
|
17
|
+
} else {
|
|
18
|
+
(el as HTMLElement).style.transform = 'translate(0px, 0px)';
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
window.addEventListener('mousemove', handleMove);
|
|
23
|
+
return () => window.removeEventListener('mousemove', handleMove);
|
|
24
|
+
}, []);
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useEngine } from '@mrigx/react';
|
|
3
|
+
|
|
4
|
+
export function OpticalAbyss({ intensity = 1.0, parallax = 1.0 }: { intensity?: number, parallax?: number }) {
|
|
5
|
+
const engine = useEngine();
|
|
6
|
+
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (engine) {
|
|
9
|
+
engine.setConfig({ abyssIntensity: intensity, parallaxIntensity: parallax });
|
|
10
|
+
return () => {
|
|
11
|
+
engine.setConfig({ abyssIntensity: 0.0, parallaxIntensity: 1.0 });
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
}, [engine, intensity, parallax]);
|
|
15
|
+
|
|
16
|
+
return null;
|
|
17
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './materials/abyss-surface';
|
|
2
|
+
export * from './materials/glass-surface';
|
|
3
|
+
export * from './materials/ripple-surface';
|
|
4
|
+
export * from './effects/optical-abyss';
|
|
5
|
+
export * from './cursors/caustic-cursor';
|
|
6
|
+
export * from './cursors/cavitation-cursor';
|
|
7
|
+
export * from './cursors/glass-rod-cursor';
|
|
8
|
+
export * from './cursors/lens-cursor';
|
|
9
|
+
export * from './cursors/magnetic-cursor';
|
|
10
|
+
export * from './cursors/prismatic-cursor';
|
|
11
|
+
export * from './cursors/tension-cursor';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import { useMrigSurface } from '@mrigx/react';
|
|
4
|
+
|
|
5
|
+
export const AbyssSurface = forwardRef<any, { as?: React.ElementType, materialStrength?: number, borderRadius?: number, children?: React.ReactNode, className?: string, [key: string]: any }>(({ as, materialStrength = 1.0, borderRadius = 16, children, className = "", ...props }, ref) => {
|
|
6
|
+
const Component = as || 'div';
|
|
7
|
+
const internalRef = useMrigSurface({ material: 'abyss', materialStrength, borderRadius }, ref);
|
|
8
|
+
return (
|
|
9
|
+
<Component ref={internalRef as any} className={className} {...props}>
|
|
10
|
+
{children}
|
|
11
|
+
</Component>
|
|
12
|
+
);
|
|
13
|
+
});
|
|
14
|
+
AbyssSurface.displayName = "AbyssSurface";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { useMrigSurface } from '@mrigx/react';
|
|
3
|
+
import type { OpticalMaterial } from '@mrigx/core';
|
|
4
|
+
|
|
5
|
+
export const GlassSurface = forwardRef<any, { as?: React.ElementType, material?: OpticalMaterial, materialStrength?: number, borderRadius?: number, children?: React.ReactNode, className?: string, [key: string]: any }>(({ as, material = 'glass', materialStrength = 1.0, borderRadius = 16, children, className = "", ...props }, ref) => {
|
|
6
|
+
const Component = as || 'div';
|
|
7
|
+
const internalRef = useMrigSurface({ material, materialStrength, borderRadius }, ref);
|
|
8
|
+
return (
|
|
9
|
+
<Component ref={internalRef as any} className={className} {...props}>
|
|
10
|
+
{children}
|
|
11
|
+
</Component>
|
|
12
|
+
);
|
|
13
|
+
});
|
|
14
|
+
GlassSurface.displayName = "GlassSurface";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import { useMrigSurface, useMrigInteraction } from '@mrigx/react';
|
|
4
|
+
|
|
5
|
+
export const RippleSurface = forwardRef<any, { as?: React.ElementType, material?: number | string, materialStrength?: number, borderRadius?: number, children?: React.ReactNode, className?: string, onClick?: (e: any) => void, [key: string]: any }>(({ as, material = 1, materialStrength = 1.5, borderRadius = 8, children, className = "", onClick, ...props }, ref) => {
|
|
6
|
+
const Component = as || 'div';
|
|
7
|
+
const internalRef = useMrigSurface({ material, materialStrength, borderRadius }, ref);
|
|
8
|
+
const { pulseCenter } = useMrigInteraction();
|
|
9
|
+
return (
|
|
10
|
+
<Component
|
|
11
|
+
ref={internalRef as any}
|
|
12
|
+
className={className}
|
|
13
|
+
onClick={(e: any) => {
|
|
14
|
+
pulseCenter(e.currentTarget, 0.4);
|
|
15
|
+
onClick?.(e);
|
|
16
|
+
}}
|
|
17
|
+
{...props}
|
|
18
|
+
>
|
|
19
|
+
{children}
|
|
20
|
+
</Component>
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
RippleSurface.displayName = "RippleSurface";
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"lib": [
|
|
6
|
+
"ES2020",
|
|
7
|
+
"DOM",
|
|
8
|
+
"DOM.Iterable"
|
|
9
|
+
],
|
|
10
|
+
"module": "ESNext",
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"moduleResolution": "bundler",
|
|
13
|
+
"allowImportingTsExtensions": true,
|
|
14
|
+
"resolveJsonModule": true,
|
|
15
|
+
"isolatedModules": true,
|
|
16
|
+
"noEmit": true,
|
|
17
|
+
"jsx": "react-jsx",
|
|
18
|
+
"strict": true,
|
|
19
|
+
"noUnusedLocals": true,
|
|
20
|
+
"noUnusedParameters": true,
|
|
21
|
+
"noFallthroughCasesInSwitch": true,
|
|
22
|
+
"baseUrl": "."
|
|
23
|
+
},
|
|
24
|
+
"include": [
|
|
25
|
+
"src"
|
|
26
|
+
]
|
|
27
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import react from '@vitejs/plugin-react';
|
|
3
|
+
import dts from 'vite-plugin-dts';
|
|
4
|
+
import { resolve } from 'path';
|
|
5
|
+
import url from 'url';
|
|
6
|
+
|
|
7
|
+
const dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
8
|
+
|
|
9
|
+
export default defineConfig({
|
|
10
|
+
publicDir: false,
|
|
11
|
+
plugins: [
|
|
12
|
+
react(),
|
|
13
|
+
dts({
|
|
14
|
+
include: ['src/**/*'],
|
|
15
|
+
outDir: 'dist',
|
|
16
|
+
insertTypesEntry: true,
|
|
17
|
+
tsconfigPath: './tsconfig.json'
|
|
18
|
+
})
|
|
19
|
+
],
|
|
20
|
+
build: {
|
|
21
|
+
outDir: 'dist',
|
|
22
|
+
emptyOutDir: true,
|
|
23
|
+
lib: {
|
|
24
|
+
entry: resolve(dirname, 'src/index.ts'),
|
|
25
|
+
name: 'MrigFx',
|
|
26
|
+
fileName: (format) => 'fx.' + format + '.js'
|
|
27
|
+
},
|
|
28
|
+
rollupOptions: {
|
|
29
|
+
external: ['react', 'react-dom', '@mrigx/core', '@mrigx/react'],
|
|
30
|
+
output: {
|
|
31
|
+
globals: {
|
|
32
|
+
'react': 'React',
|
|
33
|
+
'react-dom': 'ReactDOM',
|
|
34
|
+
'@mrigx/core': 'MrigCore',
|
|
35
|
+
'@mrigx/react': 'MrigReact'
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|