@quenty/vector3utils 6.0.1 → 6.1.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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
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
+ # [6.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/vector3utils@6.0.1...@quenty/vector3utils@6.1.0) (2022-12-06)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add Vector3Utils.reflect(vector: Vector3, unitNormal: Vector3): Vector3 ([d611559](https://github.com/Quenty/NevermoreEngine/commit/d6115599012be78d8f7498b1dbc6f1af10784821))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [6.0.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/vector3utils@6.0.0...@quenty/vector3utils@6.0.1) (2022-11-04)
7
18
 
8
19
  **Note:** Version bump only for package @quenty/vector3utils
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/vector3utils",
3
- "version": "6.0.1",
3
+ "version": "6.1.0",
4
4
  "description": "Utilities involving Vector3 objects in Roblox",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -31,5 +31,5 @@
31
31
  "publishConfig": {
32
32
  "access": "public"
33
33
  },
34
- "gitHead": "8b9877c26a3fc753409a5114e56717837291279d"
34
+ "gitHead": "d9b0d10faa443cc42a6c2ac966f2f56d124bbde5"
35
35
  }
@@ -0,0 +1,26 @@
1
+ --[=[
2
+ @class Vector3SerializationUtils
3
+ ]=]
4
+
5
+ local Vector3SerializationUtils = {}
6
+
7
+ function Vector3SerializationUtils.isSerializedVector3(data)
8
+ return type(data) == "table" and #data == 3
9
+ end
10
+
11
+ function Vector3SerializationUtils.serialize(vector3)
12
+ return {
13
+ vector3.x,
14
+ vector3.y,
15
+ vector3.z
16
+ }
17
+ end
18
+
19
+ function Vector3SerializationUtils.deserialize(data)
20
+ assert(type(data) == "table", "Bad data")
21
+ assert(#data == 3, "Bad data")
22
+
23
+ return Vector3.new(data[1], data[2], data[3])
24
+ end
25
+
26
+ return Vector3SerializationUtils
@@ -41,6 +41,17 @@ function Vector3Utils.getAngleRad(a: Vector3, b: Vector3): number
41
41
  return math.acos(a:Dot(b))
42
42
  end
43
43
 
44
+ --[=[
45
+ Reflects a vector over a unit normal
46
+
47
+ @param vector Vector3
48
+ @param unitNormal Vector3
49
+ @return Vector3
50
+ ]=]
51
+ function Vector3Utils.reflect(vector: Vector3, unitNormal: Vector3): Vector3
52
+ return vector - 2*(unitNormal*vector:Dot(unitNormal))
53
+ end
54
+
44
55
  --[=[
45
56
  Computes the angle between 2 vectors in radians
46
57
  @param a Vector3