vec3 0.1.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,7 @@ jobs:
13
13
 
14
14
  strategy:
15
15
  matrix:
16
- node-version: [18.x]
16
+ node-version: [24.x]
17
17
 
18
18
  steps:
19
19
  - uses: actions/checkout@v2
@@ -3,6 +3,9 @@ on:
3
3
  push:
4
4
  branches:
5
5
  - master # Change this to your default branch
6
+ permissions:
7
+ id-token: write
8
+ contents: write
6
9
  jobs:
7
10
  npm-publish:
8
11
  name: npm-publish
@@ -13,13 +16,12 @@ jobs:
13
16
  - name: Set up Node.js
14
17
  uses: actions/setup-node@master
15
18
  with:
16
- node-version: 18.0.0
19
+ node-version: 24
20
+ registry-url: 'https://registry.npmjs.org'
17
21
  - id: publish
18
- uses: JS-DevTools/npm-publish@v1
19
- with:
20
- token: ${{ secrets.NPM_AUTH_TOKEN }}
22
+ uses: JS-DevTools/npm-publish@v4
21
23
  - name: Create Release
22
- if: steps.publish.outputs.type != 'none'
24
+ if: ${{ steps.publish.outputs.type }}
23
25
  id: create_release
24
26
  uses: actions/create-release@v1
25
27
  env:
