opacity factor for particle system
parent
3a2b045c2e
commit
840797d38b
|
@ -5,6 +5,8 @@
|
|||
* @param lifeTime
|
||||
* @param elapsed
|
||||
* @param mesh
|
||||
* @param opacityType
|
||||
* @param opacityFactor
|
||||
* @param positionOffsetType
|
||||
* @param positionOffset
|
||||
* @param positionOffsetFn
|
||||
|
@ -28,6 +30,8 @@ GameLib.D3.API.Particle = function(
|
|||
lifeTime,
|
||||
elapsed,
|
||||
mesh,
|
||||
opacityType,
|
||||
opacityFactor,
|
||||
positionOffsetType,
|
||||
positionOffset,
|
||||
positionOffsetFn,
|
||||
|
@ -70,6 +74,16 @@ GameLib.D3.API.Particle = function(
|
|||
}
|
||||
this.mesh = mesh;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(opacityType)) {
|
||||
opacityType = GameLib.D3.Particle.OPACITY_TYPE_CONSTANT;
|
||||
}
|
||||
this.opacityType = opacityType;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(opacityFactor)) {
|
||||
opacityFactor = 0.01;
|
||||
}
|
||||
this.opacityFactor = opacityFactor;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(positionOffsetType)) {
|
||||
positionOffsetType = GameLib.D3.Particle.POSITION_OFFSET_TYPE_CONSTANT;
|
||||
}
|
||||
|
@ -171,6 +185,8 @@ GameLib.D3.API.Particle.FromObject = function(objectParticle) {
|
|||
objectParticle.lifeTime,
|
||||
objectParticle.elapsed,
|
||||
apiMesh,
|
||||
objectParticle.opacityType,
|
||||
objectParticle.opacityFactor,
|
||||
objectParticle.positionOffsetType,
|
||||
GameLib.API.Vector3.FromObject(objectParticle.positionOffset),
|
||||
objectParticle.positionOffsetFn,
|
||||
|
|
|
@ -27,6 +27,8 @@ GameLib.D3.Particle = function(
|
|||
apiParticle.lifeTime,
|
||||
apiParticle.elapsed,
|
||||
apiParticle.mesh,
|
||||
apiParticle.opacityType,
|
||||
apiParticle.opacityFactor,
|
||||
apiParticle.positionOffsetType,
|
||||
apiParticle.positionOffset,
|
||||
apiParticle.positionOffsetFn,
|
||||
|
@ -109,6 +111,10 @@ GameLib.D3.Particle = function(
|
|||
GameLib.D3.Particle.prototype = Object.create(GameLib.D3.API.Particle.prototype);
|
||||
GameLib.D3.Particle.prototype.constructor = GameLib.D3.Particle;
|
||||
|
||||
GameLib.D3.Particle.OPACITY_TYPE_CONSTANT = 0x1;
|
||||
GameLib.D3.Particle.OPACITY_TYPE_DECREASE_LINEAR = 0x2;
|
||||
GameLib.D3.Particle.OPACITY_TYPE_INCREASE_LINEAR = 0x3;
|
||||
|
||||
GameLib.D3.Particle.POSITION_OFFSET_TYPE_CONSTANT = 0x1;
|
||||
GameLib.D3.Particle.POSITION_OFFSET_TYPE_RANDOM = 0x2;
|
||||
GameLib.D3.Particle.POSITION_OFFSET_TYPE_FUNCTION = 0x3;
|
||||
|
@ -186,6 +192,8 @@ GameLib.D3.Particle.prototype.toApiObject = function() {
|
|||
this.lifeTime,
|
||||
this.elapsed,
|
||||
GameLib.Utils.IdOrNull(this.mesh),
|
||||
this.opacityType,
|
||||
this.opacityFactor,
|
||||
this.positionOffsetType,
|
||||
this.positionOffset.toApiObject(),
|
||||
this.positionOffsetFn,
|
||||
|
|
|
@ -714,7 +714,19 @@ GameLib.System.GUI.prototype.buildControl = function(folder, componentTemplate,
|
|||
}
|
||||
)
|
||||
);
|
||||
} else if (property === 'positionOffsetType') {
|
||||
} else if (property === 'opacityType') {
|
||||
controllers.push(
|
||||
folder.add(
|
||||
object,
|
||||
property,
|
||||
{
|
||||
'constant': GameLib.D3.Particle.OPACITY_TYPE_CONSTANT,
|
||||
'decrease': GameLib.D3.Particle.OPACITY_TYPE_DECREASE_LINEAR,
|
||||
'increase': GameLib.D3.Particle.OPACITY_TYPE_INCREASE_LINEAR
|
||||
}
|
||||
)
|
||||
);
|
||||
} else if (property === 'positionOffsetType') {
|
||||
controllers.push(
|
||||
folder.add(
|
||||
object,
|
||||
|
@ -1133,6 +1145,7 @@ GameLib.System.GUI.prototype.buildControl = function(folder, componentTemplate,
|
|||
*/
|
||||
if (
|
||||
property === 'opacity' ||
|
||||
property === 'opacityFactor' ||
|
||||
property === 'metalness' ||
|
||||
property === 'roughness'
|
||||
) {
|
||||
|
|
|
@ -132,7 +132,13 @@ GameLib.System.Particle.prototype.beforeRender = function(data) {
|
|||
|
||||
particle.quaternion.copy(particleEngine.camera.instance.quaternion);
|
||||
|
||||
particle.material.opacity -= 0.033333;
|
||||
if (particleEngine.templateParticle.opacityType === GameLib.D3.Particle.OPACITY_TYPE_INCREASE_LINEAR) {
|
||||
particle.material.opacity += particleEngine.templateParticle.opacityFactor;
|
||||
}
|
||||
|
||||
if (particleEngine.templateParticle.opacityType === GameLib.D3.Particle.OPACITY_TYPE_DECREASE_LINEAR) {
|
||||
particle.material.opacity -= particleEngine.templateParticle.opacityFactor;
|
||||
}
|
||||
|
||||
particle.userData.elapsed += data.delta;
|
||||
if (
|
||||
|
|
Loading…
Reference in New Issue