feat: add 3D world and drawShadow definition

This commit is contained in:
Kazhnuz 2024-11-02 09:09:37 +01:00
parent 2083374adc
commit b882471c1d

View file

@ -59,6 +59,8 @@ function World:new(datas)
self.shapes = Bump.newWorld(50) self.shapes = Bump.newWorld(50)
self.camera = Camera(self, self.def.camera) self.camera = Camera(self, self.def.camera)
self.type = self.def.type or "2D"
self.drawShadow = (self.def.drawShadow == true)
World.super.new(self) World.super.new(self)
@ -125,6 +127,11 @@ function World:_load()
print("loading objects...") print("loading objects...")
self.map:loadObjects() self.map:loadObjects()
end end
if (self.def.createCollisions ~= nil) then
for _, collision in ipairs(self.def.createCollisions) do
self:newCollision(collision.type, collision.position.x, collision.position.y, collision.position.z or 0, collision.dimensions.w, collision.dimensions.h, collision.dimensions.d or 1)
end
end
self:onLoad() self:onLoad()
end end
@ -283,6 +290,11 @@ function World:checkCollisionAtPoint(body, position, filter)
return Vector3D(x, y, z or 0), cols, collNumber return Vector3D(x, y, z or 0), cols, collNumber
end end
function World:getBodiesInCube(x, y, z, w, h, d)
return self.bodies:queryCube(x, y, z, w, h, d)
end
-- Shape handling -- Shape handling
-- Handle shapes, which make know what object is visible or not -- Handle shapes, which make know what object is visible or not