gui updates for particles
parent
ccc030a2eb
commit
fb8bff5277
|
@ -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;
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue