@wenyin/los.js
v0.1.0
Published
Small dependency-free 3D line-of-sight geometry for browsers and Node.js.
Maintainers
Readme
LOS.js
A small, dependency-free 3D line-of-sight geometry toolkit for modern browsers and Node.js.
npm install @wenyin/los.jsimport { AxisAlignedBox, PinholeCamera, visibilityBetween } from "@wenyin/los.js";
const camera = new PinholeCamera({
origin: [0, 0, 0],
direction: [1, 0, 0],
focalLength: 20,
pixelPitch: 0.005,
width: 640,
height: 480,
});
const wall = new AxisAlignedBox({
id: "wall",
minimum: [4, -1, -1],
maximum: [5, 1, 1],
});
const result = visibilityBetween([0, 0, 0], [10, 0, 0], [wall]);
console.log(result.clear, result.hit?.obstacleId); // false, "wall"
console.log(camera.fieldOfViewDegrees());The package includes:
- normalized 3D rays and vector utilities;
- pinhole-camera pixel rays and Brown–Conrady undistortion;
- plane, sphere, axis-aligned box and vertical-cylinder intersections;
- nearest-hit and point-to-point visibility queries.
All coordinates and distances are unit-agnostic, but every value in one calculation must use the same unit. Inputs are plain JavaScript arrays. The package has no runtime dependencies and does not modify global state.
Device-specific data and advanced analysis are intentionally outside this public package.
License
MIT © WenyinWei.
