forked from aya/aya
Initial commit
This commit is contained in:
21
client/common/content/scripts/ThumbnailScripts/Avatar.lua
Normal file
21
client/common/content/scripts/ThumbnailScripts/Avatar.lua
Normal file
@@ -0,0 +1,21 @@
|
||||
local characterAppearanceUrl, fileExtension, x, y = ...
|
||||
|
||||
local ThumbnailGenerator = game:GetService("ThumbnailGenerator")
|
||||
game:GetService("ScriptContext").ScriptsDisabled = true
|
||||
|
||||
local player = game:GetService("Players"):CreateLocalPlayer(0)
|
||||
player.CharacterAppearance = characterAppearanceUrl
|
||||
player:LoadCharacter()
|
||||
|
||||
-- Raise up the character's arm if they have gear.
|
||||
if player.Character then
|
||||
player.Character.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
|
||||
for _, child in pairs(player.Character:GetChildren()) do
|
||||
if child:IsA("Tool") then
|
||||
player.Character.Torso["Right Shoulder"].CurrentAngle = math.rad(90)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return ThumbnailGenerator:Click(fileExtension, x, y, --[[hideSky = ]] true)
|
||||
14
client/common/content/scripts/ThumbnailScripts/Clothing.lua
Normal file
14
client/common/content/scripts/ThumbnailScripts/Clothing.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
local assetUrl, fileExtension, x, y, baseUrl, mannequinId = ...
|
||||
|
||||
local ThumbnailGenerator = game:GetService("ThumbnailGenerator")
|
||||
game:GetService("ScriptContext").ScriptsDisabled = true
|
||||
|
||||
local mannequin = game:GetObjects("ayaassetid://" .. tostring(mannequinId))[1]
|
||||
mannequin.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
|
||||
mannequin.Parent = workspace
|
||||
|
||||
local clothing = game:GetObjects(assetUrl)[1]
|
||||
clothing.Parent = mannequin
|
||||
|
||||
return ThumbnailGenerator:Click(fileExtension, x, y, --[[hideSky = ]] true)
|
||||
58
client/common/content/scripts/ThumbnailScripts/Headshot.lua
Normal file
58
client/common/content/scripts/ThumbnailScripts/Headshot.lua
Normal file
@@ -0,0 +1,58 @@
|
||||
local characterAppearanceUrl, fileExtension, x, y, quadratic, baseHatZoom, maxHatZoom, cameraOffsetX, cameraOffsetY = ...
|
||||
|
||||
local ThumbnailGenerator = game:GetService("ThumbnailGenerator")
|
||||
game:GetService('ScriptContext').ScriptsDisabled = true
|
||||
|
||||
local player = game:GetService("Players"):CreateLocalPlayer(0)
|
||||
player.CharacterAppearance = characterAppearanceUrl
|
||||
player:LoadCharacter()
|
||||
|
||||
local maxDimension = 0
|
||||
|
||||
if player.Character then
|
||||
-- Remove gear
|
||||
for _, child in pairs(player.Character:GetChildren()) do
|
||||
if child:IsA("Tool") then
|
||||
child:Destroy()
|
||||
elseif child:IsA("Accoutrement") or child:IsA("Hat") then
|
||||
local handle = child:FindFirstChild("Handle")
|
||||
if handle then
|
||||
local attachment = handle:FindFirstChildWhichIsA("Attachment")
|
||||
-- legacy hat does not have attachment in it and should be considered when zoom out camera
|
||||
if not attachment or headAttachments[attachment.Name] then
|
||||
local size = handle.Size / 2 + handle.Position - player.Character.Head.Position
|
||||
local xy = Vector2.new(size.x, size.y)
|
||||
if xy.magnitude > maxDimension then
|
||||
maxDimension = xy.magnitude
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Setup Camera
|
||||
local maxHatOffset = 0.5 -- Maximum amount to move camera upward to accomodate large hats
|
||||
maxDimension = math.min(1, maxDimension / 3) -- Confine maxdimension to specific bounds
|
||||
|
||||
if quadratic then
|
||||
maxDimension = maxDimension * maxDimension -- Zoom out on quadratic interpolation
|
||||
end
|
||||
|
||||
local viewOffset = player.Character.Head.CFrame * CFrame.new(cameraOffsetX, cameraOffsetY + maxHatOffset * maxDimension, 0.1) -- View vector offset from head
|
||||
|
||||
local yAngle = -math.pi / 16
|
||||
if FFlagNewHeadshotLighting then
|
||||
yAngle = 0 -- Camera is looking straight at avatar's face.
|
||||
end
|
||||
local positionOffset = player.Character.Head.CFrame + (CFrame.Angles(0, yAngle, 0).lookVector.unit * 3) -- Position vector offset from head
|
||||
|
||||
local camera = Instance.new("Camera", player.Character)
|
||||
camera.Name = "ThumbnailCamera"
|
||||
camera.CameraType = Enum.CameraType.Scriptable
|
||||
camera.CoordinateFrame = CFrame.new(positionOffset.p, viewOffset.p)
|
||||
camera.FieldOfView = baseHatZoom + (maxHatZoom - baseHatZoom) * maxDimension
|
||||
end
|
||||
|
||||
local result = ThumbnailGenerator:Click(fileExtension, x, y, --[[hideSky = ]] true)
|
||||
|
||||
return result
|
||||
27
client/common/content/scripts/ThumbnailScripts/Object.lua
Normal file
27
client/common/content/scripts/ThumbnailScripts/Object.lua
Normal file
@@ -0,0 +1,27 @@
|
||||
local assetUrl, fileExtension, x, y = ...
|
||||
|
||||
local ThumbnailGenerator = game:GetService("ThumbnailGenerator")
|
||||
|
||||
game:GetService("ScriptContext").ScriptsDisabled = true
|
||||
|
||||
for _, object in pairs(game:GetObjects(assetUrl)) do
|
||||
if object:IsA("Sky") then
|
||||
local resultValues = nil
|
||||
local success = pcall(function() resultValues = {ThumbnailGenerator:ClickTexture(object.SkyboxFt, fileExtension, x, y)} end)
|
||||
if success then
|
||||
return unpack(resultValues)
|
||||
else
|
||||
object.Parent = game:GetService("Lighting")
|
||||
return ThumbnailGenerator:Click(fileExtension, x, y, --[[hideSky = ]] false)
|
||||
end
|
||||
elseif object:IsA("SpecialMesh") then
|
||||
local part = Instance.new("Part")
|
||||
part.Parent = workspace
|
||||
object.Parent = part
|
||||
return ThumbnailGenerator:Click(fileExtension, x, y, --[[hideSky = ]] true)
|
||||
else
|
||||
pcall(function() object.Parent = workspace end)
|
||||
end
|
||||
end
|
||||
|
||||
return ThumbnailGenerator:Click(fileExtension, x, y, --[[hideSky = ]] true)
|
||||
20
client/common/content/scripts/ThumbnailScripts/Place.lua
Normal file
20
client/common/content/scripts/ThumbnailScripts/Place.lua
Normal file
@@ -0,0 +1,20 @@
|
||||
local assetUrl, fileExtension, x, y, universeId = ...
|
||||
|
||||
local ThumbnailGenerator = game:GetService("ThumbnailGenerator")
|
||||
|
||||
if universeId ~= nil then
|
||||
pcall(function() game:SetUniverseId(universeId) end)
|
||||
end
|
||||
|
||||
game:GetService("ScriptContext").ScriptsDisabled = true
|
||||
game:GetService("StarterGui").ShowDevelopmentGui = false
|
||||
|
||||
game:Load(assetUrl)
|
||||
|
||||
ThumbnailGenerator:AddProfilingCheckpoint("GameLoaded")
|
||||
|
||||
-- Do this after again loading the place file to ensure that these values aren't changed when the place file is loaded.
|
||||
game:GetService("ScriptContext").ScriptsDisabled = true
|
||||
game:GetService("StarterGui").ShowDevelopmentGui = false
|
||||
|
||||
return ThumbnailGenerator:Click(fileExtension, x, y, --[[hideSky = ]] false)
|
||||
Reference in New Issue
Block a user