@quenty/camera 14.20.3 → 14.20.4-canary.11a5dcf.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 +16 -0
- package/package.json +17 -17
- package/src/Client/CameraStack.lua +27 -20
- package/src/Client/CameraStackService.lua +53 -35
- package/src/Client/CameraState.lua +8 -8
- package/src/Client/CameraUtils.lua +1 -1
- package/src/Client/CameraUtils.story.lua +5 -4
- package/src/Client/Controls/CameraControls.lua +107 -60
- package/src/Client/Controls/CameraGamepadInputUtils.lua +36 -21
- package/src/Client/Controls/GamepadRotateModel.lua +22 -12
- package/src/Client/Effects/CameraEffectUtils.lua +10 -1
- package/src/Client/Effects/CustomCameraEffect.lua +21 -5
- package/src/Client/Effects/DefaultCamera.lua +50 -32
- package/src/Client/Effects/FadeBetween/FadeBetweenCamera.lua +7 -7
- package/src/Client/Effects/FadeBetween/FadeBetweenCamera2.lua +11 -11
- package/src/Client/Effects/FadeBetween/FadeBetweenCamera3.lua +57 -21
- package/src/Client/Effects/FadeBetween/FadeBetweenCamera4.lua +17 -9
- package/src/Client/Effects/FadingCamera.lua +21 -5
- package/src/Client/Effects/HeartbeatCamera.lua +22 -9
- package/src/Client/Effects/ImpulseCamera.lua +44 -28
- package/src/Client/Effects/ImpulseCamera.story.lua +6 -6
- package/src/Client/Effects/InverseFader.lua +22 -6
- package/src/Client/Effects/LagPointCamera.lua +27 -8
- package/src/Client/Effects/OverrideDefaultCameraToo.lua +26 -4
- package/src/Client/Effects/PointCamera.lua +22 -6
- package/src/Client/Effects/PushCamera.lua +35 -14
- package/src/Client/Effects/RotatedCamera.lua +23 -9
- package/src/Client/Effects/SmoothPositionCamera.lua +22 -10
- package/src/Client/Effects/SmoothRotatedCamera.lua +52 -24
- package/src/Client/Effects/SmoothZoomedCamera.lua +31 -12
- package/src/Client/Effects/SummedCamera.lua +38 -16
- package/src/Client/Effects/TrackCamera.lua +24 -11
- package/src/Client/Effects/XZPlaneLockCamera.lua +21 -8
- package/src/Client/Effects/ZoomedCamera.lua +24 -7
- package/src/Client/Input/CameraInputUtils.lua +49 -13
- package/src/Client/Input/CameraTouchInputUtils.lua +17 -16
- package/src/Client/Utility/CameraFrame.lua +2 -2
- package/src/Client/Utility/CameraFrame.story.lua +21 -12
- package/src/Client/Utility/CameraStateTweener.lua +39 -19
- package/src/Client/Utility/FieldOfViewUtils.lua +1 -1
- package/test/scripts/Client/ClientMain.client.lua +1 -1
- package/test/scripts/Server/ServerMain.server.lua +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Add another layer of effects over any other camera by allowing an "impulse"
|
|
3
4
|
to be applied. Good for shockwaves, camera shake, and recoil.
|
|
@@ -7,6 +8,7 @@
|
|
|
7
8
|
|
|
8
9
|
local require = require(script.Parent.loader).load(script)
|
|
9
10
|
|
|
11
|
+
local CameraEffectUtils = require("CameraEffectUtils")
|
|
10
12
|
local CameraState = require("CameraState")
|
|
11
13
|
local Spring = require("Spring")
|
|
12
14
|
local SpringUtils = require("SpringUtils")
|
|
@@ -17,11 +19,26 @@ local EPSILON = 1e-6
|
|
|
17
19
|
local ImpulseCamera = {}
|
|
18
20
|
ImpulseCamera.ClassName = "ImpulseCamera"
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
export type ImpulseCamera = typeof(setmetatable(
|
|
23
|
+
{} :: {
|
|
24
|
+
CameraState: CameraState.CameraState,
|
|
25
|
+
Damper: number,
|
|
26
|
+
Speed: number,
|
|
27
|
+
Spring: Spring.Spring<Vector3>,
|
|
28
|
+
_defaultSpring: Spring.Spring<Vector3>,
|
|
29
|
+
_springs: { Spring.Spring<Vector3> },
|
|
30
|
+
},
|
|
31
|
+
{} :: typeof({ __index = ImpulseCamera })
|
|
32
|
+
)) & CameraEffectUtils.CameraEffect
|
|
33
|
+
|
|
34
|
+
function ImpulseCamera.new(): ImpulseCamera
|
|
35
|
+
local self: ImpulseCamera = setmetatable(
|
|
36
|
+
{
|
|
37
|
+
_springs = {},
|
|
38
|
+
_defaultSpring = Spring.new(Vector3.zero),
|
|
39
|
+
} :: any,
|
|
40
|
+
ImpulseCamera
|
|
41
|
+
)
|
|
25
42
|
|
|
26
43
|
self._defaultSpring.Damper = 0.5
|
|
27
44
|
self._defaultSpring.Speed = 20
|
|
@@ -32,10 +49,10 @@ end
|
|
|
32
49
|
--[=[
|
|
33
50
|
Applies an impulse to the camera, shaking it!
|
|
34
51
|
@param velocity Vector3
|
|
35
|
-
@param speed number -- Optional
|
|
36
|
-
@param damper number -- Optional
|
|
52
|
+
@param speed number? -- Optional
|
|
53
|
+
@param damper number? -- Optional
|
|
37
54
|
]=]
|
|
38
|
-
function ImpulseCamera
|
|
55
|
+
function ImpulseCamera.Impulse(self: ImpulseCamera, velocity: Vector3, speed: number?, damper: number?): ()
|
|
39
56
|
assert(typeof(velocity) == "Vector3", "Bad velocity")
|
|
40
57
|
assert(type(speed) == "number" or speed == nil, "Bad speed")
|
|
41
58
|
assert(type(damper) == "number" or damper == nil, "Bad damper")
|
|
@@ -48,28 +65,27 @@ end
|
|
|
48
65
|
Applies a random impulse
|
|
49
66
|
|
|
50
67
|
@param velocity Vector3
|
|
51
|
-
@param speed number -- Optional
|
|
52
|
-
@param damper number -- Optional
|
|
68
|
+
@param speed number? -- Optional
|
|
69
|
+
@param damper number? -- Optional
|
|
53
70
|
]=]
|
|
54
|
-
function ImpulseCamera
|
|
71
|
+
function ImpulseCamera.ImpulseRandom(self: ImpulseCamera, velocity: Vector3, speed: number?, damper: number?): ()
|
|
55
72
|
assert(typeof(velocity) == "Vector3", "Bad velocity")
|
|
56
73
|
assert(type(speed) == "number" or speed == nil, "Bad speed")
|
|
57
74
|
assert(type(damper) == "number" or damper == nil, "Bad damper")
|
|
58
75
|
|
|
59
|
-
local randomVector = Vector3.new(
|
|
60
|
-
2*(math.random() - 0.5),
|
|
61
|
-
2*(math.random() - 0.5),
|
|
62
|
-
2*(math.random() - 0.5)
|
|
63
|
-
)
|
|
76
|
+
local randomVector = Vector3.new(2 * (math.random() - 0.5), 2 * (math.random() - 0.5), 2 * (math.random() - 0.5))
|
|
64
77
|
|
|
65
|
-
return self:Impulse(velocity*randomVector, speed, damper)
|
|
78
|
+
return self:Impulse(velocity * randomVector, speed, damper)
|
|
66
79
|
end
|
|
67
80
|
|
|
68
|
-
function ImpulseCamera
|
|
69
|
-
if (not speed) and
|
|
81
|
+
function ImpulseCamera._getSpring(self: ImpulseCamera, speed: number?, damper: number?)
|
|
82
|
+
if (not speed) and not damper then
|
|
70
83
|
return self._defaultSpring
|
|
71
84
|
end
|
|
72
85
|
|
|
86
|
+
assert(speed ~= nil, "Type checker needs assert")
|
|
87
|
+
assert(damper ~= nil, "Type checker needs assert")
|
|
88
|
+
|
|
73
89
|
speed = speed or self._defaultSpring.Speed
|
|
74
90
|
damper = damper or self._defaultSpring.Damper
|
|
75
91
|
|
|
@@ -92,10 +108,10 @@ function ImpulseCamera:_getSpring(speed, damper)
|
|
|
92
108
|
return newSpring
|
|
93
109
|
end
|
|
94
110
|
|
|
95
|
-
function ImpulseCamera
|
|
111
|
+
function ImpulseCamera._aggregateSprings(self: ImpulseCamera): Vector3
|
|
96
112
|
local position = self._defaultSpring.Position
|
|
97
113
|
|
|
98
|
-
for i
|
|
114
|
+
for i = #self._springs, 1, -1 do
|
|
99
115
|
local spring = self._springs[i]
|
|
100
116
|
local animating, springPosition = SpringUtils.animating(spring, EPSILON)
|
|
101
117
|
|
|
@@ -108,11 +124,11 @@ function ImpulseCamera:_aggregateSprings()
|
|
|
108
124
|
return position
|
|
109
125
|
end
|
|
110
126
|
|
|
111
|
-
function ImpulseCamera
|
|
127
|
+
function ImpulseCamera.__add(self: ImpulseCamera, other)
|
|
112
128
|
return SummedCamera.new(self, other)
|
|
113
129
|
end
|
|
114
130
|
|
|
115
|
-
function ImpulseCamera
|
|
131
|
+
function ImpulseCamera.__newindex(self: ImpulseCamera, index, value)
|
|
116
132
|
if index == "Damper" then
|
|
117
133
|
assert(type(value) == "number", "Bad value")
|
|
118
134
|
self._defaultSpring.Damper = value
|
|
@@ -130,14 +146,14 @@ end
|
|
|
130
146
|
@prop CameraState CameraState
|
|
131
147
|
@within ImpulseCamera
|
|
132
148
|
]=]
|
|
133
|
-
function ImpulseCamera
|
|
149
|
+
function ImpulseCamera.__index(self: ImpulseCamera, index)
|
|
134
150
|
if index == "CameraState" then
|
|
135
151
|
local newState = CameraState.new()
|
|
136
152
|
|
|
137
153
|
local position = self:_aggregateSprings()
|
|
138
|
-
newState.CFrame = CFrame.Angles(0, position.
|
|
139
|
-
* CFrame.Angles(position.
|
|
140
|
-
* CFrame.Angles(0, 0, position.
|
|
154
|
+
newState.CFrame = CFrame.Angles(0, position.Y, 0)
|
|
155
|
+
* CFrame.Angles(position.X, 0, 0)
|
|
156
|
+
* CFrame.Angles(0, 0, position.Z)
|
|
141
157
|
|
|
142
158
|
return newState
|
|
143
159
|
elseif index == "Damper" then
|
|
@@ -151,4 +167,4 @@ function ImpulseCamera:__index(index)
|
|
|
151
167
|
end
|
|
152
168
|
end
|
|
153
169
|
|
|
154
|
-
return ImpulseCamera
|
|
170
|
+
return ImpulseCamera
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
@class ImpulseCamera.story
|
|
3
3
|
]]
|
|
4
4
|
|
|
5
|
-
local require =
|
|
5
|
+
local require =
|
|
6
|
+
require(game:GetService("ServerScriptService"):FindFirstChild("LoaderUtils", true).Parent).bootstrapStory(script)
|
|
6
7
|
|
|
7
8
|
local RunService = game:GetService("RunService")
|
|
8
9
|
local Workspace = game:GetService("Workspace")
|
|
9
10
|
|
|
10
|
-
local Maid = require("Maid")
|
|
11
11
|
local CameraStack = require("CameraStack")
|
|
12
|
-
local ImpulseCamera = require("ImpulseCamera")
|
|
13
12
|
local DefaultCamera = require("DefaultCamera")
|
|
13
|
+
local ImpulseCamera = require("ImpulseCamera")
|
|
14
|
+
local Maid = require("Maid")
|
|
14
15
|
|
|
15
16
|
return function(target)
|
|
16
17
|
local maid = Maid.new()
|
|
@@ -67,9 +68,8 @@ return function(target)
|
|
|
67
68
|
maid:GiveTask(button.Activated:Connect(impulse))
|
|
68
69
|
end
|
|
69
70
|
|
|
70
|
-
|
|
71
71
|
makeShaker("Shake", function()
|
|
72
|
-
impulseCamera:Impulse(Vector3.new(0, math.random() - 0.5, math.random() - 0.5)*50, 50, 0.2)
|
|
72
|
+
impulseCamera:Impulse(Vector3.new(0, math.random() - 0.5, math.random() - 0.5) * 50, 50, 0.2)
|
|
73
73
|
end)
|
|
74
74
|
makeShaker("SHAKE", function()
|
|
75
75
|
impulseCamera:ImpulseRandom(Vector3.new(0, 3, 0), 75, 0.1)
|
|
@@ -78,4 +78,4 @@ return function(target)
|
|
|
78
78
|
return function()
|
|
79
79
|
maid:DoCleaning()
|
|
80
80
|
end
|
|
81
|
-
end
|
|
81
|
+
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Be the inverse of a fading camera (makes scaling in cameras easy).
|
|
3
4
|
@class InverseFader
|
|
@@ -5,13 +6,25 @@
|
|
|
5
6
|
|
|
6
7
|
local require = require(script.Parent.loader).load(script)
|
|
7
8
|
|
|
9
|
+
local CameraEffectUtils = require("CameraEffectUtils")
|
|
10
|
+
local CameraState = require("CameraState")
|
|
11
|
+
local FadingCamera = require("FadingCamera")
|
|
8
12
|
local SummedCamera = require("SummedCamera")
|
|
9
13
|
|
|
10
14
|
local InverseFader = {}
|
|
11
15
|
InverseFader.ClassName = "InverseFader"
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
export type InverseFader = typeof(setmetatable(
|
|
18
|
+
{} :: {
|
|
19
|
+
CameraState: CameraState.CameraState,
|
|
20
|
+
_camera: CameraEffectUtils.CameraEffect,
|
|
21
|
+
_fader: FadingCamera.FadingCamera,
|
|
22
|
+
},
|
|
23
|
+
{} :: typeof({ __index = InverseFader })
|
|
24
|
+
)) & CameraEffectUtils.CameraEffect
|
|
25
|
+
|
|
26
|
+
function InverseFader.new(camera: CameraEffectUtils.CameraEffect, fader: FadingCamera.FadingCamera)
|
|
27
|
+
local self: InverseFader = setmetatable({} :: any, InverseFader)
|
|
15
28
|
|
|
16
29
|
self._camera = camera or error("No camera")
|
|
17
30
|
self._fader = fader or error("No fader")
|
|
@@ -19,16 +32,19 @@ function InverseFader.new(camera, fader)
|
|
|
19
32
|
return self
|
|
20
33
|
end
|
|
21
34
|
|
|
22
|
-
function InverseFader
|
|
35
|
+
function InverseFader.__add(self: InverseFader, other)
|
|
23
36
|
return SummedCamera.new(self, other)
|
|
24
37
|
end
|
|
25
38
|
|
|
26
|
-
function InverseFader
|
|
39
|
+
function InverseFader.__index(self: InverseFader, index)
|
|
27
40
|
if index == "CameraState" then
|
|
28
|
-
|
|
41
|
+
local cameraState: CameraState.CameraState = (self._camera.CameraState :: any) or (self._camera :: any)
|
|
42
|
+
|
|
43
|
+
-- TODO: I think this is actually wrong
|
|
44
|
+
return (cameraState :: any) * (1 - self._fader.Value)
|
|
29
45
|
else
|
|
30
46
|
return InverseFader[index]
|
|
31
47
|
end
|
|
32
48
|
end
|
|
33
49
|
|
|
34
|
-
return InverseFader
|
|
50
|
+
return InverseFader
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Point a current element but lag behind for a smoother experience
|
|
3
4
|
@class LagPointCamera
|
|
@@ -5,15 +6,30 @@
|
|
|
5
6
|
|
|
6
7
|
local require = require(script.Parent.loader).load(script)
|
|
7
8
|
|
|
9
|
+
local CameraEffectUtils = require("CameraEffectUtils")
|
|
8
10
|
local CameraState = require("CameraState")
|
|
9
|
-
local SummedCamera = require("SummedCamera")
|
|
10
11
|
local Spring = require("Spring")
|
|
12
|
+
local SummedCamera = require("SummedCamera")
|
|
11
13
|
|
|
12
14
|
local LagPointCamera = {}
|
|
13
15
|
LagPointCamera.ClassName = "LagPointCamera"
|
|
14
16
|
LagPointCamera._FocusCamera = nil
|
|
15
17
|
LagPointCamera._OriginCamera = nil
|
|
16
18
|
|
|
19
|
+
export type LagPointCamera = typeof(setmetatable(
|
|
20
|
+
{} :: {
|
|
21
|
+
CameraState: CameraState.CameraState,
|
|
22
|
+
Origin: CameraState.CameraState,
|
|
23
|
+
FocusCamera: CameraEffectUtils.CameraEffect,
|
|
24
|
+
OriginCamera: CameraEffectUtils.CameraEffect,
|
|
25
|
+
FocusSpring: Spring.Spring<Vector3>,
|
|
26
|
+
LastFocusUpdate: number,
|
|
27
|
+
FocusPosition: Vector3,
|
|
28
|
+
Speed: number,
|
|
29
|
+
},
|
|
30
|
+
{} :: typeof({ __index = LagPointCamera })
|
|
31
|
+
)) & CameraEffectUtils.CameraEffect
|
|
32
|
+
|
|
17
33
|
--[=[
|
|
18
34
|
Camera that lags behind the actual camera.
|
|
19
35
|
|
|
@@ -21,8 +37,11 @@ LagPointCamera._OriginCamera = nil
|
|
|
21
37
|
@param focusCamera CameraEffect -- The Camera to look at.
|
|
22
38
|
@return LagPointCamera
|
|
23
39
|
]=]
|
|
24
|
-
function LagPointCamera.new(
|
|
25
|
-
|
|
40
|
+
function LagPointCamera.new(
|
|
41
|
+
originCamera: CameraEffectUtils.CameraEffect,
|
|
42
|
+
focusCamera: CameraEffectUtils.CameraEffect
|
|
43
|
+
): LagPointCamera
|
|
44
|
+
local self: LagPointCamera = setmetatable({} :: any, LagPointCamera)
|
|
26
45
|
|
|
27
46
|
self.FocusSpring = Spring.new(Vector3.zero)
|
|
28
47
|
self.OriginCamera = originCamera or error("Must have originCamera")
|
|
@@ -32,11 +51,11 @@ function LagPointCamera.new(originCamera, focusCamera)
|
|
|
32
51
|
return self
|
|
33
52
|
end
|
|
34
53
|
|
|
35
|
-
function LagPointCamera
|
|
54
|
+
function LagPointCamera.__add(self: LagPointCamera, other)
|
|
36
55
|
return SummedCamera.new(self, other)
|
|
37
56
|
end
|
|
38
57
|
|
|
39
|
-
function LagPointCamera
|
|
58
|
+
function LagPointCamera.__newindex(self: LagPointCamera, index, value)
|
|
40
59
|
if index == "FocusCamera" then
|
|
41
60
|
rawset(self, "_" .. index, value)
|
|
42
61
|
self.FocusSpring.Target = self.FocusCamera.CameraState.Position
|
|
@@ -49,11 +68,11 @@ function LagPointCamera:__newindex(index, value)
|
|
|
49
68
|
elseif index == "Speed" or index == "Damper" or index == "Velocity" then
|
|
50
69
|
self.FocusSpring[index] = value
|
|
51
70
|
else
|
|
52
|
-
error(index .. " is not a valid member of LagPointCamera")
|
|
71
|
+
error(tostring(index) .. " is not a valid member of LagPointCamera")
|
|
53
72
|
end
|
|
54
73
|
end
|
|
55
74
|
|
|
56
|
-
function LagPointCamera
|
|
75
|
+
function LagPointCamera.__index(self: LagPointCamera, index): any
|
|
57
76
|
if index == "CameraState" then
|
|
58
77
|
local origin, focusPosition = self.Origin, self.FocusPosition
|
|
59
78
|
|
|
@@ -87,4 +106,4 @@ function LagPointCamera:__index(index)
|
|
|
87
106
|
end
|
|
88
107
|
end
|
|
89
108
|
|
|
90
|
-
return LagPointCamera
|
|
109
|
+
return LagPointCamera
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Allows you to override the default camera with this cameras
|
|
3
4
|
information. Useful for custom camera controls that the user
|
|
@@ -15,12 +16,24 @@
|
|
|
15
16
|
|
|
16
17
|
local require = require(script.Parent.loader).load(script)
|
|
17
18
|
|
|
19
|
+
local CameraEffectUtils = require("CameraEffectUtils")
|
|
20
|
+
local CameraState = require("CameraState")
|
|
18
21
|
local SummedCamera = require("SummedCamera")
|
|
19
22
|
local Vector3Utils = require("Vector3Utils")
|
|
20
23
|
|
|
21
24
|
local OverrideDefaultCameraToo = {}
|
|
22
25
|
OverrideDefaultCameraToo.ClassName = "OverrideDefaultCameraToo"
|
|
23
26
|
|
|
27
|
+
export type OverrideDefaultCameraToo = typeof(setmetatable(
|
|
28
|
+
{} :: {
|
|
29
|
+
CameraState: CameraState.CameraState,
|
|
30
|
+
BaseCamera: CameraEffectUtils.CameraEffect,
|
|
31
|
+
DefaultCamera: CameraEffectUtils.CameraEffect,
|
|
32
|
+
Predicate: ((CameraState.CameraState) -> boolean)?,
|
|
33
|
+
},
|
|
34
|
+
{} :: typeof({ __index = OverrideDefaultCameraToo })
|
|
35
|
+
)) & CameraEffectUtils.CameraEffect
|
|
36
|
+
|
|
24
37
|
--[=[
|
|
25
38
|
Initializes a new OverrideDefaultCameraToo
|
|
26
39
|
|
|
@@ -28,8 +41,12 @@ OverrideDefaultCameraToo.ClassName = "OverrideDefaultCameraToo"
|
|
|
28
41
|
@param defaultCamera DefaultCamera
|
|
29
42
|
@param predicate Filter on whether to override or not
|
|
30
43
|
]=]
|
|
31
|
-
function OverrideDefaultCameraToo.new(
|
|
32
|
-
|
|
44
|
+
function OverrideDefaultCameraToo.new(
|
|
45
|
+
baseCamera: CameraEffectUtils.CameraEffect,
|
|
46
|
+
defaultCamera: CameraEffectUtils.CameraEffect,
|
|
47
|
+
predicate
|
|
48
|
+
): OverrideDefaultCameraToo
|
|
49
|
+
local self: OverrideDefaultCameraToo = setmetatable({} :: any, OverrideDefaultCameraToo)
|
|
33
50
|
|
|
34
51
|
self.BaseCamera = assert(baseCamera, "No baseCamera")
|
|
35
52
|
self.DefaultCamera = assert(defaultCamera, "No defaultCamera")
|
|
@@ -60,7 +77,12 @@ function OverrideDefaultCameraToo:__index(index)
|
|
|
60
77
|
warn("[OverrideDefaultCameraToo] - No predicate set")
|
|
61
78
|
end
|
|
62
79
|
|
|
63
|
-
local angle = math.abs(
|
|
80
|
+
local angle = math.abs(
|
|
81
|
+
Vector3Utils.angleBetweenVectors(
|
|
82
|
+
result.CFrame:VectorToWorldSpace(Vector3.new(0, 0, -1)),
|
|
83
|
+
Vector3.new(0, 1, 0)
|
|
84
|
+
)
|
|
85
|
+
)
|
|
64
86
|
|
|
65
87
|
-- If the camera is straight up and down then Roblox breaks
|
|
66
88
|
if angle >= math.rad(0.1) and angle <= math.rad(179.9) then
|
|
@@ -76,4 +98,4 @@ function OverrideDefaultCameraToo:__index(index)
|
|
|
76
98
|
end
|
|
77
99
|
end
|
|
78
100
|
|
|
79
|
-
return OverrideDefaultCameraToo
|
|
101
|
+
return OverrideDefaultCameraToo
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Point a current element
|
|
3
4
|
@class PointCamera
|
|
@@ -5,20 +6,35 @@
|
|
|
5
6
|
|
|
6
7
|
local require = require(script.Parent.loader).load(script)
|
|
7
8
|
|
|
9
|
+
local CameraEffectUtils = require("CameraEffectUtils")
|
|
8
10
|
local CameraState = require("CameraState")
|
|
9
11
|
local SummedCamera = require("SummedCamera")
|
|
10
12
|
|
|
11
13
|
local PointCamera = {}
|
|
12
14
|
PointCamera.ClassName = "PointCamera"
|
|
13
15
|
|
|
16
|
+
export type PointCamera = typeof(setmetatable(
|
|
17
|
+
{} :: {
|
|
18
|
+
CameraState: CameraState.CameraState,
|
|
19
|
+
OriginCamera: CameraEffectUtils.CameraEffect,
|
|
20
|
+
FocusCamera: CameraEffectUtils.CameraEffect,
|
|
21
|
+
Origin: CameraState.CameraState,
|
|
22
|
+
Focus: CameraState.CameraState,
|
|
23
|
+
},
|
|
24
|
+
{} :: typeof({ __index = PointCamera })
|
|
25
|
+
)) & CameraEffectUtils.CameraEffect
|
|
26
|
+
|
|
14
27
|
--[=[
|
|
15
28
|
Initializes a new PointCamera
|
|
16
29
|
|
|
17
30
|
@param originCamera Camera -- A camera to use
|
|
18
31
|
@param focusCamera Camera -- The Camera to look at.
|
|
19
32
|
]=]
|
|
20
|
-
function PointCamera.new(
|
|
21
|
-
|
|
33
|
+
function PointCamera.new(
|
|
34
|
+
originCamera: CameraEffectUtils.CameraEffect,
|
|
35
|
+
focusCamera: CameraEffectUtils.CameraEffect
|
|
36
|
+
): PointCamera
|
|
37
|
+
local self: PointCamera = setmetatable({} :: any, PointCamera)
|
|
22
38
|
|
|
23
39
|
self.OriginCamera = originCamera or error("Must have originCamera")
|
|
24
40
|
self.FocusCamera = focusCamera or error("Must have focusCamera")
|
|
@@ -26,11 +42,11 @@ function PointCamera.new(originCamera, focusCamera)
|
|
|
26
42
|
return self
|
|
27
43
|
end
|
|
28
44
|
|
|
29
|
-
function PointCamera
|
|
45
|
+
function PointCamera.__add(self: PointCamera, other: CameraEffectUtils.CameraEffect): SummedCamera.SummedCamera
|
|
30
46
|
return SummedCamera.new(self, other)
|
|
31
47
|
end
|
|
32
48
|
|
|
33
|
-
function PointCamera
|
|
49
|
+
function PointCamera.__newindex(self: PointCamera, index, value)
|
|
34
50
|
if index == "OriginCamera" or index == "FocusCamera" then
|
|
35
51
|
rawset(self, index, value)
|
|
36
52
|
else
|
|
@@ -38,7 +54,7 @@ function PointCamera:__newindex(index, value)
|
|
|
38
54
|
end
|
|
39
55
|
end
|
|
40
56
|
|
|
41
|
-
function PointCamera
|
|
57
|
+
function PointCamera.__index(self: PointCamera, index)
|
|
42
58
|
if index == "CameraState" then
|
|
43
59
|
local origin, focus = self.Origin, self.Focus
|
|
44
60
|
|
|
@@ -56,4 +72,4 @@ function PointCamera:__index(index)
|
|
|
56
72
|
end
|
|
57
73
|
end
|
|
58
74
|
|
|
59
|
-
return PointCamera
|
|
75
|
+
return PointCamera
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Like a rotated camera, except we end up pushing back to a default rotation.
|
|
3
4
|
This same behavior is seen in Roblox vehicle seats
|
|
@@ -7,10 +8,11 @@
|
|
|
7
8
|
|
|
8
9
|
local require = require(script.Parent.loader).load(script)
|
|
9
10
|
|
|
11
|
+
local CameraEffectUtils = require("CameraEffectUtils")
|
|
10
12
|
local CameraState = require("CameraState")
|
|
11
|
-
local getRotationInXZPlane = require("getRotationInXZPlane")
|
|
12
13
|
local Math = require("Math")
|
|
13
14
|
local SummedCamera = require("SummedCamera")
|
|
15
|
+
local getRotationInXZPlane = require("getRotationInXZPlane")
|
|
14
16
|
|
|
15
17
|
local PushCamera = {}
|
|
16
18
|
PushCamera.ClassName = "PushCamera"
|
|
@@ -25,24 +27,43 @@ PushCamera.DefaultAngleXZ0 = 0
|
|
|
25
27
|
PushCamera._lastUpdateTime = -1
|
|
26
28
|
PushCamera.PushBackAfter = 0.5
|
|
27
29
|
|
|
30
|
+
export type PushCamera = typeof(setmetatable(
|
|
31
|
+
{} :: {
|
|
32
|
+
CameraState: CameraState.CameraState,
|
|
33
|
+
AngleX: number,
|
|
34
|
+
AngleY: number,
|
|
35
|
+
AngleXZ: number,
|
|
36
|
+
LastUpdateTime: number,
|
|
37
|
+
MinX: number,
|
|
38
|
+
MinY: number,
|
|
39
|
+
MaxY: number,
|
|
40
|
+
Rotation: CFrame,
|
|
41
|
+
CFrame: CFrame,
|
|
42
|
+
PushBackDelta: number,
|
|
43
|
+
PercentFaded: number,
|
|
44
|
+
PercentFadedCurved: number,
|
|
45
|
+
},
|
|
46
|
+
{} :: typeof({ __index = PushCamera })
|
|
47
|
+
)) & CameraEffectUtils.CameraEffect
|
|
48
|
+
|
|
28
49
|
--[=[
|
|
29
50
|
Constructs a new PushCamera
|
|
30
51
|
@return PushCamera
|
|
31
52
|
]=]
|
|
32
|
-
function PushCamera.new()
|
|
33
|
-
local self = setmetatable({}, PushCamera)
|
|
53
|
+
function PushCamera.new(): PushCamera
|
|
54
|
+
local self: PushCamera = setmetatable({} :: any, PushCamera)
|
|
34
55
|
|
|
35
56
|
return self
|
|
36
57
|
end
|
|
37
58
|
|
|
38
|
-
function PushCamera
|
|
59
|
+
function PushCamera.__add(self: PushCamera, other)
|
|
39
60
|
return SummedCamera.new(self, other)
|
|
40
61
|
end
|
|
41
62
|
|
|
42
63
|
--[=[
|
|
43
64
|
@param xzrotVector Vector2 -- The delta rotation to apply
|
|
44
65
|
]=]
|
|
45
|
-
function PushCamera
|
|
66
|
+
function PushCamera.RotateXY(self: PushCamera, xzrotVector)
|
|
46
67
|
self.AngleX = self.AngleX + xzrotVector.x
|
|
47
68
|
self.AngleY = self.AngleY + xzrotVector.y
|
|
48
69
|
end
|
|
@@ -51,29 +72,29 @@ end
|
|
|
51
72
|
Prevents the rotation back. You need to call this
|
|
52
73
|
every frame you want to prevent rotation.
|
|
53
74
|
]=]
|
|
54
|
-
function PushCamera
|
|
75
|
+
function PushCamera.StopRotateBack(self: PushCamera)
|
|
55
76
|
self.CFrame = self.CFrame
|
|
56
77
|
end
|
|
57
78
|
|
|
58
79
|
--[=[
|
|
59
80
|
Resets to default position automatically
|
|
60
81
|
]=]
|
|
61
|
-
function PushCamera
|
|
82
|
+
function PushCamera.Reset(self: PushCamera)
|
|
62
83
|
self.LastUpdateTime = 0
|
|
63
84
|
end
|
|
64
85
|
|
|
65
|
-
function PushCamera
|
|
86
|
+
function PushCamera.__newindex(self: PushCamera, index, value)
|
|
66
87
|
if index == "CFrame" then
|
|
67
88
|
local xzrot = getRotationInXZPlane(value)
|
|
68
|
-
self.AngleXZ = math.atan2(xzrot.
|
|
89
|
+
self.AngleXZ = math.atan2(xzrot.LookVector.X, xzrot.LookVector.Z) + math.pi
|
|
69
90
|
|
|
70
|
-
local yrot = xzrot:
|
|
91
|
+
local yrot = xzrot:ToObjectSpace(value).LookVector.Y
|
|
71
92
|
self.AngleY = math.asin(yrot)
|
|
72
93
|
elseif index == "DefaultCFrame" then
|
|
73
94
|
local xzrot = getRotationInXZPlane(value)
|
|
74
|
-
self.DefaultAngleXZ0 = math.atan2(xzrot.
|
|
95
|
+
self.DefaultAngleXZ0 = math.atan2(xzrot.LookVector.X, xzrot.LookVector.Z) + math.pi
|
|
75
96
|
|
|
76
|
-
local yrot = xzrot:
|
|
97
|
+
local yrot = xzrot:ToObjectSpace(value).LookVector.Y
|
|
77
98
|
self.AngleY = math.asin(yrot)
|
|
78
99
|
elseif index == "AngleY" then
|
|
79
100
|
self._angleY = math.clamp(value, self.MinY, self.MaxY)
|
|
@@ -103,7 +124,7 @@ end
|
|
|
103
124
|
@prop CameraState CameraState
|
|
104
125
|
@within PushCamera
|
|
105
126
|
]=]
|
|
106
|
-
function PushCamera
|
|
127
|
+
function PushCamera.__index(self: PushCamera, index)
|
|
107
128
|
if index == "CameraState" then
|
|
108
129
|
local state = CameraState.new()
|
|
109
130
|
state.CFrame = self.CFrame
|
|
@@ -111,7 +132,7 @@ function PushCamera:__index(index)
|
|
|
111
132
|
elseif index == "LastUpdateTime" then
|
|
112
133
|
return self._lastUpdateTime
|
|
113
134
|
elseif index == "LookVector" then
|
|
114
|
-
return self.Rotation.
|
|
135
|
+
return self.Rotation.LookVector
|
|
115
136
|
elseif index == "CFrame" then
|
|
116
137
|
return CFrame.Angles(0, self.AngleXZ, 0) * CFrame.Angles(self.AngleY, 0, 0)
|
|
117
138
|
elseif index == "AngleY" then
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Allow freedom of movement around a current place, much like the classic script works now.
|
|
3
4
|
Not intended to be use with the current character script. This is the rotation component.
|
|
@@ -8,13 +9,26 @@
|
|
|
8
9
|
|
|
9
10
|
local require = require(script.Parent.loader).load(script)
|
|
10
11
|
|
|
12
|
+
local CameraEffectUtils = require("CameraEffectUtils")
|
|
11
13
|
local CameraState = require("CameraState")
|
|
12
|
-
local getRotationInXZPlane = require("getRotationInXZPlane")
|
|
13
14
|
local SummedCamera = require("SummedCamera")
|
|
15
|
+
local getRotationInXZPlane = require("getRotationInXZPlane")
|
|
14
16
|
|
|
15
17
|
local RotatedCamera = {}
|
|
16
18
|
RotatedCamera.ClassName = "RotatedCamera"
|
|
17
19
|
|
|
20
|
+
export type RotatedCamera = typeof(setmetatable(
|
|
21
|
+
{} :: {
|
|
22
|
+
CameraState: CameraState.CameraState,
|
|
23
|
+
CFrame: CFrame,
|
|
24
|
+
AngleX: number,
|
|
25
|
+
AngleY: number,
|
|
26
|
+
MaxY: number,
|
|
27
|
+
MinY: number,
|
|
28
|
+
},
|
|
29
|
+
{} :: typeof({ __index = RotatedCamera })
|
|
30
|
+
)) & CameraEffectUtils.CameraEffect
|
|
31
|
+
|
|
18
32
|
-- Max/Min aim up and down
|
|
19
33
|
RotatedCamera._maxY = math.rad(80)
|
|
20
34
|
RotatedCamera._minY = math.rad(-80)
|
|
@@ -25,8 +39,8 @@ RotatedCamera._angleY = 0
|
|
|
25
39
|
Constructs a new RotatedCamera
|
|
26
40
|
@return RotatedCamera
|
|
27
41
|
]=]
|
|
28
|
-
function RotatedCamera.new()
|
|
29
|
-
local self = setmetatable({}, RotatedCamera)
|
|
42
|
+
function RotatedCamera.new(): RotatedCamera
|
|
43
|
+
local self: RotatedCamera = setmetatable({} :: any, RotatedCamera)
|
|
30
44
|
|
|
31
45
|
return self
|
|
32
46
|
end
|
|
@@ -38,17 +52,17 @@ end
|
|
|
38
52
|
--[=[
|
|
39
53
|
@param xzrotvector Vector2 -- The delta rotation to apply
|
|
40
54
|
]=]
|
|
41
|
-
function RotatedCamera:RotateXY(xzrotvector)
|
|
42
|
-
self.AngleX = self.AngleX + xzrotvector.
|
|
43
|
-
self.AngleY = self.AngleY + xzrotvector.
|
|
55
|
+
function RotatedCamera:RotateXY(xzrotvector: Vector2)
|
|
56
|
+
self.AngleX = self.AngleX + xzrotvector.X
|
|
57
|
+
self.AngleY = self.AngleY + xzrotvector.Y
|
|
44
58
|
end
|
|
45
59
|
|
|
46
60
|
function RotatedCamera:__newindex(index, value)
|
|
47
61
|
if index == "CFrame" then
|
|
48
62
|
local zxrot = getRotationInXZPlane(value)
|
|
49
|
-
self.AngleXZ = math.atan2(zxrot.
|
|
63
|
+
self.AngleXZ = math.atan2(zxrot.LookVector.X, zxrot.LookVector.Z) + math.pi
|
|
50
64
|
|
|
51
|
-
local yrot = zxrot:
|
|
65
|
+
local yrot = zxrot:ToObjectSpace(value).LookVector.Y
|
|
52
66
|
self.AngleY = math.asin(yrot)
|
|
53
67
|
elseif index == "AngleY" then
|
|
54
68
|
self._angleY = math.clamp(value, self.MinY, self.MaxY)
|
|
@@ -97,4 +111,4 @@ function RotatedCamera:__index(index)
|
|
|
97
111
|
end
|
|
98
112
|
end
|
|
99
113
|
|
|
100
|
-
return RotatedCamera
|
|
114
|
+
return RotatedCamera
|