reyhan-particle-morph-library
v0.1.2
Published
Reusable Three.js particle morph library for sphere-to-text animations with customizable colors and morph timing.
Maintainers
Readme
Particle Morph Library
Reusable Three.js particle morph library for sphere-to-text animations with customizable colors, hover feedback, and morph timing.
Features
- Sphere and text morph targets
- Custom text via
text - Morph timing via
morphDurationMs - Editable color themes and presets
- Pointer hover color feedback
- Separate demo for local testing
What is inside
src/core/: main library class and runtime behaviorsrc/config/: default values and editable color presetssrc/generators/: shape builders likesphereandtextsrc/utils/: small helpers like morph timingexample/: a demo page that uses the librarypackage.json: local package setup, separate from your main project
Installation
npm install reyhan-particle-morph-library threeQuick Start
import { ParticleMorph, colorPresets } from "reyhan-particle-morph-library";
const morph = new ParticleMorph({
container: document.getElementById("scene"),
particleCount: 30000,
text: "ZINAV",
morphDurationMs: 1400,
colors: colorPresets.candyPlasma,
});
morph.setText("ZINAV");
morph.setSphere();
morph.destroy();Public API
new ParticleMorph(options)setText(text)setSphere()destroy()
Config Props
container: required DOM element for the rendererparticleCount: number of particlestext: initial text to render instead of starting from the spheremorphDurationMs: morph timing in millisecondstextFont: canvas font used for text samplingsphereRadius: sphere sizecolors.baseStart: first base colorcolors.baseEnd: second base color for the mixed particle palettecolors.hover: color used when the pointer moves over particles
Project Structure
- Change default props in
src/config/defaults.js - Add new reusable themes in
src/config/colorPresets.js - Change sphere generation in
src/generators/sphere.js - Change text point generation in
src/generators/text.js - Change morph timing behavior in
src/utils/getMorphStrength.js
Local Development
npm install
npm run devThen open the local Vite URL, usually http://localhost:5173.
Build For npm
npm run buildThis creates the publishable package files in dist/.
Publish To npm
npm login
npm publish --access publicIf the package name is already taken on npm, change the name field in package.json first.
GitHub Publishing
If you want to make this available to others on GitHub:
cd /home/reyhan/Desktop/agripion/particle-morph-library
git init
git add .
git commit -m "feat: add particle morph library"
git branch -M main
git remote add origin <YOUR_GITHUB_REPO_URL>
git push -u origin mainNotes
- Nothing in this folder is wired into your existing project.
- The structure keeps rendering logic separate from the UI layer so it is easier to integrate with React, Next.js, or plain HTML later.
threeis a peer dependency, so consumers should install it in their own project.
