UNPKG

@rpgjs/physic

Version:

A deterministic 2D top-down physics library for RPG, sandbox and MMO games

28 lines (27 loc) 623 B
class Ray { /** * Creates a new ray * * @param origin - Ray origin * @param direction - Ray direction * @param length - Maximum length (default: Infinity) */ constructor(origin, direction, length = Infinity) { this.origin = origin.clone(); this.direction = direction.clone().normalizeInPlace(); this.length = length; } /** * Gets a point along the ray * * @param distance - Distance from origin * @returns Point at distance */ getPoint(distance) { return this.origin.add(this.direction.mul(distance)); } } export { Ray }; //# sourceMappingURL=index21.js.map