@quenty/particleengine 13.33.0 → 13.34.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 +10 -0
- package/package.json +4 -4
- package/src/Client/ParticleEngineClient.lua +98 -64
- package/src/Server/ParticleEngineServer.lua +33 -11
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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
|
+
# [13.34.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/particleengine@13.33.1...@quenty/particleengine@13.34.0) (2026-07-14)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **particleengine:** convert package to --!strict ([8140733](https://github.com/Quenty/NevermoreEngine/commit/8140733549712d162714c2093773ff93a11dadd9))
|
|
11
|
+
|
|
12
|
+
## [13.33.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/particleengine@13.33.0...@quenty/particleengine@13.33.1) (2026-05-30)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @quenty/particleengine
|
|
15
|
+
|
|
6
16
|
# [13.33.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/particleengine@13.32.0...@quenty/particleengine@13.33.0) (2026-05-29)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @quenty/particleengine
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/particleengine",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.34.0",
|
|
4
4
|
"description": "Adds GUI based particle engine to Roblox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@quenty/loader": "10.11.0",
|
|
33
|
-
"@quenty/remoting": "12.32.
|
|
34
|
-
"@quenty/servicebag": "11.18.
|
|
33
|
+
"@quenty/remoting": "12.32.1",
|
|
34
|
+
"@quenty/servicebag": "11.18.1",
|
|
35
35
|
"@quenty/table": "3.9.2"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "13f0162f4971a77378e55e9b7236aea94f0dd3a8"
|
|
41
41
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
--!
|
|
1
|
+
--!strict
|
|
2
2
|
--[=[
|
|
3
3
|
Legacy code written by AxisAngles to simulate particles with Guis
|
|
4
4
|
|
|
@@ -33,15 +33,74 @@ local function newFrame(name: string): Frame
|
|
|
33
33
|
return frame
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
-- Adds a new particle
|
|
37
|
+
-- @param p PropertiesTable
|
|
38
|
+
--[[
|
|
39
|
+
{
|
|
40
|
+
Position = Vector3
|
|
41
|
+
|
|
42
|
+
-- Optional
|
|
43
|
+
Global = Bool
|
|
44
|
+
Velocity = Vector3
|
|
45
|
+
Gravity = Vector3
|
|
46
|
+
WindResistance = Number
|
|
47
|
+
LifeTime = Number
|
|
48
|
+
Size = Vector2
|
|
49
|
+
Bloom = Vector2
|
|
50
|
+
Transparency = Number
|
|
51
|
+
Color = Color3
|
|
52
|
+
Occlusion = Bool
|
|
53
|
+
RemoveOnCollision = function(BasePart Hit, Vector3 Position))
|
|
54
|
+
Function = function(Table ParticleProperties, Number dt, Number t)
|
|
55
|
+
}
|
|
56
|
+
--]]
|
|
57
|
+
export type Particle = {
|
|
58
|
+
Position: Vector3,
|
|
59
|
+
Global: boolean?,
|
|
60
|
+
Velocity: Vector3,
|
|
61
|
+
Gravity: Vector3,
|
|
62
|
+
WindResistance: number?,
|
|
63
|
+
LifeTime: number,
|
|
64
|
+
Size: Vector2,
|
|
65
|
+
Bloom: Vector2,
|
|
66
|
+
Transparency: number,
|
|
67
|
+
Color: Color3,
|
|
68
|
+
Occlusion: boolean?,
|
|
69
|
+
RemoveOnCollision: ((Particle, BasePart, Vector3, Vector3, Enum.Material) -> boolean)?,
|
|
70
|
+
Function: ((Particle, number, number) -> ())?,
|
|
71
|
+
_lastScreenPosition: Vector2?,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type ParticleEngineClient = typeof(setmetatable(
|
|
75
|
+
{} :: {
|
|
76
|
+
ServiceName: string,
|
|
77
|
+
_maxParticles: number,
|
|
78
|
+
_windSpeed: number,
|
|
79
|
+
_serviceBag: ServiceBag.ServiceBag,
|
|
80
|
+
_screen: ScreenGui?,
|
|
81
|
+
_remoteEvent: RemoteEvent?,
|
|
82
|
+
_player: Player,
|
|
83
|
+
_lastUpdateTime: number,
|
|
84
|
+
_particleCount: number,
|
|
85
|
+
_particles: { [Particle]: Particle },
|
|
86
|
+
_particleFrames: { Frame },
|
|
87
|
+
_planeSizeX: number,
|
|
88
|
+
_planeSizeY: number,
|
|
89
|
+
_screenSizeX: number,
|
|
90
|
+
_screenSizeY: number,
|
|
91
|
+
},
|
|
92
|
+
{} :: typeof({ __index = ParticleEngineClient })
|
|
93
|
+
))
|
|
94
|
+
|
|
95
|
+
function ParticleEngineClient.Init(self: ParticleEngineClient, serviceBag: ServiceBag.ServiceBag): ()
|
|
37
96
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
38
|
-
self._screen = nil
|
|
97
|
+
self._screen = nil
|
|
39
98
|
|
|
40
99
|
PromiseGetRemoteEvent(ParticleEngineConstants.REMOTE_EVENT_NAME):Then(function(remoteEvent: RemoteEvent)
|
|
41
100
|
self._remoteEvent = remoteEvent
|
|
42
101
|
|
|
43
|
-
|
|
44
|
-
self:ParticleNew(...)
|
|
102
|
+
remoteEvent.OnClientEvent:Connect(function(...)
|
|
103
|
+
(self :: any):ParticleNew(...)
|
|
45
104
|
end)
|
|
46
105
|
end)
|
|
47
106
|
|
|
@@ -49,8 +108,8 @@ function ParticleEngineClient:Init(serviceBag: ServiceBag.ServiceBag)
|
|
|
49
108
|
|
|
50
109
|
self._lastUpdateTime = tick()
|
|
51
110
|
self._particleCount = 0
|
|
52
|
-
self._particles = {}
|
|
53
|
-
self._particleFrames = {}
|
|
111
|
+
self._particles = {}
|
|
112
|
+
self._particleFrames = {}
|
|
54
113
|
|
|
55
114
|
for i = 1, self._maxParticles do
|
|
56
115
|
self._particleFrames[i] = newFrame("_particle")
|
|
@@ -63,12 +122,12 @@ function ParticleEngineClient:Init(serviceBag: ServiceBag.ServiceBag)
|
|
|
63
122
|
end)
|
|
64
123
|
end
|
|
65
124
|
|
|
66
|
-
function ParticleEngineClient
|
|
125
|
+
function ParticleEngineClient.SetScreenGui(self: ParticleEngineClient, screenGui: ScreenGui): ()
|
|
67
126
|
self._screen = screenGui
|
|
68
127
|
end
|
|
69
128
|
|
|
70
129
|
-- Removes a particle
|
|
71
|
-
function ParticleEngineClient
|
|
130
|
+
function ParticleEngineClient.Remove(self: ParticleEngineClient, p: Particle): ()
|
|
72
131
|
if self._particles[p] then
|
|
73
132
|
self._particles[p] = nil
|
|
74
133
|
self._particleCount -= 1
|
|
@@ -77,43 +136,7 @@ end
|
|
|
77
136
|
|
|
78
137
|
-- Adds a new particle
|
|
79
138
|
-- @param p PropertiesTable
|
|
80
|
-
|
|
81
|
-
{
|
|
82
|
-
Position = Vector3
|
|
83
|
-
|
|
84
|
-
-- Optional
|
|
85
|
-
Global = Bool
|
|
86
|
-
Velocity = Vector3
|
|
87
|
-
Gravity = Vector3
|
|
88
|
-
WindResistance = Number
|
|
89
|
-
LifeTime = Number
|
|
90
|
-
Size = Vector2
|
|
91
|
-
Bloom = Vector2
|
|
92
|
-
Transparency = Number
|
|
93
|
-
Color = Color3
|
|
94
|
-
Occlusion = Bool
|
|
95
|
-
RemoveOnCollision = function(BasePart Hit, Vector3 Position))
|
|
96
|
-
Function = function(Table ParticleProperties, Number dt, Number t)
|
|
97
|
-
}
|
|
98
|
-
--]]
|
|
99
|
-
export type Particle = {
|
|
100
|
-
Position: Vector3,
|
|
101
|
-
Global: boolean,
|
|
102
|
-
Velocity: Vector3,
|
|
103
|
-
Gravity: Vector3,
|
|
104
|
-
WindResistance: number,
|
|
105
|
-
LifeTime: number,
|
|
106
|
-
Size: Vector2,
|
|
107
|
-
Bloom: Vector2,
|
|
108
|
-
Transparency: number,
|
|
109
|
-
Color: Color3,
|
|
110
|
-
Occlusion: boolean?,
|
|
111
|
-
RemoveOnCollision: ((BasePart, Vector3) -> boolean)?,
|
|
112
|
-
Function: ((Particle, number, number) -> ())?,
|
|
113
|
-
_lastScreenPosition: Vector2?,
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function ParticleEngineClient:Add(p: Particle)
|
|
139
|
+
function ParticleEngineClient.Add(self: ParticleEngineClient, p: Particle): ()
|
|
117
140
|
if self._particles[p] then
|
|
118
141
|
return
|
|
119
142
|
end
|
|
@@ -131,7 +154,7 @@ function ParticleEngineClient:Add(p: Particle)
|
|
|
131
154
|
local removeOnCollision = p.RemoveOnCollision
|
|
132
155
|
p.Global = nil
|
|
133
156
|
p.Function = nil
|
|
134
|
-
p.RemoveOnCollision = p.RemoveOnCollision
|
|
157
|
+
p.RemoveOnCollision = if p.RemoveOnCollision then true :: any else nil
|
|
135
158
|
|
|
136
159
|
if self._remoteEvent then
|
|
137
160
|
self._remoteEvent:FireServer(p)
|
|
@@ -146,7 +169,8 @@ function ParticleEngineClient:Add(p: Particle)
|
|
|
146
169
|
p.LifeTime = p.LifeTime and p.LifeTime + tick()
|
|
147
170
|
|
|
148
171
|
if self._particleCount > self._maxParticles then
|
|
149
|
-
|
|
172
|
+
local firstKey: any = next(self._particles)
|
|
173
|
+
self._particles[firstKey] = nil
|
|
150
174
|
else
|
|
151
175
|
self._particleCount = self._particleCount + 1
|
|
152
176
|
end
|
|
@@ -166,7 +190,7 @@ end
|
|
|
166
190
|
|
|
167
191
|
-- @param p ParticleProperties
|
|
168
192
|
-- @param dt ChangeInTime
|
|
169
|
-
function ParticleEngineClient
|
|
193
|
+
function ParticleEngineClient._updatePosVel(self: ParticleEngineClient, p: Particle, dt: number, t: number): ()
|
|
170
194
|
p.Position = p.Position + p.Velocity * dt
|
|
171
195
|
|
|
172
196
|
local wind
|
|
@@ -181,7 +205,12 @@ end
|
|
|
181
205
|
|
|
182
206
|
-- Handles both priority and regular particles
|
|
183
207
|
-- @return boolean alive, true if still fine
|
|
184
|
-
function ParticleEngineClient
|
|
208
|
+
function ParticleEngineClient._updateParticle(
|
|
209
|
+
self: ParticleEngineClient,
|
|
210
|
+
particle: Particle,
|
|
211
|
+
t: number,
|
|
212
|
+
dt: number
|
|
213
|
+
): boolean
|
|
185
214
|
if particle.LifeTime - t <= 0 then
|
|
186
215
|
return false
|
|
187
216
|
end
|
|
@@ -221,7 +250,7 @@ function ParticleEngineClient:_updateParticle(particle: Particle, t: number, dt:
|
|
|
221
250
|
return true
|
|
222
251
|
end
|
|
223
252
|
|
|
224
|
-
function ParticleEngineClient
|
|
253
|
+
function ParticleEngineClient._update(self: ParticleEngineClient): ()
|
|
225
254
|
local t = tick()
|
|
226
255
|
local dt = t - self._lastUpdateTime
|
|
227
256
|
self._lastUpdateTime = t
|
|
@@ -244,8 +273,8 @@ function ParticleEngineClient:_update()
|
|
|
244
273
|
self:_updateRender()
|
|
245
274
|
end
|
|
246
275
|
|
|
247
|
-
function ParticleEngineClient
|
|
248
|
-
local camera: Camera = Workspace.CurrentCamera
|
|
276
|
+
function ParticleEngineClient._updateRender(self: ParticleEngineClient): ()
|
|
277
|
+
local camera: Camera = Workspace.CurrentCamera :: Camera
|
|
249
278
|
self:_updateScreenInfo(camera)
|
|
250
279
|
|
|
251
280
|
local cameraInverse = camera.CFrame:Inverse()
|
|
@@ -253,14 +282,14 @@ function ParticleEngineClient:_updateRender()
|
|
|
253
282
|
|
|
254
283
|
local frameIndex, frame = next(self._particleFrames)
|
|
255
284
|
for particle in pairs(self._particles) do
|
|
256
|
-
if self:_particleRender(cameraPosition, cameraInverse, frame, particle) then
|
|
285
|
+
if frame and self:_particleRender(cameraPosition, cameraInverse, frame, particle) then
|
|
257
286
|
frame.Parent = self._screen
|
|
258
287
|
frameIndex, frame = next(self._particleFrames, frameIndex)
|
|
259
288
|
end
|
|
260
289
|
end
|
|
261
290
|
|
|
262
291
|
-- Cleanup remaining frames that are parented
|
|
263
|
-
while frameIndex and frame.Parent do
|
|
292
|
+
while frameIndex and frame and frame.Parent do
|
|
264
293
|
frame.Parent = nil
|
|
265
294
|
frameIndex, frame = next(self._particleFrames, frameIndex)
|
|
266
295
|
end
|
|
@@ -268,12 +297,13 @@ end
|
|
|
268
297
|
|
|
269
298
|
-- @param f frame
|
|
270
299
|
-- @param cameraInverse The inverse camera cframe
|
|
271
|
-
function ParticleEngineClient
|
|
300
|
+
function ParticleEngineClient._particleRender(
|
|
301
|
+
self: ParticleEngineClient,
|
|
272
302
|
cameraPosition: Vector3,
|
|
273
303
|
cameraInverse: CFrame,
|
|
274
304
|
frame: Frame,
|
|
275
305
|
particle: Particle
|
|
276
|
-
)
|
|
306
|
+
): boolean
|
|
277
307
|
local rp: Vector3 = cameraInverse * particle.Position
|
|
278
308
|
local lsp: Vector2? = particle._lastScreenPosition
|
|
279
309
|
|
|
@@ -296,10 +326,10 @@ function ParticleEngineClient:_particleRender(
|
|
|
296
326
|
local bgt: number = particle.Transparency
|
|
297
327
|
local px: number = (0.5 - sp.X / self._planeSizeX) * self._screenSizeX
|
|
298
328
|
local py: number = (0.5 + sp.Y / self._planeSizeY) * self._screenSizeY
|
|
299
|
-
local preSizeY = -particle.Size.Y / rp.
|
|
300
|
-
local sx: number = -particle.Size.X / rp.
|
|
301
|
-
local rppx, rppy = px - lsp.
|
|
302
|
-
local sy = preSizeY + math.sqrt(rppx * rppx + rppy * rppy) + b.
|
|
329
|
+
local preSizeY = -particle.Size.Y / rp.Z * self._screenSizeY / self._planeSizeY
|
|
330
|
+
local sx: number = -particle.Size.X / rp.Z * self._screenSizeY / self._planeSizeY + b.X
|
|
331
|
+
local rppx, rppy = px - lsp.X, py - lsp.Y
|
|
332
|
+
local sy = preSizeY + math.sqrt(rppx * rppx + rppy * rppy) + b.Y
|
|
303
333
|
particle._lastScreenPosition = Vector2.new(px, py)
|
|
304
334
|
|
|
305
335
|
if particle.Occlusion then
|
|
@@ -323,9 +353,13 @@ function ParticleEngineClient:_particleRender(
|
|
|
323
353
|
return true
|
|
324
354
|
end
|
|
325
355
|
|
|
326
|
-
function ParticleEngineClient
|
|
327
|
-
|
|
328
|
-
|
|
356
|
+
function ParticleEngineClient._updateScreenInfo(self: ParticleEngineClient, camera: Camera): ()
|
|
357
|
+
local screen = self._screen
|
|
358
|
+
if not screen then
|
|
359
|
+
return
|
|
360
|
+
end
|
|
361
|
+
self._screenSizeX = screen.AbsoluteSize.X
|
|
362
|
+
self._screenSizeY = screen.AbsoluteSize.Y
|
|
329
363
|
self._planeSizeY = 2 * math.tan(camera.FieldOfView * 0.0087266462599716)
|
|
330
364
|
self._planeSizeX = self._planeSizeY * self._screenSizeX / self._screenSizeY
|
|
331
365
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
--!
|
|
1
|
+
--!strict
|
|
2
2
|
--[=[
|
|
3
3
|
Handles replication on the server side
|
|
4
4
|
|
|
@@ -13,31 +13,53 @@ local Players = game:GetService("Players")
|
|
|
13
13
|
local GetRemoteEvent = require("GetRemoteEvent")
|
|
14
14
|
local ParticleEngineConstants = require("ParticleEngineConstants")
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
type ParticleProperties = {
|
|
17
|
+
Position: Vector3?,
|
|
18
|
+
Velocity: Vector3?,
|
|
19
|
+
Size: Vector2?,
|
|
20
|
+
Bloom: Vector2?,
|
|
21
|
+
Gravity: Vector3?,
|
|
22
|
+
LifeTime: number?,
|
|
23
|
+
Color: Color3?,
|
|
24
|
+
Transparency: number?,
|
|
25
|
+
Global: any?,
|
|
26
|
+
}
|
|
18
27
|
|
|
19
|
-
|
|
28
|
+
local ParticleEngineServer = {
|
|
29
|
+
ServiceName = "ParticleEngineServer",
|
|
30
|
+
_remoteEvent = nil :: RemoteEvent?,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function ParticleEngineServer.Init(self: typeof(ParticleEngineServer))
|
|
20
34
|
assert(not self._remoteEvent, "Already initialized")
|
|
21
35
|
|
|
22
|
-
|
|
36
|
+
local remoteEvent = GetRemoteEvent(ParticleEngineConstants.REMOTE_EVENT_NAME)
|
|
37
|
+
self._remoteEvent = remoteEvent
|
|
23
38
|
|
|
24
|
-
|
|
39
|
+
remoteEvent.OnServerEvent:Connect(function(player, particle)
|
|
25
40
|
self:_replicate(player, particle)
|
|
26
41
|
end)
|
|
27
42
|
end
|
|
28
43
|
|
|
29
|
-
function ParticleEngineServer
|
|
44
|
+
function ParticleEngineServer._replicate(
|
|
45
|
+
self: typeof(ParticleEngineServer),
|
|
46
|
+
player: Player,
|
|
47
|
+
particle: ParticleProperties
|
|
48
|
+
)
|
|
30
49
|
particle.Global = nil
|
|
31
50
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
51
|
+
local remoteEvent = self._remoteEvent
|
|
52
|
+
if remoteEvent then
|
|
53
|
+
for _, otherPlayer in Players:GetPlayers() do
|
|
54
|
+
if otherPlayer ~= player then
|
|
55
|
+
remoteEvent:FireClient(otherPlayer, particle)
|
|
56
|
+
end
|
|
35
57
|
end
|
|
36
58
|
end
|
|
37
59
|
end
|
|
38
60
|
|
|
39
61
|
-- @param p PropertiesTable
|
|
40
|
-
function ParticleEngineServer
|
|
62
|
+
function ParticleEngineServer.ParticleNew(self: typeof(ParticleEngineServer), p: ParticleProperties): ParticleProperties
|
|
41
63
|
assert(self._remoteEvent, "Not initialized")
|
|
42
64
|
|
|
43
65
|
p.Position = p.Position or error("No Position")
|