@quenty/camerastoryutils 3.2.0 → 3.3.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/LICENSE.md +1 -1
- package/package.json +4 -4
- package/src/Client/CameraStoryUtils.lua +62 -3
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
|
+
# [3.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/camerastoryutils@3.2.0...@quenty/camerastoryutils@3.3.0) (2021-12-18)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Better camera explainability ([4fd9016](https://github.com/Quenty/NevermoreEngine/commit/4fd9016f6914bf181e421753cbaca555394537d8))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [3.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/camerastoryutils@3.1.2...@quenty/camerastoryutils@3.2.0) (2021-11-20)
|
|
7
18
|
|
|
8
19
|
|
package/LICENSE.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/camerastoryutils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "CameraStoryUtils - utility functions for 3D viewport hoarcekat stories.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
"Quenty"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@quenty/insertserviceutils": "^3.
|
|
29
|
+
"@quenty/insertserviceutils": "^3.3.0",
|
|
30
30
|
"@quenty/loader": "^3.1.1",
|
|
31
31
|
"@quenty/math": "^2.0.0",
|
|
32
|
-
"@quenty/promise": "^3.
|
|
32
|
+
"@quenty/promise": "^3.3.0"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "6eb398e9fb81191f0815885f807ab0cb3bb9bad1"
|
|
38
38
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
local require = require(script.Parent.loader).load(script)
|
|
6
6
|
|
|
7
7
|
local RunService = game:GetService("RunService")
|
|
8
|
+
local TextService = game:GetService("TextService")
|
|
8
9
|
|
|
9
10
|
local InsertServiceUtils = require("InsertServiceUtils")
|
|
10
11
|
local Promise = require("Promise")
|
|
@@ -33,7 +34,7 @@ function CameraStoryUtils.setupViewportFrame(maid, target)
|
|
|
33
34
|
local viewportFrame = Instance.new("ViewportFrame")
|
|
34
35
|
viewportFrame.ZIndex = 0
|
|
35
36
|
viewportFrame.BorderSizePixel = 0
|
|
36
|
-
viewportFrame.BackgroundColor3 = Color3.new(0.
|
|
37
|
+
viewportFrame.BackgroundColor3 = Color3.new(0.9, 0.9, 0.85)
|
|
37
38
|
viewportFrame.Size = UDim2.new(1, 0, 1, 0)
|
|
38
39
|
maid:GiveTask(viewportFrame)
|
|
39
40
|
|
|
@@ -86,15 +87,57 @@ function CameraStoryUtils.getInterpolationFactory(maid, viewportFrame, low, high
|
|
|
86
87
|
assert(type(period) == "number", "Bad period")
|
|
87
88
|
assert(type(toCFrame) == "function", "Bad toCFrame")
|
|
88
89
|
|
|
89
|
-
return function(interpolate, color)
|
|
90
|
+
return function(interpolate, color, labelText, labelOffset)
|
|
90
91
|
assert(type(interpolate) == "function", "Bad interpolate")
|
|
91
92
|
assert(typeof(color) == "Color3", "Bad color")
|
|
92
93
|
|
|
94
|
+
labelOffset = labelOffset or Vector2.new(0, 0)
|
|
95
|
+
|
|
93
96
|
maid:GivePromise(CameraStoryUtils.promiseCrate(maid, viewportFrame, {
|
|
94
97
|
Color = color;
|
|
95
98
|
Transparency = 0.5
|
|
96
99
|
}))
|
|
97
100
|
:Then(function(crate)
|
|
101
|
+
local label
|
|
102
|
+
if labelText then
|
|
103
|
+
local h, s, _ = Color3.toHSV(color)
|
|
104
|
+
label = Instance.new("TextLabel")
|
|
105
|
+
label.AnchorPoint = Vector2.new(0.5, 0.5)
|
|
106
|
+
label.Text = labelText
|
|
107
|
+
label.BorderSizePixel = 0
|
|
108
|
+
label.BackgroundTransparency = 0.5
|
|
109
|
+
label.BackgroundColor3 = Color3.fromHSV(h, math.clamp(s/(s+0.1), 0, 1), 0.25)
|
|
110
|
+
label.TextColor3 = Color3.new(1, 1, 1)
|
|
111
|
+
label.Font = Enum.Font.FredokaOne
|
|
112
|
+
label.TextSize = 15
|
|
113
|
+
label.Parent = viewportFrame
|
|
114
|
+
label.Visible = false
|
|
115
|
+
maid:GiveTask(label)
|
|
116
|
+
|
|
117
|
+
local size = TextService:GetTextSize(labelText, label.TextSize, label.Font, Vector2.new(1e6, 1e6))
|
|
118
|
+
label.Size = UDim2.new(0, size.x + 20, 0, 20)
|
|
119
|
+
|
|
120
|
+
local uiCorner = Instance.new("UICorner")
|
|
121
|
+
uiCorner.CornerRadius = UDim.new(0.5, 0)
|
|
122
|
+
uiCorner.Parent = label
|
|
123
|
+
maid:GiveTask(label)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
-- avoid floating point numbers from :SetPrimaryPartCFrame
|
|
127
|
+
local primaryPart, primaryCFrame
|
|
128
|
+
local relCFrame = {}
|
|
129
|
+
for _, part in pairs(crate:GetDescendants()) do
|
|
130
|
+
if part:IsA("BasePart") then
|
|
131
|
+
if primaryPart then
|
|
132
|
+
relCFrame[part] = primaryCFrame:toObjectSpace(part.CFrame)
|
|
133
|
+
else
|
|
134
|
+
primaryPart = part
|
|
135
|
+
primaryCFrame = part.CFrame
|
|
136
|
+
relCFrame[part] = CFrame.new()
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
98
141
|
maid:GiveTask(RunService.RenderStepped:Connect(function()
|
|
99
142
|
local t = (os.clock()/period % 2/period)*period
|
|
100
143
|
if t >= 1 then
|
|
@@ -105,7 +148,23 @@ function CameraStoryUtils.getInterpolationFactory(maid, viewportFrame, low, high
|
|
|
105
148
|
t = math.clamp(t, low, high)
|
|
106
149
|
|
|
107
150
|
local cframe = toCFrame(interpolate(t))
|
|
108
|
-
|
|
151
|
+
|
|
152
|
+
if label then
|
|
153
|
+
local camera = viewportFrame.CurrentCamera
|
|
154
|
+
local pos = camera:WorldToViewportPoint(cframe.p)
|
|
155
|
+
local viewportSize = viewportFrame.AbsoluteSize
|
|
156
|
+
local aspectRatio = viewportSize.x/viewportSize.y
|
|
157
|
+
if pos.z > 0 then
|
|
158
|
+
label.Position = UDim2.new((pos.x - 0.5)/aspectRatio + 0.5, labelOffset.x, pos.y, 0 + labelOffset.y)
|
|
159
|
+
label.Visible = true
|
|
160
|
+
else
|
|
161
|
+
label.Visible = false
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
for part, rel in pairs(relCFrame) do
|
|
166
|
+
part.CFrame = cframe:toWorldSpace(rel)
|
|
167
|
+
end
|
|
109
168
|
end))
|
|
110
169
|
end)
|
|
111
170
|
end
|