@quenty/qframe 4.0.0-canary.236.5597d0a.0 → 4.0.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 +49 -1
- package/README.md +5 -3
- package/package.json +6 -6
- package/src/Shared/QFrame.lua +89 -2
- package/src/Shared/QFrame.story.lua +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,55 @@
|
|
|
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
|
-
# [4.0.0
|
|
6
|
+
# [4.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/qframe@3.6.0...@quenty/qframe@4.0.0) (2022-03-06)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/qframe
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [3.6.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/qframe@3.5.1...@quenty/qframe@3.6.0) (2022-01-17)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @quenty/qframe
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [3.5.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/qframe@3.5.0...@quenty/qframe@3.5.1) (2022-01-16)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @quenty/qframe
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# [3.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/qframe@3.4.0...@quenty/qframe@3.5.0) (2022-01-07)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @quenty/qframe
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# [3.4.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/qframe@3.3.1...@quenty/qframe@3.4.0) (2022-01-03)
|
|
39
|
+
|
|
40
|
+
**Note:** Version bump only for package @quenty/qframe
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## [3.3.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/qframe@3.3.0...@quenty/qframe@3.3.1) (2021-12-30)
|
|
47
|
+
|
|
48
|
+
**Note:** Version bump only for package @quenty/qframe
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# [3.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/qframe@3.2.0...@quenty/qframe@3.3.0) (2021-12-18)
|
|
7
55
|
|
|
8
56
|
|
|
9
57
|
### Features
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
## QFrame
|
|
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
|
CFrame representation as a quaternion
|
|
15
15
|
|
|
16
|
+
<div align="center"><a href="https://quenty.github.io/NevermoreEngine/api/QFrame">View docs →</a></div>
|
|
17
|
+
|
|
16
18
|
## Installation
|
|
17
19
|
```
|
|
18
20
|
npm install @quenty/qframe --save
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/qframe",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "CFrame representation as a quaternion for Roblox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"AxisAngles"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@quenty/loader": "
|
|
30
|
+
"@quenty/loader": "^4.0.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@quenty/camerastoryutils": "4.0.0
|
|
34
|
-
"@quenty/cubicspline": "
|
|
35
|
-
"@quenty/maid": "2.0
|
|
33
|
+
"@quenty/camerastoryutils": "^4.0.0",
|
|
34
|
+
"@quenty/cubicspline": "^4.0.0",
|
|
35
|
+
"@quenty/maid": "^2.1.0"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "dd428cab58282c975a4c082957dc8f58e3186905"
|
|
41
41
|
}
|
package/src/Shared/QFrame.lua
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
--[=[
|
|
2
|
+
CFrame representation as a quaternion. Alternative representation of a [CFrame].
|
|
3
|
+
@class QFrame
|
|
4
|
+
]=]
|
|
3
5
|
|
|
4
6
|
local QFrame = {}
|
|
5
7
|
QFrame.__index = QFrame
|
|
6
8
|
|
|
9
|
+
--[=[
|
|
10
|
+
Constructs a new QFrame
|
|
11
|
+
|
|
12
|
+
@param x number?
|
|
13
|
+
@param y number?
|
|
14
|
+
@param z number?
|
|
15
|
+
@param W number?
|
|
16
|
+
@param X number?
|
|
17
|
+
@param Y number?
|
|
18
|
+
@param Z number?
|
|
19
|
+
@return QFrame
|
|
20
|
+
]=]
|
|
7
21
|
function QFrame.new(x, y, z, W, X, Y, Z)
|
|
8
22
|
local self = setmetatable({}, QFrame)
|
|
9
23
|
self.x = x or 0
|
|
@@ -17,10 +31,21 @@ function QFrame.new(x, y, z, W, X, Y, Z)
|
|
|
17
31
|
return self
|
|
18
32
|
end
|
|
19
33
|
|
|
34
|
+
--[=[
|
|
35
|
+
Returns whether a value is a QFrame
|
|
36
|
+
@param value any
|
|
37
|
+
@return boolean
|
|
38
|
+
]=]
|
|
20
39
|
function QFrame.isQFrame(value)
|
|
21
40
|
return getmetatable(value) == QFrame
|
|
22
41
|
end
|
|
23
42
|
|
|
43
|
+
--[=[
|
|
44
|
+
Gets the QFrame closest to that CFrame
|
|
45
|
+
@param cframe CFrame
|
|
46
|
+
@param closestTo QFrame
|
|
47
|
+
@return QFrame
|
|
48
|
+
]=]
|
|
24
49
|
function QFrame.fromCFrameClosestTo(cframe, closestTo)
|
|
25
50
|
assert(typeof(cframe) == "CFrame", "Bad cframe")
|
|
26
51
|
assert(QFrame.isQFrame(closestTo), "Bad closestTo")
|
|
@@ -40,6 +65,12 @@ function QFrame.fromCFrameClosestTo(cframe, closestTo)
|
|
|
40
65
|
return QFrame.new(cframe.x, cframe.y, cframe.z, W, X, Y, Z)
|
|
41
66
|
end
|
|
42
67
|
|
|
68
|
+
--[=[
|
|
69
|
+
Constructs a QFrame from a position and another QFrame rotation.
|
|
70
|
+
@param vector Vector3
|
|
71
|
+
@param qFrame QFrame
|
|
72
|
+
@return QFrame
|
|
73
|
+
]=]
|
|
43
74
|
function QFrame.fromVector3(vector, qFrame)
|
|
44
75
|
assert(typeof(vector) == "Vector3", "Bad vector")
|
|
45
76
|
assert(QFrame.isQFrame(qFrame))
|
|
@@ -47,6 +78,11 @@ function QFrame.fromVector3(vector, qFrame)
|
|
|
47
78
|
return QFrame.new(vector.x, vector.y, vector.z, qFrame.W, qFrame.X, qFrame.Y, qFrame.Z)
|
|
48
79
|
end
|
|
49
80
|
|
|
81
|
+
--[=[
|
|
82
|
+
Converts the QFrame to a [CFrame]
|
|
83
|
+
@param self QFrame
|
|
84
|
+
@return CFrame
|
|
85
|
+
]=]
|
|
50
86
|
function QFrame.toCFrame(self)
|
|
51
87
|
local cframe = CFrame.new(self.x, self.y, self.z, self.X, self.Y, self.Z, self.W)
|
|
52
88
|
if cframe == cframe then
|
|
@@ -56,19 +92,40 @@ function QFrame.toCFrame(self)
|
|
|
56
92
|
end
|
|
57
93
|
end
|
|
58
94
|
|
|
95
|
+
--[=[
|
|
96
|
+
Converts the QFrame to a [Vector3] position
|
|
97
|
+
@param self QFrame
|
|
98
|
+
@return Vector3
|
|
99
|
+
]=]
|
|
59
100
|
function QFrame.toPosition(self)
|
|
60
101
|
return Vector3.new(self.x, self.y, self.z)
|
|
61
102
|
end
|
|
62
103
|
|
|
104
|
+
--[=[
|
|
105
|
+
Returns true if the QFrame contains a NaN value.
|
|
106
|
+
@param a QFrame
|
|
107
|
+
@return boolean
|
|
108
|
+
]=]
|
|
63
109
|
function QFrame.isNAN(a)
|
|
64
110
|
return a.x == a.x and a.y == a.y and a.z == a.z
|
|
65
111
|
and a.W == a.W and a.X == a.X and a.Y == a.Y and a.Z == a.Z
|
|
66
112
|
end
|
|
67
113
|
|
|
114
|
+
--[=[
|
|
115
|
+
Inverts the QFrame
|
|
116
|
+
@param a QFrame
|
|
117
|
+
@return QFrame
|
|
118
|
+
]=]
|
|
68
119
|
function QFrame.__unm(a)
|
|
69
120
|
return QFrame.new(-a.x, -a.y, -a.z, -a.W, -a.X, -a.Y, -a.Z)
|
|
70
121
|
end
|
|
71
122
|
|
|
123
|
+
--[=[
|
|
124
|
+
Adds the QFrames together
|
|
125
|
+
@param a QFrame
|
|
126
|
+
@param b QFrame
|
|
127
|
+
@return QFrame
|
|
128
|
+
]=]
|
|
72
129
|
function QFrame.__add(a, b)
|
|
73
130
|
assert(QFrame.isQFrame(a) and QFrame.isQFrame(b),
|
|
74
131
|
"QFrame + non-QFrame attempted")
|
|
@@ -76,6 +133,12 @@ function QFrame.__add(a, b)
|
|
|
76
133
|
return QFrame.new(a.x + b.x, a.y + b.y, a.z + b.z, a.W + b.W, a.X + b.X, a.Y + b.Y, a.Z + b.Z)
|
|
77
134
|
end
|
|
78
135
|
|
|
136
|
+
--[=[
|
|
137
|
+
Subtracts the QFrames together
|
|
138
|
+
@param a QFrame
|
|
139
|
+
@param b QFrame
|
|
140
|
+
@return QFrame
|
|
141
|
+
]=]
|
|
79
142
|
function QFrame.__sub(a, b)
|
|
80
143
|
assert(QFrame.isQFrame(a) and QFrame.isQFrame(b),
|
|
81
144
|
"QFrame - non-QFrame attempted")
|
|
@@ -83,6 +146,12 @@ function QFrame.__sub(a, b)
|
|
|
83
146
|
return QFrame.new(a.x - b.x, a.y - b.y, a.z - b.z, a.W - b.W, a.X - b.X, a.Y - b.Y, a.Z - b.Z)
|
|
84
147
|
end
|
|
85
148
|
|
|
149
|
+
--[=[
|
|
150
|
+
Takes the QFrame to the power, using quaternion power formula.
|
|
151
|
+
@param a QFrame
|
|
152
|
+
@param b number
|
|
153
|
+
@return QFrame
|
|
154
|
+
]=]
|
|
86
155
|
function QFrame.__pow(a, b)
|
|
87
156
|
assert(QFrame.isQFrame(a) and type(b) == "number", "Bad a or b")
|
|
88
157
|
|
|
@@ -130,6 +199,12 @@ function QFrame.__pow(a, b)
|
|
|
130
199
|
return QFrame.new(cx, cy, cz, cW, cX, cY, cZ)
|
|
131
200
|
end
|
|
132
201
|
|
|
202
|
+
--[=[
|
|
203
|
+
Multiplies the QFrames together
|
|
204
|
+
@param a QFrame | number
|
|
205
|
+
@param b QFrame | number
|
|
206
|
+
@return QFrame
|
|
207
|
+
]=]
|
|
133
208
|
function QFrame.__mul(a, b)
|
|
134
209
|
if type(a) == "number" and QFrame.isQFrame(b) then
|
|
135
210
|
return QFrame.new(a*b.x, a*b.y, a*b.z, a*b.W, a*b.X, a*b.Y, a*b.Z)
|
|
@@ -154,6 +229,12 @@ function QFrame.__mul(a, b)
|
|
|
154
229
|
end
|
|
155
230
|
end
|
|
156
231
|
|
|
232
|
+
--[=[
|
|
233
|
+
Divides the QFrame by the number
|
|
234
|
+
@param a QFrame
|
|
235
|
+
@param b number
|
|
236
|
+
@return QFrame
|
|
237
|
+
]=]
|
|
157
238
|
function QFrame.__div(a, b)
|
|
158
239
|
if type(b) == "number" then
|
|
159
240
|
return QFrame.new(a.x/b, a.y/b, a.z/b, a.W/b, a.X/b, a.Y/b, a.Z/b)
|
|
@@ -162,6 +243,12 @@ function QFrame.__div(a, b)
|
|
|
162
243
|
end
|
|
163
244
|
end
|
|
164
245
|
|
|
246
|
+
--[=[
|
|
247
|
+
Compares the QFrame for equality.
|
|
248
|
+
@param a QFrame
|
|
249
|
+
@param b QFrame
|
|
250
|
+
@return boolean
|
|
251
|
+
]=]
|
|
165
252
|
function QFrame.__eq(a, b)
|
|
166
253
|
return a.x == b.x and a.y == b.y and a.z == b.z
|
|
167
254
|
and a.W == b.W and a.X == b.X and a.Y == b.Y and a.Z == b.Z
|