@amandaghassaei/vector-math

中文文档
1.1.8发布于 2025/12/10MITTypeScriptES Module零依赖近 30 天下载 1810

A minimal vector math library to handle 2D/3D translations and rotations, written in TypeScript.

原始使用文档
文档目录7 节
  1. Installation
  2. Install via NPM
  3. Install as JS
  4. Use
  5. License
  6. Acknowledgments
  7. Development

@amandaghassaei/vector-math

NPM Package Build Size NPM Downloads License

A minimal vector math library to handle 2D/3D translations and rotations.

  • Written in Typescript with exported type declarations.
  • Supports Three.js's Vector2, Vector3, and Quaternion types as inputs.
  • Includes readonly class types.
  • Includes unit tests with 100% coverage.

Table of Contents:

Installation

Install via NPM

npm install @amandaghassaei/vector-math

Then import via:

import { Vector2 } from '@amandaghassaei/vector-math';

Install as JS

OR in the browser you can add bundle/vector-math.js or bundle/vector-math.min.js to your html:

<html>
    <head>
        ....
        <script src="vector-math.min.js"></script>
    </head>
    <body>
    </body>
</html>

Then in your js files, you can access the global variable VECTOR_MATH:

const { Vector2 } = VECTOR_MATH;

Use

See full API documentation in docs/.

License

This work is distributed under an MIT license. It has no dependencies.

Acknowledgments

Most of this library has been ported from Three.js's source code.

Development

Feel free to submit pull requests pertaining to bugs or type issues, but I probably won't want to expand the functionality of this library much beyond where it is currently. There are other libraries out there that cover a wider range of linear algebra functions and types, this library is meant to be small and bounded in its scope.

Install dev-dependencies:

npm install

Build from src to dist and compile docs:

npm run build

Test with code coverage:

npm run test-with-coverage

版本与发布记录

@amandaghassaei/vector-math 共发布 41 个版本,首次发布于 2023/06/07;过去 12 个月发布了 1 个版本。

版本发布日期距今
1.1.8latest2025/12/1010 个月前
1.1.72025/08/061.3 年前
1.1.62025/07/261.3 年前
1.1.52025/07/261.3 年前
1.1.42025/07/261.3 年前
1.1.32025/07/251.3 年前

关于 @amandaghassaei/vector-math 的常见问题

@amandaghassaei/vector-math 是什么?

A minimal vector math library to handle 2D/3D translations and rotations, written in TypeScript.

如何安装 @amandaghassaei/vector-math?

在项目目录运行 npm install @amandaghassaei/vector-math,或使用 pnpm add / yarn add / bun add。

@amandaghassaei/vector-math 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@amandaghassaei/vector-math 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@amandaghassaei/vector-math 可以商用吗?

@amandaghassaei/vector-math 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@amandaghassaei/vector-math 的下载量有多少?

根据 npm 官方下载统计,@amandaghassaei/vector-math 在 2026/10/06 – 2026/11/04 这 30 天内被下载 1,810 次,日均约 60 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@amandaghassaei/vector-math 还在维护吗?

最新版本 1.1.8 发布于 2025/12/10(10 个月前);至今共发布 41 个版本,其中过去 12 个月发布了 1 个;首次发布于 2023/06/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。