@quenty/spring 10.8.3 → 10.8.4
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 +8 -0
- package/package.json +4 -4
- package/src/Shared/LinearValue.lua +3 -3
- package/src/Shared/Spring.lua +17 -14
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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
|
+
## [10.8.4](https://github.com/Quenty/NevermoreEngine/compare/@quenty/spring@10.8.3...@quenty/spring@10.8.4) (2025-04-10)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/spring
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [10.8.3](https://github.com/Quenty/NevermoreEngine/compare/@quenty/spring@10.8.1...@quenty/spring@10.8.3) (2025-04-07)
|
|
7
15
|
|
|
8
16
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/spring",
|
|
3
|
-
"version": "10.8.
|
|
3
|
+
"version": "10.8.4",
|
|
4
4
|
"description": "Spring implementation for Roblox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@quenty/ducktype": "^5.8.
|
|
33
|
-
"@quenty/loader": "^10.8.
|
|
32
|
+
"@quenty/ducktype": "^5.8.4",
|
|
33
|
+
"@quenty/loader": "^10.8.3"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "b06c070ae91d5dab7bd8de6e290ad2caabb15d8f"
|
|
36
36
|
}
|
|
@@ -18,7 +18,7 @@ export type LinearValue<T> = typeof(setmetatable(
|
|
|
18
18
|
_constructor: (...number) -> T,
|
|
19
19
|
_values: { number },
|
|
20
20
|
},
|
|
21
|
-
LinearValue
|
|
21
|
+
{} :: typeof({ __index = LinearValue })
|
|
22
22
|
))
|
|
23
23
|
|
|
24
24
|
--[=[
|
|
@@ -110,7 +110,7 @@ end
|
|
|
110
110
|
|
|
111
111
|
@return T
|
|
112
112
|
]=]
|
|
113
|
-
function LinearValue
|
|
113
|
+
function LinearValue.ToBaseValue<T>(self: LinearValue<T>): T
|
|
114
114
|
return self._constructor(unpack(self._values))
|
|
115
115
|
end
|
|
116
116
|
|
|
@@ -155,7 +155,7 @@ end
|
|
|
155
155
|
|
|
156
156
|
@return number -- The magnitude of the linear value.
|
|
157
157
|
]=]
|
|
158
|
-
function LinearValue
|
|
158
|
+
function LinearValue.GetMagnitude(self: LinearValue<T>): number
|
|
159
159
|
local dot: number = 0
|
|
160
160
|
for i = 1, #self._values do
|
|
161
161
|
local value: number = self._values[i]
|
package/src/Shared/Spring.lua
CHANGED
|
@@ -50,7 +50,7 @@ export type Spring<T> = typeof(setmetatable(
|
|
|
50
50
|
_clock: SpringClock,
|
|
51
51
|
_positionVelocity: (self: Spring<T>, now: number) -> (T, T),
|
|
52
52
|
},
|
|
53
|
-
Spring
|
|
53
|
+
{} :: typeof({ __index = Spring })
|
|
54
54
|
))
|
|
55
55
|
|
|
56
56
|
--[=[
|
|
@@ -75,15 +75,18 @@ function Spring.new<T>(initial: T?, clock: SpringClock?): Spring<T>
|
|
|
75
75
|
local p0 = initial or 0
|
|
76
76
|
local springClock = clock or os.clock
|
|
77
77
|
|
|
78
|
-
return setmetatable(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
return setmetatable(
|
|
79
|
+
{
|
|
80
|
+
_clock = springClock,
|
|
81
|
+
_time0 = springClock(),
|
|
82
|
+
_position0 = p0,
|
|
83
|
+
_velocity0 = 0 * (p0 :: any),
|
|
84
|
+
_target = p0,
|
|
85
|
+
_damper = 1,
|
|
86
|
+
_speed = 1,
|
|
87
|
+
} :: any,
|
|
88
|
+
Spring
|
|
89
|
+
) :: Spring<T>
|
|
87
90
|
end
|
|
88
91
|
|
|
89
92
|
--[=[
|
|
@@ -254,20 +257,20 @@ function Spring.__newindex<T>(self: Spring<T>, index, value)
|
|
|
254
257
|
local position, velocity = self:_positionVelocity(now)
|
|
255
258
|
self._position0 = position
|
|
256
259
|
self._velocity0 = velocity
|
|
257
|
-
self._damper = value
|
|
260
|
+
self._damper = value :: any
|
|
258
261
|
self._time0 = now
|
|
259
262
|
elseif index == "Speed" or index == "s" then
|
|
260
263
|
local position, velocity = self:_positionVelocity(now)
|
|
261
264
|
self._position0 = position
|
|
262
265
|
self._velocity0 = velocity
|
|
263
|
-
self._speed = value < 0
|
|
266
|
+
self._speed = if (value :: any) < 0 then 0 else value :: any
|
|
264
267
|
self._time0 = now
|
|
265
268
|
elseif index == "Clock" then
|
|
266
269
|
local position, velocity = self:_positionVelocity(now)
|
|
267
270
|
self._position0 = position
|
|
268
271
|
self._velocity0 = velocity
|
|
269
|
-
self._clock = value
|
|
270
|
-
self._time0 = value()
|
|
272
|
+
self._clock = value :: any
|
|
273
|
+
self._time0 = (value :: any)()
|
|
271
274
|
else
|
|
272
275
|
error(string.format("%q is not a valid member of Spring", tostring(index)), 2)
|
|
273
276
|
end
|