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

104 lines
2.1 KiB
JavaScript
Raw Normal View History

2016-11-29 12:54:25 +01:00
/**
* Entity API
* @param id
* @param name
* @param ids
* @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
*/
GameLib.D3.API.Entity = function Entity(
id,
name,
ids,
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;
if (GameLib.D3.Utils.UndefinedOrNull(ids)) {
ids = [];
}
this.ids = ids;
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;
};
2016-12-02 13:11:56 +01:00
GameLib.D3.Entity = function Entity(
id,
name,
ids,
position,
quaternion,
scale
) {
this.id = id;
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
name = this.constructor.name;
}
this.name = name;
if (GameLib.D3.Utils.UndefinedOrNull(ids)) {
ids = [];
}
this.ids = ids;
// constructed at runtime
this.parentScene = null;
this.mesh = null;
if(GameLib.D3.Utils.UndefinedOrNull(position)) {
2016-12-02 16:03:03 +01:00
position = new GameLib.D3.API.Vector3(0, 0, 0);
2016-12-02 13:11:56 +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(0, 0, 0, 1);
2016-12-02 13:11:56 +01:00
}
this.quaternion = quaternion;
if(GameLib.D3.Utils.UndefinedOrNull(scale)) {
2016-12-02 16:03:03 +01:00
scale = new GameLib.D3.API.Vector3(1, 1, 1);
2016-12-02 13:11:56 +01:00
}
this.scale = scale;
};