audio system
parent
2560a5c795
commit
a695a2541f
|
@ -0,0 +1,207 @@
|
|||
/**
|
||||
* Raw Particle API object - should always correspond with the Particle Schema
|
||||
* @param id
|
||||
* @param name
|
||||
* @param lifeTime
|
||||
* @param elapsed
|
||||
* @param mesh
|
||||
* @param opacityType
|
||||
* @param opacityFactor
|
||||
* @param positionOffsetType
|
||||
* @param positionOffset
|
||||
* @param positionOffsetFn
|
||||
* @param directionType
|
||||
* @param rotation
|
||||
* @param scale
|
||||
* @param direction
|
||||
* @param directionFn
|
||||
* @param speed
|
||||
* @param scaleFn
|
||||
* @param scaleType
|
||||
* @param rotationType
|
||||
* @param rotationFn
|
||||
* @param parentEngine
|
||||
* @param parentEntity
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.API.Particle = function(
|
||||
id,
|
||||
name,
|
||||
lifeTime,
|
||||
elapsed,
|
||||
mesh,
|
||||
opacityType,
|
||||
opacityFactor,
|
||||
positionOffsetType,
|
||||
positionOffset,
|
||||
positionOffsetFn,
|
||||
directionType,
|
||||
direction,
|
||||
directionFn,
|
||||
speed,
|
||||
scaleType,
|
||||
scale,
|
||||
scaleFn,
|
||||
rotationType,
|
||||
rotation,
|
||||
rotationFn,
|
||||
parentEngine,
|
||||
parentEntity
|
||||
) {
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||
id = GameLib.Utils.RandomId();
|
||||
}
|
||||
this.id = id;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
||||
name = 'Particle (' + this.id + ')';
|
||||
}
|
||||
this.name = name;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(lifeTime)) {
|
||||
lifeTime = 10;
|
||||
}
|
||||
this.lifeTime = lifeTime;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(elapsed)) {
|
||||
elapsed = 0;
|
||||
}
|
||||
this.elapsed = elapsed;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(mesh)) {
|
||||
mesh = null;
|
||||
}
|
||||
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;
|
||||
}
|
||||
this.positionOffsetType = positionOffsetType;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(positionOffset)) {
|
||||
positionOffset = new GameLib.API.Vector3(0, 0, 0);
|
||||
}
|
||||
this.positionOffset = positionOffset;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(positionOffsetFn)) {
|
||||
positionOffsetFn = '//@ sourceURL=positionOffsetFn.js';
|
||||
}
|
||||
this.positionOffsetFn = positionOffsetFn;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(directionType)) {
|
||||
directionType = GameLib.D3.Particle.DIRECTION_TYPE_CONSTANT;
|
||||
}
|
||||
this.directionType = directionType;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(direction)) {
|
||||
direction = new GameLib.API.Vector3(0, 1, 0);
|
||||
}
|
||||
this.direction = direction;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(directionFn)) {
|
||||
directionFn = '//@ sourceURL=directionFn.js';
|
||||
}
|
||||
this.directionFn = directionFn;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(speed)) {
|
||||
speed = 1;
|
||||
}
|
||||
this.speed = speed;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(scaleType)) {
|
||||
scaleType = GameLib.D3.Particle.SCALE_TYPE_CONSTANT;
|
||||
}
|
||||
this.scaleType = scaleType;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(scale)) {
|
||||
scale = new GameLib.API.Vector3(1, 1, 1);
|
||||
}
|
||||
this.scale = scale;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(scaleFn)) {
|
||||
scaleFn = '//@ sourceURL=scaleFn.js';
|
||||
}
|
||||
this.scaleFn = scaleFn;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(rotationType)) {
|
||||
rotationType = GameLib.D3.Particle.ROTATION_TYPE_CONSTANT;
|
||||
}
|
||||
this.rotationType = rotationType;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(rotation)) {
|
||||
rotation = new GameLib.API.Vector3(0, 0, 0);
|
||||
}
|
||||
this.rotation = rotation;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(rotationFn)) {
|
||||
rotationFn = '//@ sourceURL=rotationFn.js';
|
||||
}
|
||||
this.rotationFn = rotationFn;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(parentEngine)) {
|
||||
parentEngine = null;
|
||||
}
|
||||
this.parentEngine = parentEngine;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||
parentEntity = null;
|
||||
}
|
||||
this.parentEntity = parentEntity;
|
||||
};
|
||||
|
||||
GameLib.D3.API.Particle.prototype = Object.create(GameLib.Component.prototype);
|
||||
GameLib.D3.API.Particle.prototype.constructor = GameLib.D3.API.Particle;
|
||||
|
||||
/**
|
||||
* Creates an API Particle from an Object Particle
|
||||
* @param objectParticle
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.API.Particle.FromObject = function(objectParticle) {
|
||||
|
||||
var apiMesh = null;
|
||||
if (objectParticle.mesh) {
|
||||
if (objectParticle.mesh instanceof Object) {
|
||||
apiMesh = GameLib.D3.API.Mesh.FromObject(objectParticle.mesh);
|
||||
} else {
|
||||
apiMesh = objectParticle.mesh;
|
||||
}
|
||||
}
|
||||
|
||||
return new GameLib.D3.API.Particle(
|
||||
objectParticle.id,
|
||||
objectParticle.name,
|
||||
objectParticle.lifeTime,
|
||||
objectParticle.elapsed,
|
||||
apiMesh,
|
||||
objectParticle.opacityType,
|
||||
objectParticle.opacityFactor,
|
||||
objectParticle.positionOffsetType,
|
||||
GameLib.API.Vector3.FromObject(objectParticle.positionOffset),
|
||||
objectParticle.positionOffsetFn,
|
||||
objectParticle.directionType,
|
||||
GameLib.API.Vector3.FromObject(objectParticle.direction),
|
||||
objectParticle.directionFn,
|
||||
objectParticle.speed,
|
||||
objectParticle.scaleType,
|
||||
GameLib.API.Vector3.FromObject(objectParticle.scale),
|
||||
objectParticle.scaleFn,
|
||||
objectParticle.rotationType,
|
||||
GameLib.API.Vector3.FromObject(objectParticle.rotation),
|
||||
objectParticle.rotationFn,
|
||||
objectParticle.parentEngine,
|
||||
objectParticle.parentEntity
|
||||
);
|
||||
|
||||
};
|
|
@ -0,0 +1,78 @@
|
|||
/**
|
||||
* System takes care of updating all the entities (based on their component data)
|
||||
* @param graphics
|
||||
* @param camera
|
||||
* @param apiSystem GameLib.API.System
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.System.Audio = function(
|
||||
graphics,
|
||||
camera,
|
||||
apiSystem
|
||||
) {
|
||||
this.graphics = graphics;
|
||||
this.graphics.isNotThreeThrow();
|
||||
|
||||
GameLib.System.call(
|
||||
this,
|
||||
apiSystem
|
||||
);
|
||||
|
||||
this.instanceCreatedSubscription = null;
|
||||
|
||||
this.removeComponentSubscription = null;
|
||||
|
||||
this.beforeRenderSubscription = null;
|
||||
|
||||
};
|
||||
|
||||
GameLib.System.Audio.prototype = Object.create(GameLib.System.prototype);
|
||||
GameLib.System.Audio.prototype.constructor = GameLib.System.Audio;
|
||||
|
||||
/**
|
||||
* Start this system (add all event listeners)
|
||||
*/
|
||||
GameLib.System.Audio.prototype.start = function() {
|
||||
|
||||
GameLib.System.prototype.start.call(this);
|
||||
|
||||
this.instanceCreatedSubscription = GameLib.Event.Subscribe(
|
||||
GameLib.Event.INSTANCE_CREATED,
|
||||
this.instanceCreated.bind(this)
|
||||
);
|
||||
|
||||
this.removeComponentSubscription = GameLib.Event.Subscribe(
|
||||
GameLib.Event.REMOVE_COMPONENT,
|
||||
this.removeComponent.bind(this)
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* From now on we want to track everything about a component, only from the systems that are active
|
||||
* @param data
|
||||
*/
|
||||
GameLib.System.Audio.prototype.instanceCreated = function(data) {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes a particle engine from this system
|
||||
* @param data
|
||||
*/
|
||||
GameLib.System.Audio.prototype.removeComponent = function(data) {
|
||||
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Stop this system (remove all event listeners)
|
||||
*/
|
||||
GameLib.System.Audio.prototype.stop = function() {
|
||||
|
||||
GameLib.System.prototype.stop.call(this);
|
||||
|
||||
this.instanceCreatedSubscription.remove();
|
||||
this.removeComponentSubscription.remove();
|
||||
|
||||
};
|
|
@ -233,6 +233,16 @@ GameLib.System.GUI.prototype.controller = function(folder, object, property, sub
|
|||
step = 1;
|
||||
}
|
||||
|
||||
if (
|
||||
// property === 'chassisConnectionPointLocal' ||
|
||||
property === 'offset' ||
|
||||
property === 'repeat'
|
||||
) {
|
||||
min = -1000;
|
||||
max = 1000;
|
||||
step = 0.00001;
|
||||
}
|
||||
|
||||
var handle = folder.add(
|
||||
object[property],
|
||||
subProperty,
|
||||
|
|
|
@ -29,6 +29,10 @@ GameLib.System.Particle = function(
|
|||
|
||||
this.totalTime = 0;
|
||||
|
||||
this.instanceCreatedSubscription = null;
|
||||
|
||||
this.removeComponentSubscription = null;
|
||||
|
||||
this.beforeRenderSubscription = null;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue