ezii 0.0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ezii-client/Gemfile +6 -0
- data/ezii-client/Gemfile.lock +32 -0
- data/ezii-client/Procfile +2 -0
- data/ezii-client/README.md +16 -0
- data/ezii-client/chat.txt +1446 -0
- data/ezii-client/config.ru +1 -0
- data/ezii-client/fake.rb +5 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/functions/base_command.rb +26 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/functions/mouse_y_axis_to_3d_z_axis.rb +4 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/functions/record_audio_and_send_to_wit.rb +18 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/functions/rotate_camera_axis_using_mouse_drag.rb +37 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/functions/selection_cube.rb +35 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/gam.rb +388 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/gems.locked +75 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/gems.rb +10 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/lib/drb_server.rb +13 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/lib/mittsu_monkeypatches/box_geometry.rb +5 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/runnable.rb +20 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/shapes/cube.rb +29 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/sig/runable.rbi +9 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/test.sh +5 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/test/commands/test_move_cube.rb +18 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/test/commands/test_selection_cube.rb +31 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/test/test_command_remapping.rb +30 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/test/test_helper.rb +75 -0
- data/ezii-client/managables/services/chat-bot-integrations/chat.txt +15 -0
- data/ezii-client/managables/services/chat-bot-integrations/gems.locked +66 -0
- data/ezii-client/managables/services/chat-bot-integrations/gems.rb +18 -0
- data/ezii-client/managables/services/chat-bot-integrations/gitter_zircon.rb +644 -0
- data/ezii-client/managables/services/chat-bot-integrations/regexes.rb +240 -0
- data/ezii-client/managables/services/chat-bot-integrations/setup-mac-os-x.sh +0 -0
- data/ezii-client/managables/services/chat-bot-integrations/setup.sh +1 -0
- data/ezii-client/managables/services/chat-bot-integrations/start.sh +3 -0
- data/ezii-client/managables/services/error-inspect/simplest-log +1 -0
- data/ezii-client/managables/services/error-inspect/simplest-log-init +1 -0
- data/ezii-client/managables/services/livestream-interactive/Twitch.Tv/ascii_nebuchadnezzar +9 -0
- data/ezii-client/managables/services/livestream-interactive/Twitch.Tv/chat.txt +1 -0
- data/ezii-client/managables/services/livestream-interactive/Twitch.Tv/twitch_zircon.rb +61 -0
- data/ezii-client/managables/services/livestream-interactive/Twitch.Tv/zion_fleet.rb +198 -0
- data/ezii-client/managables/services/livestream-interactive/chat.txt +40 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/README.md +3 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/__main__.js +58 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/black-out-random-word.js +74 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/random-sentence.js +57 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/random-wikipedia-page.js +25 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/random-words.js +34 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/rare-enough-word.js +41 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/wikipedia-page.js +35 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/package.json +20 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/statistics/count-word.js +12 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/utils/log-to-natural-database.js +10 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/word2vec-models/test-text8-vector.bin +0 -0
- data/ezii-client/managament_interface/gems.locked +13 -0
- data/ezii-client/managament_interface/gems.rb +3 -0
- data/ezii-client/managament_interface/management_interface +4 -0
- data/ezii-client/managament_interface/runnable.rb +30 -0
- data/ezii-client/rocknrolla +1 -0
- data/ezii-client/start.sh +2 -0
- data/ezii-client/test.wav +0 -0
- data/ezii-misc/detect-intent-from-git-patch.rb +46 -0
- data/ezii-server/Gemfile +23 -0
- data/ezii-server/Gemfile.lock +84 -0
- data/ezii-server/README.md +13 -0
- data/ezii-server/config.ru +2 -0
- data/ezii-server/eezee.rb +1243 -0
- data/ezii-server/httpsprojecteulernetproblem=155.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=205.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=228.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=262.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=3.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=333.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=334.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=337.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=426.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=442.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=449.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=497.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=51.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=514.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=520.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=571.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=587.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=588.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=599.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=72.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=93.png +0 -0
- data/ezii-server/regexes +258 -0
- data/ezii-server/sample.wav +0 -0
- data/ezii.gemspec +13 -0
- metadata +132 -0
@@ -0,0 +1 @@
|
|
1
|
+
load('./managables/services/livestream-interactive/Twitch.Tv/twitch_zircon.rb')
|
data/ezii-client/fake.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
class BaseCommand
|
3
|
+
def initialize(gam_main_instance)
|
4
|
+
@active = true
|
5
|
+
@gam_main_instance = gam_main_instance
|
6
|
+
|
7
|
+
run()
|
8
|
+
end
|
9
|
+
|
10
|
+
def active?
|
11
|
+
@active
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
end
|
16
|
+
|
17
|
+
def finish
|
18
|
+
@active = false
|
19
|
+
end
|
20
|
+
|
21
|
+
def mouse_down(vector)
|
22
|
+
end
|
23
|
+
|
24
|
+
def mouse_up(vector)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require_relative './base_command.rb'
|
4
|
+
|
5
|
+
class RecordAudioAndSendToWitAi < BaseCommand
|
6
|
+
def run
|
7
|
+
`sox -d --norm -t .wav - silence -l 1 0 1% 1 6.0 1% rate 16k > #{(t = Tempfile.new).path}`
|
8
|
+
|
9
|
+
`curl -XPOST 'https://api.wit.ai/speech?v=20170307' \
|
10
|
+
-i -L \
|
11
|
+
-H "Authorization: Bearer $TOKEN" \
|
12
|
+
-H "Content-Type: audio/wav" \
|
13
|
+
--data-binary "@#{t.path}"`
|
14
|
+
|
15
|
+
self.finish
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
class RotateCameraAxisUsingMouseDrag
|
3
|
+
def initialize(gam_main_instance)
|
4
|
+
@active = true
|
5
|
+
@gam_main_instance = gam_main_instance
|
6
|
+
end
|
7
|
+
|
8
|
+
def active?
|
9
|
+
@active
|
10
|
+
end
|
11
|
+
|
12
|
+
def finish
|
13
|
+
@active = false
|
14
|
+
end
|
15
|
+
|
16
|
+
def mouse_down(vector)
|
17
|
+
@mouse_down = true
|
18
|
+
end
|
19
|
+
|
20
|
+
def mouse_move(vector)
|
21
|
+
unless @last_point.nil?
|
22
|
+
difference_vector = @last_point.sub(vector)
|
23
|
+
|
24
|
+
@gam_main_instance.camera.rotation.x += difference_vector.x
|
25
|
+
@gam_main_instance.camera.rotation.y += difference_vector.y
|
26
|
+
end
|
27
|
+
|
28
|
+
if @mouse_down
|
29
|
+
@last_point = vector
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def mouse_up(vector)
|
34
|
+
@mouse_down = false
|
35
|
+
finish
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative '../shapes/cube'
|
2
|
+
|
3
|
+
class SelectionCube
|
4
|
+
def initialize(gam_main_instance)
|
5
|
+
@active = true
|
6
|
+
@gam_main_instance = gam_main_instance
|
7
|
+
end
|
8
|
+
|
9
|
+
def active?
|
10
|
+
@active
|
11
|
+
end
|
12
|
+
|
13
|
+
def finish
|
14
|
+
@active = false
|
15
|
+
|
16
|
+
difference_vector = @second_point.sub(@first_point)
|
17
|
+
|
18
|
+
z_size = 2 # unsure how to tackle z size for now, so i'll set it to a default 2 until i found a better solution, then it would be `difference_vector.z.abs`
|
19
|
+
size_vector = Mittsu::Vector3.new(difference_vector.x.abs, difference_vector.y.abs, z_size)
|
20
|
+
|
21
|
+
|
22
|
+
@selection_cube = Cube.new(size_vector: size_vector)
|
23
|
+
@selection_cube.position = @first_point
|
24
|
+
@gam_main_instance.scene.add(@selection_cube.mittsu_object)
|
25
|
+
end
|
26
|
+
|
27
|
+
def mouse_down(vector)
|
28
|
+
@first_point = vector
|
29
|
+
end
|
30
|
+
|
31
|
+
def mouse_up(vector)
|
32
|
+
@second_point = vector
|
33
|
+
self.finish
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,388 @@
|
|
1
|
+
require 'mittsu'
|
2
|
+
require_relative 'shapes/cube.rb'
|
3
|
+
require 'pry-remote'
|
4
|
+
require 'ast'
|
5
|
+
require 'byebug'
|
6
|
+
require 'wit'
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
# Monkey patching Object like it's the golden old days
|
13
|
+
|
14
|
+
class Object
|
15
|
+
def recursive_find(method_name, &find_condition_block)
|
16
|
+
if find_condition_block.call(self)
|
17
|
+
return self
|
18
|
+
end
|
19
|
+
|
20
|
+
if self.respond_to?(method_name)
|
21
|
+
enumerable = self.public_send(method_name)
|
22
|
+
elsif self.respond_to?(:each)
|
23
|
+
enumerable = self.each
|
24
|
+
else
|
25
|
+
return nil
|
26
|
+
end
|
27
|
+
|
28
|
+
enumerable.each do |item|
|
29
|
+
result = item.recursive_find(method_name, &find_condition_block)
|
30
|
+
|
31
|
+
if not result.nil?
|
32
|
+
return result
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
return nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class PlayedCommands
|
41
|
+
def initialize
|
42
|
+
@played_commands = []
|
43
|
+
end
|
44
|
+
|
45
|
+
def played_commands
|
46
|
+
@played_commands
|
47
|
+
end
|
48
|
+
|
49
|
+
def any?
|
50
|
+
@played_commands.any?
|
51
|
+
end
|
52
|
+
|
53
|
+
def last
|
54
|
+
@played_commands.last
|
55
|
+
end
|
56
|
+
|
57
|
+
def push(command)
|
58
|
+
@played_commands.push(command)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class FunctionWrapper
|
63
|
+
attr_accessor :function_class, :file_path
|
64
|
+
def initialize(file_path)
|
65
|
+
@file_path = file_path
|
66
|
+
@abstract_syntax_tree = RubyVM::AbstractSyntaxTree
|
67
|
+
.parse_file(file_path)
|
68
|
+
|
69
|
+
get_command_class_name
|
70
|
+
end
|
71
|
+
|
72
|
+
def get_command_class_name
|
73
|
+
# if class is deeper than first level, let's invent Enumerable#recursive_find
|
74
|
+
@command_class_node = @abstract_syntax_tree.recursive_find(:children) do |child|
|
75
|
+
child.class == RubyVM::AbstractSyntaxTree::Node && child.type == :CLASS
|
76
|
+
end
|
77
|
+
|
78
|
+
@command_class_name = @command_class_node
|
79
|
+
.children
|
80
|
+
.first
|
81
|
+
.pretty_print_inspect
|
82
|
+
.match(/:(\w+)\)\Z/)[1]
|
83
|
+
end
|
84
|
+
|
85
|
+
def new_command_instance(gam_main_instance)
|
86
|
+
load(@file_path)
|
87
|
+
|
88
|
+
# SEC-TODO: fix eval, especially when considering downloadable functions
|
89
|
+
command_instance = eval(@command_class_name).new(gam_main_instance)
|
90
|
+
|
91
|
+
return command_instance
|
92
|
+
end
|
93
|
+
|
94
|
+
def command_class_name
|
95
|
+
@command_class_name
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
class Gam
|
100
|
+
SELECTED_CUBE_COLOR = 0xf4e842
|
101
|
+
|
102
|
+
# TODO: cubes array needds to be eliminated
|
103
|
+
CUBES = []
|
104
|
+
attr_accessor :functions, :key_map, :scene, :camera
|
105
|
+
|
106
|
+
def cubes
|
107
|
+
CUBES
|
108
|
+
end
|
109
|
+
|
110
|
+
def initialize
|
111
|
+
self.functions = []
|
112
|
+
self.key_map = {}
|
113
|
+
@played_commands = PlayedCommands.new
|
114
|
+
load_local_functions
|
115
|
+
|
116
|
+
legacy_initialize
|
117
|
+
end
|
118
|
+
|
119
|
+
def played_commands
|
120
|
+
@played_commands
|
121
|
+
end
|
122
|
+
|
123
|
+
def execute_command(command_wrapper)
|
124
|
+
played_commands.push(command_wrapper.new_command_instance(self))
|
125
|
+
end
|
126
|
+
|
127
|
+
def active_command(&block)
|
128
|
+
if played_commands.any? && played_commands.last.active?
|
129
|
+
block.call(played_commands.last)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def legacy_initialize
|
134
|
+
@cube_index = 0
|
135
|
+
|
136
|
+
@screen_width = 800
|
137
|
+
@screen_height = 600
|
138
|
+
aspect = @screen_width.to_f / @screen_height
|
139
|
+
|
140
|
+
@renderer = Mittsu::OpenGLRenderer.new(
|
141
|
+
width: @screen_width,
|
142
|
+
height: @screen_height,
|
143
|
+
title: 'TOOLX'
|
144
|
+
)
|
145
|
+
|
146
|
+
@scene = Mittsu::Scene.new
|
147
|
+
|
148
|
+
@camera = Mittsu::PerspectiveCamera.new(75.0, aspect, 0.1, 1000.0)
|
149
|
+
@camera.position.z = 5.0
|
150
|
+
|
151
|
+
plane = Mittsu::Mesh.new(
|
152
|
+
Mittsu::BoxGeometry.new(1.0, 10.0, 10.0),
|
153
|
+
Mittsu::MeshBasicMaterial.new(color: 0x00ff00)
|
154
|
+
)
|
155
|
+
|
156
|
+
@scene.add(plane)
|
157
|
+
|
158
|
+
waiting_for_w_console_command = false
|
159
|
+
|
160
|
+
console_function = -> {
|
161
|
+
unless waiting_for_w_console_command
|
162
|
+
waiting_for_w_console_command = true
|
163
|
+
puts 'Enter ruby code that will be evaluated in the current session:'
|
164
|
+
|
165
|
+
user_input = gets
|
166
|
+
puts "Running code u entered #{user_input}"
|
167
|
+
eval(user_input)
|
168
|
+
waiting_for_w_console_command = false
|
169
|
+
end
|
170
|
+
}
|
171
|
+
|
172
|
+
previously_selected_cube_color = nil
|
173
|
+
@renderer.window.on_key_typed do |key|
|
174
|
+
case key
|
175
|
+
when GLFW_KEY_A
|
176
|
+
plane.rotation.x += 0.5
|
177
|
+
when GLFW_KEY_B
|
178
|
+
plane.rotation.y += 0.5
|
179
|
+
when GLFW_KEY_C
|
180
|
+
plane.rotation.x -= 0.5
|
181
|
+
when GLFW_KEY_D
|
182
|
+
plane.rotation.y -= 0.1
|
183
|
+
when GLFW_KEY_E
|
184
|
+
@camera.position.x -= 0.1
|
185
|
+
when GLFW_KEY_F
|
186
|
+
@camera.position.y -= 0.1
|
187
|
+
when GLFW_KEY_G
|
188
|
+
@camera.position.z -= 0.1
|
189
|
+
when GLFW_KEY_H
|
190
|
+
@camera.position.x += 0.1
|
191
|
+
when GLFW_KEY_I
|
192
|
+
@camera.position.y += 0.1
|
193
|
+
when GLFW_KEY_J
|
194
|
+
@camera.position.z += 0.1
|
195
|
+
when GLFW_KEY_K
|
196
|
+
@scene.add(Cube.new(color: 0x42e5f4).mittsu_object)
|
197
|
+
when GLFW_KEY_L
|
198
|
+
@scene.add(Cube.new(color: 0xf44941).mittsu_object)
|
199
|
+
when GLFW_KEY_M
|
200
|
+
@scene.add(Cube.new(color: 0xf441dc).mittsu_object)
|
201
|
+
when GLFW_KEY_N
|
202
|
+
CUBES[@cube_index].position.x += 0.1
|
203
|
+
when GLFW_KEY_O
|
204
|
+
CUBES[@cube_index].position.x -= 0.1
|
205
|
+
when GLFW_KEY_P
|
206
|
+
CUBES[@cube_index].position.y += 0.1
|
207
|
+
when GLFW_KEY_R
|
208
|
+
CUBES[@cube_index].position.y -= 0.1
|
209
|
+
when GLFW_KEY_S
|
210
|
+
CUBES[@cube_index].material.color.set_hex(previously_selected_cube_color) if previously_selected_cube_color != nil
|
211
|
+
@cube_index += 1
|
212
|
+
if @cube_index == CUBES.length
|
213
|
+
@cube_index = 0
|
214
|
+
end
|
215
|
+
previously_selected_cube_color = CUBES[@cube_index].material.color.hex
|
216
|
+
CUBES[@cube_index].material.color.set_hex(SELECTED_CUBE_COLOR)
|
217
|
+
when GLFW_KEY_T
|
218
|
+
CUBES[@cube_index].material.color.set_hex(previously_selected_cube_color) if previously_selected_cube_color != nil
|
219
|
+
@cube_index -= 1
|
220
|
+
if @cube_index == -1
|
221
|
+
@cube_index = [CUBES.length - 1, 0].min
|
222
|
+
end
|
223
|
+
previously_selected_cube_color = CUBES[@cube_index].material.color.hex
|
224
|
+
CUBES[@cube_index].material.color.set_hex(SELECTED_CUBE_COLOR)
|
225
|
+
when GLFW_KEY_U
|
226
|
+
@scene.remove(plane)
|
227
|
+
when GLFW_KEY_V
|
228
|
+
@scene.add(plane)
|
229
|
+
when GLFW_KEY_W
|
230
|
+
byebug
|
231
|
+
# instance_exec(&console_function)
|
232
|
+
when GLFW_KEY_X
|
233
|
+
print_local_functions
|
234
|
+
when GLFW_KEY_Y
|
235
|
+
remap_functions
|
236
|
+
when GLFW_KEY_Z
|
237
|
+
# binding.remote_pry
|
238
|
+
|
239
|
+
self.execute_command(self.key_map['z'])
|
240
|
+
# print_remote_functions
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
@renderer.window.on_resize do |width, height|
|
245
|
+
on_resize(width, height)
|
246
|
+
end
|
247
|
+
|
248
|
+
raycaster = Mittsu::Raycaster.new
|
249
|
+
|
250
|
+
object_being_moved_by_mouse = nil
|
251
|
+
|
252
|
+
previously_selected_cube_color_1 = nil
|
253
|
+
@renderer.window.on_mouse_button_pressed do |button, position|
|
254
|
+
click_to_world_var = mouse_position_to_3d_position(position)
|
255
|
+
|
256
|
+
active_command do |command|
|
257
|
+
command.mouse_down(click_to_world_var)
|
258
|
+
end
|
259
|
+
|
260
|
+
normalized = normalize_2d_screen_position(position)
|
261
|
+
raycaster.set_from_camera(normalized, @camera)
|
262
|
+
object_being_moved_by_mouse = raycaster
|
263
|
+
.intersect_objects(CUBES)
|
264
|
+
.map \
|
265
|
+
do |intersected_object_and_meta_information|
|
266
|
+
intersected_object_and_meta_information[:object]
|
267
|
+
end
|
268
|
+
.first
|
269
|
+
|
270
|
+
if object_being_moved_by_mouse
|
271
|
+
previously_selected_cube_color_1 = object_being_moved_by_mouse.material.color
|
272
|
+
object_being_moved_by_mouse.material.color = SELECTED_CUBE_COLOR
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
|
277
|
+
@renderer.window.on_mouse_move do |position|
|
278
|
+
click_to_world_var = mouse_position_to_3d_position(position)
|
279
|
+
|
280
|
+
active_command do |command|
|
281
|
+
command.mouse_move(click_to_world_var)
|
282
|
+
end
|
283
|
+
|
284
|
+
unless object_being_moved_by_mouse.nil?
|
285
|
+
object_being_moved_by_mouse.position.x = click_to_world_var.x
|
286
|
+
object_being_moved_by_mouse.position.y = click_to_world_var.y
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
@renderer.window.on_mouse_button_released do |_button, position|
|
291
|
+
click_to_world_var = mouse_position_to_3d_position(position)
|
292
|
+
|
293
|
+
active_command do |command|
|
294
|
+
command.mouse_up(click_to_world_var)
|
295
|
+
end
|
296
|
+
|
297
|
+
unless object_being_moved_by_mouse.nil?
|
298
|
+
object_been_moved_by_mouse = object_being_moved_by_mouse
|
299
|
+
object_being_moved_by_mouse = nil
|
300
|
+
|
301
|
+
|
302
|
+
object_been_moved_by_mouse.position.x = click_to_world_var.x
|
303
|
+
object_been_moved_by_mouse.position.y = click_to_world_var.y
|
304
|
+
|
305
|
+
object_been_moved_by_mouse.material.color = previously_selected_cube_color_1
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
@renderer.window.on_scroll do |offset|
|
310
|
+
@camera.position.z += offset.y
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
def on_resize(width, height)
|
315
|
+
@screen_width = width
|
316
|
+
@screen_height = height
|
317
|
+
|
318
|
+
@renderer.width = width
|
319
|
+
@renderer.height = height
|
320
|
+
|
321
|
+
@camera.aspect = width.to_f / height
|
322
|
+
@camera.update_projection_matrix
|
323
|
+
end
|
324
|
+
|
325
|
+
def print_local_functions
|
326
|
+
p self.functions
|
327
|
+
end
|
328
|
+
|
329
|
+
def load_local_functions
|
330
|
+
Dir[File.dirname(__FILE__) + '/functions/*.rb'].each do |file_path|
|
331
|
+
functions.push(FunctionWrapper.new(file_path))
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
def normalize_2d_screen_position(position)
|
336
|
+
new_position = Mittsu::Vector2.new
|
337
|
+
new_position.x = (((position.x * 2)/@screen_width)*2.0-1.0)
|
338
|
+
new_position.y = (((position.y * 2)/@screen_height)*-2.0+1.0)
|
339
|
+
new_position
|
340
|
+
end
|
341
|
+
|
342
|
+
def screen_to_world(vector, camera)
|
343
|
+
vector.unproject(camera).sub(camera.position).normalize
|
344
|
+
distance = -camera.position.z / vector.z
|
345
|
+
vector.multiply_scalar(distance).add(camera.position)
|
346
|
+
end
|
347
|
+
|
348
|
+
def mouse_position_to_3d_position(position)
|
349
|
+
normalized = normalize_2d_screen_position(position)
|
350
|
+
normalized_3d = Mittsu::Vector3.new(
|
351
|
+
normalized.x,
|
352
|
+
normalized.y,
|
353
|
+
0 # object_been_moved_by_mouse.position.z
|
354
|
+
)
|
355
|
+
|
356
|
+
screen_to_world(normalized_3d, @camera)
|
357
|
+
end
|
358
|
+
|
359
|
+
def remap_functions
|
360
|
+
print_local_functions
|
361
|
+
|
362
|
+
p 'Enter index of unmapped function:'
|
363
|
+
index_of_unmapped_function = gets.to_i
|
364
|
+
|
365
|
+
p 'Enter key to map function to:'
|
366
|
+
keyboard_key = gets
|
367
|
+
|
368
|
+
keyboard_key.chomp!
|
369
|
+
|
370
|
+
key_map[keyboard_key] = functions[index_of_unmapped_function]
|
371
|
+
end
|
372
|
+
|
373
|
+
def start
|
374
|
+
@renderer.window.run do
|
375
|
+
@renderer.render(@scene, @camera)
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
def move_cube(which_one = :any, a, b, c)
|
380
|
+
case which_one
|
381
|
+
when :any
|
382
|
+
cube = CUBES.sample
|
383
|
+
cube.position.x = a
|
384
|
+
cube.position.y = b
|
385
|
+
cube.position.z = c
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|