mittsu 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build-workflow.yml +71 -0
- data/.gitignore +1 -0
- data/Gemfile +0 -3
- data/LICENSE.txt +1 -1
- data/README.md +6 -8
- data/Rakefile +1 -0
- data/install-glfw.ps1 +13 -0
- data/lib/mittsu/cameras/camera.rb +0 -2
- data/lib/mittsu/cameras/cube_camera.rb +0 -2
- data/lib/mittsu/cameras/orthographic_camera.rb +2 -4
- data/lib/mittsu/cameras/perspective_camera.rb +4 -5
- data/lib/mittsu/core/buffer_attribute.rb +12 -0
- data/lib/mittsu/core/buffer_geometry.rb +3 -3
- data/lib/mittsu/core/geometry.rb +2 -4
- data/lib/mittsu/core/object_3d.rb +9 -7
- data/lib/mittsu/core/raycaster.rb +0 -2
- data/lib/mittsu/extras/geometries/circle_geometry.rb +3 -3
- data/lib/mittsu/extras/geometries/cylinder_geometry.rb +5 -5
- data/lib/mittsu/extras/geometries/dodecahedron_geometry.rb +2 -2
- data/lib/mittsu/extras/geometries/icosahedron_geometry.rb +2 -2
- data/lib/mittsu/extras/geometries/lathe_geometry.rb +3 -3
- data/lib/mittsu/extras/geometries/parametric_geometry.rb +19 -19
- data/lib/mittsu/extras/geometries/polyhedron_geometry.rb +6 -7
- data/lib/mittsu/extras/geometries/ring_geometry.rb +4 -4
- data/lib/mittsu/extras/geometries/sphere_geometry.rb +4 -4
- data/lib/mittsu/extras/geometries/torus_geometry.rb +7 -7
- data/lib/mittsu/extras/geometries/torus_knot_buffer_geometry.rb +9 -9
- data/lib/mittsu/extras/helpers/camera_helper.rb +38 -38
- data/lib/mittsu/extras/image_utils.rb +1 -1
- data/lib/mittsu/lights/directional_light.rb +9 -5
- data/lib/mittsu/lights/spot_light.rb +1 -1
- data/lib/mittsu/loaders/loader.rb +2 -2
- data/lib/mittsu/loaders/obj_loader.rb +4 -0
- data/lib/mittsu/materials/material.rb +6 -3
- data/lib/mittsu/math/box2.rb +0 -2
- data/lib/mittsu/math/box3.rb +0 -2
- data/lib/mittsu/math/color.rb +3 -4
- data/lib/mittsu/math/euler.rb +25 -26
- data/lib/mittsu/math/frustum.rb +0 -2
- data/lib/mittsu/math/line3.rb +0 -2
- data/lib/mittsu/math/matrix3.rb +0 -2
- data/lib/mittsu/math/matrix4.rb +10 -12
- data/lib/mittsu/math/plane.rb +0 -2
- data/lib/mittsu/math/quaternion.rb +18 -20
- data/lib/mittsu/math/ray.rb +1 -3
- data/lib/mittsu/math/sphere.rb +1 -3
- data/lib/mittsu/math/spline.rb +0 -2
- data/lib/mittsu/math/triangle.rb +1 -3
- data/lib/mittsu/math/vector.rb +3 -3
- data/lib/mittsu/math/vector2.rb +0 -1
- data/lib/mittsu/math/vector3.rb +108 -1
- data/lib/mittsu/math/vector4.rb +8 -9
- data/lib/mittsu/math.rb +0 -5
- data/lib/mittsu/objects/line.rb +0 -1
- data/lib/mittsu/renderers/glfw_lib.rb +24 -3
- data/lib/mittsu/renderers/glfw_window.rb +6 -2
- data/lib/mittsu/renderers/opengl/core/object_3d.rb +1 -1
- data/lib/mittsu/renderers/opengl/lights/spot_light.rb +1 -1
- data/lib/mittsu/renderers/opengl/opengl_geometry_group.rb +1 -0
- data/lib/mittsu/renderers/opengl/opengl_program.rb +1 -2
- data/lib/mittsu/renderers/opengl/textures/texture.rb +2 -2
- data/lib/mittsu/renderers/opengl_renderer.rb +9 -14
- data/lib/mittsu/scenes/scene.rb +0 -2
- data/lib/mittsu/textures/texture.rb +4 -2
- data/lib/mittsu/utils.rb +15 -0
- data/lib/mittsu/version.rb +1 -2
- data/lib/mittsu.rb +1 -16
- data/mittsu.gemspec +14 -13
- metadata +60 -47
- data/.circleci/config.yml +0 -87
- data/.circleci/images/primary/Dockerfile +0 -10
- data/appveyor.yml +0 -23
- data/install_glfw.ps1 +0 -11
data/lib/mittsu/math/triangle.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'mittsu/math'
|
2
|
-
|
3
1
|
module Mittsu
|
4
2
|
class Triangle
|
5
3
|
attr_accessor :a, :b, :c
|
@@ -73,7 +71,7 @@ module Mittsu
|
|
73
71
|
|
74
72
|
result_length_sq = target.length_sq
|
75
73
|
if (result_length_sq > 0)
|
76
|
-
target.multiply_scalar(1.0 / Math.sqrt(result_length_sq))
|
74
|
+
target.multiply_scalar(1.0 / ::Math.sqrt(result_length_sq))
|
77
75
|
else
|
78
76
|
target.set(0.0, 0.0, 0.0)
|
79
77
|
end
|
data/lib/mittsu/math/vector.rb
CHANGED
@@ -160,7 +160,7 @@ module Mittsu
|
|
160
160
|
end
|
161
161
|
|
162
162
|
def length
|
163
|
-
Math.sqrt(length_sq)
|
163
|
+
::Math.sqrt(length_sq)
|
164
164
|
end
|
165
165
|
|
166
166
|
def normalize
|
@@ -211,11 +211,11 @@ module Mittsu
|
|
211
211
|
theta = self.dot(v) / (self.length * v.length)
|
212
212
|
|
213
213
|
# clamp, to handle numerical problems
|
214
|
-
Math.acos(Math.clamp(theta, -1.0, 1.0))
|
214
|
+
::Math.acos(Math.clamp(theta, -1.0, 1.0))
|
215
215
|
end
|
216
216
|
|
217
217
|
def distance_to(v)
|
218
|
-
Math.sqrt(self.distance_to_squared(v))
|
218
|
+
::Math.sqrt(self.distance_to_squared(v))
|
219
219
|
end
|
220
220
|
|
221
221
|
def ==(v)
|
data/lib/mittsu/math/vector2.rb
CHANGED
data/lib/mittsu/math/vector3.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'mittsu/math'
|
2
1
|
require 'mittsu/math/vector'
|
3
2
|
|
4
3
|
module Mittsu
|
@@ -188,6 +187,114 @@ module Mittsu
|
|
188
187
|
self
|
189
188
|
end
|
190
189
|
|
190
|
+
def set_scalar(scalar)
|
191
|
+
set(scalar, scalar, scalar)
|
192
|
+
|
193
|
+
self
|
194
|
+
end
|
195
|
+
|
196
|
+
def set_component(index, value)
|
197
|
+
_x, _y, _z = *@elements
|
198
|
+
|
199
|
+
case index
|
200
|
+
when 0
|
201
|
+
set(value, _y, _z)
|
202
|
+
when 1
|
203
|
+
set(_x, value, _z)
|
204
|
+
when 2
|
205
|
+
set(_x, _y, value)
|
206
|
+
else
|
207
|
+
raise ArgumentError, "index is out of range: #{index}"
|
208
|
+
end
|
209
|
+
|
210
|
+
self
|
211
|
+
end
|
212
|
+
|
213
|
+
def get_component(index)
|
214
|
+
_x, _y, _z = *@elements
|
215
|
+
|
216
|
+
case index
|
217
|
+
when 0
|
218
|
+
return _x
|
219
|
+
when 1
|
220
|
+
return _y
|
221
|
+
when 2
|
222
|
+
return _z
|
223
|
+
else
|
224
|
+
raise ArgumentError, "index is out of range: #{index}"
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
def add_scaled_vector(vector, scalar)
|
229
|
+
set(vector.x * scalar, vector.y * scalar, vector.z * scalar)
|
230
|
+
|
231
|
+
self
|
232
|
+
end
|
233
|
+
|
234
|
+
def set_from_spherical(sphere)
|
235
|
+
set_from_spherical_coords(sphere.radius, sphere.phi, sphere.theta)
|
236
|
+
end
|
237
|
+
|
238
|
+
def set_from_spherical_coords(radius, phi, theta)
|
239
|
+
sin_phi_radius = ::Math.sin(phi) * radius
|
240
|
+
set(sin_phi_radius * ::Math.sin(theta), ::Math.cos(phi) * radius, sin_phi_radius * ::Math.cos(theta))
|
241
|
+
|
242
|
+
self
|
243
|
+
end
|
244
|
+
|
245
|
+
def set_from_cylindrical(cylinder)
|
246
|
+
set_from_cylindrical_coords(cylinder.radius, cylinder.theta, cylinder.y)
|
247
|
+
end
|
248
|
+
|
249
|
+
def set_from_cylindrical_coords(radius, theta, y)
|
250
|
+
set(radius * ::Math.sin(theta), y, radius * ::Math.sin(theta))
|
251
|
+
|
252
|
+
self
|
253
|
+
end
|
254
|
+
|
255
|
+
def set_from_matrix3_column(matrix, index)
|
256
|
+
from_array(matrix.elements, index * 3)
|
257
|
+
end
|
258
|
+
|
259
|
+
def equals(vector)
|
260
|
+
_x, _y, _z = *@elements
|
261
|
+
|
262
|
+
((vector.x == _x) && (vector.y == _y) && (vector.z == _z ))
|
263
|
+
end
|
264
|
+
|
265
|
+
def from_buffer_attribute(attribute, index)
|
266
|
+
set(attribute.get_x(index), attribute.get_y(index), attribute.get_z(index))
|
267
|
+
|
268
|
+
self
|
269
|
+
end
|
270
|
+
|
271
|
+
def clamp_length(min, max)
|
272
|
+
divide_scalar(length || 1).multiply_scalar([min, [max, length].min].max)
|
273
|
+
end
|
274
|
+
|
275
|
+
def manhattan_distance_to(vector)
|
276
|
+
_x, _y, _z = *@elements
|
277
|
+
|
278
|
+
(_x - vector.x).abs + (_y - vector.y).abs + (_z - vector.z).abs
|
279
|
+
end
|
280
|
+
|
281
|
+
# TODO: maybe add range 3 values as arguments (range_x, range_y, range_z) to this method
|
282
|
+
def random()
|
283
|
+
set(Random.new.rand, Random.new.rand, Random.new.rand)
|
284
|
+
|
285
|
+
self
|
286
|
+
end
|
287
|
+
|
288
|
+
def random_direction()
|
289
|
+
u = (Random.new.rand - 0.5) *2
|
290
|
+
t = Random.new.rand * ::Math::PI * 2
|
291
|
+
f = ::Math.sqrt(1 - u ** 2)
|
292
|
+
|
293
|
+
set(f * ::Math.cos(t), f * ::Math.sin(t), u)
|
294
|
+
|
295
|
+
self
|
296
|
+
end
|
297
|
+
|
191
298
|
def from_attribute(attribute, index, offset = 0)
|
192
299
|
index = index * attribute.itemSize + offset
|
193
300
|
|
data/lib/mittsu/math/vector4.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'mittsu/math'
|
2
1
|
require 'mittsu/math/vector'
|
3
2
|
|
4
3
|
module Mittsu
|
@@ -50,8 +49,8 @@ module Mittsu
|
|
50
49
|
def set_axis_angle_from_quaternion(q)
|
51
50
|
# http:#www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm
|
52
51
|
# q is assumed to be normalized
|
53
|
-
@elements[3] = 2.0 * Math.acos(q.w)
|
54
|
-
s = Math.sqrt(1.0 - q.w * q.w)
|
52
|
+
@elements[3] = 2.0 * ::Math.acos(q.w)
|
53
|
+
s = ::Math.sqrt(1.0 - q.w * q.w)
|
55
54
|
if s < 0.0001
|
56
55
|
@elements[0] = 1.0
|
57
56
|
@elements[1] = 0.0
|
@@ -89,7 +88,7 @@ module Mittsu
|
|
89
88
|
return self # zero angle, arbitrary axis
|
90
89
|
end
|
91
90
|
# otherwise self singularity is angle = 180
|
92
|
-
angle = Math::PI
|
91
|
+
angle = ::Math::PI
|
93
92
|
xx = (m11 + 1.0) / 2.0
|
94
93
|
yy = (m22 + 1.0) / 2.0
|
95
94
|
zz = (m33 + 1.0) / 2.0
|
@@ -102,7 +101,7 @@ module Mittsu
|
|
102
101
|
y1 = 0.707106781
|
103
102
|
z1 = 0.707106781
|
104
103
|
else
|
105
|
-
x1 = Math.sqrt(xx)
|
104
|
+
x1 = ::Math.sqrt(xx)
|
106
105
|
y1 = xy / x1
|
107
106
|
z1 = xz / x1
|
108
107
|
end
|
@@ -112,7 +111,7 @@ module Mittsu
|
|
112
111
|
y1 = 0.0
|
113
112
|
z1 = 0.707106781
|
114
113
|
else
|
115
|
-
y1 = Math.sqrt(yy)
|
114
|
+
y1 = ::Math.sqrt(yy)
|
116
115
|
x1 = xy / y1
|
117
116
|
z1 = yz / y1
|
118
117
|
end
|
@@ -122,7 +121,7 @@ module Mittsu
|
|
122
121
|
y1 = 0.707106781
|
123
122
|
z1 = 0.0
|
124
123
|
else
|
125
|
-
z1 = Math.sqrt(zz)
|
124
|
+
z1 = ::Math.sqrt(zz)
|
126
125
|
x1 = xz / z1
|
127
126
|
y1 = yz / z1
|
128
127
|
end
|
@@ -131,7 +130,7 @@ module Mittsu
|
|
131
130
|
return self # return 180 deg rotation
|
132
131
|
end
|
133
132
|
# as we have reached here there are no singularities so we can handle normally
|
134
|
-
s = Math.sqrt((m32 - m23) * (m32 - m23) +
|
133
|
+
s = ::Math.sqrt((m32 - m23) * (m32 - m23) +
|
135
134
|
(m13 - m31) * (m13 - m31) +
|
136
135
|
(m21 - m12) * (m21 - m12)) # used to normalize
|
137
136
|
s = 1.0 if (s.abs < 0.001)
|
@@ -140,7 +139,7 @@ module Mittsu
|
|
140
139
|
@elements[0] = (m32 - m23) / s
|
141
140
|
@elements[1] = (m13 - m31) / s
|
142
141
|
@elements[2] = (m21 - m12) / s
|
143
|
-
@elements[3] = Math.acos((m11 + m22 + m33 - 1.0) / 2.0)
|
142
|
+
@elements[3] = ::Math.acos((m11 + m22 + m33 - 1.0) / 2.0)
|
144
143
|
self
|
145
144
|
end
|
146
145
|
|
data/lib/mittsu/math.rb
CHANGED
@@ -17,13 +17,8 @@ require 'mittsu/math/vector2'
|
|
17
17
|
require 'mittsu/math/vector3'
|
18
18
|
require 'mittsu/math/vector4'
|
19
19
|
|
20
|
-
BuiltInMath = Math
|
21
|
-
|
22
20
|
module Mittsu
|
23
21
|
module Math
|
24
|
-
extend BuiltInMath
|
25
|
-
include BuiltInMath
|
26
|
-
BuiltInMath.methods.each { |m| public_class_method m }
|
27
22
|
|
28
23
|
def self.sign(x)
|
29
24
|
return Float::NAN unless x.is_a? Numeric
|
data/lib/mittsu/objects/line.rb
CHANGED
@@ -25,17 +25,38 @@ module Mittsu
|
|
25
25
|
end
|
26
26
|
|
27
27
|
class Windows < GenericLib::Base
|
28
|
+
def file
|
29
|
+
'glfw3.dll'
|
30
|
+
end
|
28
31
|
end
|
29
32
|
|
30
33
|
class MacOS < GenericLib::Base
|
34
|
+
SEARCH_GLOBS = ['/usr/local/lib/**',
|
35
|
+
'/usr/lib/**',
|
36
|
+
'/opt/homebrew/**']
|
37
|
+
|
31
38
|
def path
|
32
|
-
|
39
|
+
File.dirname(match)
|
33
40
|
end
|
34
41
|
|
35
42
|
def file
|
36
|
-
|
37
|
-
return matches.find { |m| m == 'libglfw3.dylib' || m == 'libglfw.3.dylib' } || matches.first
|
43
|
+
File.basename(match)
|
38
44
|
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def match
|
49
|
+
@match ||= find_match
|
50
|
+
end
|
51
|
+
|
52
|
+
def find_match
|
53
|
+
SEARCH_GLOBS.each do |glob|
|
54
|
+
matches = Dir.glob("#{glob}/libglfw*.dylib")
|
55
|
+
next if matches.empty?
|
56
|
+
|
57
|
+
return matches.find { |m| m.end_with?('libglfw3.dylib') || m.end_with?('libglfw.3.dylib') } || matches.first
|
58
|
+
end
|
59
|
+
end
|
39
60
|
end
|
40
61
|
end
|
41
62
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'opengl'
|
2
2
|
require 'glfw'
|
3
3
|
|
4
|
-
require 'mittsu'
|
4
|
+
require 'mittsu/utils'
|
5
5
|
require 'mittsu/renderers/glfw_lib'
|
6
6
|
glfw_lib = Mittsu::GLFWLib.discover
|
7
7
|
GLFW.load_lib(ENV["MITTSU_LIBGLFW_FILE"] || glfw_lib.file, ENV["MITTSU_LIBGLFW_PATH"] || glfw_lib.path) unless Mittsu.test?
|
@@ -13,7 +13,7 @@ module Mittsu
|
|
13
13
|
class Window
|
14
14
|
attr_accessor :key_press_handler, :key_release_handler, :key_repeat_handler, :char_input_handler, :cursor_pos_handler, :mouse_button_press_handler, :mouse_button_release_handler, :scroll_handler, :framebuffer_size_handler
|
15
15
|
|
16
|
-
def initialize(width, height, title)
|
16
|
+
def initialize(width, height, title, antialias: 0)
|
17
17
|
glfwInit
|
18
18
|
|
19
19
|
glfwWindowHint GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE
|
@@ -22,6 +22,10 @@ module Mittsu
|
|
22
22
|
glfwWindowHint GLFW_CONTEXT_VERSION_MINOR, 3
|
23
23
|
glfwWindowHint GLFW_CONTEXT_REVISION, 0
|
24
24
|
|
25
|
+
if antialias > 0
|
26
|
+
glfwWindowHint GLFW_SAMPLES, antialias
|
27
|
+
end
|
28
|
+
|
25
29
|
@width, @height, @title = width, height, title
|
26
30
|
@handle = glfwCreateWindow(@width, @height, @title, nil, nil)
|
27
31
|
if @handle.null?
|
@@ -35,7 +35,7 @@ module Mittsu
|
|
35
35
|
directions[offset + 1] = @_direction.y
|
36
36
|
directions[offset + 2] = @_direction.z
|
37
37
|
|
38
|
-
@cache.angles_cos[index] = Math.cos(angle)
|
38
|
+
@cache.angles_cos[index] = ::Math.cos(angle)
|
39
39
|
@cache.exponents[index] = exponent;
|
40
40
|
@cache.decays[index] = distance.zero? ? 0.0 : decay
|
41
41
|
end
|
@@ -1,10 +1,9 @@
|
|
1
1
|
require 'erb'
|
2
|
-
|
3
2
|
require 'mittsu/renderers/opengl/opengl_shader'
|
4
3
|
|
5
4
|
module Mittsu
|
6
5
|
class OpenGLProgram
|
7
|
-
attr_reader :id, :program, :uniforms
|
6
|
+
attr_reader :id, :program, :uniforms
|
8
7
|
attr_accessor :code, :used_times, :attributes, :vertex_shader, :fragment_shader
|
9
8
|
|
10
9
|
def initialize(renderer, code, material, parameters)
|
@@ -61,14 +61,14 @@ module Mittsu
|
|
61
61
|
glTexParameteri(texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)
|
62
62
|
|
63
63
|
if wrap_s != ClampToEdgeWrapping || wrap_t != ClampToEdgeWrapping
|
64
|
-
puts "WARNING: Mittsu::Texture: Texture is not power of two. Texture.wrap_s and Texture.wrap_t should be set to Mittsu::ClampToEdgeWrapping. (#{
|
64
|
+
puts "WARNING: Mittsu::Texture: Texture is not power of two. Texture.wrap_s and Texture.wrap_t should be set to Mittsu::ClampToEdgeWrapping. (#{source_file})"
|
65
65
|
end
|
66
66
|
|
67
67
|
glTexParameteri(texture_type, GL_TEXTURE_MAG_FILTER, filter_fallback(mag_filter))
|
68
68
|
glTexParameteri(texture_type, GL_TEXTURE_MIN_FILTER, filter_fallback(min_filter))
|
69
69
|
|
70
70
|
if min_filter != NearestFilter && min_filter != LinearFilter
|
71
|
-
puts "WARNING: Mittsu::Texture: Texture is not a power of two. Texture.min_filter should be set to Mittsu::NearestFilter or Mittsu::LinearFilter. (#{
|
71
|
+
puts "WARNING: Mittsu::Texture: Texture is not a power of two. Texture.min_filter should be set to Mittsu::NearestFilter or Mittsu::LinearFilter. (#{source_file})"
|
72
72
|
end
|
73
73
|
|
74
74
|
# TODO: anisotropic extension ???
|
@@ -2,12 +2,10 @@ require 'opengl'
|
|
2
2
|
require 'glfw'
|
3
3
|
require 'fiddle'
|
4
4
|
|
5
|
-
|
6
5
|
require 'mittsu/renderers/opengl/opengl_lib'
|
7
6
|
opengl_lib = Mittsu::OpenGLLib.discover
|
8
7
|
OpenGL.load_lib(ENV["MITTSU_LIBGL_FILE"] || opengl_lib.file, ENV["MITTSU_LIBGL_PATH"] || opengl_lib.path)
|
9
8
|
|
10
|
-
require 'mittsu'
|
11
9
|
require 'mittsu/renderers/glfw_window'
|
12
10
|
require 'mittsu/renderers/opengl/opengl_implementations'
|
13
11
|
require 'mittsu/renderers/opengl/opengl_debug'
|
@@ -30,12 +28,14 @@ require 'mittsu/renderers/opengl/opengl_mittsu_params'
|
|
30
28
|
|
31
29
|
module Mittsu
|
32
30
|
class OpenGLRenderer
|
33
|
-
attr_accessor :auto_clear, :auto_clear_color, :auto_clear_depth, :auto_clear_stencil, :sort_objects, :gamma_factor, :gamma_input,
|
31
|
+
attr_accessor :auto_clear, :auto_clear_color, :auto_clear_depth, :auto_clear_stencil, :sort_objects, :gamma_factor, :gamma_input,
|
32
|
+
:gamma_output, :shadow_map_enabled, :shadow_map_type, :shadow_map_cull_face, :shadow_map_debug, :shadow_map_cascade,
|
33
|
+
:max_morph_targets, :max_morph_normals, :info, :pixel_ratio, :window, :width, :height, :state
|
34
34
|
|
35
|
-
attr_reader :logarithmic_depth_buffer, :
|
35
|
+
attr_reader :logarithmic_depth_buffer, :programs, :light_renderer, :proj_screen_matrix
|
36
36
|
|
37
37
|
def initialize(parameters = {})
|
38
|
-
puts "
|
38
|
+
puts "Mittsu OpenGL Renderer #{VERSION}"
|
39
39
|
|
40
40
|
fetch_parameters(parameters)
|
41
41
|
|
@@ -81,11 +81,6 @@ module Mittsu
|
|
81
81
|
|
82
82
|
# TODO: get_context ???
|
83
83
|
# TODO: force_context_loss ???
|
84
|
-
|
85
|
-
def supports_vertex_textures?
|
86
|
-
@_supports_vertex_textures
|
87
|
-
end
|
88
|
-
|
89
84
|
# TODO: supports_float_textures? ???
|
90
85
|
# TODO: supports[half|standard|compressed|blend min max] ... ???
|
91
86
|
|
@@ -940,14 +935,14 @@ module Mittsu
|
|
940
935
|
@_alpha = parameters.fetch(:alpha, false)
|
941
936
|
@_depth = parameters.fetch(:depth, true)
|
942
937
|
@_stencil = parameters.fetch(:stencil, true)
|
943
|
-
@_antialias = parameters.fetch(:antialias, false)
|
944
938
|
@_premultiplied_alpha = parameters.fetch(:premultiplied_alpha, true)
|
945
939
|
@_preserve_drawing_buffer = parameters.fetch(:preserve_drawing_buffer, false)
|
946
940
|
@logarithmic_depth_buffer = parameters.fetch(:logarithmic_depth_buffer, false)
|
947
941
|
|
948
942
|
@width = parameters.fetch(:width, 800)
|
949
943
|
@height = parameters.fetch(:height, 600)
|
950
|
-
@title = parameters.fetch(:title, "Mittsu #{
|
944
|
+
@title = parameters.fetch(:title, "Mittsu #{VERSION}")
|
945
|
+
@antialias = parameters.fetch(:antialias, 0)
|
951
946
|
end
|
952
947
|
|
953
948
|
def get_gpu_capabilities
|
@@ -979,7 +974,7 @@ module Mittsu
|
|
979
974
|
# preserve_drawing_buffer: _preserve_drawing_buffer
|
980
975
|
# }
|
981
976
|
|
982
|
-
@window = GLFW::Window.new(@width, @height, @title)
|
977
|
+
@window = GLFW::Window.new(@width, @height, @title, antialias: @antialias)
|
983
978
|
|
984
979
|
default_target.set_viewport_size(*(@window.framebuffer_size))
|
985
980
|
|
@@ -1006,7 +1001,7 @@ module Mittsu
|
|
1006
1001
|
glUniformMatrix4fv(uniforms['projectionMatrix'], 1, GL_FALSE, array_to_ptr_easy(camera.projection_matrix.elements))
|
1007
1002
|
|
1008
1003
|
if @logarithmic_depth_buffer
|
1009
|
-
glUniform1f(uniforms['logDepthBuffFC'], 2.0 / Math.log(camera.far + 1.0) / Math::LN2)
|
1004
|
+
glUniform1f(uniforms['logDepthBuffFC'], 2.0 / ::Math.log(camera.far + 1.0) / Math::LN2)
|
1010
1005
|
end
|
1011
1006
|
|
1012
1007
|
if material.needs_camera_position_uniform? && !uniforms['cameraPosition'].nil?
|
data/lib/mittsu/scenes/scene.rb
CHANGED
@@ -10,9 +10,10 @@ module Mittsu
|
|
10
10
|
DEFAULT_IMAGE = nil
|
11
11
|
DEFAULT_MAPPING = UVMapping
|
12
12
|
|
13
|
-
attr_reader :id, :uuid
|
13
|
+
attr_reader :id, :uuid
|
14
14
|
|
15
|
-
attr_accessor :image, :name, :source_file, :mipmaps, :offset, :repeat, :generate_mipmaps, :premultiply_alpha, :filp_y,
|
15
|
+
attr_accessor :image, :name, :source_file, :mipmaps, :offset, :repeat, :generate_mipmaps, :premultiply_alpha, :filp_y,
|
16
|
+
:unpack_alignment, :on_update, :mapping, :wrap_s, :wrap_t, :mag_filter, :min_filter, :anisotropy, :format, :type
|
16
17
|
|
17
18
|
def initialize(image = DEFAULT_IMAGE, mapping = DEFAULT_MAPPING, wrap_s = ClampToEdgeWrapping, wrap_t = ClampToEdgeWrapping, mag_filter = LinearFilter, min_filter = LinearMipMapLinearFilter, format = RGBAFormat, type = UnsignedByteType, anisotropy = 1)
|
18
19
|
super()
|
@@ -42,6 +43,7 @@ module Mittsu
|
|
42
43
|
|
43
44
|
@_needs_update = false
|
44
45
|
@on_update = nil
|
46
|
+
@_listeners = {}
|
45
47
|
end
|
46
48
|
|
47
49
|
def needs_update?
|
data/lib/mittsu/utils.rb
ADDED
data/lib/mittsu/version.rb
CHANGED
data/lib/mittsu.rb
CHANGED
@@ -1,19 +1,4 @@
|
|
1
|
-
|
2
|
-
DEBUG = ENV["DEBUG"] == "true"
|
3
|
-
|
4
|
-
def self.debug?
|
5
|
-
DEBUG
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.env
|
9
|
-
ENV["MITTSU_ENV"]
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.test?
|
13
|
-
env == 'test'
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
1
|
+
require "mittsu/utils"
|
17
2
|
require "mittsu/version"
|
18
3
|
require "mittsu/math"
|
19
4
|
require "mittsu/core"
|
data/mittsu.gemspec
CHANGED
@@ -6,15 +6,15 @@ require 'mittsu/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "mittsu"
|
8
8
|
spec.version = Mittsu::VERSION
|
9
|
-
spec.authors = ["
|
10
|
-
spec.email = ["
|
9
|
+
spec.authors = ["Danielle Smith"]
|
10
|
+
spec.email = ["danini@hey.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{3D Graphics Library for Ruby}
|
13
13
|
spec.description = %q{Mittsu makes 3D graphics easier by providing an abstraction over OpenGL, and is based heavily off of THREE.js. No more weird pointers and wondering about the difference between a VAO and a VBO (besides the letter). Simply think of something awesome and make it!}
|
14
|
-
spec.homepage = "https://github.com/
|
14
|
+
spec.homepage = "https://github.com/danini-the-panini/mittsu"
|
15
15
|
spec.license = "MIT"
|
16
16
|
spec.metadata = {
|
17
|
-
"bug_tracker" => "https://github.com/
|
17
|
+
"bug_tracker" => "https://github.com/danini-the-panini/mittsu/issues"
|
18
18
|
}
|
19
19
|
|
20
20
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{(^(test|examples)/|\.sh$)}) }
|
@@ -23,14 +23,15 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.required_ruby_version = '>= 2.0.0'
|
24
24
|
spec.requirements << 'OpenGL 3.3+ capable hardware and drivers'
|
25
25
|
|
26
|
-
spec.add_runtime_dependency 'opengl-bindings'
|
27
|
-
spec.add_runtime_dependency 'ffi'
|
28
|
-
spec.add_runtime_dependency 'chunky_png'
|
26
|
+
spec.add_runtime_dependency 'opengl-bindings'
|
27
|
+
spec.add_runtime_dependency 'ffi'
|
28
|
+
spec.add_runtime_dependency 'chunky_png'
|
29
29
|
|
30
|
-
spec.add_development_dependency "bundler"
|
31
|
-
spec.add_development_dependency "rake"
|
32
|
-
spec.add_development_dependency 'minitest'
|
33
|
-
spec.add_development_dependency 'minitest-reporters'
|
34
|
-
spec.add_development_dependency 'pry'
|
35
|
-
spec.add_development_dependency 'benchmark-ips'
|
30
|
+
spec.add_development_dependency "bundler"
|
31
|
+
spec.add_development_dependency "rake"
|
32
|
+
spec.add_development_dependency 'minitest'
|
33
|
+
spec.add_development_dependency 'minitest-reporters'
|
34
|
+
spec.add_development_dependency 'pry'
|
35
|
+
spec.add_development_dependency 'benchmark-ips'
|
36
|
+
spec.add_development_dependency 'simplecov', '0.17.1'
|
36
37
|
end
|