@quenty/inputobjectutils 2.0.0 → 2.0.2-canary.238.2c4d310.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,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
+ ## [2.0.2-canary.238.2c4d310.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/inputobjectutils@2.0.1...@quenty/inputobjectutils@2.0.2-canary.238.2c4d310.0) (2021-12-29)
7
+
8
+ **Note:** Version bump only for package @quenty/inputobjectutils
9
+
10
+
11
+
12
+
13
+
14
+ ## [2.0.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/inputobjectutils@2.0.0...@quenty/inputobjectutils@2.0.1) (2021-10-13)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * InputObjectRayUtils allows the specification of the camera ([4956ef9](https://github.com/Quenty/NevermoreEngine/commit/4956ef91728c9a8f763dab565f56e439981b122f))
20
+
21
+
22
+
23
+
24
+
6
25
  # [2.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/inputobjectutils@1.2.0...@quenty/inputobjectutils@2.0.0) (2021-09-05)
7
26
 
8
27
 
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2014 Quenty
3
+ Copyright (c) 2014-2021 Quenty
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  ## InputObjectUtils
2
2
  <div align="center">
3
- <a href="http://quenty.github.io/api/">
3
+ <a href="http://quenty.github.io/NevermoreEngine/">
4
4
  <img src="https://img.shields.io/badge/docs-website-green.svg" alt="Documentation" />
5
5
  </a>
6
6
  <a href="https://discord.gg/mhtGUS8">
7
- <img src="https://img.shields.io/badge/discord-nevermore-blue.svg" alt="Discord" />
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" />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/inputobjectutils",
3
- "version": "2.0.0",
3
+ "version": "2.0.2-canary.238.2c4d310.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": "c06170ec47b0d4520c587ce2e6404d14b5dbb851"
30
+ "gitHead": "2c4d310b84afd0570d89667dc5d4aa69a0ef304a"
31
31
  }
@@ -1,5 +1,7 @@
1
- --- Utility functions for constructing rays from input objects
2
- -- @module InputObjectRayUtils
1
+ --[=[
2
+ Utility functions for constructing rays from input objects
3
+ @class InputObjectRayUtils
4
+ ]=]
3
5
 
4
6
  local Workspace = game:GetService("Workspace")
5
7
 
@@ -7,34 +9,90 @@ local DEFAULT_RAY_DISTANCE = 1000
7
9
 
8
10
  local InputObjectRayUtils = {}
9
11
 
10
- function InputObjectRayUtils.cameraRayFromInputObject(inputObject, distance)
12
+ --[=[
13
+ Computes a camera ray from an inputObject
14
+ @param inputObject InputObject
15
+ @param distance number
16
+ @param offset Vector3? -- Optional
17
+ @param camera Camera? -- Optional
18
+ @return Ray
19
+ ]=]
20
+ function InputObjectRayUtils.cameraRayFromInputObject(inputObject, distance, offset, camera)
11
21
  assert(inputObject, "Bad inputObject")
22
+ offset = offset or Vector3.new()
12
23
 
13
- return InputObjectRayUtils.cameraRayFromScreenPosition(inputObject.Position, distance)
24
+ return InputObjectRayUtils.cameraRayFromScreenPosition(inputObject.Position + offset, distance, camera)
14
25
  end
15
26
 
16
- function InputObjectRayUtils.cameraRayFromInputObjectWithOffset(inputObject, distance, offset)
27
+ --[=[
28
+ Computes a camera ray from the mouse
29
+ @param mouse Mouse
30
+ @param distance number
31
+ @param offset Vector3? -- Optional
32
+ @param camera Camera? -- Optional
33
+ @return Ray
34
+ ]=]
35
+ function InputObjectRayUtils.cameraRayFromMouse(mouse, distance, offset, camera)
36
+ assert(mouse, "Bad mouse")
37
+ offset = offset or Vector3.new(0, 0, 0)
38
+
39
+ return InputObjectRayUtils.cameraRayFromScreenPosition(
40
+ Vector2.new(mouse.x + offset.x, mouse.y + offset.y),
41
+ distance,
42
+ camera)
43
+ end
44
+
45
+ --[=[
46
+ @param inputObject InputObject
47
+ @param distance number? -- Optional
48
+ @param offset Vector3
49
+ @param camera Camera? -- Optional
50
+ @return Ray
51
+ ]=]
52
+ function InputObjectRayUtils.cameraRayFromInputObjectWithOffset(inputObject, distance, offset, camera)
17
53
  assert(inputObject, "Bad inputObject")
