@quenty/geometryutils 6.9.0-canary.0a5db80.0 → 6.9.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 +9 -1
- package/package.json +4 -4
- package/src/Shared/CameraPyramidUtils.lua +8 -3
- package/src/Shared/CircleUtils.lua +7 -3
- package/src/Shared/Line.lua +1 -1
- package/src/Shared/OrthogonalUtils.lua +1 -1
- package/src/Shared/PlaneUtils.lua +7 -2
- package/src/Shared/ScaleModelUtils.lua +1 -1
- package/src/Shared/SphereUtils.lua +9 -7
- package/src/Shared/SurfaceUtils.lua +1 -1
- package/src/Shared/SwingTwistUtils.lua +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,15 @@
|
|
|
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.9.0
|
|
6
|
+
# [6.9.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/geometryutils@6.8.4...@quenty/geometryutils@6.9.0) (2025-05-10)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/geometryutils
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [6.8.4](https://github.com/Quenty/NevermoreEngine/compare/@quenty/geometryutils@6.8.3...@quenty/geometryutils@6.8.4) (2025-04-10)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @quenty/geometryutils
|
|
9
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/geometryutils",
|
|
3
|
-
"version": "6.9.0
|
|
3
|
+
"version": "6.9.0",
|
|
4
4
|
"description": "Utility functions involving 3D and 2D geometry",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@quenty/draw": "7.9.0
|
|
32
|
-
"@quenty/loader": "10.9.0
|
|
31
|
+
"@quenty/draw": "^7.9.0",
|
|
32
|
+
"@quenty/loader": "^10.9.0"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "20cff952c2cf06b959f2f11d2293bdef38acc604"
|
|
35
35
|
}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
local require = require(script.Parent.loader).load(script)
|
|
7
7
|
|
|
8
|
-
local PlaneUtils = require("PlaneUtils")
|
|
9
8
|
local Draw = require("Draw")
|
|
9
|
+
local PlaneUtils = require("PlaneUtils")
|
|
10
10
|
|
|
11
11
|
local CameraPyramidUtils = {}
|
|
12
12
|
|
|
@@ -183,7 +183,12 @@ function CameraPyramidUtils._drawIntersection(
|
|
|
183
183
|
end
|
|
184
184
|
end
|
|
185
185
|
|
|
186
|
-
function CameraPyramidUtils._isInBounds(
|
|
186
|
+
function CameraPyramidUtils._isInBounds(
|
|
187
|
+
camCFrame: CFrame,
|
|
188
|
+
intersection: Vector3?,
|
|
189
|
+
halfFov: number,
|
|
190
|
+
isVertical: boolean
|
|
191
|
+
): boolean
|
|
187
192
|
if not intersection then
|
|
188
193
|
return false
|
|
189
194
|
end
|
|
@@ -207,4 +212,4 @@ function CameraPyramidUtils._isInBounds(camCFrame: CFrame, intersection: Vector3
|
|
|
207
212
|
return angle <= halfFov
|
|
208
213
|
end
|
|
209
214
|
|
|
210
|
-
return CameraPyramidUtils
|
|
215
|
+
return CameraPyramidUtils
|
|
@@ -14,10 +14,14 @@ local CircleUtils = {}
|
|
|
14
14
|
@param circumference number
|
|
15
15
|
@return number
|
|
16
16
|
]=]
|
|
17
|
-
function CircleUtils.updatePositionToSmallestDistOnCircle(
|
|
17
|
+
function CircleUtils.updatePositionToSmallestDistOnCircle(
|
|
18
|
+
position: number,
|
|
19
|
+
target: number,
|
|
20
|
+
circumference: number
|
|
21
|
+
): number
|
|
18
22
|
assert(target >= 0 and target <= circumference, "Target must be between 0 and circumference")
|
|
19
23
|
|
|
20
|
-
if math.abs(position - target) <= circumference/2 then
|
|
24
|
+
if math.abs(position - target) <= circumference / 2 then
|
|
21
25
|
-- No need to force spring update
|
|
22
26
|
return position
|
|
23
27
|
end
|
|
@@ -41,4 +45,4 @@ function CircleUtils.updatePositionToSmallestDistOnCircle(position: number, targ
|
|
|
41
45
|
end
|
|
42
46
|
end
|
|
43
47
|
|
|
44
|
-
return CircleUtils
|
|
48
|
+
return CircleUtils
|
package/src/Shared/Line.lua
CHANGED
|
@@ -19,7 +19,12 @@ local PlaneUtils = {}
|
|
|
19
19
|
@return Vector3? -- Intersection point
|
|
20
20
|
@return number? -- Distance to intersection point
|
|
21
21
|
]=]
|
|
22
|
-
function PlaneUtils.rayIntersection(
|
|
22
|
+
function PlaneUtils.rayIntersection(
|
|
23
|
+
origin: Vector3,
|
|
24
|
+
normal: Vector3,
|
|
25
|
+
rayOrigin: Vector3,
|
|
26
|
+
unitRayDirection: Vector3
|
|
27
|
+
): (Vector3?, number?)
|
|
23
28
|
local rpoint = rayOrigin - origin
|
|
24
29
|
local dot = unitRayDirection:Dot(normal)
|
|
25
30
|
if dot == 0 then
|
|
@@ -31,4 +36,4 @@ function PlaneUtils.rayIntersection(origin: Vector3, normal: Vector3, rayOrigin:
|
|
|
31
36
|
return rayOrigin + t * unitRayDirection, t
|
|
32
37
|
end
|
|
33
38
|
|
|
34
|
-
return PlaneUtils
|
|
39
|
+
return PlaneUtils
|
|
@@ -16,19 +16,21 @@ local SphereUtils = {}
|
|
|
16
16
|
@return boolean
|
|
17
17
|
]=]
|
|
18
18
|
function SphereUtils.intersectsRay(
|
|
19
|
-
sphereCenter: Vector3,
|
|
20
|
-
|
|
19
|
+
sphereCenter: Vector3,
|
|
20
|
+
sphereRadius: number,
|
|
21
|
+
rayOrigin: Vector3,
|
|
22
|
+
rayDirection: Vector3
|
|
21
23
|
): boolean
|
|
22
24
|
local relOrigin = rayOrigin - sphereCenter
|
|
23
25
|
local rr = relOrigin:Dot(relOrigin)
|
|
24
26
|
local dr = rayDirection:Dot(relOrigin)
|
|
25
27
|
local dd = rayDirection:Dot(rayDirection)
|
|
26
28
|
|
|
27
|
-
local passTime = -dr/dd
|
|
28
|
-
local passDist2 = rr - dr*dr/dd
|
|
29
|
+
local passTime = -dr / dd
|
|
30
|
+
local passDist2 = rr - dr * dr / dd
|
|
29
31
|
|
|
30
|
-
if passDist2 <= sphereRadius*sphereRadius then
|
|
31
|
-
local offset = math.sqrt((sphereRadius*sphereRadius - passDist2)/dd)
|
|
32
|
+
if passDist2 <= sphereRadius * sphereRadius then
|
|
33
|
+
local offset = math.sqrt((sphereRadius * sphereRadius - passDist2) / dd)
|
|
32
34
|
local t0 = passTime - offset
|
|
33
35
|
local t1 = passTime + offset
|
|
34
36
|
|
|
@@ -40,4 +42,4 @@ function SphereUtils.intersectsRay(
|
|
|
40
42
|
return false
|
|
41
43
|
end
|
|
42
44
|
|
|
43
|
-
return SphereUtils
|
|
45
|
+
return SphereUtils
|
|
@@ -36,11 +36,11 @@ end
|
|
|
36
36
|
]=]
|
|
37
37
|
function SwingTwistUtils.twistAngle(cf: CFrame, direction: Vector3): number
|
|
38
38
|
local axis, theta = cf:ToAxisAngle()
|
|
39
|
-
local w, v = math.cos(theta/2),
|
|
40
|
-
local proj = v:Dot(direction)*direction
|
|
39
|
+
local w, v = math.cos(theta / 2), math.sin(theta / 2) * axis
|
|
40
|
+
local proj = v:Dot(direction) * direction
|
|
41
41
|
local twist = CFrame.new(0, 0, 0, proj.X, proj.Y, proj.Z, w)
|
|
42
42
|
local _, nTheta = twist:ToAxisAngle()
|
|
43
|
-
return math.sign(v:Dot(direction))*nTheta
|
|
43
|
+
return math.sign(v:Dot(direction)) * nTheta
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
return SwingTwistUtils
|
|
46
|
+
return SwingTwistUtils
|