Skip to content

Commit faef874

Browse files
committed
Update Readme
1 parent 90dc7c3 commit faef874

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

README.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
# Webgl Generative Particles <img src="https://github.com/react18-tools/webgl-generative-particles/blob/main/popper.png?raw=true" style="height: 40px"/>
1+
# WebGL Generative Particles <img src="https://github.com/react18-tools/webgl-generative-particles/blob/main/popper.png?raw=true" style="height: 40px"/>
22

3-
> This library is a Work In Progress... Feel free to request features, report bugs or contribute.
4-
> We will try to keep the APIs stable, however, some APIs might change.
3+
> This library is a Work In Progress. Feel free to request features, report bugs, or contribute. We aim to keep the APIs stable, though some changes may occur.
54
65
[![test](https://github.com/react18-tools/webgl-generative-particles/actions/workflows/test.yml/badge.svg)](https://github.com/react18-tools/webgl-generative-particles/actions/workflows/test.yml) [![Maintainability](https://api.codeclimate.com/v1/badges/17e43ef7ca4593a18757/maintainability)](https://codeclimate.com/github/react18-tools/webgl-generative-particles/maintainability) [![codecov](https://codecov.io/gh/react18-tools/webgl-generative-particles/graph/badge.svg)](https://codecov.io/gh/react18-tools/webgl-generative-particles) [![Version](https://img.shields.io/npm/v/webgl-generative-particles.svg?colorB=green)](https://www.npmjs.com/package/webgl-generative-particles) [![Downloads](https://img.jsdelivr.com/img.shields.io/npm/d18m/webgl-generative-particles.svg)](https://www.npmjs.com/package/webgl-generative-particles) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/webgl-generative-particles) [![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/from-referrer/)
76

87
"webgl-generative-particles" is an efficient WebGL-based generative particle system simulator designed for both React and vanilla JS applications. This system follows the mouse pointer, providing interactive and dynamic visual effects. It offers seamless integration with React (including React 18 and beyond) and Next.js, making it an ideal choice for modern frontend development. The simulator is customizable, compatible with various frameworks, and delivers high performance and real-time rendering for progressive web development.
98

9+
> Check out the live demo at - https://webgl-generative-particles.vercel.app/
10+
11+
## Features
12+
1013
✅ Fully Treeshakable (import from `webgl-generative-particles/react`)
1114

1215
✅ Fully TypeScript Supported
@@ -25,17 +28,19 @@
2528

2629
### Installation
2730

31+
Using pnpm:
32+
2833
```bash
2934
$ pnpm add webgl-generative-particles
3035
```
3136

32-
**_or_**
37+
Using npm:
3338

3439
```bash
3540
$ npm install webgl-generative-particles
3641
```
3742

38-
**_or_**
43+
Using yarn:
3944

4045
```bash
4146
$ yarn add webgl-generative-particles
@@ -58,35 +63,32 @@ import { Particles } from "webgl-generative-particles/react";
5863

5964
```ts
6065
export interface ParticlesOptions {
61-
/** particle Color @defaultValue [1, 0, 0, 1] -> red */
66+
/** Particle Color @defaultValue [1, 0, 0, 1] -> red */
6267
rgba?: [number, number, number, number];
63-
/** @defaultValue 100_000 */
68+
/** Maximum number of particles @defaultValue 100_000 */
6469
maxParticles?: number;
65-
/** @defaultValue 0.5 */
70+
/** Particle generation rate @defaultValue 0.5 */
6671
generationRate?: number;
67-
/** @defaultValue false */
72+
/** Overlay mode @defaultValue false */
6873
overlay?: boolean;
69-
/** @defaultValue false */
74+
/** Disable mouse interaction @defaultValue false */
7075
mouseOff?: boolean;
71-
/** min and max Angles in radians: @defaultValue [-Math.PI, Math.PI] */
72-
angleRage?: [number, number];
73-
/** min and max age of particles in seconds */
76+
/** Min and max angles in radians @defaultValue [-Math.PI, Math.PI] */
77+
angleRange?: [number, number];
78+
/** Min and max age of particles in seconds */
7479
ageRange?: [number, number];
75-
/** [minSpeed, maxSpeed] */
80+
/** Speed range [minSpeed, maxSpeed] */
7681
speedRange?: [number, number];
77-
/** Initial origin -> Will update as per mouse position when mouse moved if mouseOff is not set.
78-
* @defaultValue [0, 0]
79-
*/
82+
/** Initial origin, will update as per mouse position if mouseOff is not set @defaultValue [0, 0] */
8083
origin?: [number, number];
81-
/** todo */
82-
/** todo: WIP constant force [fx, fy] or a force field texture */
84+
/** Constant force [fx, fy] or a force field texture (Work In Progress) */
8385
forceField?: Vector2D; //| Vector[][] | string;
8486
}
8587
```
8688

87-
## Creadits
89+
## Credits
8890

89-
I have learnt the concepts from the following blogs and tutorials.
91+
The concepts in this library were learned from the following blogs and tutorials:
9092

9193
- https://experiments.withgoogle.com/search?q=particles
9294
- https://nullprogram.com/blog/2014/06/29/

lib/src/simulator.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,25 @@ const OUT_VELOCITY = "oV";
3030
type Vector2D = [number, number];
3131

3232
export interface ParticlesOptions {
33-
/** particle Color @defaultValue [1, 0, 0, 1] -> red */
33+
/** Particle Color @defaultValue [1, 0, 0, 1] -> red */
3434
rgba?: [number, number, number, number];
35-
/** @defaultValue 100_000 */
35+
/** Maximum number of particles @defaultValue 100_000 */
3636
maxParticles?: number;
37-
/** @defaultValue 0.5 */
37+
/** Particle generation rate @defaultValue 0.5 */
3838
generationRate?: number;
39-
/** @defaultValue false */
39+
/** Overlay mode @defaultValue false */
4040
overlay?: boolean;
41-
/** @defaultValue false */
41+
/** Disable mouse interaction @defaultValue false */
4242
mouseOff?: boolean;
43-
/** min and max Angles in radians: @defaultValue [-Math.PI, Math.PI] */
44-
angleRage?: [number, number];
45-
/** min and max age of particles in seconds */
43+
/** Min and max angles in radians @defaultValue [-Math.PI, Math.PI] */
44+
angleRange?: [number, number];
45+
/** Min and max age of particles in seconds */
4646
ageRange?: [number, number];
47-
/** [minSpeed, maxSpeed] */
47+
/** Speed range [minSpeed, maxSpeed] */
4848
speedRange?: [number, number];
49-
/** Initial origin -> Will update as per mouse position when mouse moved if mouseOff is not set.
50-
* @defaultValue [0, 0]
51-
*/
49+
/** Initial origin, will update as per mouse position if mouseOff is not set @defaultValue [0, 0] */
5250
origin?: [number, number];
53-
/** todo */
54-
/** todo: WIP constant force [fx, fy] or a force field texture */
51+
/** Constant force [fx, fy] or a force field texture (Work In Progress) */
5552
forceField?: Vector2D; //| Vector[][] | string;
5653
}
5754

@@ -60,7 +57,7 @@ const defaultOptions: ParticlesOptions = {
6057
maxParticles: 1000,
6158
generationRate: 0.25,
6259
// setting range from -PI to PI craetes some patches because of overflows
63-
angleRage: [-2 * PI, 2 * PI],
60+
angleRange: [-2 * PI, 2 * PI],
6461
origin: [-1, -1],
6562
speedRange: [0.01, 0.1],
6663
ageRange: [0.01, 0.5],
@@ -91,7 +88,7 @@ const simulate = (
9188
* canvas positions are between -1 to 1 on all axes
9289
*/
9390
// skipcq: JS-0339 -- defined in default options
94-
const angleRage = options.angleRage! as [number, number];
91+
const angleRange = options.angleRange! as [number, number];
9592
/** Create shader */
9693
const createShader = (type: number, source: string): WebGLShader => {
9794
const shader = gl.createShader(type);
@@ -240,6 +237,7 @@ const simulate = (
240237
let mouseX = 0;
241238
let mouseY = 0;
242239

240+
/** Set origin - from where all particles are generateds */
243241
const setOrigin = (x: number, y: number): void => {
244242
mouseX = x;
245243
mouseY = y;
@@ -258,7 +256,7 @@ const simulate = (
258256
// skipcq: JS-0339 -- forcefield is always set by the default options
259257
setUpdateUniform(U_FORCE_FIELD, ...options.forceField!);
260258
setUpdateUniform(U_ORIGIN, mouseX, mouseY);
261-
setUpdateUniform(U_ANGLE_RANGE, ...angleRage);
259+
setUpdateUniform(U_ANGLE_RANGE, ...angleRange);
262260
// skipcq: JS-0339 -- set in default options
263261
setUpdateUniform(U_LIFE_RANGE, ...options.ageRange!);
264262
// skipcq: JS-0339 -- set in default options

0 commit comments

Comments
 (0)