@quenty/trajectory 2.3.0 → 2.4.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
|
+
# [2.4.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/trajectory@2.3.0...@quenty/trajectory@2.4.0) (2024-09-25)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add TrajectoryDrawUtils ([6b7f1bf](https://github.com/Quenty/NevermoreEngine/commit/6b7f1bf9905a1cfa5864dcd5de4b811ad0b6f0a5))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [2.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/trajectory@2.2.0...@quenty/trajectory@2.3.0) (2024-05-09)
|
|
7
18
|
|
|
8
19
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/trajectory",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Utility function for estimating low and high arcs of projectiles. Solves for bullet drop given",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -28,5 +28,9 @@
|
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
|
-
"
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@quenty/draw": "^7.5.0",
|
|
33
|
+
"@quenty/loader": "^10.5.0"
|
|
34
|
+
},
|
|
35
|
+
"gitHead": "9b17fe79cddd071f0f06a9d35184e76b44bd6fe6"
|
|
32
36
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
--[=[
|
|
2
|
+
@class TrajectoryDrawUtils
|
|
3
|
+
]=]
|
|
4
|
+
|
|
5
|
+
local require = require(script.Parent.loader).load(script)
|
|
6
|
+
|
|
7
|
+
local MinEntranceVelocityUtils = require("MinEntranceVelocityUtils")
|
|
8
|
+
local Draw = require("Draw")
|
|
9
|
+
|
|
10
|
+
local ORIGIN_COLOR = Color3.new(0, 1, 0)
|
|
11
|
+
local FINISH_COLOR = Color3.new(1, 0, 0)
|
|
12
|
+
|
|
13
|
+
local TrajectoryDrawUtils = {}
|
|
14
|
+
|
|
15
|
+
function TrajectoryDrawUtils.draw(velocity, origin, target, accel)
|
|
16
|
+
Draw.point(origin, ORIGIN_COLOR)
|
|
17
|
+
Draw.point(target, FINISH_COLOR)
|
|
18
|
+
|
|
19
|
+
local entranceTime = MinEntranceVelocityUtils.computeEntranceTime(velocity, origin, target, accel)
|
|
20
|
+
|
|
21
|
+
for t=0, entranceTime, 0.1 do
|
|
22
|
+
local t0 = math.clamp(t, 0, entranceTime)
|
|
23
|
+
local t1 = math.clamp(t + 0.1, 0, entranceTime)
|
|
24
|
+
|
|
25
|
+
local p0 = origin + velocity*t0 + 0.5*accel*t0*t0
|
|
26
|
+
local p1 = origin + velocity*t1 + 0.5*accel*t1*t1
|
|
27
|
+
|
|
28
|
+
local percent = t/entranceTime
|
|
29
|
+
Draw.line(p0, p1, ORIGIN_COLOR:Lerp(FINISH_COLOR, percent))
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
return TrajectoryDrawUtils
|