This commit is contained in:
2025-03-02 23:44:58 +03:00
parent 342c98e915
commit e3f195cf71
2 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,38 @@
local Vector3 = require "types.vector3"
---@class AABB
local AABB = {
min = Vector3(),
max = Vector3(),
}
setmetatable(AABB, AABB)
AABB.__index = AABB
---@param min vectorlike
---@param max vectorlike
---@return AABB
function AABB.new(min, max)
min = min or Vector3()
max = max or Vector3()
local aabb = {
min = min,
max = max,
}
return setmetatable(aabb, AABB)
end
function AABB:draw()
-- bottom rectangle
draw_line_3d{start = self.min, finish = Vector3(self.max.x, self.min.y, self.min.z)}
draw_line_3d{start = self.min, finish = Vector3(self.min.x, self.min.y, self.max.z)}
draw_line_3d{start = Vector3(self.max.x, self.min.y, self.max.z), finish = Vector3(self.min.x, self.min.y, self.max.z)}
-- draw_line_3d{start = self.min, finish = Vector3(self.max.x, self.min.y, self.min.z)}
-- draw_line_3d{start = self.min, finish = Vector3(self.min.x, self.max.y, self.min.z)}
-- draw_line_3d{start = self.min, finish = Vector3(self.min.x, self.min.y, self.max.z)}
end
return AABB