@newkrok/three-particles 2.11.1 → 2.12.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 +1 -0
- package/dist/index.d.ts +108 -2
- package/dist/index.js +498 -2
- 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 +58 -0
- package/llms.txt +27 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,6 +20,7 @@ Particle system for ThreeJS.
|
|
|
20
20
|
* Sub-emitters triggered on particle birth or death events.
|
|
21
21
|
* Serialization support for saving and loading particle system configs.
|
|
22
22
|
* GPU instancing renderer (`RendererType.INSTANCED`) — removes `gl_PointSize` hardware limit, ideal for large particles or high particle counts.
|
|
23
|
+
* Trail / Ribbon renderer (`RendererType.TRAIL`) — continuous ribbon trails behind particles with configurable width, opacity, and color tapering.
|
|
23
24
|
* TypeDoc API documentation available.
|
|
24
25
|
|
|
25
26
|
# Live Demo & Examples
|
package/dist/index.d.ts
CHANGED
|
@@ -169,7 +169,18 @@ declare const enum RendererType {
|
|
|
169
169
|
* and enables batching multiple emitters into fewer draw calls.
|
|
170
170
|
* Recommended for 10 000+ particles or when large on-screen particle sizes are needed.
|
|
171
171
|
*/
|
|
172
|
-
INSTANCED = "INSTANCED"
|
|
172
|
+
INSTANCED = "INSTANCED",
|
|
173
|
+
/**
|
|
174
|
+
* Render each particle as a ribbon trail connecting its current and previous positions.
|
|
175
|
+
* Each particle stores a configurable number of position history samples, and the
|
|
176
|
+
* renderer builds a camera-facing triangle-strip ribbon through those samples.
|
|
177
|
+
*
|
|
178
|
+
* Trail width and opacity can taper along the ribbon length for effects like
|
|
179
|
+
* sword slashes, magic missiles, comet tails, and speed lines.
|
|
180
|
+
*
|
|
181
|
+
* Configure trail-specific properties via {@link TrailConfig} on the renderer.
|
|
182
|
+
*/
|
|
183
|
+
TRAIL = "TRAIL"
|
|
173
184
|
}
|
|
174
185
|
/**
|
|
175
186
|
* Defines how force diminishes with distance from a POINT force field center.
|
|
@@ -620,6 +631,57 @@ type TextureSheetAnimation = {
|
|
|
620
631
|
fps?: number;
|
|
621
632
|
startFrame?: Constant | RandomBetweenTwoConstants;
|
|
622
633
|
};
|
|
634
|
+
/**
|
|
635
|
+
* Configuration for the trail/ribbon renderer.
|
|
636
|
+
* Controls how particle trails are drawn when using `RendererType.TRAIL`.
|
|
637
|
+
*
|
|
638
|
+
* @property length - Number of position history samples per particle (trail segments).
|
|
639
|
+
* Higher values produce longer, smoother trails but cost more memory.
|
|
640
|
+
* @default 20
|
|
641
|
+
* @property widthOverTrail - Lifetime curve that controls the ribbon width along its length.
|
|
642
|
+
* At 0 the trail head (current position), at 1 the trail tail (oldest position).
|
|
643
|
+
* @default constant 1.0
|
|
644
|
+
* @property opacityOverTrail - Lifetime curve that controls opacity along the trail length.
|
|
645
|
+
* @default linear fade from 1 (head) to 0 (tail)
|
|
646
|
+
*
|
|
647
|
+
* @example
|
|
648
|
+
* ```typescript
|
|
649
|
+
* // Long comet-style trail tapering to nothing
|
|
650
|
+
* trail: {
|
|
651
|
+
* length: 40,
|
|
652
|
+
* widthOverTrail: {
|
|
653
|
+
* type: LifeTimeCurve.BEZIER,
|
|
654
|
+
* scale: 1,
|
|
655
|
+
* bezierPoints: [
|
|
656
|
+
* { x: 0, y: 1, percentage: 0 },
|
|
657
|
+
* { x: 0.5, y: 0.4 },
|
|
658
|
+
* { x: 1, y: 0, percentage: 1 },
|
|
659
|
+
* ],
|
|
660
|
+
* },
|
|
661
|
+
* }
|
|
662
|
+
* ```
|
|
663
|
+
*/
|
|
664
|
+
type TrailConfig = {
|
|
665
|
+
/** Number of position history samples per particle. @default 20 */
|
|
666
|
+
length?: number;
|
|
667
|
+
/** Base ribbon width in world units. @default 1.0 */
|
|
668
|
+
width?: number;
|
|
669
|
+
/** Curve controlling ribbon width from head (0) to tail (1). */
|
|
670
|
+
widthOverTrail?: LifetimeCurve;
|
|
671
|
+
/** Curve controlling opacity from head (0) to tail (1). */
|
|
672
|
+
opacityOverTrail?: LifetimeCurve;
|
|
673
|
+
/**
|
|
674
|
+
* Per-channel color multiplier curves along the trail (head=0, tail=1).
|
|
675
|
+
* Works as multipliers on the particle's current color, same as colorOverLifetime.
|
|
676
|
+
* To achieve full color transitions, use white startColor.
|
|
677
|
+
*/
|
|
678
|
+
colorOverTrail?: {
|
|
679
|
+
isActive: boolean;
|
|
680
|
+
r: LifetimeCurve;
|
|
681
|
+
g: LifetimeCurve;
|
|
682
|
+
b: LifetimeCurve;
|
|
683
|
+
};
|
|
684
|
+
};
|
|
623
685
|
/**
|
|
624
686
|
* Configuration for the particle system renderer, controlling blending, transparency, depth, and background color behavior.
|
|
625
687
|
*
|
|
@@ -673,6 +735,13 @@ type Renderer = {
|
|
|
673
735
|
* @default RendererType.POINTS
|
|
674
736
|
*/
|
|
675
737
|
rendererType?: RendererType;
|
|
738
|
+
/**
|
|
739
|
+
* Trail/ribbon renderer configuration.
|
|
740
|
+
* Only used when `rendererType` is `RendererType.TRAIL`.
|
|
741
|
+
*
|
|
742
|
+
* @see TrailConfig
|
|
743
|
+
*/
|
|
744
|
+
trail?: TrailConfig;
|
|
676
745
|
};
|
|
677
746
|
/**
|
|
678
747
|
* Configuration for noise effects applied to particles in a particle system.
|
|
@@ -1482,6 +1551,20 @@ type GeneralData = {
|
|
|
1482
1551
|
isEnabled: boolean;
|
|
1483
1552
|
/** Tracks the state of each burst emission event */
|
|
1484
1553
|
burstStates?: Array<BurstState>;
|
|
1554
|
+
/**
|
|
1555
|
+
* Circular buffer storing position history for trail renderer.
|
|
1556
|
+
* Each particle has `trailLength` slots of (x, y, z) positions.
|
|
1557
|
+
* Only allocated when `RendererType.TRAIL` is used.
|
|
1558
|
+
*/
|
|
1559
|
+
positionHistory?: Float32Array;
|
|
1560
|
+
/** Write index per particle into the circular position history buffer. */
|
|
1561
|
+
positionHistoryIndex?: Uint16Array;
|
|
1562
|
+
/** Number of valid history samples per particle (fills up from 0 to trailLength). */
|
|
1563
|
+
positionHistoryCount?: Uint16Array;
|
|
1564
|
+
/** Trail length (number of history samples per particle). */
|
|
1565
|
+
trailLength?: number;
|
|
1566
|
+
/** Cached camera world position, updated each frame via onBeforeRender for billboard trails. */
|
|
1567
|
+
trailCameraPosition?: THREE.Vector3;
|
|
1485
1568
|
};
|
|
1486
1569
|
/** Union of all buffer attribute types Three.js uses in geometry. */
|
|
1487
1570
|
type AnyBufferAttribute = THREE.BufferAttribute | THREE.InstancedBufferAttribute | THREE.InterleavedBufferAttribute;
|
|
@@ -1544,6 +1627,29 @@ type ParticleSystemInstance = {
|
|
|
1544
1627
|
onParticleDeath?: (particleIndex: number, positionArr: THREE.TypedArray, velocity: THREE.Vector3, now: number) => void;
|
|
1545
1628
|
/** Called when a particle is born to trigger birth sub-emitters */
|
|
1546
1629
|
onParticleBirth?: (particleIndex: number, positionArr: THREE.TypedArray, velocity: THREE.Vector3, now: number) => void;
|
|
1630
|
+
/** Trail mesh for RendererType.TRAIL */
|
|
1631
|
+
trailMesh?: THREE.Mesh;
|
|
1632
|
+
/** Trail geometry position attribute */
|
|
1633
|
+
trailPositionAttr?: THREE.BufferAttribute;
|
|
1634
|
+
/** Trail geometry alpha attribute */
|
|
1635
|
+
trailAlphaAttr?: THREE.BufferAttribute;
|
|
1636
|
+
/** Trail geometry color attribute */
|
|
1637
|
+
trailColorAttr?: THREE.BufferAttribute;
|
|
1638
|
+
/** Trail width curve function */
|
|
1639
|
+
trailWidthCurveFn?: CurveFunction;
|
|
1640
|
+
/** Trail opacity curve function */
|
|
1641
|
+
trailOpacityCurveFn?: CurveFunction;
|
|
1642
|
+
/** Trail color-over-trail curve functions (r, g, b multipliers) */
|
|
1643
|
+
trailColorOverTrailFns?: {
|
|
1644
|
+
r: CurveFunction;
|
|
1645
|
+
g: CurveFunction;
|
|
1646
|
+
b: CurveFunction;
|
|
1647
|
+
};
|
|
1648
|
+
/** Trail config (length, width) */
|
|
1649
|
+
trailConfig?: {
|
|
1650
|
+
length: number;
|
|
1651
|
+
width: number;
|
|
1652
|
+
};
|
|
1547
1653
|
};
|
|
1548
1654
|
/**
|
|
1549
1655
|
* Represents a particle system instance, providing methods to control and manage its lifecycle.
|
|
@@ -2036,4 +2142,4 @@ declare const getDefaultParticleSystemConfig: () => any;
|
|
|
2036
2142
|
declare const createParticleSystem: (config?: ParticleSystemConfig, externalNow?: number) => ParticleSystem;
|
|
2037
2143
|
declare const updateParticleSystems: (cycleData: CycleData) => void;
|
|
2038
2144
|
|
|
2039
|
-
export { type BezierCurve, type BezierPoint, type Box, type Burst, type BurstState, type Circle, type Cone, type Constant, type CurveBase, type CurveFunction, CurveFunctionId, type CycleData, type EasingCurve, type Emission, EmitFrom, type ForceFieldConfig, ForceFieldFalloff, ForceFieldType, type GeneralData, LifeTimeCurve, type LifetimeCurve, type MappedAttributes, type MinMaxColor, type Noise, type NoiseConfig, type NormalizedForceFieldConfig, type NormalizedParticleSystemConfig, type ParticleSystem, type ParticleSystemConfig, type ParticleSystemInstance, type Point3D, type RandomBetweenTwoConstants, type Rectangle, type Renderer, RendererType, type Rgb, Shape, type ShapeConfig, SimulationSpace, type Sphere, type SubEmitterConfig, SubEmitterTrigger, type TextureSheetAnimation, TimeMode, type Transform, type VelocityOverLifetime, applyModifiers, blendingMap, calculateRandomPositionAndVelocityOnBox, calculateRandomPositionAndVelocityOnCircle, calculateRandomPositionAndVelocityOnCone, calculateRandomPositionAndVelocityOnRectangle, calculateRandomPositionAndVelocityOnSphere, calculateValue, createBezierCurveFunction, createDefaultParticleTexture, createParticleSystem, curveFunctionIdMap, getBezierCacheSize, getCurveFunction, getCurveFunctionFromConfig, getDefaultParticleSystemConfig, isLifeTimeCurve, removeBezierCurveFunction, updateParticleSystems };
|
|
2145
|
+
export { type BezierCurve, type BezierPoint, type Box, type Burst, type BurstState, type Circle, type Cone, type Constant, type CurveBase, type CurveFunction, CurveFunctionId, type CycleData, type EasingCurve, type Emission, EmitFrom, type ForceFieldConfig, ForceFieldFalloff, ForceFieldType, type GeneralData, LifeTimeCurve, type LifetimeCurve, type MappedAttributes, type MinMaxColor, type Noise, type NoiseConfig, type NormalizedForceFieldConfig, type NormalizedParticleSystemConfig, type ParticleSystem, type ParticleSystemConfig, type ParticleSystemInstance, type Point3D, type RandomBetweenTwoConstants, type Rectangle, type Renderer, RendererType, type Rgb, Shape, type ShapeConfig, SimulationSpace, type Sphere, type SubEmitterConfig, SubEmitterTrigger, type TextureSheetAnimation, TimeMode, type TrailConfig, type Transform, type VelocityOverLifetime, applyModifiers, blendingMap, calculateRandomPositionAndVelocityOnBox, calculateRandomPositionAndVelocityOnCircle, calculateRandomPositionAndVelocityOnCone, calculateRandomPositionAndVelocityOnRectangle, calculateRandomPositionAndVelocityOnSphere, calculateValue, createBezierCurveFunction, createDefaultParticleTexture, createParticleSystem, curveFunctionIdMap, getBezierCacheSize, getCurveFunction, getCurveFunctionFromConfig, getDefaultParticleSystemConfig, isLifeTimeCurve, removeBezierCurveFunction, updateParticleSystems };
|