@newkrok/three-particles 0.6.2 → 0.7.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
CHANGED
|
@@ -7,6 +7,7 @@ Particle system for ThreeJS
|
|
|
7
7
|
You can create your own particle effects with it's editor https://github.com/NewKrok/three-particles-editor
|
|
8
8
|
|
|
9
9
|
# Video
|
|
10
|
+
|
|
10
11
|
- Projectiles: https://youtu.be/Q352JuxON04
|
|
11
12
|
- First preview: https://youtu.be/dtN_bndvoGU
|
|
12
13
|
|
|
@@ -22,4 +23,4 @@ Install with npm
|
|
|
22
23
|
`npm i @newkrok/three-particles`
|
|
23
24
|
|
|
24
25
|
Add as a package.json dependency
|
|
25
|
-
`"dependencies": { ... "@newkrok/three-particles": "0.
|
|
26
|
+
`"dependencies": { ... "@newkrok/three-particles": "0.7.0" ... }, `
|
package/package.json
CHANGED
|
@@ -4,6 +4,9 @@ const ParticleSystemFragmentShader = `
|
|
|
4
4
|
uniform float fps;
|
|
5
5
|
uniform bool useFPSForFrameIndex;
|
|
6
6
|
uniform vec2 tiles;
|
|
7
|
+
uniform bool discardBackgroundColor;
|
|
8
|
+
uniform vec3 backgroundColor;
|
|
9
|
+
uniform float backgroundColorTolerance;
|
|
7
10
|
|
|
8
11
|
varying vec4 vColor;
|
|
9
12
|
varying float vLifetime;
|
|
@@ -56,6 +59,8 @@ const ParticleSystemFragmentShader = `
|
|
|
56
59
|
vec4 rotatedTexture = texture2D(map, uvPoint);
|
|
57
60
|
|
|
58
61
|
gl_FragColor = gl_FragColor * rotatedTexture;
|
|
62
|
+
|
|
63
|
+
if (discardBackgroundColor && abs(length(rotatedTexture.rgb - backgroundColor.rgb)) < backgroundColorTolerance ) discard;
|
|
59
64
|
}
|
|
60
65
|
`;
|
|
61
66
|
|
|
@@ -108,6 +108,9 @@ const DEFAULT_PARTICLE_SYSTEM_CONFIG = {
|
|
|
108
108
|
map: null,
|
|
109
109
|
renderer: {
|
|
110
110
|
blending: THREE.NormalBlending,
|
|
111
|
+
discardBackgroundColor: false,
|
|
112
|
+
backgroundColorTolerance: 1.0,
|
|
113
|
+
backgroundColor: { r: 1.0, g: 1.0, b: 1.0 },
|
|
111
114
|
transparent: true,
|
|
112
115
|
depthTest: true,
|
|
113
116
|
depthWrite: false,
|
|
@@ -391,6 +394,15 @@ export const createParticleSystem = (
|
|
|
391
394
|
useFPSForFrameIndex: {
|
|
392
395
|
value: textureSheetAnimation.timeMode === TimeMode.FPS,
|
|
393
396
|
},
|
|
397
|
+
backgroundColor: {
|
|
398
|
+
value: renderer.backgroundColor,
|
|
399
|
+
},
|
|
400
|
+
discardBackgroundColor: {
|
|
401
|
+
value: renderer.discardBackgroundColor,
|
|
402
|
+
},
|
|
403
|
+
backgroundColorTolerance: {
|
|
404
|
+
value: renderer.backgroundColorTolerance,
|
|
405
|
+
},
|
|
394
406
|
},
|
|
395
407
|
vertexShader: ParticleSystemVertexShader,
|
|
396
408
|
fragmentShader: ParticleSystemFragmentShader,
|