Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/camerastoryutils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"Quenty"
],
"dependencies": {
"@quenty/insertserviceutils": "workspace:*",
"@quenty/blend": "workspace:*",
"@quenty/loader": "workspace:*",
"@quenty/math": "workspace:*",
"@quenty/promise": "workspace:*"
Expand Down
17 changes: 8 additions & 9 deletions src/camerastoryutils/src/Client/CameraStoryUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ local require = require(script.Parent.loader).load(script)
local RunService = game:GetService("RunService")
local TextService = game:GetService("TextService")

local InsertServiceUtils = require("InsertServiceUtils")
local Maid = require("Maid")
local Math = require("Math")
local Promise = require("Promise")
local RenderCrateUtils = require("RenderCrateUtils")

local CameraStoryUtils = {}

Expand Down Expand Up @@ -71,17 +71,16 @@ end
]=]
function CameraStoryUtils.promiseCrate(
maid: Maid.Maid,
viewportFrame: ViewportFrame,
properties
viewportFrame: ViewportFrame?,
properties: { [string]: any }?
): Promise.Promise<Instance>
return maid:GivePromise(InsertServiceUtils.promiseAsset(182451181)):Then(function(model)
maid:GiveTask(model)
local promise = maid:GivePromise(Promise.new())

local crate = (model :: any):GetChildren()[1]
if not crate then
return Promise.rejected()
end
maid:GiveTask(RenderCrateUtils.crate():Subscribe(function(crate)
promise:Resolve(crate)
end))

return promise:Then(function(crate)
if properties then
for _, item in crate:GetDescendants() do
if item:IsA("BasePart") then
Expand Down
183 changes: 183 additions & 0 deletions src/camerastoryutils/src/Client/RenderCrateUtils.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
--!strict
--[=[
@class RenderCrateUtils
]=]

local require = require(script.Parent.loader).load(script)

local Blend = require("Blend")

local RenderCrateUtils = {}

function RenderCrateUtils.crate()
local center = Blend.State(nil)

return Blend.New "Model" {
Name = "Wood Crate",
PrimaryPart = center,
Blend.New "Part" {
Size = Vector3.new(3.4, 0.6, 0.6),
BrickColor = BrickColor.new("Reddish brown"),
CFrame = CFrame.new(1.7, -0.300135, -1.699984, 0, -1, 0, -1, 0, 0, 0, 0, -1),
Color = Color3.fromRGB(105, 64, 40),
Material = Enum.Material.WoodPlanks,
Rotation = Vector3.new(180, 0, 90),
},
Blend.New "Part" {
Size = Vector3.new(2.8, 0.6, 0.6),
BrickColor = BrickColor.new("Reddish brown"),
CFrame = CFrame.new(0, 1.7, -1.7, 1, 0, 0, 0, 1, 0, 0, 0, 1),
Color = Color3.fromRGB(105, 64, 40),
Material = Enum.Material.WoodPlanks,
},
Blend.New "Part" {
Size = Vector3.new(4, 0.6, 0.6),
BrickColor = BrickColor.new("Reddish brown"),
CFrame = CFrame.new(0, 0.028748, 1.641696, -0.707111, -0.707102, 0, 0.707102, -0.707112, 0, 0, 0, 1),
Color = Color3.fromRGB(105, 64, 40),
Material = Enum.Material.WoodPlanks,
Rotation = Vector3.new(0, 0, 135),
},
Blend.New "Part" {
Size = Vector3.new(0.6, 0.6, 4),
BrickColor = BrickColor.new("Reddish brown"),
CFrame = CFrame.new(0, 0.028749, -1.658263, 0, -0.707102, -0.707111, 0, -0.707111, 0.707102, -1, -0, 0),
Color = Color3.fromRGB(105, 64, 40),
Material = Enum.Material.WoodPlanks,
Rotation = Vector3.new(-90, -45, 90),
},
Blend.New "Part" {
Size = Vector3.new(4, 0.6, 0.6),
BrickColor = BrickColor.new("Reddish brown"),
CFrame = CFrame.new(
-1.649982,
0.02874,
-0.008285,
0,
0,
-1,
0.707106,
-0.707108,
0,
-0.707108,
-0.707106,
-0
),
Color = Color3.fromRGB(105, 64, 40),
Material = Enum.Material.WoodPlanks,
Rotation = Vector3.new(-135, -90, 0),
},
Blend.New "Part" {
Size = Vector3.new(3.4, 0.6, 0.6),
BrickColor = BrickColor.new("Reddish brown"),
CFrame = CFrame.new(0.3, -1.7, 1.7, 1, 0, 0, 0, 1, 0, 0, 0, 1),
Color = Color3.fromRGB(105, 64, 40),
Material = Enum.Material.WoodPlanks,
},
Blend.New "Part" {
Size = Vector3.new(3.4, 0.6, 0.6),
BrickColor = BrickColor.new("Reddish brown"),
CFrame = CFrame.new(-1.7, 1.7, -0.3) * CFrame.Angles(0, math.pi / 2, 0),
Color = Color3.fromRGB(105, 64, 40),
Material = Enum.Material.WoodPlanks,
Rotation = Vector3.new(0, 90, 0),
},
Blend.New "Part" {
Size = Vector3.new(3.4, 0.6, 0.6),
BrickColor = BrickColor.new("Reddish brown"),
CFrame = CFrame.new(-1.7, -0.3, -1.7) * CFrame.Angles(-math.pi / 2, math.pi / 2, 0),
Color = Color3.fromRGB(105, 64, 40),
Material = Enum.Material.WoodPlanks,
Rotation = Vector3.new(-90, 90, 0),
},
Blend.New "Part" {
Size = Vector3.new(2.8, 0.6, 0.6),
BrickColor = BrickColor.new("Reddish brown"),
CFrame = CFrame.new(0.000019, -1.70013, -1.7, 1, 0, 0, 0, 1, 0, 0, 0, 1),
Color = Color3.fromRGB(105, 64, 40),
Material = Enum.Material.WoodPlanks,
},
Blend.New "Part" {
Size = Vector3.new(3.4, 0.6, 0.6),
BrickColor = BrickColor.new("Reddish brown"),
CFrame = CFrame.new(1.7, 0.3, 1.7, 0, -1, 0, 1, 0, 0, 0, 0, 1),
Color = Color3.fromRGB(105, 64, 40),
Material = Enum.Material.WoodPlanks,
Rotation = Vector3.new(0, 0, 90),
},
Blend.New "Part" {
Size = Vector3.new(3.4, 0.6, 0.6),
BrickColor = BrickColor.new("Reddish brown"),
CFrame = CFrame.new(-0.3, 1.7, 1.7, 1, 0, 0, 0, 1, 0, 0, 0, 1),
Color = Color3.fromRGB(105, 64, 40),
Material = Enum.Material.WoodPlanks,
},
Blend.New "Part" {
Size = Vector3.new(4, 0.6, 0.6),
BrickColor = BrickColor.new("Reddish brown"),
CFrame = CFrame.new(1.649986, 0.028765, 0, 0, 0, 1, 0.707111, 0.707102, 0, -0.707102, 0.707111, 0),
Color = Color3.fromRGB(105, 64, 40),
Material = Enum.Material.WoodPlanks,
Rotation = Vector3.new(45, 90, 0),
},
Blend.New "Part" {
Size = Vector3.new(4, 0.6, 0.6),
BrickColor = BrickColor.new("Reddish brown"),
CFrame = CFrame.new(-0.007957, 1.649938, 0.054213, 0.707106, 0, 0.707108, 0, 1, 0, -0.707108, 0, 0.707106),
Color = Color3.fromRGB(105, 64, 40),
Material = Enum.Material.WoodPlanks,
Rotation = Vector3.new(0, 45, 0.001),
},
Blend.New "Part" {
Size = Vector3.new(3.4, 0.6, 0.6),
BrickColor = BrickColor.new("Reddish brown"),
CFrame = CFrame.new(-1.699978, -1.700141, 0.299995) * CFrame.Angles(0, math.pi / 2, 0),
Color = Color3.fromRGB(105, 64, 40),
Material = Enum.Material.WoodPlanks,
Rotation = Vector3.new(0, 90, 0),
},
Blend.New "Part" {
Size = Vector3.new(2.8, 0.6, 0.6),
BrickColor = BrickColor.new("Reddish brown"),
CFrame = CFrame.new(-1.7, 0, 1.7, 0, 1, 0, -1, 0, 0, 0, 0, 1),
Color = Color3.fromRGB(105, 64, 40),
Material = Enum.Material.WoodPlanks,
Rotation = Vector3.new(0, 0, -90),
},
Blend.New "Part" {
Size = Vector3.new(4, 0.6, 0.6),
BrickColor = BrickColor.new("Reddish brown"),
CFrame = CFrame.new(0, -1.671373, -0.008285, 0.707105, 0.707108, -0, 0, 0, 1, 0.707108, -0.707105, -0),
Color = Color3.fromRGB(105, 64, 40),
Material = Enum.Material.WoodPlanks,
Rotation = Vector3.new(-90, -0.001, -45),
},
Blend.New "Part" {
Size = Vector3.new(2.8, 0.6, 0.6),
BrickColor = BrickColor.new("Reddish brown"),
CFrame = CFrame.new(1.7, -1.7, 0) * CFrame.Angles(math.pi, math.pi / 2, 0),
Color = Color3.fromRGB(105, 64, 40),
Material = Enum.Material.WoodPlanks,
Rotation = Vector3.new(180, 90, 0),
},
Blend.New "Part" {
Name = "Center",
Size = Vector3.new(3.6, 3.6, 3.6),
BrickColor = BrickColor.new("Brown"),
CFrame = CFrame.Angles(0, 0, 0),
Color = Color3.fromRGB(124, 92, 70),
Material = Enum.Material.WoodPlanks,
[Blend.Instance] = center,
},
Blend.New "Part" {
Size = Vector3.new(3.4, 0.6, 0.6),
BrickColor = BrickColor.new("Reddish brown"),
CFrame = CFrame.new(1.7, 1.7, -0.3) * CFrame.Angles(0, -math.pi / 2, 0),
Color = Color3.fromRGB(105, 64, 40),
Material = Enum.Material.WoodPlanks,
Rotation = Vector3.new(0, -90, 0),
},
}
end

return RenderCrateUtils
12 changes: 6 additions & 6 deletions src/uiobjectutils/src/Client/UICornerUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function UICornerUtils.clampPositionToFrame(
frameSize: Vector2,
radius: number,
point: Vector2
): (Vector2?, Vector2?)
): (Vector2?, Vector2?, Vector2?)
assert(radius >= 0, "Bad radius")
assert(point, "Bad point")

Expand Down Expand Up @@ -77,18 +77,18 @@ function UICornerUtils.clampPositionToFrame(
rpy = miny
end

local position = Vector2.new(rpx, rpy)
local insidePosition = Vector2.new(rpx, rpy)

-- project in direction of offset
local direction = point - position
local direction = point - insidePosition
if direction.Magnitude == 0 then
-- Shouldn't happen!
return nil, nil
return nil, nil, nil
end

local normal = direction.Unit
local outsidePosition = position + normal * radius
return outsidePosition, normal
local outsidePosition = insidePosition + normal * radius
return outsidePosition, normal, insidePosition
end

return UICornerUtils
Loading