Skip to content

Releases: AugustinMauroy/vec3

v1.1.0

06 Jun 08:35
ac9322d

Choose a tag to compare

What's Changed

Full Changelog: v1.0.1...v1.1.0

v1.0.1

02 Jun 09:39
1d52463

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v1.0.0...v1.0.1

v1.0.0

04 May 14:40
bf65fb6

Choose a tag to compare

Release Notes - v1.0.0 (Initial Release)

This is the initial release of @augustinmauroy/vec3.

This library provides a small and efficient solution for 3D vector mathematics in JavaScript and TypeScript environments.

Examples

import { Vec3, v } from '@augustinmauroy/vec3';

// Create vectors using the constructor
const v1 = new Vec3(1, 2, 3);
const v2 = new Vec3(4, 5, 6);

// Create vectors using the helper function
const v3 = v(7, 8, 9); // From numbers
const v4 = v([10, 11, 12]); // From an array
const v5 = v({ x: 13, y: 14, z: 15 }); // From an object
const v6 = v('(1, -1, 3.14)'); // From a string representation

// Perform operations (most methods modify the vector in place)
v1.add(v2); // v1 is now (5, 7, 9)
console.log(v1.toString()); // Output: (5, 7, 9)

// Use immutable operations (return a new Vec3 instance)
const sum = v3.plus(v4); // sum is (17, 19, 21), v3 remains unchanged
console.log(sum.toString()); // Output: (17, 19, 21)

const scaled = v5.scaled(2); // scaled is (26, 28, 30), v5 remains unchanged
console.log(scaled.toString()); // Output: (26, 28, 30)

// Calculate distance
const distance = v1.distanceTo(v2);
console.log(distance);

// Normalize a vector
const normalized = v3.unit(); // normalized is a unit vector, v3 remains unchanged
console.log(normalized.norm()); // Output: ~1