svelte-image-particles
⨠A Svelte component for rendering interactive particle systems from images, powered by Three.js and GLSL shaders.
š Features
Render images as particle fields
Smooth interactive motion
Built with Svelte 5 + Three.js
Customizable shaders for advanced effects
š¦ Installation
You can install directly from GitHub (no npm publish required):
pnpm add github:DauRagnarokas/svelte-image-particles#main
For stable releases, use a tagged version instead of #main:
pnpm add github:DauRagnarokas/svelte-image-particles#v0.0.1
š Consumer Setup
Because this library uses GLSL shaders (.vert / .frag files), you need to configure Vite to handle them.
Option 1 ā Minimal (recommended)
Add this to your vite.config.ts:
export default defineConfig({ assetsInclude: ['/*.frag', '/*.vert'], optimizeDeps: { esbuildOptions: { loader: { '.vert': 'text', '.frag': 'text' } } } });
Option 2 ā With plugin (alternative)
Install vite-plugin-glsl :
pnpm add -D vite-plugin-glsl
And in vite.config.ts:
import glsl from 'vite-plugin-glsl';
export default defineConfig({ plugins: [glsl()] });
šØ Usage
In your Svelte component:
āļø Props Prop Type Default Description image string null Path/URL to the image to convert to particles width number auto Canvas width height number auto Canvas height
(More props will be added as customization grows ā e.g., particle size, density, interactivity strength.)
š Project Structure src/lib āāā ParticlesCanvas.svelte # main exported component āāā scripts/ # JS helpers āāā shaders/ # GLSL shaders (.vert / .frag)
š License
MIT Ā© DauRagnarokas