@quenty/viewport 5.4.1 → 5.5.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,14 @@
|
|
|
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
|
+
# [5.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/viewport@5.4.1...@quenty/viewport@5.5.0) (2022-11-08)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/viewport
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [5.4.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/viewport@5.4.0...@quenty/viewport@5.4.1) (2022-11-04)
|
|
7
15
|
|
|
8
16
|
**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": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"description": "Rendering functionality for viewportFrames",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@quenty/insertserviceutils": "^6.0.1"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "3432599d8ed7bf7f0436d7cd5495925543450117"
|
|
49
49
|
}
|
package/src/Client/Viewport.lua
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
--[=[
|
|
2
|
+
Creates a ViewportFrame with size fitting and drag controls. This means that the
|
|
3
|
+
viewport will center the camera around the given instance, and allow the user
|
|
4
|
+
to control the camera itself.
|
|
5
|
+
|
|
6
|
+
```lua
|
|
7
|
+
local viewport = Viewport.new()
|
|
8
|
+
viewport:SetInstance(instance)
|
|
9
|
+
|
|
10
|
+
maid:GiveTask(viewport:Render({
|
|
11
|
+
Parent = target;
|
|
12
|
+
}):Subscribe())
|
|
13
|
+
```
|
|
14
|
+
|
|
2
15
|
@class Viewport
|
|
3
16
|
]=]
|
|
4
17
|
|
|
@@ -26,6 +39,12 @@ local Viewport = setmetatable({}, BasicPane)
|
|
|
26
39
|
Viewport.ClassName = "Viewport"
|
|
27
40
|
Viewport.__index = Viewport
|
|
28
41
|
|
|
42
|
+
--[=[
|
|
43
|
+
Constructs a new viewport. Unlike a normal [BasicPane] this will not render anything
|
|
44
|
+
immediately. See [Viewport.Render] for details.
|
|
45
|
+
|
|
46
|
+
@return Viewport
|
|
47
|
+
]=]
|
|
29
48
|
function Viewport.new()
|
|
30
49
|
local self = setmetatable(BasicPane.new(), Viewport)
|
|
31
50
|
|
|
@@ -55,8 +74,28 @@ function Viewport.new()
|
|
|
55
74
|
return self
|
|
56
75
|
end
|
|
57
76
|
|
|
77
|
+
--[=[
|
|
78
|
+
Creates a Viewport and render it to Blend. The following properties are supported
|
|
79
|
+
|
|
80
|
+
* Ambient - Color3
|
|
81
|
+
* AnchorPoint - Vector2
|
|
82
|
+
* FieldOfView - number
|
|
83
|
+
* Instance - Instance
|
|
84
|
+
* LayoutOrder - number
|
|
85
|
+
* LightColor - Color3
|
|
86
|
+
* Parent - Instance
|
|
87
|
+
* Position - UDim2
|
|
88
|
+
* Size - Vector3
|
|
89
|
+
* Transparency - number
|
|
90
|
+
|
|
91
|
+
Properties may be anything Blend would take as computable. See [Blend] for details.
|
|
92
|
+
|
|
93
|
+
@param props { string }
|
|
94
|
+
@return Observable<Instance>
|
|
95
|
+
]=]
|
|
58
96
|
function Viewport.blend(props)
|
|
59
97
|
assert(type(props) == "table", "Bad props")
|
|
98
|
+
|
|
60
99
|
return Observable.new(function(sub)
|
|
61
100
|
local maid = Maid.new()
|
|
62
101
|
|
|
@@ -93,24 +132,51 @@ function Viewport.blend(props)
|
|
|
93
132
|
end)
|
|
94
133
|
end
|
|
95
134
|
|
|
135
|
+
|
|
136
|
+
--[=[
|
|
137
|
+
Sets the field of view on the viewport.
|
|
138
|
+
|
|
139
|
+
@param transparency number
|
|
140
|
+
]=]
|
|
96
141
|
function Viewport:SetTransparency(transparency)
|
|
97
142
|
assert(type(transparency) == "number", "Bad transparency")
|
|
98
143
|
|
|
99
144
|
self._transparency.Value = transparency
|
|
100
145
|
end
|
|
101
146
|
|
|
147
|
+
--[=[
|
|
148
|
+
Sets the field of view on the viewport.
|
|
149
|
+
|
|
150
|
+
@param fieldOfView number
|
|
151
|
+
]=]
|
|
102
152
|
function Viewport:SetFieldOfView(fieldOfView)
|
|
103
153
|
assert(type(fieldOfView) == "number", "Bad fieldOfView")
|
|
104
154
|
|
|
105
155
|
self._fieldOfView.Value = fieldOfView
|
|
106
156
|
end
|
|
107
157
|
|
|
158
|
+
--[=[
|
|
159
|
+
Set the instance to be rendered. The instance will be reparented
|
|
160
|
+
to the viewport.
|
|
161
|
+
|
|
162
|
+
:::warning
|
|
163
|
+
The instance you set here will NOT be destroyed by the viewport. This lets the
|
|
164
|
+
performance be optimized or the instance used in good transitions. However,
|
|
165
|
+
be sure to destroy it if you need to.
|
|
166
|
+
:::
|
|
167
|
+
|
|
168
|
+
@param instance Instance?
|
|
169
|
+
]=]
|
|
108
170
|
function Viewport:SetInstance(instance)
|
|
109
171
|
assert(typeof(instance) == "Instance" or instance == nil, "Bad instance")
|
|
110
172
|
|
|
111
173
|
self._current.Value = instance
|
|
112
174
|
end
|
|
113
175
|
|
|
176
|
+
--[=[
|
|
177
|
+
Notifies the viewport of the instance size changing. We don't connect to
|
|
178
|
+
any events here because the instance can be anything.
|
|
179
|
+
]=]
|
|
114
180
|
function Viewport:NotifyInstanceSizeChanged()
|
|
115
181
|
self._notifyInstanceSizeChanged:Fire()
|
|
116
182
|
end
|
|
@@ -131,6 +197,26 @@ function Viewport:RotateBy(deltaV2, doNotAnimate)
|
|
|
131
197
|
end
|
|
132
198
|
end
|
|
133
199
|
|
|
200
|
+
--[=[
|
|
201
|
+
Renders the viewport. Allows the following properties.
|
|
202
|
+
|
|
203
|
+
* Ambient - Color3
|
|
204
|
+
* AnchorPoint - Vector2
|
|
205
|
+
* LayoutOrder - number
|
|
206
|
+
* LightColor - Color3
|
|
207
|
+
* Parent - Instance
|
|
208
|
+
* Position - UDim2
|
|
209
|
+
* Size - Vector3
|
|
210
|
+
* Transparency - number
|
|
211
|
+
|
|
212
|
+
:::warning
|
|
213
|
+
This should only be called once per a Viewport instance, since the Instance property is
|
|
214
|
+
not duplicated.
|
|
215
|
+
:::
|
|
216
|
+
|
|
217
|
+
@param props { any }
|
|
218
|
+
@return Observable<ViewportFrame>
|
|
219
|
+
]=]
|
|
134
220
|
function Viewport:Render(props)
|
|
135
221
|
local currentCamera = ValueObject.new()
|
|
136
222
|
self._maid:GiveTask(currentCamera)
|
|
@@ -212,4 +298,4 @@ function Viewport:Render(props)
|
|
|
212
298
|
};
|
|
213
299
|
end
|
|
214
300
|
|
|
215
|
-
return Viewport
|
|
301
|
+
return Viewport
|
|
@@ -15,7 +15,7 @@ return function(target)
|
|
|
15
15
|
local viewport = Viewport.new()
|
|
16
16
|
maid:GiveTask(viewport)
|
|
17
17
|
|
|
18
|
-
maid:GivePromise(InsertServiceUtils.promiseAsset(182451181))
|
|
18
|
+
maid:GivePromise(InsertServiceUtils.promiseAsset(182451181)) --The account must own the asset in order to insert it.
|
|
19
19
|
:Then(function(crate)
|
|
20
20
|
viewport:SetInstance(crate)
|
|
21
21
|
end)
|
|
@@ -27,4 +27,4 @@ return function(target)
|
|
|
27
27
|
return function()
|
|
28
28
|
maid:DoCleaning()
|
|
29
29
|
end
|
|
30
|
-
end
|
|
30
|
+
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
--[=[
|
|
2
|
+
Controls for [Viewport]
|
|
2
3
|
@class ViewportControls
|
|
3
4
|
]=]
|
|
4
5
|
|
|
@@ -14,6 +15,12 @@ local ViewportControls = setmetatable({}, BaseObject)
|
|
|
14
15
|
ViewportControls.ClassName = "ViewportControls"
|
|
15
16
|
ViewportControls.__index = ViewportControls
|
|
16
17
|
|
|
18
|
+
--[=[
|
|
19
|
+
Create the controls for dragging.
|
|
20
|
+
@param viewport Instance
|
|
21
|
+
@param viewportModel Viewport
|
|
22
|
+
@return BaseObject
|
|
23
|
+
]=]
|
|
17
24
|
function ViewportControls.new(viewport, viewportModel)
|
|
18
25
|
local self = setmetatable(BaseObject.new(viewport), ViewportControls)
|
|
19
26
|
|
|
@@ -80,4 +87,4 @@ function ViewportControls:_stopDrag()
|
|
|
80
87
|
self._maid._dragging = nil
|
|
81
88
|
end
|
|
82
89
|
|
|
83
|
-
return ViewportControls
|
|
90
|
+
return ViewportControls
|