package/HISTORY.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 0.2.0
2
+ * [Update CI to Node 24 (#58)](https://github.com/PrismarineJS/node-vec3/commit/b3c068d8eafa614b779074087fd2a387fac29256) (thanks @rom1504)
3
+ * [Add angleTo (#54)](https://github.com/PrismarineJS/node-vec3/commit/3a84c18eca955391975969a8484fffcd5e751d60) (thanks @eevleevs)
4
+ * [Fix publish condition for npm-publish v4 (#57)](https://github.com/PrismarineJS/node-vec3/commit/22ac569ec9c47347bfce588bcb7faddaf830ff4f) (thanks @rom1504)
5
+ * [Switch to trusted publishing via OIDC (#56)](https://github.com/PrismarineJS/node-vec3/commit/1cea1c152bd5ee354b83bc3e97905c0d36044d7b) (thanks @rom1504)
6
+ * [node 22 (#52)](https://github.com/PrismarineJS/node-vec3/commit/7c362a39de77c35677c9c98ed4cb56fd3cef124a) (thanks @rom1504)
7
+ * [Bump mocha from 10.8.2 to 11.0.1 (#51)](https://github.com/PrismarineJS/node-vec3/commit/3b2bf2a14dc6458f0b84bed6c96b911f44451b14) (thanks @dependabot[bot])
8
+
9
+ ## 0.1.10
10
+ * [add new types export (#49)](https://github.com/PrismarineJS/node-vec3/commit/9a3c259a361de7b6053c5e60ac70ba8ce658aeb0) (thanks @zerozeynep)
11
+
1
12
  ## 0.1.9
2
13
  * [Add methods, fix .equals (#46)](https://github.com/PrismarineJS/node-vec3/commit/c6b94c4289cfba5fc460bed99d112cec85fe1cf3) (thanks @szdytom)
3
14
  * [Add command gh workflow allowing to use release command in comments (#45)](https://github.com/PrismarineJS/node-vec3/commit/8675f8ecf6065278c0d1f889a585a5febf446cc0) (thanks @rom1504)
package/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # vec3
2
+
2
3
  [![NPM version](https://img.shields.io/npm/v/vec3.svg)](http://npmjs.com/package/vec3)
3
4
  [![Build Status](https://github.com/PrismarineJS/node-vec3/workflows/CI/badge.svg)](https://github.com/PrismarineJS/node-vec3/actions?query=workflow%3A%22CI%22)
4
5
 
@@ -7,7 +8,7 @@
7
8
  ## Usage
8
9
 
9
10
  ```js
10
- var v = require('vec3');
11
+ var v = require("vec3");
11
12
 
12
13
  var v1 = v(1, 2, 3);
13
14
  console.log(v1); // prints "(1, 2, 3)"
@@ -18,7 +19,7 @@ console.log(v2); // prints "(1, 2, 4)"
18
19
  Or:
19
20
 
20
21
  ```js
21
- var Vec3 = require('vec3').Vec3;
22
+ var Vec3 = require("vec3").Vec3;
22
23
 
23
24
  var v1 = new Vec3(1, 2, 3);
24
25
  // etc...
@@ -55,6 +56,7 @@ More available functions are listed below in Test Coverage.
55
56
  ✔ minus
56
57
  ✔ scaled
57
58
  ✔ abs
59
+ ✔ angleTo
58
60
  ✔ distanceTo
59
61
  ✔ distanceSquared
60
62
  ✔ equals
package/index.d.ts CHANGED
@@ -126,6 +126,11 @@ export class Vec3 {
126
126
  */
127
127
  modulus(other: Vec3): Vec3;
128
128
 
129
+ /**
130
+ * Return the angle in rad between another vector and this one
131
+ */
132
+ angleTo(other: Vec3): number;
133
+
129
134
  /**
130
135
  * Return the euclidean distance to another vector
131
136
  */
package/index.js CHANGED
@@ -133,6 +133,10 @@ class Vec3 {
133
133
  euclideanMod(this.z, other.z))
134
134
  }
135
135
 
136
+ angleTo (other) {
137
+ return Math.acos(this.dot(other) / (this.norm() * other.norm()))
138
+ }
139
+
136
140
  distanceTo (other) {
137
141
  const dx = other.x - this.x
138
142
  const dy = other.y - this.y
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vec3",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "description": "3d vector math with good unit tests",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -16,13 +16,14 @@
16
16
  "point"
17
17
  ],
18
18
  "exports": {
19
+ "types": "./index.d.ts",
19
20
  "require": "./index.js",
20
21
  "import": "./wrapper.mjs"
21
22
  },
22
23
  "author": "Andrew Kelley",
23
24
  "license": "BSD",
24
25
  "devDependencies": {
25
- "mocha": "^10.0.0",
26
+ "mocha": "^11.0.1",
26
27
  "standard": "^17.0.0",
27
28
  "tsd": "^0.25.0"
28
29
  },
@@ -39,6 +39,7 @@ expectType<Vec3>(vec.scaled(2));
39
39
  expectType<Vec3>(vec.abs());
40
40
  expectType<number>(vec.volume());
41
41
  expectType<Vec3>(vec.modulus(vec));
42
+ expectType<number>(vec.angleTo(vec));
42
43
  expectType<number>(vec.distanceTo(vec));
43
44
  expectType<number>(vec.distanceSquared(vec));
44
45
  expectType<boolean>(vec.equals(vec));
package/test/test.js CHANGED
@@ -182,6 +182,24 @@ describe('vec3', function () {
182
182
  assert.strictEqual(v2.y, 1.5)
183
183
  assert.strictEqual(v2.z, 1.9)
184
184
  })
185
+ it('angleTo', function () {
186
+ const v1 = new Vec3(1, 1, 1)
187
+ const v2 = new Vec3(1, 0, 0)
188
+ const angle1 = v1.angleTo(v2)
189
+ const angle2 = v2.angleTo(v1)
190
+ const expected = 0.9553166181
191
+ assert.strictEqual(angle1, angle2)
192
+ assert.strictEqual(Math.round(angle1 * 100000), Math.round(expected * 100000))
193
+ })
194
+ it('angleToNullVectors', function () {
195
+ const v1 = new Vec3(0, 0, 0)
196
+ const v2 = new Vec3(0, 0, 0)
197
+ const angle1 = v1.angleTo(v2)
198
+ const angle2 = v2.angleTo(v1)
199
+ const expected = NaN
200
+ assert.strictEqual(angle1, angle2)
201
+ assert.strictEqual(Math.round(angle1 * 100000), Math.round(expected * 100000))
202
+ })
185
203
  it('distanceTo', function () {
186
204
  const v1 = new Vec3(1, 1, 1)
187
205
  const v2 = new Vec3(2, 2, 2)