From 13d29e18cbdd3a3cef42e9a737aef29506aafb1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jhonny=20Go=CC=88ransson?= Date: Sun, 30 Apr 2023 01:01:47 +0200 Subject: [PATCH] Orbital camera moves on scroll instead --- vantage/vantage.input_binding | 8 ++++++++ vantage/vantage_core.lua | 28 ++++++++++++++++------------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/vantage/vantage.input_binding b/vantage/vantage.input_binding index b789f71..1feaa8f 100644 --- a/vantage/vantage.input_binding +++ b/vantage/vantage.input_binding @@ -34,3 +34,11 @@ mouse_trigger { input: MOUSE_BUTTON_3 action: "VANTAGE_MOUSE_3" } +mouse_trigger { + input: MOUSE_WHEEL_UP + action: "VANTAGE_WHEEL_UP" +} +mouse_trigger { + input: MOUSE_WHEEL_DOWN + action: "VANTAGE_WHEEL_DOWN" +} diff --git a/vantage/vantage_core.lua b/vantage/vantage_core.lua index 65ae6d4..8d8a5ed 100644 --- a/vantage/vantage_core.lua +++ b/vantage/vantage_core.lua @@ -1,14 +1,16 @@ local M = {} -M.VANTAGE_W = hash("VANTAGE_W") -M.VANTAGE_S = hash("VANTAGE_S") -M.VANTAGE_A = hash("VANTAGE_A") -M.VANTAGE_D = hash("VANTAGE_D") -M.VANTAGE_Q = hash("VANTAGE_Q") -M.VANTAGE_E = hash("VANTAGE_E") -M.VANTAGE_MOUSE_1 = hash("VANTAGE_MOUSE_1") -M.VANTAGE_MOUSE_2 = hash("VANTAGE_MOUSE_2") -M.VANTAGE_MOUSE_3 = hash("VANTAGE_MOUSE_3") +M.VANTAGE_W = hash("VANTAGE_W") +M.VANTAGE_S = hash("VANTAGE_S") +M.VANTAGE_A = hash("VANTAGE_A") +M.VANTAGE_D = hash("VANTAGE_D") +M.VANTAGE_Q = hash("VANTAGE_Q") +M.VANTAGE_E = hash("VANTAGE_E") +M.VANTAGE_MOUSE_1 = hash("VANTAGE_MOUSE_1") +M.VANTAGE_MOUSE_2 = hash("VANTAGE_MOUSE_2") +M.VANTAGE_MOUSE_3 = hash("VANTAGE_MOUSE_3") +M.VANTAGE_WHEEL_UP = hash("VANTAGE_WHEEL_UP") +M.VANTAGE_WHEEL_DOWN = hash("VANTAGE_WHEEL_DOWN") M.VANTAGE_TYPE_WASD = 0 M.VANTAGE_TYPE_ORBITAL = 1 @@ -98,11 +100,13 @@ M.orbital = { go.set_position(camera_position, main_camera) go.set_rotation(camera_rot, self.id) end, - on_input = function(self, action_id, action) + on_input = function(self, action_id, action) if action_id == hash(M.VANTAGE_MOUSE_1) then rotate(self, action.dx, action.dy) - elseif action_id == hash(M.VANTAGE_MOUSE_2) then - self.zoom_offset = self.zoom_offset + action.dy * self.movement_speed + elseif action_id == hash(M.VANTAGE_WHEEL_UP) then + self.zoom_offset = self.zoom_offset - self.movement_speed + elseif action_id == hash(M.VANTAGE_WHEEL_DOWN) then + self.zoom_offset = self.zoom_offset + self.movement_speed end end }