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

24 lines
839 B
JavaScript
Raw Normal View History

2016-11-01 10:30:55 +01:00
GameLib.D3.ComponentColorFlash = function(
componentId
) {
this.componentId = componentId || GameLib.D3.Tools.RandomId();
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();
};