vec3 0.1.10 → 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.
- package/.github/workflows/ci.yml +1 -1
- package/.github/workflows/publish.yml +7 -5
- package/HISTORY.md +8 -0
- package/README.md +4 -2
- package/index.d.ts +5 -0
- package/index.js +4 -0
- package/package.json +2 -2
- package/test/index.test-d.ts +1 -0
- package/test/test.js +18 -0
package/.github/workflows/ci.yml
CHANGED
|
@@ -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:
|
|
19
|
+
node-version: 24
|
|
20
|
+
registry-url: 'https://registry.npmjs.org'
|
|
17
21
|
- id: publish
|
|
18
|
-
uses: JS-DevTools/npm-publish@
|
|
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
|
|
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,11 @@
|
|
|
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
|
+
|
|
1
9
|
## 0.1.10
|
|
2
10
|
* [add new types export (#49)](https://github.com/PrismarineJS/node-vec3/commit/9a3c259a361de7b6053c5e60ac70ba8ce658aeb0) (thanks @zerozeynep)
|
|
3
11
|
|
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# vec3
|
|
2
|
+
|
|
2
3
|
[](http://npmjs.com/package/vec3)
|
|
3
4
|
[](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(
|
|
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(
|
|
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.
|
|
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",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"author": "Andrew Kelley",
|
|
24
24
|
"license": "BSD",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"mocha": "^
|
|
26
|
+
"mocha": "^11.0.1",
|
|
27
27
|
"standard": "^17.0.0",
|
|
28
28
|
"tsd": "^0.25.0"
|
|
29
29
|
},
|
package/test/index.test-d.ts
CHANGED
|
@@ -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)
|