@newkrok/three-particles 2.13.0 → 2.14.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 +124 -2
- package/dist/index.js +764 -128
- 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/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,6 +22,7 @@ Particle system for ThreeJS.
|
|
|
22
22
|
* GPU instancing renderer (`RendererType.INSTANCED`) — removes `gl_PointSize` hardware limit, ideal for large particles or high particle counts.
|
|
23
23
|
* Trail / Ribbon renderer (`RendererType.TRAIL`) — continuous ribbon trails behind particles with configurable width, opacity, and color tapering.
|
|
24
24
|
* Mesh particle renderer (`RendererType.MESH`) — render each particle as a 3D mesh (debris, gems, coins) using GPU instancing with full 3D rotation and simple directional lighting.
|
|
25
|
+
* Soft particles — depth-based alpha fade near opaque geometry, eliminating hard intersection lines.
|
|
25
26
|
* TypeDoc API documentation available.
|
|
26
27
|
|
|
27
28
|
# Live Demo & Examples
|
package/dist/index.d.ts
CHANGED
|
@@ -697,6 +697,59 @@ type TrailConfig = {
|
|
|
697
697
|
g: LifetimeCurve;
|
|
698
698
|
b: LifetimeCurve;
|
|
699
699
|
};
|
|
700
|
+
/**
|
|
701
|
+
* Minimum distance (in world units) a particle must travel before a new
|
|
702
|
+
* trail sample is recorded. When set, the trail becomes frame-rate
|
|
703
|
+
* independent — at high FPS the samples are spread further apart in time,
|
|
704
|
+
* at low FPS they cluster around sharp turns.
|
|
705
|
+
*
|
|
706
|
+
* When `0` or `undefined`, a sample is recorded every frame (legacy behavior).
|
|
707
|
+
* @default 0
|
|
708
|
+
*/
|
|
709
|
+
minVertexDistance?: number;
|
|
710
|
+
/**
|
|
711
|
+
* Maximum trail duration in seconds. Trail segments older than this value
|
|
712
|
+
* are faded out and expired, regardless of the ring-buffer `length`.
|
|
713
|
+
* This enables time-based trail length (e.g. "2-second trails") in addition
|
|
714
|
+
* to the segment-count cap.
|
|
715
|
+
*
|
|
716
|
+
* When `0` or `undefined`, trail length is governed only by `length`.
|
|
717
|
+
* @default 0
|
|
718
|
+
*/
|
|
719
|
+
maxTime?: number;
|
|
720
|
+
/**
|
|
721
|
+
* Enable Catmull-Rom spline interpolation between history samples.
|
|
722
|
+
* Inserts additional subdivided points between raw samples, eliminating
|
|
723
|
+
* sharp kinks at trail bends. The `smoothingSubdivisions` property controls
|
|
724
|
+
* how many extra points are inserted per segment.
|
|
725
|
+
*
|
|
726
|
+
* @default false
|
|
727
|
+
*/
|
|
728
|
+
smoothing?: boolean;
|
|
729
|
+
/**
|
|
730
|
+
* Number of Catmull-Rom subdivisions inserted between each pair of raw
|
|
731
|
+
* history samples when `smoothing` is enabled. Higher values produce
|
|
732
|
+
* smoother curves at the cost of more vertices.
|
|
733
|
+
*
|
|
734
|
+
* @default 3
|
|
735
|
+
*/
|
|
736
|
+
smoothingSubdivisions?: number;
|
|
737
|
+
/**
|
|
738
|
+
* Enable twist prevention for the ribbon. Uses frame tracking to maintain
|
|
739
|
+
* consistent ribbon orientation during rapid direction changes, preventing
|
|
740
|
+
* self-intersecting or flipped ribbon quads.
|
|
741
|
+
*
|
|
742
|
+
* @default false
|
|
743
|
+
*/
|
|
744
|
+
twistPrevention?: boolean;
|
|
745
|
+
/**
|
|
746
|
+
* Connect multiple particles into a single continuous ribbon.
|
|
747
|
+
* All particles that share the same `ribbonId` are sorted by age and
|
|
748
|
+
* their positions are chained into one continuous strip.
|
|
749
|
+
*
|
|
750
|
+
* When `undefined`, each particle has its own independent trail (default behavior).
|
|
751
|
+
*/
|
|
752
|
+
ribbonId?: number;
|
|
700
753
|
};
|
|
701
754
|
/**
|
|
702
755
|
* Configuration for the mesh particle renderer.
|
|
@@ -790,6 +843,53 @@ type Renderer = {
|
|
|
790
843
|
* @see MeshConfig
|
|
791
844
|
*/
|
|
792
845
|
mesh?: MeshConfig;
|
|
846
|
+
/**
|
|
847
|
+
* Soft particles configuration.
|
|
848
|
+
* When enabled, particles fade smoothly near opaque geometry instead of
|
|
849
|
+
* producing a hard intersection line. Requires a depth texture from a
|
|
850
|
+
* `WebGLRenderTarget`.
|
|
851
|
+
*
|
|
852
|
+
* @see SoftParticlesConfig
|
|
853
|
+
*/
|
|
854
|
+
softParticles?: SoftParticlesConfig;
|
|
855
|
+
};
|
|
856
|
+
/**
|
|
857
|
+
* Configuration for soft (depth-faded) particles.
|
|
858
|
+
* When enabled, particles fade out smoothly near opaque geometry instead
|
|
859
|
+
* of producing a hard intersection line.
|
|
860
|
+
*
|
|
861
|
+
* Requires a depth texture from a `WebGLRenderTarget` with `DepthTexture`.
|
|
862
|
+
* If `depthTexture` is not provided, soft particles are automatically disabled
|
|
863
|
+
* regardless of the `enabled` flag.
|
|
864
|
+
*
|
|
865
|
+
* @property enabled - Whether soft particle fading is active. @default false
|
|
866
|
+
* @property intensity - Controls the fade distance in world units. Higher values
|
|
867
|
+
* produce a wider fade zone. Typical range: 0.1 to 5.0. @default 1.0
|
|
868
|
+
* @property depthTexture - A `THREE.DepthTexture` attached to the render target
|
|
869
|
+
* that contains the scene's depth pass. Must be updated every frame before
|
|
870
|
+
* the particle system renders.
|
|
871
|
+
*
|
|
872
|
+
* @example
|
|
873
|
+
* // Create a render target with a depth texture
|
|
874
|
+
* const rt = new THREE.WebGLRenderTarget(width, height, {
|
|
875
|
+
* depthTexture: new THREE.DepthTexture(width, height),
|
|
876
|
+
* });
|
|
877
|
+
*
|
|
878
|
+
* // Pass it to the particle system config
|
|
879
|
+
* const config = {
|
|
880
|
+
* renderer: {
|
|
881
|
+
* softParticles: {
|
|
882
|
+
* enabled: true,
|
|
883
|
+
* intensity: 1.5,
|
|
884
|
+
* depthTexture: rt.depthTexture,
|
|
885
|
+
* },
|
|
886
|
+
* },
|
|
887
|
+
* };
|
|
888
|
+
*/
|
|
889
|
+
type SoftParticlesConfig = {
|
|
890
|
+
enabled?: boolean;
|
|
891
|
+
intensity?: number;
|
|
892
|
+
depthTexture?: THREE.DepthTexture;
|
|
793
893
|
};
|
|
794
894
|
/**
|
|
795
895
|
* Configuration for noise effects applied to particles in a particle system.
|
|
@@ -1613,6 +1713,22 @@ type GeneralData = {
|
|
|
1613
1713
|
trailLength?: number;
|
|
1614
1714
|
/** Cached camera world position, updated each frame via onBeforeRender for billboard trails. */
|
|
1615
1715
|
trailCameraPosition?: THREE.Vector3;
|
|
1716
|
+
/**
|
|
1717
|
+
* Timestamp (in ms) when each trail history sample was recorded.
|
|
1718
|
+
* Used by `maxTime` to expire old segments.
|
|
1719
|
+
* Layout: `maxParticles * trailLength` entries.
|
|
1720
|
+
*/
|
|
1721
|
+
trailSampleTimes?: Float64Array;
|
|
1722
|
+
/**
|
|
1723
|
+
* Last recorded position per particle for adaptive sampling (`minVertexDistance`).
|
|
1724
|
+
* Layout: `maxParticles * 3` (x, y, z).
|
|
1725
|
+
*/
|
|
1726
|
+
trailLastSampledPosition?: Float32Array;
|
|
1727
|
+
/**
|
|
1728
|
+
* Per-particle previous ribbon normal vector for twist prevention.
|
|
1729
|
+
* Layout: `maxParticles * 3` (nx, ny, nz).
|
|
1730
|
+
*/
|
|
1731
|
+
trailPrevNormal?: Float32Array;
|
|
1616
1732
|
};
|
|
1617
1733
|
/** Union of all buffer attribute types Three.js uses in geometry. */
|
|
1618
1734
|
type AnyBufferAttribute = THREE.BufferAttribute | THREE.InstancedBufferAttribute | THREE.InterleavedBufferAttribute;
|
|
@@ -1695,10 +1811,16 @@ type ParticleSystemInstance = {
|
|
|
1695
1811
|
g: CurveFunction;
|
|
1696
1812
|
b: CurveFunction;
|
|
1697
1813
|
};
|
|
1698
|
-
/** Trail config (length, width) */
|
|
1814
|
+
/** Trail config (length, width, and advanced features) */
|
|
1699
1815
|
trailConfig?: {
|
|
1700
1816
|
length: number;
|
|
1701
1817
|
width: number;
|
|
1818
|
+
minVertexDistance: number;
|
|
1819
|
+
maxTime: number;
|
|
1820
|
+
smoothing: boolean;
|
|
1821
|
+
smoothingSubdivisions: number;
|
|
1822
|
+
twistPrevention: boolean;
|
|
1823
|
+
ribbonId?: number;
|
|
1702
1824
|
};
|
|
1703
1825
|
};
|
|
1704
1826
|
/**
|
|
@@ -2199,4 +2321,4 @@ declare const getDefaultParticleSystemConfig: () => any;
|
|
|
2199
2321
|
declare const createParticleSystem: (config?: ParticleSystemConfig, externalNow?: number) => ParticleSystem;
|
|
2200
2322
|
declare const updateParticleSystems: (cycleData: CycleData) => void;
|
|
2201
2323
|
|
|
2202
|
-
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 MeshConfig, 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, createDefaultMeshTexture, createDefaultParticleTexture, createParticleSystem, curveFunctionIdMap, getBezierCacheSize, getCurveFunction, getCurveFunctionFromConfig, getDefaultParticleSystemConfig, isLifeTimeCurve, removeBezierCurveFunction, updateParticleSystems };
|
|
2324
|
+
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 MeshConfig, 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 SoftParticlesConfig, type Sphere, type SubEmitterConfig, SubEmitterTrigger, type TextureSheetAnimation, TimeMode, type TrailConfig, type Transform, type VelocityOverLifetime, applyModifiers, blendingMap, calculateRandomPositionAndVelocityOnBox, calculateRandomPositionAndVelocityOnCircle, calculateRandomPositionAndVelocityOnCone, calculateRandomPositionAndVelocityOnRectangle, calculateRandomPositionAndVelocityOnSphere, calculateValue, createBezierCurveFunction, createDefaultMeshTexture, createDefaultParticleTexture, createParticleSystem, curveFunctionIdMap, getBezierCacheSize, getCurveFunction, getCurveFunctionFromConfig, getDefaultParticleSystemConfig, isLifeTimeCurve, removeBezierCurveFunction, updateParticleSystems };
|