naive extension of classes.
parent
92c7b6db6c
commit
2098af0c7e
File diff suppressed because one or more lines are too long
|
@ -166,6 +166,30 @@ GameLib.D3.Color = function(r, g, b, a) {
|
||||||
this.b = b;
|
this.b = b;
|
||||||
this.a = a;
|
this.a = a;
|
||||||
};
|
};
|
||||||
|
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();
|
||||||
|
};
|
||||||
GameLib.D3.ComponentInterface = function(
|
GameLib.D3.ComponentInterface = function(
|
||||||
componentId
|
componentId
|
||||||
) {
|
) {
|
||||||
|
@ -4763,6 +4787,17 @@ GameLib.D3.TriangleFace.prototype.equals = function(triangle) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
GameLib.D3.Utils = function() {};
|
||||||
|
GameLib.D3.Utils.Extend = function(
|
||||||
|
child, // child class
|
||||||
|
parent // parent class
|
||||||
|
) {
|
||||||
|
for(var prop in parent.prototype) {
|
||||||
|
if(!child.prototype[prop]) {
|
||||||
|
child.prototype[prop] = parent.prototype[prop];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
GameLib.D3.Vector2 = function(x, y) {
|
GameLib.D3.Vector2 = function(x, y) {
|
||||||
|
|
||||||
this.x = 0;
|
this.x = 0;
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
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();
|
||||||
|
};
|
|
@ -0,0 +1,11 @@
|
||||||
|
GameLib.D3.Utils = function() {};
|
||||||
|
GameLib.D3.Utils.Extend = function(
|
||||||
|
child, // child class
|
||||||
|
parent // parent class
|
||||||
|
) {
|
||||||
|
for(var prop in parent.prototype) {
|
||||||
|
if(!child.prototype[prop]) {
|
||||||
|
child.prototype[prop] = parent.prototype[prop];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue