Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ var particleEmitter = new ShaderParticleEmitter({
// [OPTIONAL] Particle end size.
sizeEnd: 10,

// [OPTIONAL] Particle start rotation.
particleRotation: 0

// [OPTIONAL] Particle rotation variance ( in radians ).
particleRotationSpread: 0

// [OPTIONAL] Particle start colour.
colorStart: new THREE.Color( 'white' ),
Expand Down Expand Up @@ -253,4 +258,4 @@ See the [issues page](https://github.com/squarefeet/ShaderParticleEngine/issues)

Thanks
======
Huge thanks are extended to [Stemkoski](http://stemkoski.github.io/Three.js/) for his initial particle engine, and to [Mr Doob, AlteredQualia, et. al](https://github.com/mrdoob/three.js/graphs/contributors) for their awesome work on [THREE.js](http://threejs.org/).
Huge thanks are extended to [Stemkoski](http://stemkoski.github.io/Three.js/) for his initial particle engine, and to [Mr Doob, AlteredQualia, et. al](https://github.com/mrdoob/three.js/graphs/contributors) for their awesome work on [THREE.js](http://threejs.org/).
10 changes: 8 additions & 2 deletions build/ShaderParticles.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ ShaderParticleGroup.prototype = {
opacity[i] = emitter.opacityStart;
opacityMiddle[i] = emitter.opacityMiddle;
opacityEnd[i] = emitter.opacityEnd;
rotation[i] = that._randomFloat( emitter.particleRotation, emitter.particleRotationSpread );
}

// Cache properties on the emitter so we can access
Expand Down Expand Up @@ -505,6 +506,7 @@ ShaderParticleGroup.shaders = {

'attribute vec3 customColor;',
'attribute vec3 customColorEnd;',
'attribute float rotation;',
'attribute float opacity;',
'attribute float opacityMiddle;',
'attribute float opacityEnd;',
Expand All @@ -517,6 +519,7 @@ ShaderParticleGroup.shaders = {
'attribute float sizeEnd;',

'varying vec4 vColor;',
'varying float vRotation;',

// Linearly lerp a float
'float Lerp( float start, float end, float amount ) {',
Expand Down Expand Up @@ -552,6 +555,8 @@ ShaderParticleGroup.shaders = {

'void main() {',

'vRotation = rotation;',

'float positionInTime = (age / duration);',
'float halfDuration = (duration / 2.0);',

Expand Down Expand Up @@ -610,10 +615,11 @@ ShaderParticleGroup.shaders = {
'uniform int colorize;',

'varying vec4 vColor;',
'varying float vRotation;',

'void main() {',
'float c = cos(0.0);',
'float s = sin(0.0);',
'float c = cos( vRotation );',
'float s = sin( vRotation );',

'vec2 rotatedUV = vec2(c * (gl_PointCoord.x - 0.5) + s * (gl_PointCoord.y - 0.5) + 0.5,',
'c * (gl_PointCoord.y - 0.5) - s * (gl_PointCoord.x - 0.5) + 0.5);',
Expand Down
3 changes: 3 additions & 0 deletions src/ShaderParticleEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ function ShaderParticleEmitter( options ) {
that.colorEnd = options.colorEnd instanceof THREE.Color ? options.colorEnd : new THREE.Color( 'blue' );
that.colorSpread = options.colorSpread instanceof THREE.Vector3 ? options.colorSpread : new THREE.Vector3();

that.particleRotation = parseFloat( typeof options.particleRotation === 'number' ? options.particleRotation : 0, 10 );
that.particleRotationSpread = parseFloat( typeof options.particleRotationSpread === 'number' ? options.particleRotationSpread : 0, 10 );

that.opacityStart = parseFloat( typeof options.opacityStart !== 'undefined' ? options.opacityStart : 1, 10 );
that.opacityEnd = parseFloat( typeof options.opacityEnd === 'number' ? options.opacityEnd : 0, 10 );
that.opacityMiddle = parseFloat(
Expand Down