diff --git a/src/game-lib-d3-api-custom-code.js b/src/game-lib-d3-api-custom-code.js index 4f73b34..dee8436 100644 --- a/src/game-lib-d3-api-custom-code.js +++ b/src/game-lib-d3-api-custom-code.js @@ -30,7 +30,7 @@ GameLib.D3.API.CustomCode = function ( this.eventId = eventId; if (GameLib.Utils.UndefinedOrNull(code)) { - code = 'return null;'; + code = "return null;\n//@ sourceURL=" + this.name + ".js"; } this.code = code; diff --git a/src/game-lib-system-gui.js b/src/game-lib-system-gui.js index 3266aa6..a43ebaf 100644 --- a/src/game-lib-system-gui.js +++ b/src/game-lib-system-gui.js @@ -714,7 +714,57 @@ GameLib.System.GUI.prototype.buildControl = function(folder, componentTemplate, } ) ); - } else if (property === 'broadphaseType') { + } else if (property === 'positionOffsetType') { + controllers.push( + folder.add( + object, + property, + { + 'constant': GameLib.D3.Particle.POSITION_OFFSET_TYPE_CONSTANT, + 'random': GameLib.D3.Particle.POSITION_OFFSET_TYPE_RANDOM, + 'function': GameLib.D3.Particle.POSITION_OFFSET_TYPE_FUNCTION + } + ) + ); + } else if (property === 'directionType') { + controllers.push( + folder.add( + object, + property, + { + 'constant': GameLib.D3.Particle.DIRECTION_TYPE_CONSTANT, + 'random': GameLib.D3.Particle.DIRECTION_TYPE_RANDOM, + 'function': GameLib.D3.Particle.DIRECTION_TYPE_FUNCTION + } + ) + ); + } else if (property === 'scaleType') { + controllers.push( + folder.add( + object, + property, + { + 'constant': GameLib.D3.Particle.SCALE_TYPE_CONSTANT, + 'linear': GameLib.D3.Particle.SCALE_TYPE_LINEAR, + 'exponential': GameLib.D3.Particle.SCALE_TYPE_EXPONENTIAL, + 'random': GameLib.D3.Particle.SCALE_TYPE_RANDOM, + 'function': GameLib.D3.Particle.SCALE_TYPE_FUNCTION + } + ) + ); + } else if (property === 'rotationType') { + controllers.push( + folder.add( + object, + property, + { + 'constant': GameLib.D3.Particle.ROTATION_TYPE_CONSTANT, + 'random': GameLib.D3.Particle.ROTATION_TYPE_RANDOM, + 'function': GameLib.D3.Particle.ROTATION_TYPE_FUNCTION + } + ) + ); + } else if (property === 'broadphaseType') { controllers.push( folder.add( object, diff --git a/src/game-lib-system-particle.js b/src/game-lib-system-particle.js index 64bc785..eb10058 100644 --- a/src/game-lib-system-particle.js +++ b/src/game-lib-system-particle.js @@ -113,13 +113,44 @@ GameLib.System.Particle.prototype.beforeRender = function(data) { function(particleEngine) { particleEngine.elapsed += data.delta; - particleEngine.processParticles(data.delta); + + particleEngine.particles = particleEngine.particles.reduce( + + function(result, particle){ + + particle.position.x += particle.userData.direction.x * data.delta; + particle.position.y += particle.userData.direction.y * data.delta; + particle.position.z += particle.userData.direction.z * data.delta; + + particle.userData.elapsed += data.delta; + if (particle.userData.elapsed > particle.userData.lifeTime) { + particle.parent.remove(particle); + } else { + result.push(particle); + } + + return result; + }, + [] + ); if (particleEngine.enabled) { if (particleEngine.elapsed > particleEngine.frequency) { + particleEngine.elapsed = 0; - particleEngine.createNewParticle(this.camera); + + + var particleInstance = particleEngine.templateParticle.cloneInstance(); + + particleEngine.particles.push(particleInstance); + + particleEngine.templateParticle.parentScene.instance.add(particleInstance); + + particleInstance.userData.direction = this.direction.instance.clone(); + particleInstance.userData.elapsed = 0; + particleInstance.userData.lifeTime = this.lifeTime; + } }