r3-legacy/src/game-lib-component-colorfla...

37 lines
1003 B
JavaScript

/**
*
* @param id
* @param name
* @constructor
*/
GameLib.D3.ComponentColorFlash = function ComponentColorFlash(
id,
name
) {
this.id = id || GameLib.D3.Tools.RandomId();
if (typeof name == 'undefined') {
name = this.constructor.name;
}
this.name = name;
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();
};