Skip to content

cstrlcs/glam-js

Repository files navigation

glam-js

A simple and fast 3D math library for games and graphics. Written in TypeScript.


Quick Links 📚


Overview 📖

glam-js is a TypeScript port of the incredible glam-rs library. Its primary objective is to provide a straightforward and efficient 3D math library for game development and computer graphics, written entirely in TypeScript.

Although some features specific to Rust are not available in TypeScript, glam-js aims to offer a similar API.

Notable Changes:

  • Unified types for number and boolean vectors
  • Removal of Rust-specific methods related to the borrow checker
  • Elimination of SIMD support
  • Transition from snake_case to camelCase for naming conventions

Development status 🚧

glam-js is currently in active development and is not yet suitable for production use. While some types are still missing, the Vector types have already been ported.

Features 🌟

  • ✨ Simple to use: since the code is generated, the API is super simple to understand
  • 📦 0 dependencies
  • 🔢 number types
    • vectors: Vec2, Vec3 and Vec4
    • square matrices: Mat2, Mat3, Mat3A and Mat4 (⚠️ PARTIAL, untested)
    • a quaternion type: Quat (⚠️ WIP)
    • affine transformation types: Affine2 and Affine3A (⚠️ WIP)
  • ☑️ boolean types
    • vectors: BVec2, BVec3 and BVec4

Design Philosophy 📐

The design of this library is guided by a desire for simplicity and good performance.

  • No generics and minimal type complexity in the public API for simplicity of usage
  • Aiming for 100% test [coverage]

Installation 🛠️

  1. Add the package to your project:
npm i glam-js
  1. Import the package into your project:
import { Vec3 } from "glam-js";

const vec = new Vec3(1, 2, 3);

vec.div(3);
vec.normalize();

Inspirations 🌌

The code in glam-js is a direct port of the Rust library glam-rs, which in turn has inspirations for the interface and internals of glam from the Rust and C++ worlds. In particular:

License 📜

Licensed under either of

at your option.

Contributing 🤝

Contributions in any form (issues, pull requests, etc.) to this project must adhere to Rust's Code of Conduct and NPM's Code of Conduct.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

If you are interested in contributing or have a request or suggestion [start a discussion] on GitHub. See [CONTRIBUTING.md] (TBA) for more information for contributors.

Most code in glam-js is generated, see the [codegen README] (TBA) for details.

Attribution 🙏

glam contains code ported from the following C++ libraries:

  • DirectXMath - MIT License - Copyright (c) 2011-2020 Microsoft Corp
  • Realtime Math - MIT License - Copyright (c) 2018 Nicholas Frechette
  • GLM - MIT License - Copyright (c) 2005 - G-Truc Creation

See ATTRIBUTION.md for details.

About

A simple and fast linear algebra library for games and graphics (ported from bitshifter/glam-rs)

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published