@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
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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
|
+
## [14.20.4-canary.11a5dcf.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/camera@14.20.3...@quenty/camera@14.20.4-canary.11a5dcf.0) (2025-05-10)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Additional type checking updates ([05ba29a](https://github.com/Quenty/NevermoreEngine/commit/05ba29a03efc9f3feed74b34f1d9dfb237496214))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* Add even more types ([b31717d](https://github.com/Quenty/NevermoreEngine/commit/b31717d8c9f7620c457f5018a2affa760a65334a))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [14.20.3](https://github.com/Quenty/NevermoreEngine/compare/@quenty/camera@14.20.2...@quenty/camera@14.20.3) (2025-04-10)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @quenty/camera
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/camera",
|
|
3
|
-
"version": "14.20.
|
|
3
|
+
"version": "14.20.4-canary.11a5dcf.0",
|
|
4
4
|
"description": "Quenty's camera system for Roblox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,26 +25,26 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/acceltween": "
|
|
29
|
-
"@quenty/baseobject": "
|
|
30
|
-
"@quenty/cframeutils": "
|
|
31
|
-
"@quenty/cubicspline": "
|
|
32
|
-
"@quenty/ducktype": "
|
|
33
|
-
"@quenty/inputobjectutils": "
|
|
34
|
-
"@quenty/loader": "
|
|
35
|
-
"@quenty/maid": "
|
|
36
|
-
"@quenty/math": "
|
|
37
|
-
"@quenty/qframe": "
|
|
38
|
-
"@quenty/servicebag": "
|
|
39
|
-
"@quenty/spring": "
|
|
40
|
-
"@quenty/valueobject": "
|
|
41
|
-
"@quenty/vector3utils": "
|
|
28
|
+
"@quenty/acceltween": "2.5.3",
|
|
29
|
+
"@quenty/baseobject": "10.8.4-canary.11a5dcf.0",
|
|
30
|
+
"@quenty/cframeutils": "5.5.3",
|
|
31
|
+
"@quenty/cubicspline": "10.8.4-canary.11a5dcf.0",
|
|
32
|
+
"@quenty/ducktype": "5.8.5-canary.11a5dcf.0",
|
|
33
|
+
"@quenty/inputobjectutils": "4.18.4-canary.11a5dcf.0",
|
|
34
|
+
"@quenty/loader": "10.8.4-canary.11a5dcf.0",
|
|
35
|
+
"@quenty/maid": "3.4.4-canary.11a5dcf.0",
|
|
36
|
+
"@quenty/math": "2.7.3",
|
|
37
|
+
"@quenty/qframe": "10.10.5-canary.11a5dcf.0",
|
|
38
|
+
"@quenty/servicebag": "11.11.5-canary.11a5dcf.0",
|
|
39
|
+
"@quenty/spring": "10.8.5-canary.11a5dcf.0",
|
|
40
|
+
"@quenty/valueobject": "13.17.4-canary.11a5dcf.0",
|
|
41
|
+
"@quenty/vector3utils": "10.8.5-canary.11a5dcf.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@quenty/camerastoryutils": "
|
|
44
|
+
"@quenty/camerastoryutils": "10.10.5-canary.11a5dcf.0"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "11a5dcf7d4c7a0bfbf3337e97d30e8346ea09d3f"
|
|
50
50
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
@class CameraStack
|
|
3
4
|
]=]
|
|
@@ -7,9 +8,10 @@ local require = require(script.Parent.loader).load(script)
|
|
|
7
8
|
local HttpService = game:GetService("HttpService")
|
|
8
9
|
|
|
9
10
|
local BaseObject = require("BaseObject")
|
|
11
|
+
local CameraEffectUtils = require("CameraEffectUtils")
|
|
12
|
+
local CameraState = require("CameraState")
|
|
10
13
|
local CustomCameraEffect = require("CustomCameraEffect")
|
|
11
14
|
local DuckTypeUtils = require("DuckTypeUtils")
|
|
12
|
-
local _Maid = require("Maid")
|
|
13
15
|
|
|
14
16
|
local CameraStack = setmetatable({}, BaseObject)
|
|
15
17
|
CameraStack.ClassName = "CameraStack"
|
|
@@ -17,7 +19,7 @@ CameraStack.__index = CameraStack
|
|
|
17
19
|
|
|
18
20
|
export type CameraStack = typeof(setmetatable(
|
|
19
21
|
{} :: {
|
|
20
|
-
_stack: {
|
|
22
|
+
_stack: { CameraEffectUtils.CameraLike },
|
|
21
23
|
_disabledSet: { [string]: boolean },
|
|
22
24
|
},
|
|
23
25
|
{} :: typeof({ __index = CameraStack })
|
|
@@ -29,7 +31,7 @@ export type CameraStack = typeof(setmetatable(
|
|
|
29
31
|
@return CameraStack
|
|
30
32
|
]=]
|
|
31
33
|
function CameraStack.new(): CameraStack
|
|
32
|
-
local self: CameraStack = setmetatable(BaseObject.new(), CameraStack)
|
|
34
|
+
local self: CameraStack = setmetatable(BaseObject.new() :: any, CameraStack)
|
|
33
35
|
|
|
34
36
|
self._stack = {}
|
|
35
37
|
self._disabledSet = {}
|
|
@@ -49,7 +51,7 @@ end
|
|
|
49
51
|
Pushes a disable state onto the camera stack
|
|
50
52
|
@return function -- Function to cancel disable
|
|
51
53
|
]=]
|
|
52
|
-
function CameraStack
|
|
54
|
+
function CameraStack.PushDisable(self: CameraStack): () -> ()
|
|
53
55
|
assert(self._stack, "Not initialized")
|
|
54
56
|
|
|
55
57
|
local disabledKey = HttpService:GenerateGUID(false)
|
|
@@ -63,11 +65,11 @@ end
|
|
|
63
65
|
--[=[
|
|
64
66
|
Outputs the camera stack. Intended for diagnostics.
|
|
65
67
|
]=]
|
|
66
|
-
function CameraStack
|
|
68
|
+
function CameraStack.PrintCameraStack(self: CameraStack): ()
|
|
67
69
|
assert(self._stack, "Stack is not initialized yet")
|
|
68
70
|
|
|
69
71
|
for _, value in self._stack do
|
|
70
|
-
print(tostring(type(value) == "table" and value.ClassName or tostring(value)))
|
|
72
|
+
print(tostring(type(value) == "table" and (value :: any).ClassName or tostring(value)))
|
|
71
73
|
end
|
|
72
74
|
end
|
|
73
75
|
|
|
@@ -75,7 +77,7 @@ end
|
|
|
75
77
|
Gets the camera current on the top of the stack
|
|
76
78
|
@return CameraEffect
|
|
77
79
|
]=]
|
|
78
|
-
function CameraStack
|
|
80
|
+
function CameraStack.GetTopCamera(self: CameraStack): CameraEffectUtils.CameraLike
|
|
79
81
|
assert(self._stack, "Not initialized")
|
|
80
82
|
|
|
81
83
|
return self._stack[#self._stack]
|
|
@@ -85,7 +87,7 @@ end
|
|
|
85
87
|
Retrieves the top state off the stack at this time
|
|
86
88
|
@return CameraState?
|
|
87
89
|
]=]
|
|
88
|
-
function CameraStack
|
|
90
|
+
function CameraStack.GetTopState(self: CameraStack): CameraState.CameraState?
|
|
89
91
|
assert(self._stack, "Stack is not initialized yet")
|
|
90
92
|
|
|
91
93
|
if next(self._disabledSet) then
|
|
@@ -95,7 +97,7 @@ function CameraStack:GetTopState()
|
|
|
95
97
|
if #self._stack > 10 then
|
|
96
98
|
warn(string.format("[CameraStack] - Stack is bigger than 10 in CameraStack (%d)", #self._stack))
|
|
97
99
|
end
|
|
98
|
-
local topState = self._stack[#self._stack]
|
|
100
|
+
local topState: any = self._stack[#self._stack]
|
|
99
101
|
|
|
100
102
|
if type(topState) == "table" then
|
|
101
103
|
local state = topState.CameraState or topState
|
|
@@ -119,7 +121,7 @@ end
|
|
|
119
121
|
@return CustomCameraEffect -- Effect below
|
|
120
122
|
@return (CameraState) -> () -- Function to set the state
|
|
121
123
|
]=]
|
|
122
|
-
function CameraStack
|
|
124
|
+
function CameraStack.GetNewStateBelow(self: CameraStack)
|
|
123
125
|
assert(self._stack, "Stack is not initialized yet")
|
|
124
126
|
|
|
125
127
|
local _stateToUse = nil
|
|
@@ -127,16 +129,16 @@ function CameraStack:GetNewStateBelow()
|
|
|
127
129
|
return CustomCameraEffect.new(function()
|
|
128
130
|
local index = self:GetIndex(_stateToUse)
|
|
129
131
|
if index then
|
|
130
|
-
local below = self._stack[index - 1]
|
|
132
|
+
local below: any = self._stack[index - 1]
|
|
131
133
|
if below then
|
|
132
134
|
return below.CameraState or below
|
|
133
135
|
else
|
|
134
136
|
warn("[CameraStack] - Could not get state below, found current state. Returning default.")
|
|
135
|
-
return self
|
|
137
|
+
return self:_getDefaultState()
|
|
136
138
|
end
|
|
137
139
|
else
|
|
138
140
|
warn(string.format("[CameraStack] - Could not get state from %q, returning default", tostring(_stateToUse)))
|
|
139
|
-
return self
|
|
141
|
+
return self:_getDefaultState()
|
|
140
142
|
end
|
|
141
143
|
end),
|
|
142
144
|
function(newStateToUse)
|
|
@@ -144,13 +146,17 @@ function CameraStack:GetNewStateBelow()
|
|
|
144
146
|
end
|
|
145
147
|
end
|
|
146
148
|
|
|
149
|
+
function CameraStack:_getDefaultState(): CameraState.CameraState
|
|
150
|
+
return self._stack[1].CameraState or self._stack[1]
|
|
151
|
+
end
|
|
152
|
+
|
|
147
153
|
--[=[
|
|
148
154
|
Retrieves the index of a state
|
|
149
155
|
@param state CameraEffect
|
|
150
156
|
@return number? -- index
|
|
151
157
|
|
|
152
158
|
]=]
|
|
153
|
-
function CameraStack
|
|
159
|
+
function CameraStack.GetIndex(self: CameraStack, state: CameraEffectUtils.CameraLike): number?
|
|
154
160
|
assert(self._stack, "Stack is not initialized yet")
|
|
155
161
|
|
|
156
162
|
for index, value in self._stack do
|
|
@@ -169,9 +175,9 @@ end
|
|
|
169
175
|
Do not modify this stack, this is the raw memory of the stack
|
|
170
176
|
:::
|
|
171
177
|
|
|
172
|
-
@return {
|
|
178
|
+
@return { CameraLike }
|
|
173
179
|
]=]
|
|
174
|
-
function CameraStack
|
|
180
|
+
function CameraStack.GetStack(self: CameraStack): { CameraEffectUtils.CameraLike }
|
|
175
181
|
assert(self._stack, "Not initialized")
|
|
176
182
|
|
|
177
183
|
return self._stack
|
|
@@ -179,9 +185,9 @@ end
|
|
|
179
185
|
|
|
180
186
|
--[=[
|
|
181
187
|
Removes the state from the stack
|
|
182
|
-
@param state
|
|
188
|
+
@param state CameraLike
|
|
183
189
|
]=]
|
|
184
|
-
function CameraStack
|
|
190
|
+
function CameraStack.Remove(self: CameraStack, state: CameraEffectUtils.CameraLike)
|
|
185
191
|
assert(self._stack, "Stack is not initialized yet")
|
|
186
192
|
|
|
187
193
|
local index = self:GetIndex(state)
|
|
@@ -194,8 +200,9 @@ end
|
|
|
194
200
|
--[=[
|
|
195
201
|
Adds the state from the stack
|
|
196
202
|
@param state CameraState
|
|
203
|
+
@return () -> () -- Cleanup function
|
|
197
204
|
]=]
|
|
198
|
-
function CameraStack
|
|
205
|
+
function CameraStack.Add(self: CameraStack, state: CameraEffectUtils.CameraLike): () -> ()
|
|
199
206
|
assert(self._stack, "Stack is not initialized yet")
|
|
200
207
|
|
|
201
208
|
table.insert(self._stack, state)
|
|
@@ -207,4 +214,4 @@ function CameraStack:Add(state)
|
|
|
207
214
|
end
|
|
208
215
|
end
|
|
209
216
|
|
|
210
|
-
return CameraStack
|
|
217
|
+
return CameraStack
|
|
@@ -7,26 +7,40 @@
|
|
|
7
7
|
|
|
8
8
|
local require = require(script.Parent.loader).load(script)
|
|
9
9
|
|
|
10
|
+
local HttpService = game:GetService("HttpService")
|
|
10
11
|
local RunService = game:GetService("RunService")
|
|
11
12
|
local Workspace = game:GetService("Workspace")
|
|
12
|
-
local HttpService = game:GetService("HttpService")
|
|
13
13
|
|
|
14
|
+
local CameraEffectUtils = require("CameraEffectUtils")
|
|
14
15
|
local CameraStack = require("CameraStack")
|
|
16
|
+
local CameraState = require("CameraState")
|
|
15
17
|
local DefaultCamera = require("DefaultCamera")
|
|
16
18
|
local ImpulseCamera = require("ImpulseCamera")
|
|
17
19
|
local Maid = require("Maid")
|
|
18
20
|
local ServiceBag = require("ServiceBag")
|
|
19
21
|
|
|
20
|
-
assert(RunService:IsClient(), "[CameraStackService] - Only require CameraStackService on client")
|
|
21
|
-
|
|
22
22
|
local CameraStackService = {}
|
|
23
23
|
CameraStackService.ServiceName = "CameraStackService"
|
|
24
24
|
|
|
25
|
+
export type CameraStackService = typeof(setmetatable(
|
|
26
|
+
{} :: {
|
|
27
|
+
_maid: Maid.Maid,
|
|
28
|
+
_cameraStack: CameraStack.CameraStack,
|
|
29
|
+
_rawDefaultCamera: DefaultCamera.DefaultCamera,
|
|
30
|
+
_impulseCamera: ImpulseCamera.ImpulseCamera,
|
|
31
|
+
_defaultCamera: CameraEffectUtils.CameraEffect,
|
|
32
|
+
_key: string,
|
|
33
|
+
_serviceBag: ServiceBag.ServiceBag,
|
|
34
|
+
_started: boolean,
|
|
35
|
+
_doNotUseDefaultCamera: boolean,
|
|
36
|
+
},
|
|
37
|
+
{} :: typeof({ __index = CameraStackService })
|
|
38
|
+
))
|
|
25
39
|
--[=[
|
|
26
40
|
Initializes a new camera stack. Should be done via the ServiceBag.
|
|
27
41
|
@param serviceBag ServiceBag
|
|
28
42
|
]=]
|
|
29
|
-
function CameraStackService
|
|
43
|
+
function CameraStackService.Init(self: CameraStackService, serviceBag: ServiceBag.ServiceBag)
|
|
30
44
|
assert(ServiceBag.isServiceBag(serviceBag), "Not a valid service bag")
|
|
31
45
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
32
46
|
|
|
@@ -39,17 +53,17 @@ function CameraStackService:Init(serviceBag: ServiceBag.ServiceBag)
|
|
|
39
53
|
self._rawDefaultCamera = self._maid:Add(DefaultCamera.new())
|
|
40
54
|
|
|
41
55
|
self._impulseCamera = ImpulseCamera.new()
|
|
42
|
-
self._defaultCamera = (self._rawDefaultCamera + self._impulseCamera):SetMode("Relative")
|
|
56
|
+
self._defaultCamera = ((self :: any)._rawDefaultCamera + (self :: any)._impulseCamera):SetMode("Relative")
|
|
43
57
|
|
|
44
58
|
-- Add camera to stack
|
|
45
59
|
self:Add(self._defaultCamera)
|
|
46
60
|
end
|
|
47
61
|
|
|
48
|
-
function CameraStackService
|
|
62
|
+
function CameraStackService.GetRenderPriority(_self: CameraStackService): number
|
|
49
63
|
return Enum.RenderPriority.Camera.Value + 75
|
|
50
64
|
end
|
|
51
65
|
|
|
52
|
-
function CameraStackService
|
|
66
|
+
function CameraStackService.Start(self: CameraStackService): ()
|
|
53
67
|
RunService:BindToRenderStep("CameraStackUpdateInternal" .. self._key, self:GetRenderPriority(), function()
|
|
54
68
|
debug.profilebegin("camerastackservice")
|
|
55
69
|
|
|
@@ -61,7 +75,6 @@ function CameraStackService:Start()
|
|
|
61
75
|
state:Set(Workspace.CurrentCamera)
|
|
62
76
|
end
|
|
63
77
|
|
|
64
|
-
|
|
65
78
|
debug.profileend()
|
|
66
79
|
end)
|
|
67
80
|
|
|
@@ -88,7 +101,7 @@ end
|
|
|
88
101
|
Prevents the default camera from being used
|
|
89
102
|
@param doNotUseDefaultCamera boolean
|
|
90
103
|
]=]
|
|
91
|
-
function CameraStackService
|
|
104
|
+
function CameraStackService.SetDoNotUseDefaultCamera(self: CameraStackService, doNotUseDefaultCamera: boolean): ()
|
|
92
105
|
assert(not self._started, "Already started")
|
|
93
106
|
|
|
94
107
|
self._doNotUseDefaultCamera = doNotUseDefaultCamera
|
|
@@ -98,8 +111,8 @@ end
|
|
|
98
111
|
Pushes a disable state onto the camera stack
|
|
99
112
|
@return function -- Function to cancel disable
|
|
100
113
|
]=]
|
|
101
|
-
function CameraStackService
|
|
102
|
-
|
|
114
|
+
function CameraStackService.PushDisable(self: CameraStackService): () -> ()
|
|
115
|
+
self:_ensureInitOrError()
|
|
103
116
|
|
|
104
117
|
return self._cameraStack:PushDisable()
|
|
105
118
|
end
|
|
@@ -107,8 +120,8 @@ end
|
|
|
107
120
|
--[=[
|
|
108
121
|
Outputs the camera stack. Intended for diagnostics.
|
|
109
122
|
]=]
|
|
110
|
-
function CameraStackService
|
|
111
|
-
|
|
123
|
+
function CameraStackService.PrintCameraStack(self: CameraStackService): ()
|
|
124
|
+
self:_ensureInitOrError()
|
|
112
125
|
|
|
113
126
|
return self._cameraStack:PrintCameraStack()
|
|
114
127
|
end
|
|
@@ -117,7 +130,7 @@ end
|
|
|
117
130
|
Returns the default camera
|
|
118
131
|
@return SummedCamera -- DefaultCamera + ImpulseCamera
|
|
119
132
|
]=]
|
|
120
|
-
function CameraStackService
|
|
133
|
+
function CameraStackService.GetDefaultCamera(self: CameraStackService): CameraEffectUtils.CameraEffect
|
|
121
134
|
assert(self._defaultCamera, "Not initialized")
|
|
122
135
|
|
|
123
136
|
return self._defaultCamera
|
|
@@ -142,7 +155,7 @@ end
|
|
|
142
155
|
|
|
143
156
|
@return ImpulseCamera
|
|
144
157
|
]=]
|
|
145
|
-
function CameraStackService
|
|
158
|
+
function CameraStackService.GetImpulseCamera(self: CameraStackService): ImpulseCamera.ImpulseCamera
|
|
146
159
|
assert(self._impulseCamera, "Not initialized")
|
|
147
160
|
|
|
148
161
|
return self._impulseCamera
|
|
@@ -152,7 +165,7 @@ end
|
|
|
152
165
|
Returns the default camera without any impulse cameras
|
|
153
166
|
@return DefaultCamera
|
|
154
167
|
]=]
|
|
155
|
-
function CameraStackService
|
|
168
|
+
function CameraStackService.GetRawDefaultCamera(self: CameraStackService): DefaultCamera.DefaultCamera
|
|
156
169
|
assert(self._rawDefaultCamera, "Not initialized")
|
|
157
170
|
|
|
158
171
|
return self._rawDefaultCamera
|
|
@@ -162,8 +175,8 @@ end
|
|
|
162
175
|
Gets the camera current on the top of the stack
|
|
163
176
|
@return CameraEffect
|
|
164
177
|
]=]
|
|
165
|
-
function CameraStackService
|
|
166
|
-
|
|
178
|
+
function CameraStackService.GetTopCamera(self: CameraStackService): CameraEffectUtils.CameraLike
|
|
179
|
+
self:_ensureInitOrError()
|
|
167
180
|
|
|
168
181
|
return self._cameraStack:GetTopCamera()
|
|
169
182
|
end
|
|
@@ -172,8 +185,8 @@ end
|
|
|
172
185
|
Retrieves the top state off the stack at this time
|
|
173
186
|
@return CameraState?
|
|
174
187
|
]=]
|
|
175
|
-
function CameraStackService
|
|
176
|
-
|
|
188
|
+
function CameraStackService.GetTopState(self: CameraStackService): CameraState.CameraState?
|
|
189
|
+
self:_ensureInitOrError()
|
|
177
190
|
|
|
178
191
|
return self._cameraStack:GetTopState()
|
|
179
192
|
end
|
|
@@ -184,8 +197,8 @@ end
|
|
|
184
197
|
@return CustomCameraEffect -- Effect below
|
|
185
198
|
@return (CameraState) -> () -- Function to set the state
|
|
186
199
|
]=]
|
|
187
|
-
function CameraStackService
|
|
188
|
-
|
|
200
|
+
function CameraStackService.GetNewStateBelow(self: CameraStackService)
|
|
201
|
+
self:_ensureInitOrError()
|
|
189
202
|
|
|
190
203
|
return self._cameraStack:GetNewStateBelow()
|
|
191
204
|
end
|
|
@@ -196,8 +209,8 @@ end
|
|
|
196
209
|
@return number? -- index
|
|
197
210
|
|
|
198
211
|
]=]
|
|
199
|
-
function CameraStackService
|
|
200
|
-
|
|
212
|
+
function CameraStackService.GetIndex(self: CameraStackService, state: CameraEffectUtils.CameraEffect): number?
|
|
213
|
+
self:_ensureInitOrError()
|
|
201
214
|
|
|
202
215
|
return self._cameraStack:GetIndex(state)
|
|
203
216
|
end
|
|
@@ -211,10 +224,10 @@ end
|
|
|
211
224
|
|
|
212
225
|
@return { CameraState<T> }
|
|
213
226
|
]=]
|
|
214
|
-
function CameraStackService
|
|
215
|
-
|
|
227
|
+
function CameraStackService.GetRawStack(self: CameraStackService): { CameraEffectUtils.CameraLike }
|
|
228
|
+
self:_ensureInitOrError()
|
|
216
229
|
|
|
217
|
-
return self._cameraStack:
|
|
230
|
+
return self._cameraStack:GetStack()
|
|
218
231
|
end
|
|
219
232
|
|
|
220
233
|
--[=[
|
|
@@ -222,8 +235,8 @@ end
|
|
|
222
235
|
|
|
223
236
|
@return CameraStack
|
|
224
237
|
]=]
|
|
225
|
-
function CameraStackService
|
|
226
|
-
|
|
238
|
+
function CameraStackService.GetCameraStack(self: CameraStackService): CameraStack.CameraStack
|
|
239
|
+
self:_ensureInitOrError()
|
|
227
240
|
|
|
228
241
|
return self._cameraStack
|
|
229
242
|
end
|
|
@@ -232,8 +245,8 @@ end
|
|
|
232
245
|
Removes the state from the stack
|
|
233
246
|
@param state CameraState
|
|
234
247
|
]=]
|
|
235
|
-
function CameraStackService
|
|
236
|
-
|
|
248
|
+
function CameraStackService.Remove(self: CameraStackService, state: CameraEffectUtils.CameraEffect)
|
|
249
|
+
self:_ensureInitOrError()
|
|
237
250
|
|
|
238
251
|
return self._cameraStack:Remove(state)
|
|
239
252
|
end
|
|
@@ -241,15 +254,20 @@ end
|
|
|
241
254
|
--[=[
|
|
242
255
|
Adds the state from the stack
|
|
243
256
|
@param state CameraState
|
|
257
|
+
@return () -> () -- Cleanup function
|
|
244
258
|
]=]
|
|
245
|
-
function CameraStackService
|
|
246
|
-
|
|
259
|
+
function CameraStackService.Add(self: CameraStackService, state: CameraEffectUtils.CameraEffect): () -> ()
|
|
260
|
+
self:_ensureInitOrError()
|
|
247
261
|
|
|
248
262
|
return self._cameraStack:Add(state)
|
|
249
263
|
end
|
|
250
264
|
|
|
251
|
-
function CameraStackService:
|
|
265
|
+
function CameraStackService._ensureInitOrError(self: CameraStackService)
|
|
266
|
+
assert(self._cameraStack, "Not initialized. Initialize via ServiceBag")
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
function CameraStackService.Destroy(self: CameraStackService)
|
|
252
270
|
self._maid:DoCleaning()
|
|
253
271
|
end
|
|
254
272
|
|
|
255
|
-
return CameraStackService
|
|
273
|
+
return CameraStackService
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
local require = require(script.Parent.loader).load(script)
|
|
8
8
|
|
|
9
|
-
local QFrame = require("QFrame")
|
|
10
9
|
local CameraFrame = require("CameraFrame")
|
|
11
10
|
local DuckTypeUtils = require("DuckTypeUtils")
|
|
11
|
+
local QFrame = require("QFrame")
|
|
12
12
|
|
|
13
13
|
local CameraState = {}
|
|
14
14
|
CameraState.ClassName = "CameraState"
|
|
@@ -69,15 +69,15 @@ end
|
|
|
69
69
|
@prop cframe CFrame
|
|
70
70
|
@within CameraState
|
|
71
71
|
]=]
|
|
72
|
-
function CameraState
|
|
72
|
+
function CameraState.__index(self: CameraState, index)
|
|
73
73
|
if index == "CFrame" then
|
|
74
74
|
return self.CameraFrame.CFrame
|
|
75
75
|
elseif index == "Position" then
|
|
76
76
|
return self.CameraFrame.Position
|
|
77
77
|
elseif index == "CameraFrame" then
|
|
78
|
-
return rawget(self, "CameraFrame")
|
|
78
|
+
return rawget(self :: any, "CameraFrame")
|
|
79
79
|
elseif index == "CameraFrameDerivative" then
|
|
80
|
-
return rawget(self, "CameraFrameDerivative")
|
|
80
|
+
return rawget(self :: any, "CameraFrameDerivative")
|
|
81
81
|
elseif index == "Velocity" then
|
|
82
82
|
return self.CameraFrameDerivative.Position
|
|
83
83
|
elseif index == "FieldOfView" then
|
|
@@ -87,7 +87,7 @@ function CameraState:__index(index)
|
|
|
87
87
|
end
|
|
88
88
|
end
|
|
89
89
|
|
|
90
|
-
function CameraState
|
|
90
|
+
function CameraState.__newindex(self: CameraState, index, value)
|
|
91
91
|
if index == "CFrame" then
|
|
92
92
|
self.CameraFrame.CFrame = value
|
|
93
93
|
elseif index == "Position" then
|
|
@@ -97,7 +97,7 @@ function CameraState:__newindex(index, value)
|
|
|
97
97
|
elseif index == "FieldOfView" then
|
|
98
98
|
self.CameraFrame.FieldOfView = value
|
|
99
99
|
elseif index == "CameraFrame" or index == "CameraFrameDerivative" then
|
|
100
|
-
rawset(self, index, value)
|
|
100
|
+
rawset(self :: any, index, value)
|
|
101
101
|
else
|
|
102
102
|
error(string.format("'%s' is not a valid index of CameraState", tostring(index)))
|
|
103
103
|
end
|
|
@@ -107,9 +107,9 @@ end
|
|
|
107
107
|
Set another camera state. Typically used to set Workspace.CurrentCamera's state to match this camera's state
|
|
108
108
|
@param camera Camera -- A CameraState to set, also accepts a Roblox Camera
|
|
109
109
|
]=]
|
|
110
|
-
function CameraState
|
|
110
|
+
function CameraState.Set(self: CameraState, camera: Camera)
|
|
111
111
|
camera.FieldOfView = self.FieldOfView
|
|
112
112
|
camera.CFrame = self.CFrame
|
|
113
113
|
end
|
|
114
114
|
|
|
115
|
-
return CameraState
|
|
115
|
+
return CameraState
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
@class CameraUtils.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 Maid = require("Maid")
|
|
8
9
|
|
|
@@ -25,7 +26,7 @@ return function(target: Instance)
|
|
|
25
26
|
|
|
26
27
|
local ball: Part = maid:Add(Instance.new("Part"))
|
|
27
28
|
ball.Color = Color3.new(1, 0.5, 0.5)
|
|
28
|
-
ball.Size = Vector3.new(2*radius, 2*radius, 2*radius)
|
|
29
|
+
ball.Size = Vector3.new(2 * radius, 2 * radius, 2 * radius)
|
|
29
30
|
ball.Shape = Enum.PartType.Ball
|
|
30
31
|
ball.CFrame = CFrame.new()
|
|
31
32
|
ball.Anchored = true
|
|
@@ -34,7 +35,7 @@ return function(target: Instance)
|
|
|
34
35
|
local function update()
|
|
35
36
|
local absSize = viewportFrame.AbsoluteSize
|
|
36
37
|
if absSize.x > 0 and absSize.y > 0 then
|
|
37
|
-
local aspectRatio = absSize.x/absSize.y
|
|
38
|
+
local aspectRatio = absSize.x / absSize.y
|
|
38
39
|
local dist = CameraUtils.fitSphereToCamera(radius, camera.FieldOfView, aspectRatio)
|
|
39
40
|
camera.CFrame = CFrame.new(0, 0, dist)
|
|
40
41
|
end
|
|
@@ -48,4 +49,4 @@ return function(target: Instance)
|
|
|
48
49
|
return function()
|
|
49
50
|
maid:DoCleaning()
|
|
50
51
|
end
|
|
51
|
-
end
|
|
52
|
+
end
|