|
@@ -1,16 +1,5 @@
|
|
-local ZOOM_SPEED = 0.2
|
|
|
|
-local ROTATION_SPEED = 0.5
|
|
|
|
-
|
|
|
|
function init(self)
|
|
function init(self)
|
|
- msg.post("@render:", "use_camera_projection")
|
|
|
|
- msg.post(".", "acquire_input_focus")
|
|
|
|
-
|
|
|
|
- self.yaw = go.get(".", "euler.y") -- for camera rotation
|
|
|
|
- self.pitch = go.get(".", "euler.x") -- for camera rotation
|
|
|
|
- self.offset = go.get_position()
|
|
|
|
- self.zoom = 3 -- default zoom
|
|
|
|
- self.zoom_offset = 0 -- modification from default zoom
|
|
|
|
- self.time = 0 -- for pattern animation
|
|
|
|
|
|
+ self.time = 0 -- for pattern animation
|
|
|
|
|
|
-- The model with the pattern - we enabled the effect, 0.5 is the intensity (alpha)
|
|
-- The model with the pattern - we enabled the effect, 0.5 is the intensity (alpha)
|
|
go.set("/crate_selected#model", "pattern_opts.x", 0.5)
|
|
go.set("/crate_selected#model", "pattern_opts.x", 0.5)
|
|
@@ -22,14 +11,6 @@ function init(self)
|
|
end
|
|
end
|
|
|
|
|
|
function update(self, dt)
|
|
function update(self, dt)
|
|
- -- Camera controls
|
|
|
|
- local camera_yaw = vmath.quat_rotation_y(math.rad(self.yaw))
|
|
|
|
- local camera_pitch = vmath.quat_rotation_x(math.rad(self.pitch))
|
|
|
|
- local camera_rot = camera_yaw * camera_pitch
|
|
|
|
- local camera_position = self.offset + vmath.rotate(camera_rot, vmath.vector3(0, 0, self.zoom + self.zoom_offset))
|
|
|
|
- go.set_position(camera_position)
|
|
|
|
- go.set_rotation(camera_rot)
|
|
|
|
-
|
|
|
|
-- Animate the pattern by changing the z value
|
|
-- Animate the pattern by changing the z value
|
|
self.time = self.time - dt
|
|
self.time = self.time - dt
|
|
go.set("/crate_selected#model", "pattern_opts.z", self.time)
|
|
go.set("/crate_selected#model", "pattern_opts.z", self.time)
|
|
@@ -39,14 +20,3 @@ function update(self, dt)
|
|
local w, h = window.get_size()
|
|
local w, h = window.get_size()
|
|
go.set("/crate_selected#model", "screen_size", vmath.vector4(w, h, 0, 0))
|
|
go.set("/crate_selected#model", "screen_size", vmath.vector4(w, h, 0, 0))
|
|
end
|
|
end
|
|
-
|
|
|
|
-function on_input(self, action_id, action)
|
|
|
|
- if action_id == hash("touch") then
|
|
|
|
- self.yaw = self.yaw - action.dx * ROTATION_SPEED
|
|
|
|
- self.pitch = self.pitch + action.dy * ROTATION_SPEED
|
|
|
|
- elseif action_id == hash("wheel_up") then
|
|
|
|
- self.zoom_offset = self.zoom_offset - ZOOM_SPEED
|
|
|
|
- elseif action_id == hash("wheel_down") then
|
|
|
|
- self.zoom_offset = self.zoom_offset + ZOOM_SPEED
|
|
|
|
- end
|
|
|
|
-end
|
|
|