/** * Raycaster for GameLib.D3 * @param id * @param name * @param position GameLib.API.Vector3 * @param direction GameLib.API.Vector3 * @constructor */ GameLib.D3.API.Raycaster = function( id, name, position, direction ) { if (GameLib.Utils.UndefinedOrNull(id)) { id = GameLib.Utils.RandomId(); } this.id = id; if (GameLib.Utils.UndefinedOrNull(name)) { name = 'Raycaster (' + this.id + ')'; } this.name = name; 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; }; /** * Returns an API raycaster from an Object raycaster * @param objectRaycaster * @constructor */ GameLib.D3.API.Raycaster.FromObjectRaycaster = function(objectRaycaster) { return new GameLib.D3.API.Raycaster( objectRaycaster.id, objectRaycaster.name, GameLib.API.Vector3.FromObjectVector(objectRaycaster.position), GameLib.API.Vector3.FromObjectVector(objectRaycaster.direction) ); };