/** * * Class Name : Particle * Created : 28/08/2012 * Require : Three.js * **/ GAME_ENGINE.Particle = function(picture, psize, max) { this.psize = (psize) ? psize : 20; this.maxParticleCount = (max) ? max : 100; this.emitting = false; this.particlesCount = 0; this.particles = new THREE.Geometry(), this.pMaterial = new THREE.ParticleBasicMaterial({ color: 0xFFFFFF, size: psize, map: THREE.ImageUtils.loadTexture(picture), blending: THREE.AdditiveBlending, transparent: true }); this.particleSystem = new THREE.ParticleSystem(this.particles, this.pMaterial); this.particleSystem.sortParticles = true; this.position = new THREE.Vector3(0, 0, 0); } GAME_ENGINE.Particle.prototype.getEmitter = function() { return this.particleSystem; }; GAME_ENGINE.Particle.prototype.start = function() { this.emitting = true; }; GAME_ENGINE.Particle.prototype.stop = function() { this.emitting = false; }; GAME_ENGINE.Particle.prototype.update = function( delta ) { if (this.emitting) { while(this.particlesCount < this.maxParticleCount) { particle = new THREE.Vertex(this.position ); this.particles.vertices.push(particle); this.particlesCount +=1; } } };