@newkrok/three-particles 2.11.2 → 2.13.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/README.md +2 -0
- package/dist/index.d.ts +165 -2
- package/dist/index.js +724 -23
- package/dist/index.js.map +1 -1
- package/dist/three-particles.min.js +1 -1
- package/dist/three-particles.min.js.map +1 -1
- package/llms-full.txt +95 -1
- package/llms.txt +47 -0
- package/package.json +1 -1
package/llms-full.txt
CHANGED
|
@@ -338,6 +338,8 @@ type Renderer = {
|
|
|
338
338
|
depthTest: boolean; // Default: true
|
|
339
339
|
depthWrite: boolean; // Default: false
|
|
340
340
|
rendererType?: RendererType; // Default: RendererType.POINTS
|
|
341
|
+
trail?: TrailConfig; // Only for RendererType.TRAIL
|
|
342
|
+
mesh?: MeshConfig; // Only for RendererType.MESH
|
|
341
343
|
};
|
|
342
344
|
|
|
343
345
|
enum RendererType {
|
|
@@ -345,11 +347,103 @@ enum RendererType {
|
|
|
345
347
|
INSTANCED = 'INSTANCED', // Camera-facing quads via InstancedBufferGeometry.
|
|
346
348
|
// Removes gl_PointSize hardware limit, supports large particles.
|
|
347
349
|
// Recommended for 10 000+ particles or large on-screen sizes.
|
|
350
|
+
TRAIL = 'TRAIL', // Ribbon trails behind particles. Each particle records a position
|
|
351
|
+
// history and the renderer builds a camera-facing triangle-strip
|
|
352
|
+
// ribbon through those samples.
|
|
353
|
+
MESH = 'MESH', // 3D mesh particles via GPU instancing. Each particle is rendered
|
|
354
|
+
// as a full 3D mesh with quaternion-based rotation, normals, and
|
|
355
|
+
// directional lighting. Any THREE.BufferGeometry can be used.
|
|
348
356
|
}
|
|
357
|
+
|
|
358
|
+
type MeshConfig = {
|
|
359
|
+
geometry: THREE.BufferGeometry; // The geometry to render for each particle
|
|
360
|
+
};
|
|
349
361
|
```
|
|
350
362
|
|
|
351
363
|
Common blending modes: `THREE.NormalBlending`, `THREE.AdditiveBlending`, `THREE.SubtractiveBlending`
|
|
352
364
|
|
|
365
|
+
### Mesh Particle Configuration
|
|
366
|
+
|
|
367
|
+
When using `RendererType.MESH`, configure mesh-specific properties via `renderer.mesh`:
|
|
368
|
+
|
|
369
|
+
```typescript
|
|
370
|
+
renderer: {
|
|
371
|
+
rendererType: RendererType.MESH,
|
|
372
|
+
blending: THREE.NormalBlending,
|
|
373
|
+
transparent: true,
|
|
374
|
+
depthTest: true,
|
|
375
|
+
depthWrite: true,
|
|
376
|
+
mesh: {
|
|
377
|
+
geometry: new THREE.BoxGeometry(1, 1, 1),
|
|
378
|
+
},
|
|
379
|
+
}
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
Mesh particle features:
|
|
383
|
+
- GPU instancing (`InstancedBufferGeometry`) — one draw call for all particles
|
|
384
|
+
- Quaternion-based 3D rotation (particles rotate in all 3 axes)
|
|
385
|
+
- Normals preserved from the source geometry, simple directional lighting from camera
|
|
386
|
+
- Any `THREE.BufferGeometry` works: `BoxGeometry`, `SphereGeometry`, `IcosahedronGeometry`, custom meshes, etc.
|
|
387
|
+
- All modifiers work: sizeOverLifetime, colorOverLifetime, opacityOverLifetime, rotationOverLifetime, noise, force fields, sub-emitters
|
|
388
|
+
- Default texture: solid white 1×1 (preserves mesh shape); point/billboard renderers default to a circle texture
|
|
389
|
+
- Sub-emitter note: sub-emitters do not inherit `RendererType.MESH` or `RendererType.TRAIL` from the parent because mesh geometry and trail config cannot be passed through; sub-emitters fall back to their own `rendererType` or `POINTS` by default
|
|
390
|
+
- Note: `mesh.geometry` is a runtime object (not serializable to JSON); provide it programmatically
|
|
391
|
+
|
|
392
|
+
### Trail / Ribbon Configuration
|
|
393
|
+
|
|
394
|
+
When using `RendererType.TRAIL`, configure trail-specific properties via `renderer.trail`:
|
|
395
|
+
|
|
396
|
+
```typescript
|
|
397
|
+
type TrailConfig = {
|
|
398
|
+
length?: number; // Position history samples per particle. Default: 20
|
|
399
|
+
width?: number; // Base ribbon width in world units. Default: 1.0
|
|
400
|
+
widthOverTrail?: LifetimeCurve; // Width taper from head (0) to tail (1)
|
|
401
|
+
opacityOverTrail?: LifetimeCurve; // Opacity taper from head (0) to tail (1)
|
|
402
|
+
colorOverTrail?: { // Optional per-channel color multiplier curves
|
|
403
|
+
isActive: boolean;
|
|
404
|
+
r: LifetimeCurve; // Red channel multiplier (0=head, 1=tail)
|
|
405
|
+
g: LifetimeCurve; // Green channel multiplier
|
|
406
|
+
b: LifetimeCurve; // Blue channel multiplier
|
|
407
|
+
};
|
|
408
|
+
};
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
Trail features:
|
|
412
|
+
- GPU billboard rendering (vertex shader computes perpendicular offset from camera direction)
|
|
413
|
+
- Soft-edge fade on ribbon borders (no hard edges)
|
|
414
|
+
- Optional texture mapping (texture modulates brightness via luminance)
|
|
415
|
+
- `colorOverTrail` multiplies the particle's current color at each trail position — use white `startColor` for full color transitions
|
|
416
|
+
- Works with all particle features: colorOverLifetime, noise, gravity, force fields
|
|
417
|
+
|
|
418
|
+
Example — comet trail with color shift:
|
|
419
|
+
|
|
420
|
+
```typescript
|
|
421
|
+
renderer: {
|
|
422
|
+
rendererType: RendererType.TRAIL,
|
|
423
|
+
blending: THREE.AdditiveBlending,
|
|
424
|
+
transparent: true,
|
|
425
|
+
depthWrite: false,
|
|
426
|
+
trail: {
|
|
427
|
+
length: 60,
|
|
428
|
+
width: 0.5,
|
|
429
|
+
widthOverTrail: {
|
|
430
|
+
type: LifeTimeCurve.BEZIER,
|
|
431
|
+
bezierPoints: [
|
|
432
|
+
{ x: 0, y: 1, percentage: 0 },
|
|
433
|
+
{ x: 0.5, y: 0.4 },
|
|
434
|
+
{ x: 1, y: 0, percentage: 1 },
|
|
435
|
+
],
|
|
436
|
+
},
|
|
437
|
+
colorOverTrail: {
|
|
438
|
+
isActive: true,
|
|
439
|
+
r: { type: LifeTimeCurve.BEZIER, bezierPoints: [{ x: 0, y: 0.2, percentage: 0 }, { x: 0.5, y: 0.5 }, { x: 1, y: 0.8, percentage: 1 }] },
|
|
440
|
+
g: { type: LifeTimeCurve.BEZIER, bezierPoints: [{ x: 0, y: 1.0, percentage: 0 }, { x: 0.5, y: 0.5 }, { x: 1, y: 0.1, percentage: 1 }] },
|
|
441
|
+
b: { type: LifeTimeCurve.BEZIER, bezierPoints: [{ x: 0, y: 0.4, percentage: 0 }, { x: 0.5, y: 0.9 }, { x: 1, y: 1.0, percentage: 1 }] },
|
|
442
|
+
},
|
|
443
|
+
},
|
|
444
|
+
}
|
|
445
|
+
```
|
|
446
|
+
|
|
353
447
|
---
|
|
354
448
|
|
|
355
449
|
## Texture Sheet Animation
|
|
@@ -426,7 +520,7 @@ const system = createParticleSystem({
|
|
|
426
520
|
`BEZIER` | `EASING`
|
|
427
521
|
|
|
428
522
|
### RendererType
|
|
429
|
-
`POINTS` (default — classic point sprites) | `INSTANCED` (GPU instanced quads, no gl_PointSize limit)
|
|
523
|
+
`POINTS` (default — classic point sprites) | `INSTANCED` (GPU instanced quads, no gl_PointSize limit) | `TRAIL` (ribbon trails behind particles) | `MESH` (3D mesh particles via GPU instancing)
|
|
430
524
|
|
|
431
525
|
---
|
|
432
526
|
|
package/llms.txt
CHANGED
|
@@ -75,6 +75,53 @@ function animate() {
|
|
|
75
75
|
|
|
76
76
|
- `RendererType.POINTS` (default) — Classic point sprites via `THREE.Points`
|
|
77
77
|
- `RendererType.INSTANCED` — Camera-facing quads via `InstancedBufferGeometry`, removes `gl_PointSize` hardware limit
|
|
78
|
+
- `RendererType.TRAIL` — Ribbon trails behind particles with configurable width, opacity, and color tapering
|
|
79
|
+
- `RendererType.MESH` — Render each particle as a 3D mesh (cubes, spheres, custom geometry) via GPU instancing with quaternion-based 3D rotation and directional lighting. Uses solid white default texture (not circle) to preserve mesh shape. Sub-emitters do not inherit MESH or TRAIL rendererType from parent
|
|
80
|
+
|
|
81
|
+
## Mesh Particle Renderer
|
|
82
|
+
|
|
83
|
+
Configure via `renderer.mesh`:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
renderer: {
|
|
87
|
+
rendererType: RendererType.MESH,
|
|
88
|
+
blending: THREE.NormalBlending,
|
|
89
|
+
transparent: true,
|
|
90
|
+
depthTest: true,
|
|
91
|
+
depthWrite: true,
|
|
92
|
+
mesh: {
|
|
93
|
+
geometry: new THREE.BoxGeometry(1, 1, 1), // Any THREE.BufferGeometry
|
|
94
|
+
},
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Mesh particles use GPU instancing (`InstancedBufferGeometry`). Each particle is a full 3D mesh with quaternion rotation, normals, and UVs preserved. All modifiers (sizeOverLifetime, colorOverLifetime, noise, force fields, sub-emitters) work with mesh particles.
|
|
99
|
+
|
|
100
|
+
## Trail / Ribbon Renderer
|
|
101
|
+
|
|
102
|
+
Configure via `renderer.trail`:
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
renderer: {
|
|
106
|
+
rendererType: RendererType.TRAIL,
|
|
107
|
+
blending: THREE.AdditiveBlending,
|
|
108
|
+
transparent: true,
|
|
109
|
+
trail: {
|
|
110
|
+
length: 40, // History samples per particle (default: 20)
|
|
111
|
+
width: 0.5, // Ribbon width in world units (default: 1.0)
|
|
112
|
+
widthOverTrail: { ... }, // LifetimeCurve: width taper (0=head, 1=tail)
|
|
113
|
+
opacityOverTrail: { ... }, // LifetimeCurve: opacity taper
|
|
114
|
+
colorOverTrail: { // Optional per-channel color multipliers
|
|
115
|
+
isActive: true,
|
|
116
|
+
r: { type: LifeTimeCurve.BEZIER, bezierPoints: [...] },
|
|
117
|
+
g: { type: LifeTimeCurve.BEZIER, bezierPoints: [...] },
|
|
118
|
+
b: { type: LifeTimeCurve.BEZIER, bezierPoints: [...] },
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Trails use GPU billboard rendering (vertex shader). Supports optional textures and soft-edge fade.
|
|
78
125
|
|
|
79
126
|
## Emitter Shapes
|
|
80
127
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newkrok/three-particles",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.13.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Three.js-based high-performance particle system library designed for creating visually stunning particle effects with ease. Perfect for game developers and 3D applications.",
|
|
6
6
|
"main": "./dist/index.js",
|