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

104 lines
2.1 KiB
JavaScript

/**
* Entity API
* @param id
* @param name
* @param ids
* @param position
* @param quaternion
* @param scale
* @param parentScene
* @param mesh
* @constructor
*/
GameLib.D3.API.Entity = function Entity(
id,
name,
ids,
position,
quaternion,
scale,
parentScene,
mesh
) {
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
id = GameLib.D3.Tools.RandomId();
}
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)) {
position = new GameLib.D3.API.Vector3();
}
this.position = position;
if(GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
quaternion = new GameLib.D3.API.Vector4();
}
this.quaternion = quaternion;
if(GameLib.D3.Utils.UndefinedOrNull(scale)) {
scale = new GameLib.D3.API.Vector3(1, 1, 1);
}
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;
};
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)) {
position = new GameLib.D3.Vector3(0, 0, 0);
}
this.position = position;
if(GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
quaternion = new GameLib.D3.Vector4(0, 0, 0, 1);
}
this.quaternion = quaternion;
if(GameLib.D3.Utils.UndefinedOrNull(scale)) {
scale = new GameLib.D3.Vector3(1, 1, 1);
}
this.scale = scale;
};