@quenty/draw 7.8.1 → 7.8.2

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 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
+ ## [7.8.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/draw@7.8.1...@quenty/draw@7.8.2) (2025-04-05)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [7.8.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/draw@7.8.0...@quenty/draw@7.8.1) (2025-03-21)
7
18
 
8
19
  **Note:** Version bump only for package @quenty/draw
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/draw",
3
- "version": "7.8.1",
3
+ "version": "7.8.2",
4
4
  "description": "A utility library to debug things in 3D space for Roblox.",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -29,8 +29,8 @@
29
29
  "access": "public"
30
30
  },
31
31
  "dependencies": {
32
- "@quenty/loader": "^10.8.0",
33
- "@quenty/maid": "^3.4.0"
32
+ "@quenty/loader": "^10.8.1",
33
+ "@quenty/maid": "^3.4.1"
34
34
  },
35
- "gitHead": "6b7c3e15e60cdb185986207b574e2b5591261e7a"
35
+ "gitHead": "78c3ac0ab08dd18085b6e6e6e4f745e76ed99f68"
36
36
  }
@@ -1,3 +1,4 @@
1
+ --!strict
1
2
  --[=[
2
3
  Debug drawing library useful for debugging 3D abstractions. One of
3
4
  the more useful utility libraries.
@@ -141,7 +142,7 @@ function Draw.spherecast(
141
142
  folder.Archivable = false
142
143
 
143
144
  Draw.ray(Ray.new(castOrigin, castDirection), color, folder, 2 * radius)
144
- Draw.sphere(castOrigin + direction, radius, castColor, folder)
145
+ Draw.sphere(castOrigin + castDirection, radius, castColor, folder)
145
146
 
146
147
  folder.Parent = parent
147
148
 
@@ -184,6 +185,12 @@ function Draw.blockcast(
184
185
  return folder
185
186
  end
186
187
 
188
+ type Edge = {
189
+ longest: Vector3,
190
+ other: Vector3,
191
+ origin: Vector3,
192
+ }
193
+
187
194
  --[=[
188
195
  Draws a triangle between 3 points
189
196
 
@@ -204,10 +211,10 @@ function Draw.triangle(
204
211
  local a = assert(Draw._toVector3(pointA), "Bad a")
205
212
  local b = assert(Draw._toVector3(pointB), "Bad b")
206
213
  local c = assert(Draw._toVector3(pointC), "Bad c")
207
- color = Draw._toColor3(color) or Draw._defaultColor
214
+ local triangleColor = Draw._toColor3(color) or Draw._defaultColor
208
215
  parent = parent or Draw.getDefaultParent()
209
216
 
210
- local edges = {
217
+ local edges: { Edge } = {
211
218
  { longest = (c - a), other = (b - a), origin = a },
212
219
  { longest = (a - b), other = (c - b), origin = b },
213
220
  { longest = (b - c), other = (a - c), origin = c },
@@ -215,26 +222,26 @@ function Draw.triangle(
215
222
 
216
223
  local edge = edges[1]
217
224
  for i = 2, #edges do
218
- if edges[i].longest.magnitude > edge.longest.magnitude then
225
+ if edges[i].longest.Magnitude > edge.longest.Magnitude then
219
226
  edge = edges[i]
220
227
  end
221
228
  end
222
229
 
223
- local theta = math.acos(edge.longest.unit:Dot(edge.other.unit))
224
- local w1 = math.cos(theta) * edge.other.magnitude
225
- local w2 = edge.longest.magnitude - w1
226
- local h = math.sin(theta) * edge.other.magnitude
230
+ local theta = math.acos(edge.longest.Unit:Dot(edge.other.Unit))
231
+ local w1 = math.cos(theta) * edge.other.Magnitude
232
+ local w2 = edge.longest.Magnitude - w1
233
+ local h = math.sin(theta) * edge.other.Magnitude
227
234
 
228
235
  local p1 = edge.origin + edge.other * 0.5
229
236
  local p2 = edge.origin + edge.longest + (edge.other - edge.longest) * 0.5
230
237
 
231
- local right = edge.longest:Cross(edge.other).unit
232
- local up = right:Cross(edge.longest).unit
233
- local back = edge.longest.unit
238
+ local right = edge.longest:Cross(edge.other).Unit
239
+ local up = right:Cross(edge.longest).Unit
240
+ local back = edge.longest.Unit
234
241
 
235
- local cf1 = CFrame.new(p1.x, p1.y, p1.z, -right.x, up.x, back.x, -right.y, up.y, back.y, -right.z, up.z, back.z)
242
+ local cf1 = CFrame.new(p1.X, p1.Y, p1.Z, -right.X, up.X, back.X, -right.Y, up.Y, back.Y, -right.Z, up.Z, back.Z)
236
243
 
237
- local cf2 = CFrame.new(p2.x, p2.y, p2.z, right.x, up.x, -back.x, right.y, up.y, -back.y, right.z, up.z, -back.z)
244
+ local cf2 = CFrame.new(p2.X, p2.Y, p2.Z, right.X, up.X, -back.X, right.Y, up.Y, -back.Y, right.Z, up.Z, -back.Z)
238
245
 
239
246
  -- put it all together by creating the wedges
240
247
  local triangle = Instance.new("Folder")
@@ -252,7 +259,7 @@ function Draw.triangle(
252
259
  wedge1.CastShadow = false
253
260
  wedge1.Size = Vector3.new(0.05, h, w1)
254
261
  wedge1.CFrame = cf1
255
- wedge1.Color = color
262
+ wedge1.Color = triangleColor
256
263
 
257
264
  local mesh1 = Instance.new("SpecialMesh")
258
265
  mesh1.MeshType = Enum.MeshType.Wedge
@@ -270,7 +277,7 @@ function Draw.triangle(
270
277
  wedge2.CastShadow = false
271
278
  wedge2.Size = Vector3.new(0.05, h, w2)
272
279
  wedge2.CFrame = cf2
273
- wedge2.Color = color
280
+ wedge2.Color = triangleColor
274
281
 
275
282
  local mesh2 = Instance.new("SpecialMesh")
276
283
  mesh2.MeshType = Enum.MeshType.Wedge
@@ -365,7 +372,7 @@ function Draw.ray(ray: Ray, color: Color3Like?, parent: Instance?, diameter: num
365
372
  local mesh = Instance.new("SpecialMesh")
366
373
  mesh.MeshType = Enum.MeshType.Cylinder
367
374
  mesh.Name = "DrawRayMesh"
368
- mesh.Scale = Vector3.new(distance / partSize.x, rayDiameter / partSize.y, rayDiameter / partSize.z)
375
+ mesh.Scale = Vector3.new(distance / partSize.X, rayDiameter / partSize.Y, rayDiameter / partSize.Z)
369
376
  mesh.Parent = part
370
377
 
371
378
  part.Parent = rayParent
@@ -416,7 +423,7 @@ function Draw.updateRay(rayPart: BasePart, ray: Ray, color: Color3?, diameter: n
416
423
  local partSize = rayPart.Size
417
424
  local mesh = rayPart:FindFirstChildWhichIsA("SpecialMesh")
418
425
  if mesh then
419
- mesh.Scale = Vector3.new(distance / partSize.x, rayDiameter / partSize.y, rayDiameter / partSize.z)
426
+ mesh.Scale = Vector3.new(distance / partSize.X, rayDiameter / partSize.Y, rayDiameter / partSize.Z)
420
427
  end
421
428
  end
422
429
 
@@ -492,11 +499,11 @@ function Draw._textOnAdornee(adornee: Instance, text: string, color: Color3): Bi
492
499
 
493
500
  local textSize = TextService:GetTextSize(textLabel.Text, textLabel.TextSize, textLabel.Font, Vector2.new(1024, 1e6))
494
501
 
495
- local lines = textSize.y / textLabel.TextSize
502
+ local lines = textSize.Y / textLabel.TextSize
496
503
 
497
504
  local paddingOffset = textLabel.TextSize * PADDING_PERCENT_OF_LINE_HEIGHT
498
- local paddedHeight = textSize.y + 2 * paddingOffset
499
- local paddedWidth = textSize.x + 2 * paddingOffset
505
+ local paddedHeight = textSize.Y + 2 * paddingOffset
506
+ local paddedWidth = textSize.X + 2 * paddingOffset
500
507
  local aspectRatio = paddedWidth / paddedHeight
501
508
 
502
509
  local uiAspectRatio = Instance.new("UIAspectRatioConstraint")
@@ -669,8 +676,8 @@ function Draw.part(template: BasePart, cframe: CFrameLike?, color: Color3Like?,
669
676
  local partColor = Draw._toColor3(color) or Draw._defaultColor
670
677
 
671
678
  local part = template:Clone()
672
- for _, child in pairs(part:GetChildren()) do
673
- if child:IsA("Mesh") then
679
+ for _, child in part:GetChildren() do
680
+ if child:IsA("DataModelMesh") then
674
681
  Draw._sanitize(child)
675
682
  child:ClearAllChildren()
676
683
  else
@@ -723,8 +730,8 @@ end
723
730
  @return BasePart
724
731
  ]=]
725
732
  function Draw.box(cframe: CFrameLike, size: Vector3Like, color: Color3Like?): BasePart
726
- cframe = assert(Draw._toCFrame(cframe), "Bad cframe")
727
- size = assert(Draw._toVector3(size), "Bad size")
733
+ local boxCFrame = assert(Draw._toCFrame(cframe), "Bad cframe")
734
+ local boxSize = assert(Draw._toVector3(size), "Bad size")
728
735
  local boxColor = Draw._toColor3(color) or Draw._defaultColor
729
736
 
730
737
  local part = Instance.new("Part")
@@ -740,12 +747,12 @@ function Draw.box(cframe: CFrameLike, size: Vector3Like, color: Color3Like?): Ba
740
747
  part.BottomSurface = Enum.SurfaceType.Smooth
741
748
  part.TopSurface = Enum.SurfaceType.Smooth
742
749
  part.Transparency = 0.75
743
- part.Size = size
744
- part.CFrame = cframe
750
+ part.Size = boxSize
751
+ part.CFrame = boxCFrame
745
752
 
746
753
  local boxHandleAdornment = Instance.new("BoxHandleAdornment")
747
754
  boxHandleAdornment.Adornee = part
748
- boxHandleAdornment.Size = size
755
+ boxHandleAdornment.Size = boxSize
749
756
  boxHandleAdornment.Color3 = boxColor
750
757
  boxHandleAdornment.AlwaysOnTop = true
751
758
  boxHandleAdornment.Transparency = 0.75
@@ -793,7 +800,7 @@ function Draw.terrainCell(position: Vector3Like, color: Color3Like?): BasePart
793
800
  local size = Vector3.new(4, 4, 4)
794
801
 
795
802
  local solidCell = Terrain:WorldToCell(position)
796
- local terrainPosition = Terrain:CellCenterToWorld(solidCell.x, solidCell.y, solidCell.z)
803
+ local terrainPosition = Terrain:CellCenterToWorld(solidCell.X, solidCell.Y, solidCell.Z)
797
804
 
798
805
  local part = Draw.box(CFrame.new(terrainPosition), size, color)
799
806
  part.Name = "DebugTerrainCell"
@@ -812,16 +819,16 @@ function Draw.screenPointLine(a: Vector2, b: Vector2, parent: Instance?, color:
812
819
 
813
820
  local frame = Instance.new("Frame")
814
821
  frame.Name = "DebugScreenLine"
815
- frame.Size = UDim2.fromScale(math.abs(offset.x), math.abs(offset.y))
822
+ frame.Size = UDim2.fromScale(math.abs(offset.X), math.abs(offset.Y))
816
823
 
817
824
  frame.BackgroundTransparency = 1
818
- frame.Position = UDim2.fromScale(pos.x, pos.y)
825
+ frame.Position = UDim2.fromScale(pos.X, pos.Y)
819
826
  frame.AnchorPoint = Vector2.new(0.5, 0.5)
820
827
  frame.BorderSizePixel = 0
821
828
  frame.ZIndex = 10000
822
829
  frame.Parent = parent
823
830
 
824
- local length = offset.magnitude
831
+ local length = offset.Magnitude
825
832
  if length == 0 then
826
833
  return frame
827
834
  end
@@ -829,7 +836,7 @@ function Draw.screenPointLine(a: Vector2, b: Vector2, parent: Instance?, color:
829
836
  local diameter = 3
830
837
  local count = 25
831
838
 
832
- local slope = offset.y / offset.x
839
+ local slope = offset.Y / offset.X
833
840
  if slope > 0 then
834
841
  for i = 0, count do
835
842
  Draw.screenPoint(Vector2.new(i / count, i / count), frame, color, diameter)
@@ -847,12 +854,12 @@ end
847
854
  Draws a screen point
848
855
  ]=]
849
856
  function Draw.screenPoint(position: Vector2, parent: Instance, color: Color3Like?, diameter: number?): Frame
850
- color = Draw._toColor3(color)
857
+ local pointColor = Draw._toColor3(color) or Color3.new(0.658824, 0.501961, 0.501961)
851
858
 
852
859
  local frame = Instance.new("Frame")
853
860
  frame.Name = "DebugScreenPoint"
854
861
  frame.Size = UDim2.new(0, diameter, 0, diameter)
855
- frame.BackgroundColor3 = color or Color3.new(1, 0.1, 0.1)
862
+ frame.BackgroundColor3 = pointColor
856
863
  frame.BackgroundTransparency = 0.5
857
864
  frame.Position = UDim2.fromScale(position.X, position.Y)
858
865
  frame.AnchorPoint = Vector2.new(0.5, 0.5)
@@ -917,11 +924,11 @@ function Draw.ring(position: Vector3Like, normal: Vector3Like, radius: number?,
917
924
 
918
925
  local ringCFrame = CFrame.new(ringPosition, ringPosition + ringNormal)
919
926
 
920
- local points = {}
927
+ local points: { Vector3 } = {}
921
928
  for angle = 0, 2 * math.pi, math.pi / 8 do
922
929
  local x = math.cos(angle) * ringRadius
923
930
  local y = math.sin(angle) * ringRadius
924
- local vector = ringCFrame:pointToWorldSpace(Vector3.new(x, y, 0))
931
+ local vector = ringCFrame:PointToWorldSpace(Vector3.new(x, y, 0))
925
932
  table.insert(points, vector)
926
933
  end
927
934