@quenty/inputobjectutils 2.1.0 → 3.0.1-canary.38bdfe3.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 +19 -0
- package/LICENSE.md +1 -1
- package/package.json +2 -2
- package/src/Client/InputObjectRayUtils.lua +9 -7
- package/src/Client/InputObjectUtils.lua +19 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
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
|
+
## [3.0.1-canary.38bdfe3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/inputobjectutils@3.0.0...@quenty/inputobjectutils@3.0.1-canary.38bdfe3.0) (2022-09-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Support Vector2 and Vector3 in InputObjectRayUtils ([8843d02](https://github.com/Quenty/NevermoreEngine/commit/8843d02fd1c4e7aa6fee4cbd9cd1cafe076ca7ef))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [3.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/inputobjectutils@2.1.0...@quenty/inputobjectutils@3.0.0) (2022-05-21)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @quenty/inputobjectutils
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
# [2.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/inputobjectutils@2.0.2...@quenty/inputobjectutils@2.1.0) (2022-03-27)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package @quenty/inputobjectutils
|
package/LICENSE.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/inputobjectutils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1-canary.38bdfe3.0",
|
|
4
4
|
"description": "Provides utility functions involving input objects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "38bdfe3721bddf1d272628b1104b1d8e0abaf24f"
|
|
31
31
|
}
|
|
@@ -13,7 +13,7 @@ local InputObjectRayUtils = {}
|
|
|
13
13
|
Computes a camera ray from an inputObject
|
|
14
14
|
@param inputObject InputObject
|
|
15
15
|
@param distance number
|
|
16
|
-
@param offset Vector3
|
|
16
|
+
@param offset Vector3 | Vector2 | nil -- Optional
|
|
17
17
|
@param camera Camera? -- Optional
|
|
18
18
|
@return Ray
|
|
19
19
|
]=]
|
|
@@ -21,14 +21,15 @@ function InputObjectRayUtils.cameraRayFromInputObject(inputObject, distance, off
|
|
|
21
21
|
assert(inputObject, "Bad inputObject")
|
|
22
22
|
offset = offset or Vector3.new()
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
local position = inputObject.Position
|
|
25
|
+
return InputObjectRayUtils.cameraRayFromScreenPosition(Vector2.new(position.x + offset.x, position.y + offset.y), distance, camera)
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
--[=[
|
|
28
29
|
Computes a camera ray from the mouse
|
|
29
30
|
@param mouse Mouse
|
|
30
31
|
@param distance number
|
|
31
|
-
@param offset Vector3
|
|
32
|
+
@param offset Vector3 | Vector2 | nil -- Optional
|
|
32
33
|
@param camera Camera? -- Optional
|
|
33
34
|
@return Ray
|
|
34
35
|
]=]
|
|
@@ -45,21 +46,22 @@ end
|
|
|
45
46
|
--[=[
|
|
46
47
|
@param inputObject InputObject
|
|
47
48
|
@param distance number? -- Optional
|
|
48
|
-
@param offset Vector3
|
|
49
|
+
@param offset Vector3 | Vector2
|
|
49
50
|
@param camera Camera? -- Optional
|
|
50
51
|
@return Ray
|
|
51
52
|
]=]
|
|
52
53
|
function InputObjectRayUtils.cameraRayFromInputObjectWithOffset(inputObject, distance, offset, camera)
|
|
53
54
|
assert(inputObject, "Bad inputObject")
|
|
54
55
|
|
|
56
|
+
local position = inputObject.Position
|
|
55
57
|
return InputObjectRayUtils.cameraRayFromScreenPosition(
|
|
56
|
-
|
|
58
|
+
Vector2.new(position.x + offset.x, position.y + offset.y),
|
|
57
59
|
distance,
|
|
58
60
|
camera)
|
|
59
61
|
end
|
|
60
62
|
|
|
61
63
|
--[=[
|
|
62
|
-
@param position Vector3
|
|
64
|
+
@param position Vector3 | Vector2
|
|
63
65
|
@param distance number? -- Optional
|
|
64
66
|
@param camera Camera? -- Optional
|
|
65
67
|
@return Ray
|
|
@@ -73,7 +75,7 @@ function InputObjectRayUtils.cameraRayFromScreenPosition(position, distance, cam
|
|
|
73
75
|
end
|
|
74
76
|
|
|
75
77
|
--[=[
|
|
76
|
-
@param position Vector3
|
|
78
|
+
@param position Vector3 | Vector2
|
|
77
79
|
@param distance number? -- Optional
|
|
78
80
|
@param camera Camera? -- Optional
|
|
79
81
|
@return Ray
|
|
@@ -13,11 +13,17 @@ local MOUSE_USER_INPUT_TYPES = {
|
|
|
13
13
|
[Enum.UserInputType.MouseMovement] = true;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
local MOUSE_BUTTON_USER_INPUT_TYPES = {
|
|
17
|
+
[Enum.UserInputType.MouseButton1] = true;
|
|
18
|
+
[Enum.UserInputType.MouseButton2] = true;
|
|
19
|
+
[Enum.UserInputType.MouseButton3] = true;
|
|
20
|
+
}
|
|
21
|
+
|
|
16
22
|
--[=[
|
|
17
23
|
Returns whether a user input type involves the mouse.
|
|
18
24
|
|
|
19
25
|
@param userInputType UserInputType
|
|
20
|
-
@return
|
|
26
|
+
@return boolean
|
|
21
27
|
]=]
|
|
22
28
|
function InputObjectUtils.isMouseUserInputType(userInputType)
|
|
23
29
|
assert(typeof(userInputType) == "EnumItem", "Bad userInputType")
|
|
@@ -25,6 +31,18 @@ function InputObjectUtils.isMouseUserInputType(userInputType)
|
|
|
25
31
|
return MOUSE_USER_INPUT_TYPES[userInputType] or false
|
|
26
32
|
end
|
|
27
33
|
|
|
34
|
+
--[=[
|
|
35
|
+
Returns whether a user input type is a mouse button specifically.
|
|
36
|
+
|
|
37
|
+
@param userInputType UserInputType
|
|
38
|
+
@return boolean
|
|
39
|
+
]=]
|
|
40
|
+
function InputObjectUtils.isMouseButtonInputType(userInputType)
|
|
41
|
+
assert(typeof(userInputType) == "EnumItem", "Bad userInputType")
|
|
42
|
+
|
|
43
|
+
return MOUSE_BUTTON_USER_INPUT_TYPES[userInputType] or false
|
|
44
|
+
end
|
|
45
|
+
|
|
28
46
|
--[=[
|
|
29
47
|
Compares the two input objects and determines if they are the same thing. For example,
|
|
30
48
|
a finger being dragged across a screen, or a mouse input being used as a cursor.
|