@quenty/viewport 11.21.0 → 11.21.1-canary.545.2374fb2.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 +11 -0
- package/package.json +17 -17
- package/src/Client/Viewport.lua +51 -44
- package/src/Client/ViewportControls.lua +10 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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
|
+
## [11.21.1-canary.545.2374fb2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/viewport@11.21.0...@quenty/viewport@11.21.1-canary.545.2374fb2.0) (2025-04-05)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [11.21.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/viewport@11.20.3...@quenty/viewport@11.21.0) (2025-04-02)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/viewport
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/viewport",
|
|
3
|
-
"version": "11.21.0",
|
|
3
|
+
"version": "11.21.1-canary.545.2374fb2.0",
|
|
4
4
|
"description": "Rendering functionality for viewportFrames",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -24,26 +24,26 @@
|
|
|
24
24
|
"Quenty"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@quenty/adorneeutils": "
|
|
28
|
-
"@quenty/baseobject": "
|
|
29
|
-
"@quenty/basicpane": "
|
|
30
|
-
"@quenty/blend": "
|
|
31
|
-
"@quenty/camera": "
|
|
32
|
-
"@quenty/geometryutils": "
|
|
33
|
-
"@quenty/inputobjectutils": "
|
|
34
|
-
"@quenty/loader": "
|
|
35
|
-
"@quenty/maid": "
|
|
36
|
-
"@quenty/math": "
|
|
37
|
-
"@quenty/rx": "
|
|
38
|
-
"@quenty/signal": "
|
|
39
|
-
"@quenty/spring": "
|
|
40
|
-
"@quenty/valueobject": "
|
|
27
|
+
"@quenty/adorneeutils": "3.3.2-canary.545.2374fb2.0",
|
|
28
|
+
"@quenty/baseobject": "10.8.1-canary.545.2374fb2.0",
|
|
29
|
+
"@quenty/basicpane": "13.17.1-canary.545.2374fb2.0",
|
|
30
|
+
"@quenty/blend": "12.18.1-canary.545.2374fb2.0",
|
|
31
|
+
"@quenty/camera": "14.20.1-canary.545.2374fb2.0",
|
|
32
|
+
"@quenty/geometryutils": "6.8.2-canary.545.2374fb2.0",
|
|
33
|
+
"@quenty/inputobjectutils": "4.18.1-canary.545.2374fb2.0",
|
|
34
|
+
"@quenty/loader": "10.8.1-canary.545.2374fb2.0",
|
|
35
|
+
"@quenty/maid": "3.4.1-canary.545.2374fb2.0",
|
|
36
|
+
"@quenty/math": "2.7.2-canary.545.2374fb2.0",
|
|
37
|
+
"@quenty/rx": "13.17.1-canary.545.2374fb2.0",
|
|
38
|
+
"@quenty/signal": "7.10.1-canary.545.2374fb2.0",
|
|
39
|
+
"@quenty/spring": "10.8.2-canary.545.2374fb2.0",
|
|
40
|
+
"@quenty/valueobject": "13.17.1-canary.545.2374fb2.0"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@quenty/insertserviceutils": "
|
|
46
|
+
"@quenty/insertserviceutils": "10.10.2-canary.545.2374fb2.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "2374fb2b043cfbe0e9b507b3316eec46a4e353a0"
|
|
49
49
|
}
|
package/src/Client/Viewport.lua
CHANGED
|
@@ -103,7 +103,7 @@ function Viewport.blend(props)
|
|
|
103
103
|
end)
|
|
104
104
|
end
|
|
105
105
|
|
|
106
|
-
function Viewport:ObserveTransparency()
|
|
106
|
+
function Viewport:ObserveTransparency(): Observable.Observable<number>
|
|
107
107
|
return self._transparency:Observe()
|
|
108
108
|
end
|
|
109
109
|
|
|
@@ -112,7 +112,7 @@ end
|
|
|
112
112
|
|
|
113
113
|
@param enabled boolean
|
|
114
114
|
]=]
|
|
115
|
-
function Viewport:SetControlsEnabled(enabled)
|
|
115
|
+
function Viewport:SetControlsEnabled(enabled: boolean)
|
|
116
116
|
assert(type(enabled) == "boolean", "Bad enabled")
|
|
117
117
|
|
|
118
118
|
self._controlsEnabled.Value = enabled
|
|
@@ -123,7 +123,7 @@ end
|
|
|
123
123
|
|
|
124
124
|
@param transparency number
|
|
125
125
|
]=]
|
|
126
|
-
function Viewport:SetTransparency(transparency)
|
|
126
|
+
function Viewport:SetTransparency(transparency: number)
|
|
127
127
|
return self._transparency:Mount(transparency or 0)
|
|
128
128
|
end
|
|
129
129
|
|
|
@@ -132,7 +132,7 @@ end
|
|
|
132
132
|
|
|
133
133
|
@param fieldOfView number
|
|
134
134
|
]=]
|
|
135
|
-
function Viewport:SetFieldOfView(fieldOfView)
|
|
135
|
+
function Viewport:SetFieldOfView(fieldOfView: number)
|
|
136
136
|
return self._fieldOfView:Mount(fieldOfView or 20)
|
|
137
137
|
end
|
|
138
138
|
|
|
@@ -148,7 +148,7 @@ end
|
|
|
148
148
|
|
|
149
149
|
@param instance Instance?
|
|
150
150
|
]=]
|
|
151
|
-
function Viewport:SetInstance(instance)
|
|
151
|
+
function Viewport:SetInstance(instance: Instance?): () -> ()
|
|
152
152
|
self._current:Mount(instance)
|
|
153
153
|
|
|
154
154
|
return function()
|
|
@@ -166,10 +166,11 @@ function Viewport:NotifyInstanceSizeChanged()
|
|
|
166
166
|
self._notifyInstanceSizeChanged:Fire()
|
|
167
167
|
end
|
|
168
168
|
|
|
169
|
-
function Viewport:SetYaw(yaw, doNotAnimate)
|
|
169
|
+
function Viewport:SetYaw(yaw: number, doNotAnimate: boolean?)
|
|
170
170
|
yaw = yaw % TAU
|
|
171
171
|
|
|
172
|
-
self._rotationYawSpring.Position =
|
|
172
|
+
self._rotationYawSpring.Position =
|
|
173
|
+
CircleUtils.updatePositionToSmallestDistOnCircle(self._rotationYawSpring.Position, yaw, TAU)
|
|
173
174
|
self._rotationYawSpring.Target = yaw
|
|
174
175
|
|
|
175
176
|
if doNotAnimate then
|
|
@@ -177,16 +178,16 @@ function Viewport:SetYaw(yaw, doNotAnimate)
|
|
|
177
178
|
end
|
|
178
179
|
end
|
|
179
180
|
|
|
180
|
-
function Viewport:SetPitch(pitch, doNotAnimate)
|
|
181
|
+
function Viewport:SetPitch(pitch: number, doNotAnimate: boolean?)
|
|
181
182
|
self._rotationPitchSpring.Target = math.clamp(pitch, MIN_PITCH, MAX_PITCH)
|
|
182
183
|
if doNotAnimate then
|
|
183
184
|
self._rotationPitchSpring.Position = self._rotationPitchSpring.Target
|
|
184
185
|
end
|
|
185
186
|
end
|
|
186
187
|
|
|
187
|
-
function Viewport:RotateBy(deltaV2, doNotAnimate)
|
|
188
|
-
self:SetYaw(self._rotationYawSpring.Value + deltaV2.
|
|
189
|
-
self:SetPitch(self._rotationPitchSpring.Value + deltaV2.
|
|
188
|
+
function Viewport:RotateBy(deltaV2: Vector2, doNotAnimate: boolean?)
|
|
189
|
+
self:SetYaw(self._rotationYawSpring.Value + deltaV2.X, doNotAnimate)
|
|
190
|
+
self:SetPitch(self._rotationPitchSpring.Value + deltaV2.Y, doNotAnimate)
|
|
190
191
|
end
|
|
191
192
|
|
|
192
193
|
--[=[
|
|
@@ -214,30 +215,32 @@ function Viewport:Render(props)
|
|
|
214
215
|
local currentCamera = ValueObject.new()
|
|
215
216
|
self._maid:GiveTask(currentCamera)
|
|
216
217
|
|
|
217
|
-
local lightDirectionCFrame = (CFrame.Angles(0, math.rad(180), 0)
|
|
218
|
-
* CFrame.Angles(math.rad(-45), 0, 0))
|
|
218
|
+
local lightDirectionCFrame = (CFrame.Angles(0, math.rad(180), 0) * CFrame.Angles(math.rad(-45), 0, 0))
|
|
219
219
|
local brightness = 1.25
|
|
220
220
|
local ambientBrightness = 0.75
|
|
221
221
|
|
|
222
|
-
return Blend.New
|
|
223
|
-
Parent = props.Parent
|
|
224
|
-
Size = props.Size or UDim2.new(1, 0, 1, 0)
|
|
225
|
-
AnchorPoint = props.AnchorPoint
|
|
226
|
-
Position = props.Position
|
|
227
|
-
ImageColor3 = props.ImageColor3
|
|
228
|
-
LayoutOrder = props.LayoutOrder
|
|
229
|
-
BackgroundTransparency = 1
|
|
230
|
-
BackgroundColor3 = props.BackgroundColor3
|
|
231
|
-
CurrentCamera = currentCamera
|
|
222
|
+
return Blend.New("ViewportFrame")({
|
|
223
|
+
Parent = props.Parent,
|
|
224
|
+
Size = props.Size or UDim2.new(1, 0, 1, 0),
|
|
225
|
+
AnchorPoint = props.AnchorPoint,
|
|
226
|
+
Position = props.Position,
|
|
227
|
+
ImageColor3 = props.ImageColor3,
|
|
228
|
+
LayoutOrder = props.LayoutOrder,
|
|
229
|
+
BackgroundTransparency = 1,
|
|
230
|
+
BackgroundColor3 = props.BackgroundColor3,
|
|
231
|
+
CurrentCamera = currentCamera,
|
|
232
232
|
-- selene:allow(roblox_incorrect_color3_new_bounds)
|
|
233
|
-
LightColor = props.LightColor or Color3.new(brightness, brightness, brightness + 0.15)
|
|
234
|
-
LightDirection = props.LightDirection or lightDirectionCFrame:vectorToWorldSpace(Vector3.new(0, 0, -1))
|
|
235
|
-
Ambient = props.Ambient or Color3.new(ambientBrightness, ambientBrightness, ambientBrightness + 0.15)
|
|
236
|
-
ImageTransparency = Blend.Computed(
|
|
233
|
+
LightColor = props.LightColor or Color3.new(brightness, brightness, brightness + 0.15),
|
|
234
|
+
LightDirection = props.LightDirection or lightDirectionCFrame:vectorToWorldSpace(Vector3.new(0, 0, -1)),
|
|
235
|
+
Ambient = props.Ambient or Color3.new(ambientBrightness, ambientBrightness, ambientBrightness + 0.15),
|
|
236
|
+
ImageTransparency = Blend.Computed(
|
|
237
|
+
props.Transparency or 0,
|
|
238
|
+
self._transparency,
|
|
237
239
|
function(propTransparency, selfTransparency)
|
|
238
240
|
return Math.map(propTransparency, 0, 1, selfTransparency, 1)
|
|
239
|
-
end
|
|
240
|
-
|
|
241
|
+
end
|
|
242
|
+
),
|
|
243
|
+
[Blend.OnChange("AbsoluteSize")] = self._absoluteSize,
|
|
241
244
|
[Blend.Attached(function(viewport)
|
|
242
245
|
local controlsMaid = Maid.new()
|
|
243
246
|
|
|
@@ -249,7 +252,7 @@ function Viewport:Render(props)
|
|
|
249
252
|
end))
|
|
250
253
|
|
|
251
254
|
return controlsMaid
|
|
252
|
-
end)] = true
|
|
255
|
+
end)] = true,
|
|
253
256
|
[Blend.Attached(function(viewport)
|
|
254
257
|
-- custom parenting scheme to ensure we don't call destroy on children
|
|
255
258
|
local maid = Maid.new()
|
|
@@ -274,16 +277,16 @@ function Viewport:Render(props)
|
|
|
274
277
|
end)
|
|
275
278
|
|
|
276
279
|
return maid
|
|
277
|
-
end)] = true
|
|
280
|
+
end)] = true,
|
|
278
281
|
[Blend.Children] = {
|
|
279
|
-
props[Blend.Children]
|
|
282
|
+
props[Blend.Children],
|
|
280
283
|
|
|
281
|
-
self._current
|
|
284
|
+
self._current,
|
|
282
285
|
|
|
283
|
-
Blend.New
|
|
284
|
-
[Blend.Instance] = currentCamera
|
|
285
|
-
Name = "CurrentCamera"
|
|
286
|
-
FieldOfView = self._fieldOfView
|
|
286
|
+
Blend.New("Camera")({
|
|
287
|
+
[Blend.Instance] = currentCamera,
|
|
288
|
+
Name = "CurrentCamera",
|
|
289
|
+
FieldOfView = self._fieldOfView,
|
|
287
290
|
CFrame = Blend.Computed(
|
|
288
291
|
self._current,
|
|
289
292
|
self._absoluteSize,
|
|
@@ -291,25 +294,29 @@ function Viewport:Render(props)
|
|
|
291
294
|
self._rotationYawSpring:ObserveRenderStepped(),
|
|
292
295
|
self._rotationPitchSpring:ObserveRenderStepped(),
|
|
293
296
|
Rx.fromSignal(self._notifyInstanceSizeChanged):Pipe({
|
|
294
|
-
Rx.defaultsToNil
|
|
297
|
+
Rx.defaultsToNil,
|
|
295
298
|
}),
|
|
296
299
|
function(inst, absSize, fov, rotationYaw, rotationPitch)
|
|
297
300
|
if typeof(inst) ~= "Instance" then
|
|
298
301
|
return CFrame.new()
|
|
299
302
|
end
|
|
300
303
|
|
|
301
|
-
local aspectRatio = absSize.x/absSize.y
|
|
304
|
+
local aspectRatio = absSize.x / absSize.y
|
|
302
305
|
local bbCFrame, bbSize = AdorneeUtils.getBoundingBox(inst)
|
|
303
306
|
if not bbCFrame then
|
|
304
307
|
return CFrame.new()
|
|
305
308
|
end
|
|
306
309
|
|
|
307
310
|
local fit = CameraUtils.fitBoundingBoxToCamera(bbSize, fov, aspectRatio)
|
|
308
|
-
return CFrame.new(bbCFrame.Position)
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
311
|
+
return CFrame.new(bbCFrame.Position)
|
|
312
|
+
* CFrame.Angles(0, rotationYaw, 0)
|
|
313
|
+
* CFrame.Angles(rotationPitch, 0, 0)
|
|
314
|
+
* CFrame.new(0, 0, fit)
|
|
315
|
+
end
|
|
316
|
+
),
|
|
317
|
+
}),
|
|
318
|
+
},
|
|
319
|
+
})
|
|
313
320
|
end
|
|
314
321
|
|
|
315
322
|
return Viewport
|
|
@@ -22,17 +22,20 @@ ViewportControls.__index = ViewportControls
|
|
|
22
22
|
@param viewportModel Viewport
|
|
23
23
|
@return BaseObject
|
|
24
24
|
]=]
|
|
25
|
-
function ViewportControls.new(viewport, viewportModel)
|
|
25
|
+
function ViewportControls.new(viewport: ViewportFrame, viewportModel)
|
|
26
26
|
local self = setmetatable(BaseObject.new(viewport), ViewportControls)
|
|
27
27
|
|
|
28
28
|
self._viewportModel = assert(viewportModel, "No rotationYaw")
|
|
29
29
|
self._enabled = self._maid:Add(ValueObject.new(true, "boolean"))
|
|
30
30
|
|
|
31
31
|
self._maid:GiveTask(self._obj.InputBegan:Connect(function(inputObject)
|
|
32
|
-
if
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
if
|
|
33
|
+
(
|
|
34
|
+
inputObject.UserInputType == Enum.UserInputType.MouseButton1
|
|
35
|
+
or inputObject.UserInputType == Enum.UserInputType.MouseButton2
|
|
36
|
+
or inputObject.UserInputType == Enum.UserInputType.Touch
|
|
37
|
+
) and self._enabled.Value
|
|
38
|
+
then
|
|
36
39
|
self:_startDrag(inputObject)
|
|
37
40
|
end
|
|
38
41
|
end))
|
|
@@ -45,13 +48,13 @@ end
|
|
|
45
48
|
|
|
46
49
|
@param enabled boolean
|
|
47
50
|
]=]
|
|
48
|
-
function ViewportControls:SetEnabled(enabled)
|
|
51
|
+
function ViewportControls:SetEnabled(enabled: boolean)
|
|
49
52
|
assert(type(enabled) == "boolean", "Bad enabled")
|
|
50
53
|
|
|
51
54
|
self._enabled.Value = enabled
|
|
52
55
|
end
|
|
53
56
|
|
|
54
|
-
function ViewportControls:_startDrag(startInputObject)
|
|
57
|
+
function ViewportControls:_startDrag(startInputObject: InputObject)
|
|
55
58
|
if self._maid._dragging then
|
|
56
59
|
return
|
|
57
60
|
end
|