2016-11-14 14:48:37 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param id
|
|
|
|
* @param name
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
GameLib.D3.ComponentColorFlash = function ComponentColorFlash(
|
|
|
|
id,
|
|
|
|
name
|
2016-11-01 10:30:55 +01:00
|
|
|
) {
|
2016-11-14 14:48:37 +01:00
|
|
|
this.id = id || GameLib.D3.Tools.RandomId();
|
|
|
|
|
|
|
|
if (typeof name == 'undefined') {
|
|
|
|
name = this.constructor.name;
|
|
|
|
}
|
|
|
|
this.name = name;
|
|
|
|
|
2016-11-01 10:30:55 +01:00
|
|
|
this.parentEntity = null;
|
|
|
|
|
|
|
|
// Todo: this should be executed somewhere in game-lib-z, so that we don't execute it on every construction of an object.
|
|
|
|
GameLib.D3.Utils.Extend(GameLib.D3.ComponentColorFlash, GameLib.D3.ComponentInterface);
|
|
|
|
};
|
|
|
|
|
|
|
|
///////////////////////// Methods to override //////////////////////////
|
|
|
|
GameLib.D3.ComponentColorFlash.prototype.onUpdate = function(
|
|
|
|
deltaTime,
|
|
|
|
parentEntity
|
|
|
|
) {
|
|
|
|
this.parentEntity.mesh.material.color = new THREE.Color(Math.random(), Math.random(), Math.random());
|
|
|
|
};
|
|
|
|
|
|
|
|
GameLib.D3.ComponentColorFlash.prototype.onSetParentEntity = function(
|
|
|
|
parentScene,
|
|
|
|
parentEntity
|
|
|
|
) {
|
|
|
|
parentEntity.mesh.material = new THREE.MeshBasicMaterial();
|
|
|
|
};
|