Added functions to EffectMaker (not functional)
This commit is contained in:
parent
c2711b4c11
commit
d1680bf63c
3 changed files with 119 additions and 2 deletions
8
Test.lua
Normal file
8
Test.lua
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
local TweenService = game:GetService("TweenService")
|
||||||
|
local clock = os.clock
|
||||||
|
local first = clock()
|
||||||
|
for i = 1, 500 do
|
||||||
|
local alpha = TweenService:GetValue(20/6, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
|
||||||
|
end
|
||||||
|
local second = clock()
|
||||||
|
print(second-first)
|
|
@ -1 +1,110 @@
|
||||||
export function kablooey() {}
|
const TweenService = game.GetService("TweenService");
|
||||||
|
type effectKeypoint = [number, Color3, Vector3, CFrame, number, Enum.EasingStyle?, Enum.EasingDirection?];
|
||||||
|
|
||||||
|
export function meshPartEffect(
|
||||||
|
effectFolder: Folder,
|
||||||
|
meshPart: MeshPart,
|
||||||
|
material: Enum.Material,
|
||||||
|
effectKeypoints: effectKeypoint[],
|
||||||
|
) {
|
||||||
|
const effectMeshPart = meshPart.Clone();
|
||||||
|
effectMeshPart.Material = material;
|
||||||
|
|
||||||
|
effectMeshPart.Color = effectKeypoints[0][1];
|
||||||
|
effectMeshPart.Size = effectKeypoints[0][2];
|
||||||
|
effectMeshPart.CFrame = effectKeypoints[0][3];
|
||||||
|
effectMeshPart.Transparency = effectKeypoints[0][4];
|
||||||
|
|
||||||
|
effectMeshPart.CastShadow = false;
|
||||||
|
effectMeshPart.CanCollide = false;
|
||||||
|
effectMeshPart.Anchored = true;
|
||||||
|
effectMeshPart.Parent = effectFolder;
|
||||||
|
effectKeypoints.remove(0);
|
||||||
|
return [effectMeshPart, effectKeypoints, 0] as [MeshPart, effectKeypoint[], number];
|
||||||
|
// Do the interpolation on one thread somehow
|
||||||
|
}
|
||||||
|
|
||||||
|
function particleEffect() {}
|
||||||
|
/*
|
||||||
|
function getLerpKeypoint(time: number, pastKeypoint: effectKeypoint, futureKeypoint: effectKeypoint) {
|
||||||
|
let alpha = 0;
|
||||||
|
if (pastKeypoint[5]) {
|
||||||
|
alpha = TweenService.GetValue(time / futureKeypoint[0], pastKeypoint[5], Enum.EasingDirection.InOut);
|
||||||
|
} else {
|
||||||
|
alpha = time;
|
||||||
|
}
|
||||||
|
let new
|
||||||
|
for (let i = 1; i < 5; i += 1) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
function runEffects(timeSinceLastFrame: number, effectsToRun: [MeshPart, effectKeypoint[], number][]) {
|
||||||
|
for (const effect of effectsToRun) {
|
||||||
|
const meshPart = effect[0];
|
||||||
|
const futureKeypoint = effect[1][1];
|
||||||
|
const timeToNext = futureKeypoint[0];
|
||||||
|
const timeSinceLastKeypoint = effect[2] + timeSinceLastFrame;
|
||||||
|
if (timeSinceLastKeypoint >= timeToNext) {
|
||||||
|
// Remove keypoint
|
||||||
|
// Set effect[3] to 0
|
||||||
|
// Delete effect if no keypoints left
|
||||||
|
} else {
|
||||||
|
effect[2] = timeSinceLastKeypoint;
|
||||||
|
}
|
||||||
|
const pastKeypoint = effect[1][0];
|
||||||
|
const easingStyle = pastKeypoint[5];
|
||||||
|
// Get the alpha
|
||||||
|
let alpha = 0;
|
||||||
|
if (easingStyle) {
|
||||||
|
alpha = TweenService.GetValue(
|
||||||
|
timeSinceLastKeypoint / timeToNext,
|
||||||
|
easingStyle,
|
||||||
|
pastKeypoint[6] || Enum.EasingDirection.InOut,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
alpha = timeSinceLastKeypoint / timeToNext;
|
||||||
|
}
|
||||||
|
// Alter the effect
|
||||||
|
meshPart.Color = pastKeypoint[1].Lerp(futureKeypoint[1], alpha);
|
||||||
|
meshPart.Position = pastKeypoint[2].Lerp(futureKeypoint[2], alpha);
|
||||||
|
meshPart.CFrame = pastKeypoint[3].Lerp(futureKeypoint[3], alpha);
|
||||||
|
meshPart.Transparency = pastKeypoint[4] + (futureKeypoint[4] - pastKeypoint[4]) * alpha;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
local function horseEffModule(o,typ,a1,a2,a3,a4,a5,a6,a7)
|
||||||
|
return {
|
||||||
|
Color = a1,
|
||||||
|
Size = a2*typ[2],
|
||||||
|
["CFrame"] = (type(a3) == "table" and o.CFrame*a3[1]) or a3,
|
||||||
|
Transparency = a4
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
--sequence entry format:
|
||||||
|
--{color,size,cframe,transparency,time to next,easingstyle,easingdirection}
|
||||||
|
--horseeffect "typ" takes a table with a meshpart as the first value and a scale vector3 as the second
|
||||||
|
local function horseEff(typ,material,sequence) --I understand if you don't use this function. Not everyone is cool enough.
|
||||||
|
wrap(function()
|
||||||
|
local o = typ[1]:Clone()
|
||||||
|
o.CastShadow = false
|
||||||
|
o.Anchored = true
|
||||||
|
o.CanCollide = false
|
||||||
|
o.Material = material
|
||||||
|
o.Color = sequence[1][1]
|
||||||
|
o.Size = sequence[1][2]*typ[2]
|
||||||
|
o.CFrame = sequence[1][3]
|
||||||
|
o.Transparency = sequence[1][4]
|
||||||
|
o.Parent = efFolder or workspace
|
||||||
|
for i = 2, #sequence do
|
||||||
|
local g = horseEffModule(o,typ,unpack(sequence[i])) -- goes and gets the information to be tweened to with less table indices
|
||||||
|
local tinfo = TweenInfo.new(sequence[i-1][5] or sequence[1][5],sequence[i-1][6] or sequence[1][6],sequence[i-1][7] or sequence[1][7])
|
||||||
|
play(tweenServiceCreate(twS,o,tinfo,g))
|
||||||
|
wait(sequence[i-1][5] or sequence[1][5])
|
||||||
|
end
|
||||||
|
destroy(o)
|
||||||
|
end)()
|
||||||
|
end
|
||||||
|
*/
|
||||||
|
|
|
@ -97,7 +97,7 @@ const guiTable: guiTable = {
|
||||||
Position: new UDim2(0.375, 0, 0.5, 0),
|
Position: new UDim2(0.375, 0, 0.5, 0),
|
||||||
Size: new UDim2(0.25, 0, 0.125, 0),
|
Size: new UDim2(0.25, 0, 0.125, 0),
|
||||||
Text: "Play",
|
Text: "Play",
|
||||||
onClick: [["MessageServer", "EnterGame"]], // The main menu should disappear in respone
|
onClick: [["MessageServer", "EnterGame"]], // The main menu should disappear in response
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: "TextButton",
|
Type: "TextButton",
|
||||||
|
|
Loading…
Reference in a new issue