@fimbul-works/vec
Version:
A comprehensive TypeScript vector math library providing 2D, 3D, and 4D vector operations with a focus on performance and type safety.
15 lines (14 loc) • 926 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.lookAt3D = void 0;
const magnitude_3d_js_1 = require("./magnitude-3d.js");
/**
* Creates a vector pointing from the first vector to the second vector, maintaining the magnitude of the first vector.
* @param {ArrayVector3D} xyz1 - First vector as `[x, y, z]` (source direction)
* @param {ArrayVector3D} xyz2 - Second vector as `[x, y, z]` (target direction)
* @param {number} [m1] - Optional current magnitude of the first vector (default: `magnitude3D(xyz1)`)
* @param {number} [m2] - Optional current magnitude of the second vector (default: `magnitude3D(xyz2)`)
* @returns {ArrayVector3D} The look-at vector
*/
const lookAt3D = (xyz1, xyz2, m1 = (0, magnitude_3d_js_1.magnitude3D)(xyz1), m2 = (0, magnitude_3d_js_1.magnitude3D)(xyz2)) => [(xyz2[0] / m2) * m1, (xyz2[1] / m2) * m1, (xyz2[2] / m2) * m1];
exports.lookAt3D = lookAt3D;