summaryrefslogtreecommitdiff
path: root/main.lua
diff options
context:
space:
mode:
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua38
1 files changed, 2 insertions, 36 deletions
diff --git a/main.lua b/main.lua
index 1381c64..d35872c 100644
--- a/main.lua
+++ b/main.lua
@@ -29,17 +29,6 @@ systems:addSystem(honey.ecs.render.system)
systems:addSystem(honey.ecs.script.system)
systems:addSystem(honey.ecs.collision.system, {space=space})
systems:addSystem(honey.ecs.physics.system, {space=space, world=world})
-package.loaded['baseRotationScript'] = function(entities, id, dt)
- local node = entities:getComponent(id, "node")
- node.matrix:rotateZ(math.pi * dt)
-end
-package.loaded['cameraRotationScript'] = function(entities, id, dt)
- local node = entities:getComponent(id, "node")
- local z = entities:getComponent(id, "z")
- node.matrix
- :identity()
- :translate(Vec3{0, 0, z.value + math.sin(math.pi * glfw.GetTime())})
-end
function setupEntities()
@@ -164,31 +153,8 @@ function setupEntities()
pitch = 0,
yaw = 0,
},
- onCursorPos = { script = "cameraCursorPos" },
+ onCursorPos = { script = "scripts.cameraPivot" },
}
- package.loaded["cameraCursorPos"] = (function()
- local prevx, prevy
- return function(entities, id, data)
- if not prevx then
- prevx, prevy = data.xpos, data.ypos
- end
- local dx = data.xpos - prevx
- local dy = data.ypos - prevy
- prevx, prevy = data.xpos, data.ypos
-
- local node = entities:getComponent(id, "node")
- local py = entities:getComponent(id, "pitchyaw")
- py.pitch = py.pitch - dy
- py.yaw = py.yaw - dx
- if py.pitch > 89.9 then py.pitch = 89.9 end
- if py.pitch < -89.9 then py.pitch = -89.9 end
-
- node.matrix
- :identity()
- :rotateY(math.rad(py.yaw))
- :rotateX(math.rad(py.pitch))
- end
- end)()
local capcam = entities:createEntityWithComponents{
@@ -200,7 +166,7 @@ function setupEntities()
parent = capcamPivot,
matrix = Mat4():identity():translate(Vec3{0,0,20}),
},
- onWindowResize = { script = "scripts.cameraHandleResize" },
+ onFramebufferSize = { script = "scripts.cameraHandleResize" },
}