From b882471c1d11ef74f06dcb741b8a4db100ee08df Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 2 Nov 2024 09:09:37 +0100 Subject: [PATCH] feat: add 3D world and drawShadow definition --- framework/scenes/world/init.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/framework/scenes/world/init.lua b/framework/scenes/world/init.lua index 6a990cd..ec36d6d 100644 --- a/framework/scenes/world/init.lua +++ b/framework/scenes/world/init.lua @@ -59,6 +59,8 @@ function World:new(datas) self.shapes = Bump.newWorld(50) self.camera = Camera(self, self.def.camera) + self.type = self.def.type or "2D" + self.drawShadow = (self.def.drawShadow == true) World.super.new(self) @@ -125,6 +127,11 @@ function World:_load() print("loading objects...") self.map:loadObjects() 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() end @@ -283,6 +290,11 @@ function World:checkCollisionAtPoint(body, position, filter) return Vector3D(x, y, z or 0), cols, collNumber end + +function World:getBodiesInCube(x, y, z, w, h, d) + return self.bodies:queryCube(x, y, z, w, h, d) + end + -- Shape handling -- Handle shapes, which make know what object is visible or not