2016-12-15 14:53:39 +01:00
|
|
|
/**
|
|
|
|
* Raycaster for GameLib.D3
|
2017-01-09 15:20:48 +01:00
|
|
|
* @param id
|
|
|
|
* @param name
|
2016-12-15 14:53:39 +01:00
|
|
|
* @param position GameLib.API.Vector3
|
|
|
|
* @param direction GameLib.API.Vector3
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
GameLib.D3.API.Raycaster = function(
|
2017-01-09 15:20:48 +01:00
|
|
|
id,
|
|
|
|
name,
|
2016-12-15 14:53:39 +01:00
|
|
|
position,
|
|
|
|
direction
|
|
|
|
) {
|
|
|
|
|
2017-01-09 15:20:48 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
|
|
id = GameLib.Utils.RandomId();
|
|
|
|
}
|
|
|
|
this.id = id;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
|
|
name = 'Raycaster (' + this.id + ')';
|
|
|
|
}
|
|
|
|
this.name = name;
|
|
|
|
|
2016-12-15 14:53:39 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(position)) {
|
|
|
|
position = new GameLib.API.Vector3();
|
|
|
|
}
|
|
|
|
this.position = position;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(direction)) {
|
|
|
|
direction = new GameLib.API.Vector3(0, -1, 0);
|
|
|
|
}
|
|
|
|
this.direction = direction;
|
|
|
|
};
|
2017-01-06 16:53:53 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an API raycaster from an Object raycaster
|
|
|
|
* @param objectRaycaster
|
|
|
|
* @constructor
|
|
|
|
*/
|
2017-06-14 14:21:57 +02:00
|
|
|
GameLib.D3.API.Raycaster.FromObject = function(objectRaycaster) {
|
2017-01-06 16:53:53 +01:00
|
|
|
return new GameLib.D3.API.Raycaster(
|
2017-01-09 15:20:48 +01:00
|
|
|
objectRaycaster.id,
|
|
|
|
objectRaycaster.name,
|
2017-06-14 14:21:57 +02:00
|
|
|
GameLib.API.Vector3.FromObject(objectRaycaster.position),
|
|
|
|
GameLib.API.Vector3.FromObject(objectRaycaster.direction)
|
2017-01-06 16:53:53 +01:00
|
|
|
);
|
|
|
|
};
|