|
@@ -15,7 +15,7 @@
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
|
|
|
|
-THREE.GPUParticleSystem = function( options ) {
|
|
|
|
|
|
+THREE.GPUParticleSystem = function ( options ) {
|
|
|
|
|
|
THREE.Object3D.apply( this, arguments );
|
|
THREE.Object3D.apply( this, arguments );
|
|
|
|
|
|
@@ -158,13 +158,13 @@ THREE.GPUParticleSystem = function( options ) {
|
|
|
|
|
|
var i;
|
|
var i;
|
|
|
|
|
|
- for ( i = 1e5; i > 0; i-- ) {
|
|
|
|
|
|
+ for ( i = 1e5; i > 0; i -- ) {
|
|
|
|
|
|
this.rand.push( Math.random() - 0.5 );
|
|
this.rand.push( Math.random() - 0.5 );
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- this.random = function() {
|
|
|
|
|
|
+ this.random = function () {
|
|
|
|
|
|
return ++ i >= this.rand.length ? this.rand[ i = 1 ] : this.rand[ i ];
|
|
return ++ i >= this.rand.length ? this.rand[ i = 1 ] : this.rand[ i ];
|
|
|
|
|
|
@@ -205,7 +205,7 @@ THREE.GPUParticleSystem = function( options ) {
|
|
this.particleShaderMat.defaultAttributeValues.particlePositionsStartTime = [ 0, 0, 0, 0 ];
|
|
this.particleShaderMat.defaultAttributeValues.particlePositionsStartTime = [ 0, 0, 0, 0 ];
|
|
this.particleShaderMat.defaultAttributeValues.particleVelColSizeLife = [ 0, 0, 0, 0 ];
|
|
this.particleShaderMat.defaultAttributeValues.particleVelColSizeLife = [ 0, 0, 0, 0 ];
|
|
|
|
|
|
- this.init = function() {
|
|
|
|
|
|
+ this.init = function () {
|
|
|
|
|
|
for ( var i = 0; i < this.PARTICLE_CONTAINERS; i ++ ) {
|
|
for ( var i = 0; i < this.PARTICLE_CONTAINERS; i ++ ) {
|
|
|
|
|
|
@@ -217,7 +217,7 @@ THREE.GPUParticleSystem = function( options ) {
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
- this.spawnParticle = function( options ) {
|
|
|
|
|
|
+ this.spawnParticle = function ( options ) {
|
|
|
|
|
|
this.PARTICLE_CURSOR ++;
|
|
this.PARTICLE_CURSOR ++;
|
|
|
|
|
|
@@ -233,7 +233,7 @@ THREE.GPUParticleSystem = function( options ) {
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
- this.update = function( time ) {
|
|
|
|
|
|
+ this.update = function ( time ) {
|
|
|
|
|
|
for ( var i = 0; i < this.PARTICLE_CONTAINERS; i ++ ) {
|
|
for ( var i = 0; i < this.PARTICLE_CONTAINERS; i ++ ) {
|
|
|
|
|
|
@@ -243,7 +243,7 @@ THREE.GPUParticleSystem = function( options ) {
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
- this.dispose = function() {
|
|
|
|
|
|
+ this.dispose = function () {
|
|
|
|
|
|
this.particleShaderMat.dispose();
|
|
this.particleShaderMat.dispose();
|
|
this.particleNoiseTex.dispose();
|
|
this.particleNoiseTex.dispose();
|
|
@@ -267,7 +267,7 @@ THREE.GPUParticleSystem.prototype.constructor = THREE.GPUParticleSystem;
|
|
|
|
|
|
// Subclass for particle containers, allows for very large arrays to be spread out
|
|
// Subclass for particle containers, allows for very large arrays to be spread out
|
|
|
|
|
|
-THREE.GPUParticleContainer = function( maxParticles, particleSystem ) {
|
|
|
|
|
|
+THREE.GPUParticleContainer = function ( maxParticles, particleSystem ) {
|
|
|
|
|
|
THREE.Object3D.apply( this, arguments );
|
|
THREE.Object3D.apply( this, arguments );
|
|
|
|
|
|
@@ -301,7 +301,7 @@ THREE.GPUParticleContainer = function( maxParticles, particleSystem ) {
|
|
var velocity = new THREE.Vector3();
|
|
var velocity = new THREE.Vector3();
|
|
var color = new THREE.Color();
|
|
var color = new THREE.Color();
|
|
|
|
|
|
- this.spawnParticle = function( options ) {
|
|
|
|
|
|
+ this.spawnParticle = function ( options ) {
|
|
|
|
|
|
var positionStartAttribute = this.particleShaderGeo.getAttribute( 'positionStart' );
|
|
var positionStartAttribute = this.particleShaderGeo.getAttribute( 'positionStart' );
|
|
var startTimeAttribute = this.particleShaderGeo.getAttribute( 'startTime' );
|
|
var startTimeAttribute = this.particleShaderGeo.getAttribute( 'startTime' );
|
|
@@ -402,7 +402,7 @@ THREE.GPUParticleContainer = function( maxParticles, particleSystem ) {
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
- this.init = function() {
|
|
|
|
|
|
+ this.init = function () {
|
|
|
|
|
|
this.particleSystem = new THREE.Points( this.particleShaderGeo, this.particleShaderMat );
|
|
this.particleSystem = new THREE.Points( this.particleShaderGeo, this.particleShaderMat );
|
|
this.particleSystem.frustumCulled = false;
|
|
this.particleSystem.frustumCulled = false;
|
|
@@ -410,7 +410,7 @@ THREE.GPUParticleContainer = function( maxParticles, particleSystem ) {
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
- this.update = function( time ) {
|
|
|
|
|
|
+ this.update = function ( time ) {
|
|
|
|
|
|
this.time = time;
|
|
this.time = time;
|
|
this.particleShaderMat.uniforms.uTime.value = time;
|
|
this.particleShaderMat.uniforms.uTime.value = time;
|
|
@@ -419,7 +419,7 @@ THREE.GPUParticleContainer = function( maxParticles, particleSystem ) {
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
- this.geometryUpdate = function() {
|
|
|
|
|
|
+ this.geometryUpdate = function () {
|
|
|
|
|
|
if ( this.particleUpdate === true ) {
|
|
if ( this.particleUpdate === true ) {
|
|
|
|
|
|
@@ -462,13 +462,13 @@ THREE.GPUParticleContainer = function( maxParticles, particleSystem ) {
|
|
lifeTimeAttribute.updateRange.offset = 0;
|
|
lifeTimeAttribute.updateRange.offset = 0;
|
|
|
|
|
|
// Use -1 to update the entire buffer, see #11476
|
|
// Use -1 to update the entire buffer, see #11476
|
|
- positionStartAttribute.updateRange.count = -1;
|
|
|
|
- startTimeAttribute.updateRange.count = -1;
|
|
|
|
- velocityAttribute.updateRange.count = -1;
|
|
|
|
- turbulenceAttribute.updateRange.count = -1;
|
|
|
|
- colorAttribute.updateRange.count = -1;
|
|
|
|
- sizeAttribute.updateRange.count = -1;
|
|
|
|
- lifeTimeAttribute.updateRange.count = -1;
|
|
|
|
|
|
+ positionStartAttribute.updateRange.count = - 1;
|
|
|
|
+ startTimeAttribute.updateRange.count = - 1;
|
|
|
|
+ velocityAttribute.updateRange.count = - 1;
|
|
|
|
+ turbulenceAttribute.updateRange.count = - 1;
|
|
|
|
+ colorAttribute.updateRange.count = - 1;
|
|
|
|
+ sizeAttribute.updateRange.count = - 1;
|
|
|
|
+ lifeTimeAttribute.updateRange.count = - 1;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -487,7 +487,7 @@ THREE.GPUParticleContainer = function( maxParticles, particleSystem ) {
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
- this.dispose = function() {
|
|
|
|
|
|
+ this.dispose = function () {
|
|
|
|
|
|
this.particleShaderGeo.dispose();
|
|
this.particleShaderGeo.dispose();
|
|
|
|
|