r3-legacy/src/game-lib-api-entity.js

63 lines
1.4 KiB
JavaScript
Raw Normal View History

2016-11-29 12:54:25 +01:00
/**
2016-12-12 17:24:05 +01:00
* Entity API Object (for storing / loading entities to and from API)
2016-11-29 12:54:25 +01:00
* @param id
* @param name
2016-12-12 17:24:05 +01:00
* @param components GameLib.D3.Component[]
2016-11-29 12:54:25 +01:00
* @param position
* @param quaternion
* @param scale
2016-12-09 20:32:09 +01:00
* @param parentScene GameLib.D3.Scene
* @param mesh GameLib.D3.Mesh
2016-11-29 12:54:25 +01:00
* @constructor
*/
2016-12-12 17:24:05 +01:00
GameLib.D3.API.Entity = function(
2016-11-29 12:54:25 +01:00
id,
name,
2016-12-12 17:24:05 +01:00
components,
2016-11-29 12:54:25 +01:00
position,
quaternion,
scale,
parentScene,
mesh
) {
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
2016-12-02 16:03:03 +01:00
id = GameLib.D3.Utils.RandomId();
2016-11-29 12:54:25 +01:00
}
this.id = id;
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
name = this.constructor.name;
}
this.name = name;
2016-12-12 17:24:05 +01:00
if (GameLib.D3.Utils.UndefinedOrNull(components)) {
components = [];
2016-11-29 12:54:25 +01:00
}
2016-12-12 17:24:05 +01:00
this.components = components;
2016-11-29 12:54:25 +01:00
if(GameLib.D3.Utils.UndefinedOrNull(position)) {
2016-12-02 13:00:56 +01:00
position = new GameLib.D3.API.Vector3();
2016-11-29 12:54:25 +01:00
}
this.position = position;
if(GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
2016-12-09 20:32:09 +01:00
quaternion = new GameLib.D3.API.Quaternion();
2016-11-29 12:54:25 +01:00
}
this.quaternion = quaternion;
if(GameLib.D3.Utils.UndefinedOrNull(scale)) {
2016-12-02 13:00:56 +01:00
scale = new GameLib.D3.API.Vector3(1, 1, 1);
2016-11-29 12:54:25 +01:00
}
this.scale = scale;
if (GameLib.D3.Utils.UndefinedOrNull(parentScene)) {
parentScene = null;
}
this.parentScene = parentScene;
if (GameLib.D3.Utils.UndefinedOrNull(mesh)) {
mesh = null;
}
this.mesh = mesh;
};