added some stuff to rotator & offsettor components. also added some docs + lapcounter to the main.js
parent
52af3c1f3d
commit
490001d316
|
@ -1,8 +1,9 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id {String}
|
||||||
* @param name
|
* @param name {String}
|
||||||
* @param parent
|
* @param parent {GameLib.D3.Entity}
|
||||||
|
* @param centerToOrigin {Boolean}
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.ComponentEntityParent = function ComponentEntityParent(
|
GameLib.D3.ComponentEntityParent = function ComponentEntityParent(
|
||||||
|
|
|
@ -34,7 +34,7 @@ GameLib.D3.ComponentEntityPermutation = function ComponentEntityPermutation(
|
||||||
|
|
||||||
|
|
||||||
if(GameLib.D3.Utils.UndefinedOrNull(scaleOffset)) {
|
if(GameLib.D3.Utils.UndefinedOrNull(scaleOffset)) {
|
||||||
scaleOffset = new GameLib.D3.Vector3(0, 0, 0);
|
scaleOffset = new GameLib.D3.Vector3(1, 1, 1);
|
||||||
} this.scaleOffset = scaleOffset;
|
} this.scaleOffset = scaleOffset;
|
||||||
|
|
||||||
GameLib.D3.Utils.Extend(GameLib.D3.ComponentEntityPermutation, GameLib.D3.ComponentInterface);
|
GameLib.D3.Utils.Extend(GameLib.D3.ComponentEntityPermutation, GameLib.D3.ComponentInterface);
|
||||||
|
@ -71,7 +71,7 @@ GameLib.D3.ComponentEntityPermutation.prototype.onUpdate = function(
|
||||||
ComponentEntityPermutation_scale.copy(parentEntity.scale);
|
ComponentEntityPermutation_scale.copy(parentEntity.scale);
|
||||||
|
|
||||||
ComponentEntityPermutation_offsetScale.copy(this.scaleOffset);
|
ComponentEntityPermutation_offsetScale.copy(this.scaleOffset);
|
||||||
ComponentEntityPermutation_scale = ComponentEntityPermutation_scale.add(ComponentEntityPermutation_offsetScale);
|
ComponentEntityPermutation_scale = ComponentEntityPermutation_scale.multiply(ComponentEntityPermutation_offsetScale);
|
||||||
|
|
||||||
parentEntity.position.x = ComponentEntityPermutation_position.x;
|
parentEntity.position.x = ComponentEntityPermutation_position.x;
|
||||||
parentEntity.position.y = ComponentEntityPermutation_position.y;
|
parentEntity.position.y = ComponentEntityPermutation_position.y;
|
||||||
|
|
|
@ -25,7 +25,7 @@ GameLib.D3.ComponentMeshPermutation = function ComponentMeshPermutation(
|
||||||
|
|
||||||
this.positionOffset = positionOffset || new GameLib.D3.Vector3(0, 0, 0);
|
this.positionOffset = positionOffset || new GameLib.D3.Vector3(0, 0, 0);
|
||||||
this.quaternionOffset = quaternionOffset || new GameLib.D3.Vector4(0, 0, 0, 1);
|
this.quaternionOffset = quaternionOffset || new GameLib.D3.Vector4(0, 0, 0, 1);
|
||||||
this.scaleOffset = scaleOffset || new GameLib.D3.Vector3(0, 0, 0);
|
this.scaleOffset = scaleOffset || new GameLib.D3.Vector3(1, 1, 1);
|
||||||
|
|
||||||
// Todo: this should be executed somewhere in game-lib-z, so that we don't execute it on every construction of an object.
|
// 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.ComponentMeshPermutation, GameLib.D3.ComponentInterface);
|
GameLib.D3.Utils.Extend(GameLib.D3.ComponentMeshPermutation, GameLib.D3.ComponentInterface);
|
||||||
|
@ -62,7 +62,7 @@ GameLib.D3.ComponentMeshPermutation.prototype.onLateUpdate = function(
|
||||||
ComponentMeshPermutation_scale.copy(parentEntity.mesh.scale);
|
ComponentMeshPermutation_scale.copy(parentEntity.mesh.scale);
|
||||||
|
|
||||||
ComponentMeshPermutation_offsetScale.copy(this.scaleOffset);
|
ComponentMeshPermutation_offsetScale.copy(this.scaleOffset);
|
||||||
ComponentMeshPermutation_scale = ComponentMeshPermutation_scale.add(ComponentMeshPermutation_offsetScale);
|
ComponentMeshPermutation_scale = ComponentMeshPermutation_scale.multiply(ComponentMeshPermutation_offsetScale);
|
||||||
|
|
||||||
parentEntity.mesh.position.copy(ComponentMeshPermutation_position);
|
parentEntity.mesh.position.copy(ComponentMeshPermutation_position);
|
||||||
parentEntity.mesh.quaternion.copy(ComponentMeshPermutation_quaternion);
|
parentEntity.mesh.quaternion.copy(ComponentMeshPermutation_quaternion);
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
* @param id
|
* @param id
|
||||||
* @param name
|
* @param name
|
||||||
* @param axis {GameLib.D3.Vector3}
|
* @param axis {GameLib.D3.Vector3}
|
||||||
* @param getOffsetFunc
|
* @param getOffsetFunc {function}
|
||||||
* @param userData
|
* @param userData {Object}
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.ComponentOffsettor = function ComponentOffsettor(
|
GameLib.D3.ComponentOffsettor = function ComponentOffsettor(
|
||||||
|
@ -23,7 +23,9 @@ GameLib.D3.ComponentOffsettor = function ComponentOffsettor(
|
||||||
this.parentEntity = null;
|
this.parentEntity = null;
|
||||||
|
|
||||||
this.axis = axis || new GameLib.D3.Vector3();
|
this.axis = axis || new GameLib.D3.Vector3();
|
||||||
this.getOffsetFunc = getOffsetFunc || function(entity, component, userData){ return 1; };
|
this.offset = 1;
|
||||||
|
var component = this;
|
||||||
|
this.getOffsetFunc = getOffsetFunc || function(entity, component, userData){ return component.offset; };
|
||||||
this.userData = userData;
|
this.userData = userData;
|
||||||
|
|
||||||
GameLib.D3.Utils.Extend(GameLib.D3.ComponentOffsettor, GameLib.D3.ComponentInterface);
|
GameLib.D3.Utils.Extend(GameLib.D3.ComponentOffsettor, GameLib.D3.ComponentInterface);
|
||||||
|
|
|
@ -39,7 +39,8 @@ GameLib.D3.ComponentPathControls.prototype.onUpdate = function(
|
||||||
if (this.keyForwardPressed) { // Forward [i]
|
if (this.keyForwardPressed) { // Forward [i]
|
||||||
this.pathFollowingComponent.direction = 1;
|
this.pathFollowingComponent.direction = 1;
|
||||||
} else if (this.keyBackPressed){
|
} else if (this.keyBackPressed){
|
||||||
this.pathFollowingComponent.direction = -1;
|
this.pathFollowingComponent.direction = 0;
|
||||||
|
// this.pathFollowingComponent.direction = -1;
|
||||||
} else {
|
} else {
|
||||||
this.pathFollowingComponent.direction = 0;
|
this.pathFollowingComponent.direction = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
* @param id
|
* @param id
|
||||||
* @param name
|
* @param name
|
||||||
* @param axis {GameLib.D3.Vector3}
|
* @param axis {GameLib.D3.Vector3}
|
||||||
* @param getRotationFunc {Number}
|
* @param getRotationFunc {Function}
|
||||||
|
* @param userData {Object}
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.ComponentRotator = function ComponentRotator(
|
GameLib.D3.ComponentRotator = function ComponentRotator(
|
||||||
|
@ -21,8 +22,10 @@ GameLib.D3.ComponentRotator = function ComponentRotator(
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.parentEntity = null;
|
this.parentEntity = null;
|
||||||
|
|
||||||
|
this.rotation = 0;
|
||||||
|
var component = this;
|
||||||
this.axis = axis || new GameLib.D3.Vector3();
|
this.axis = axis || new GameLib.D3.Vector3();
|
||||||
this.getRotationFunc = getRotationFunc || function(entity, component, userData){ return 1; };
|
this.getRotationFunc = getRotationFunc || function(entity, component, userData){ return component.rotation; };
|
||||||
this.userData = userData;
|
this.userData = userData;
|
||||||
|
|
||||||
GameLib.D3.Utils.Extend(GameLib.D3.ComponentRotator, GameLib.D3.ComponentInterface);
|
GameLib.D3.Utils.Extend(GameLib.D3.ComponentRotator, GameLib.D3.ComponentInterface);
|
||||||
|
|
Loading…
Reference in New Issue