18
54
 
19
- return InputObjectRayUtils.cameraRayFromScreenPosition(inputObject.Position + offset, distance)
55
+ return InputObjectRayUtils.cameraRayFromScreenPosition(
56
+ inputObject.Position + offset,
57
+ distance,
58
+ camera)
20
59
  end
21
60
 
22
- function InputObjectRayUtils.cameraRayFromScreenPosition(position, distance)
61
+ --[=[
62
+ @param position Vector3
63
+ @param distance number? -- Optional
64
+ @param camera Camera? -- Optional
65
+ @return Ray
66
+ ]=]
67
+ function InputObjectRayUtils.cameraRayFromScreenPosition(position, distance, camera)
23
68
  distance = distance or DEFAULT_RAY_DISTANCE
69
+ camera = camera or Workspace.CurrentCamera
24
70
 
25
- local baseRay = Workspace.CurrentCamera:ScreenPointToRay(position.X, position.Y)
71
+ local baseRay = camera:ScreenPointToRay(position.X, position.Y)
26
72
  return Ray.new(baseRay.Origin, baseRay.Direction.unit * distance)
27
73
  end
28
74
 
29
- function InputObjectRayUtils.cameraRayFromViewportPosition(position, distance)
75
+ --[=[
76
+ @param position Vector3
77
+ @param distance number? -- Optional
78
+ @param camera Camera? -- Optional
79
+ @return Ray
80
+ ]=]
81
+ function InputObjectRayUtils.cameraRayFromViewportPosition(position, distance, camera)
30
82
  distance = distance or DEFAULT_RAY_DISTANCE
83
+ camera = camera or Workspace.CurrentCamera
31
84
 
32
- local baseRay = Workspace.CurrentCamera:ViewportPointToRay(position.X, position.Y)
85
+ local baseRay = camera:ViewportPointToRay(position.X, position.Y)
33
86
  return Ray.new(baseRay.Origin, baseRay.Direction.unit * distance)
34
87
  end
35
88
 
36
-
37
- -- Generates a circle of rays including the center ray
89
+ --[=[
90
+ Generates a circle of rays including the center ray
91
+ @param ray Ray
92
+ @param count number
93
+ @param radius number
94
+ @return { Ray }
95
+ ]=]
38
96
  function InputObjectRayUtils.generateCircleRays(ray, count, radius)
39
97
  local rays = { }
40
98
 
@@ -1,5 +1,7 @@
1
- --- Provides utility functions involving input objects
2
- -- @module InputObjectUtils
1
+ --[=[
2
+ Provides utility functions involving input objects
3
+ @class InputObjectUtils
4
+ ]=]
3
5
 
4
6
  local InputObjectUtils = {}
5
7
 
@@ -11,12 +13,26 @@ local MOUSE_USER_INPUT_TYPES = {
11
13
  [Enum.UserInputType.MouseMovement] = true;
12
14
  }
13
15
 
16
+ --[=[
17
+ Returns whether a user input type involves the mouse.
18
+
19
+ @param userInputType UserInputType
20
+ @return true
21
+ ]=]
14
22
  function InputObjectUtils.isMouseUserInputType(userInputType)
15
23
  assert(typeof(userInputType) == "EnumItem", "Bad userInputType")
16
24
 
17
- return MOUSE_USER_INPUT_TYPES[userInputType]
25
+ return MOUSE_USER_INPUT_TYPES[userInputType] or false
18
26
  end
19
27
 
28
+ --[=[
29
+ Compares the two input objects and determines if they are the same thing. For example,
30
+ a finger being dragged across a screen, or a mouse input being used as a cursor.
31
+
32
+ @param inputObject InputObject
33
+ @param otherInputObject InputObject
34
+ @return boolean
35
+ ]=]
20
36
  function InputObjectUtils.isSameInputObject(inputObject, otherInputObject)
21
37
  assert(inputObject, "Bad inputObject")
22
38
  assert(otherInputObject, "Bad otherInputObject")