@quenty/vector3utils 3.1.2-canary.c50dead.0 → 3.2.1
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/CHANGELOG.md +10 -2
- package/LICENSE.md +1 -1
- package/README.md +5 -3
- package/package.json +4 -4
- package/src/Shared/RandomVector3Utils.lua +9 -5
- package/src/Shared/Vector3Utils.lua +32 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,12 +3,20 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [3.
|
|
6
|
+
## [3.2.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/vector3utils@3.2.0...@quenty/vector3utils@3.2.1) (2021-12-30)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/vector3utils
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [3.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/vector3utils@3.1.1...@quenty/vector3utils@3.2.0) (2021-11-20)
|
|
7
15
|
|
|
8
16
|
|
|
9
17
|
### Bug Fixes
|
|
10
18
|
|
|
11
|
-
* Support MacOS syncing ([
|
|
19
|
+
* Support MacOS syncing ([#225](https://github.com/Quenty/NevermoreEngine/issues/225)) ([03f9183](https://github.com/Quenty/NevermoreEngine/commit/03f918392c6a5bdd33f8a17c38de371d1e06c67a))
|
|
12
20
|
|
|
13
21
|
|
|
14
22
|
|
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
## Vector3Utils
|
|
2
2
|
<div align="center">
|
|
3
|
-
<a href="http://quenty.github.io/
|
|
4
|
-
<img src="https://
|
|
3
|
+
<a href="http://quenty.github.io/NevermoreEngine/">
|
|
4
|
+
<img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/docs.yml/badge.svg" alt="Documentation status" />
|
|
5
5
|
</a>
|
|
6
6
|
<a href="https://discord.gg/mhtGUS8">
|
|
7
|
-
<img src="https://img.shields.io/
|
|
7
|
+
<img src="https://img.shields.io/discord/385151591524597761?color=5865F2&label=discord&logo=discord&logoColor=white" alt="Discord" />
|
|
8
8
|
</a>
|
|
9
9
|
<a href="https://github.com/Quenty/NevermoreEngine/actions">
|
|
10
10
|
<img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/build.yml/badge.svg" alt="Build and release status" />
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
Utilities involving Vector3 objects in Roblox
|
|
15
15
|
|
|
16
|
+
<div align="center"><a href="https://quenty.github.io/NevermoreEngine/api/Vector3Utils">View docs →</a></div>
|
|
17
|
+
|
|
16
18
|
## Installation
|
|
17
19
|
```
|
|
18
20
|
npm install @quenty/vector3utils --save
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/vector3utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "Utilities involving Vector3 objects in Roblox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/loader": "3.1.
|
|
29
|
-
"@quenty/math": "2.0.
|
|
28
|
+
"@quenty/loader": "^3.1.2",
|
|
29
|
+
"@quenty/math": "^2.0.1"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "d146c77d0a8e452824de0ab0b4b03ba0370bcc1b"
|
|
35
35
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
--[=[
|
|
2
|
+
Utility functions involving RandomVector3Utils
|
|
3
|
+
@class RandomVector3Utils
|
|
4
|
+
]=]
|
|
4
5
|
|
|
5
6
|
local RandomVector3Utils = {}
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
--[=[
|
|
9
|
+
Equal distribution unit vectors around a sphere
|
|
10
|
+
@return Vector3
|
|
11
|
+
]=]
|
|
8
12
|
function RandomVector3Utils.getRandomUnitVector()
|
|
9
13
|
local s = 2*(math.random()-0.5)
|
|
10
14
|
local t = 6.2831853071796*math.random()
|
|
@@ -12,7 +16,7 @@ function RandomVector3Utils.getRandomUnitVector()
|
|
|
12
16
|
local m = (1-s*s)^0.5
|
|
13
17
|
local ry = m*math.cos(t)
|
|
14
18
|
local rz = m*math.sin(t)
|
|
15
|
-
return Vector3.new(rx,ry,rz)
|
|
19
|
+
return Vector3.new(rx, ry, rz)
|
|
16
20
|
end
|
|
17
21
|
|
|
18
22
|
return RandomVector3Utils
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
--[=[
|
|
2
|
+
Utilities involving Vector3 objects in Roblox
|
|
3
|
+
@class Vector3Utils
|
|
4
|
+
]=]
|
|
3
5
|
|
|
4
6
|
local require = require(script.Parent.loader).load(script)
|
|
5
7
|
|
|
@@ -7,14 +9,30 @@ local Math = require("Math")
|
|
|
7
9
|
|
|
8
10
|
local Vector3Utils = {}
|
|
9
11
|
|
|
12
|
+
--[=[
|
|
13
|
+
Creates a Vector3 from a Vector2 in the XY plane
|
|
14
|
+
@param vector2 Vector2
|
|
15
|
+
@return Vector3
|
|
16
|
+
]=]
|
|
10
17
|
function Vector3Utils.fromVector2XY(vector2)
|
|
11
18
|
return Vector3.new(vector2.x, vector2.y, 0)
|
|
12
19
|
end
|
|
13
20
|
|
|
21
|
+
--[=[
|
|
22
|
+
Creates a Vector3 from a Vector2 in the XZ plane
|
|
23
|
+
@param vector2 Vector2
|
|
24
|
+
@return Vector3
|
|
25
|
+
]=]
|
|
14
26
|
function Vector3Utils.fromVector2XZ(vector2)
|
|
15
27
|
return Vector3.new(vector2.x, 0, vector2.y)
|
|
16
28
|
end
|
|
17
29
|
|
|
30
|
+
--[=[
|
|
31
|
+
Computes the angle between 2 vectors in radians
|
|
32
|
+
@param a Vector3
|
|
33
|
+
@param b Vector3
|
|
34
|
+
@return number?
|
|
35
|
+
]=]
|
|
18
36
|
function Vector3Utils.getAngleRad(a, b)
|
|
19
37
|
if a.magnitude == 0 then
|
|
20
38
|
return nil
|
|
@@ -23,12 +41,24 @@ function Vector3Utils.getAngleRad(a, b)
|
|
|
23
41
|
return math.acos(a:Dot(b))
|
|
24
42
|
end
|
|
25
43
|
|
|
44
|
+
--[=[
|
|
45
|
+
Computes the angle between 2 vectors
|
|
46
|
+
@param a Vector3
|
|
47
|
+
@param b Vector3
|
|
48
|
+
@return number
|
|
49
|
+
]=]
|
|
26
50
|
function Vector3Utils.angleBetweenVectors(a, b)
|
|
27
51
|
local u = b.magnitude*a
|
|
28
52
|
local v = a.magnitude*b
|
|
29
53
|
return 2*math.atan2((v - u).magnitude, (u + v).magnitude)
|
|
30
54
|
end
|
|
31
55
|
|
|
56
|
+
--[=[
|
|
57
|
+
Rounds the vector to the nearest number
|
|
58
|
+
@param vector3 Vector3
|
|
59
|
+
@param amount number
|
|
60
|
+
@return Vector3
|
|
61
|
+
]=]
|
|
32
62
|
function Vector3Utils.round(vector3, amount)
|
|
33
63
|
return Vector3.new(Math.round(vector3.x, amount), Math.round(vector3.y, amount), Math.round(vector3.z, amount))
|
|
34
64
|
end
|