mittsu 0.2.3 → 0.3.3
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 +95 -0
- data/.gitignore +1 -0
- data/Gemfile +3 -2
- data/README.md +3 -7
- data/Rakefile +1 -0
- data/install-glfw.ps1 +13 -0
- data/lib/mittsu.rb +1 -16
- 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_geometry.rb +3 -3
- data/lib/mittsu/core/geometry.rb +10 -9
- data/lib/mittsu/core/object_3d.rb +9 -7
- data/lib/mittsu/core/raycaster.rb +0 -2
- data/lib/mittsu/extras/geometries.rb +13 -0
- data/lib/mittsu/extras/geometries/circle_geometry.rb +48 -0
- data/lib/mittsu/extras/geometries/cylinder_geometry.rb +145 -0
- data/lib/mittsu/extras/geometries/dodecahedron_geometry.rb +56 -0
- data/lib/mittsu/extras/geometries/icosahedron_geometry.rb +33 -0
- data/lib/mittsu/extras/geometries/lathe_geometry.rb +78 -0
- data/lib/mittsu/extras/geometries/octahedron_geometry.rb +26 -0
- data/lib/mittsu/extras/geometries/parametric_buffer_geometry.rb +92 -0
- data/lib/mittsu/extras/geometries/parametric_geometry.rb +93 -0
- data/lib/mittsu/extras/geometries/plane_buffer_geometry.rb +81 -0
- data/lib/mittsu/extras/geometries/plane_geometry.rb +22 -0
- data/lib/mittsu/extras/geometries/polyhedron_geometry.rb +168 -0
- data/lib/mittsu/extras/geometries/ring_geometry.rb +80 -0
- data/lib/mittsu/extras/geometries/sphere_geometry.rb +4 -4
- data/lib/mittsu/extras/geometries/tetrahedron_geometry.rb +26 -0
- data/lib/mittsu/extras/geometries/torus_geometry.rb +63 -0
- data/lib/mittsu/extras/geometries/torus_knot_buffer_geometry.rb +120 -0
- data/lib/mittsu/extras/geometries/torus_knot_geometry.rb +25 -0
- 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.rb +0 -5
- 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 +4 -4
- data/lib/mittsu/math/vector2.rb +0 -1
- data/lib/mittsu/math/vector3.rb +0 -1
- data/lib/mittsu/math/vector4.rb +8 -9
- data/lib/mittsu/objects/line.rb +0 -1
- data/lib/mittsu/renderers/glfw_lib.rb +1 -1
- data/lib/mittsu/renderers/glfw_window.rb +1 -1
- 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 +1 -1
- data/lib/mittsu/renderers/opengl_renderer.rb +5 -10
- 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 -1
- data/mittsu.gemspec +10 -9
- metadata +75 -47
- data/.circleci/config.yml +0 -44
- data/.travis.yml +0 -20
- data/appveyor.yml +0 -23
- data/install_glfw.ps1 +0 -11
@@ -0,0 +1,120 @@
|
|
1
|
+
module Mittsu
|
2
|
+
class TorusKnotBufferGeometry < BufferGeometry
|
3
|
+
def initialize(radius = 100.0, tube = 40.0, radial_segments = 64, tubular_segments = 8, p_val = 2, q_val = 3)
|
4
|
+
super()
|
5
|
+
|
6
|
+
@type = 'TorusKnotBufferGeometry'
|
7
|
+
|
8
|
+
@parameters = {
|
9
|
+
radius: radius,
|
10
|
+
tube: tube,
|
11
|
+
radial_segments: radial_segments,
|
12
|
+
tubular_segments: tubular_segments,
|
13
|
+
p_val: p_val,
|
14
|
+
q_val: q_val
|
15
|
+
}
|
16
|
+
|
17
|
+
# buffers
|
18
|
+
|
19
|
+
indices = []
|
20
|
+
vertices = []
|
21
|
+
normals = []
|
22
|
+
uvs = []
|
23
|
+
|
24
|
+
# helper variables
|
25
|
+
|
26
|
+
vertex = Vector3.new
|
27
|
+
normal = Vector3.new
|
28
|
+
|
29
|
+
p1 = Vector3.new
|
30
|
+
p2 = Vector3.new
|
31
|
+
|
32
|
+
b = Vector3.new
|
33
|
+
t = Vector3.new
|
34
|
+
n = Vector3.new
|
35
|
+
|
36
|
+
# generate vertices, normals and uvs
|
37
|
+
|
38
|
+
for i in 0..tubular_segments do
|
39
|
+
# the radian "u" is used to calculate the position on the torus curve of the current tubular segement
|
40
|
+
u = i.to_f / tubular_segments.to_f * p_val.to_f * ::Math::PI * 2.0
|
41
|
+
|
42
|
+
# now we calculate two points. P1 is our current position on the curve, P2 is a little farther ahead.
|
43
|
+
# these points are used to create a special "coordinate space", which is necessary to calculate the correct vertex positions
|
44
|
+
calculate_position_on_curve(u, p_val, q_val, radius, p1)
|
45
|
+
calculate_position_on_curve(u + 0.01, p_val, q_val, radius, p2)
|
46
|
+
|
47
|
+
# calculate orthonormal basis
|
48
|
+
t.sub_vectors(p2, p1)
|
49
|
+
n.add_vectors(p2, p1)
|
50
|
+
b.cross_vectors(t, n)
|
51
|
+
n.cross_vectors(b, t)
|
52
|
+
|
53
|
+
# normalize B, N. T can be ignored, we don't use it
|
54
|
+
b.normalize
|
55
|
+
n.normalize
|
56
|
+
|
57
|
+
for j in 0..radial_segments do
|
58
|
+
# now calculate the vertices. they are nothing more than an extrusion of the torus curve.
|
59
|
+
# because we extrude a shape in the xy-plane, there is no need to calculate a z-value.
|
60
|
+
v = j.to_f / radial_segments.to_f * ::Math::PI * 2.0
|
61
|
+
cx = -tube * ::Math.cos(v)
|
62
|
+
cy = tube * ::Math.sin(v)
|
63
|
+
|
64
|
+
# now calculate the final vertex position.
|
65
|
+
# first we orient the extrusion with our basis vectos, then we add it to the current position on the curve
|
66
|
+
vertex.x = p1.x + (cx * n.x + cy * b.x)
|
67
|
+
vertex.y = p1.y + (cx * n.y + cy * b.y)
|
68
|
+
vertex.z = p1.z + (cx * n.z + cy * b.z)
|
69
|
+
|
70
|
+
vertices += vertex.elements
|
71
|
+
|
72
|
+
# normal (P1 is always the center/origin of the extrusion, thus we can use it to calculate the normal)
|
73
|
+
normal.sub_vectors(vertex, p1).normalize
|
74
|
+
|
75
|
+
normals += normal.elements
|
76
|
+
|
77
|
+
# uv
|
78
|
+
uvs << i.to_f / tubular_segments.to_f
|
79
|
+
uvs << j.to_f / radial_segments.to_f
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# generate indices
|
84
|
+
|
85
|
+
for j in 1..tubular_segments do
|
86
|
+
for i in 1..radial_segments do
|
87
|
+
# indices
|
88
|
+
a = (radial_segments + 1) * (j - 1) + (i - 1)
|
89
|
+
b = (radial_segments + 1) * j + (i - 1)
|
90
|
+
c = (radial_segments + 1) * j + i
|
91
|
+
d = (radial_segments + 1) * (j - 1) + i
|
92
|
+
|
93
|
+
# faces
|
94
|
+
indices += [a, b, d]
|
95
|
+
indices += [b, c, d]
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# build geometry
|
100
|
+
|
101
|
+
self[:index] = BufferAttribute.new(indices, 1)
|
102
|
+
self[:position] = BufferAttribute.new(vertices, 3)
|
103
|
+
self[:normal] = BufferAttribute.new(normals, 3)
|
104
|
+
self[:uv] = BufferAttribute.new(uvs, 2)
|
105
|
+
end
|
106
|
+
|
107
|
+
private
|
108
|
+
|
109
|
+
def calculate_position_on_curve(u, p_val, q_val, radius, position)
|
110
|
+
cu = ::Math.cos(u)
|
111
|
+
su = ::Math.sin(u)
|
112
|
+
qu_over_p = q_val.to_f / p_val.to_f * u
|
113
|
+
cs = ::Math.cos(qu_over_p)
|
114
|
+
|
115
|
+
position.x = radius * (2.0 + cs) * 0.5 * cu
|
116
|
+
position.y = radius * (2.0 + cs) * su * 0.5
|
117
|
+
position.z = radius * ::Math.sin(qu_over_p) * 0.5
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'mittsu/core'
|
2
|
+
require 'mittsu/math'
|
3
|
+
require 'mittsu/extras/geometries/torus_knot_buffer_geometry'
|
4
|
+
|
5
|
+
module Mittsu
|
6
|
+
class TorusKnotGeometry < Geometry
|
7
|
+
def initialize(radius = 100.0, tube = 40.0, radial_segments = 64, tubular_segments = 8, p_val = 2, q_val = 3)
|
8
|
+
super()
|
9
|
+
|
10
|
+
@type = 'TorusKnotGeometry'
|
11
|
+
|
12
|
+
@parameters = {
|
13
|
+
radius: radius,
|
14
|
+
tube: tube,
|
15
|
+
radial_segments: radial_segments,
|
16
|
+
tubular_segments: tubular_segments,
|
17
|
+
p_val: p_val,
|
18
|
+
q_val: q_val
|
19
|
+
}
|
20
|
+
|
21
|
+
from_buffer_geometry(TorusKnotBufferGeometry.new(radius, tube, tubular_segments, radial_segments, p_val, q_val))
|
22
|
+
merge_vertices
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -15,58 +15,58 @@ module Mittsu
|
|
15
15
|
|
16
16
|
# colors
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
hex_frustrum = 0xffaa00
|
19
|
+
hex_cone = 0xff0000
|
20
|
+
hex_up = 0x00aaff
|
21
|
+
hex_target = 0xffffff
|
22
|
+
hex_cross = 0x333333
|
23
23
|
|
24
24
|
# near
|
25
25
|
|
26
|
-
add_line(:n1, :n2,
|
27
|
-
add_line(:n2, :n4,
|
28
|
-
add_line(:n4, :n3,
|
29
|
-
add_line(:n3, :n1,
|
26
|
+
add_line(:n1, :n2, hex_frustrum)
|
27
|
+
add_line(:n2, :n4, hex_frustrum)
|
28
|
+
add_line(:n4, :n3, hex_frustrum)
|
29
|
+
add_line(:n3, :n1, hex_frustrum)
|
30
30
|
|
31
31
|
# far
|
32
32
|
|
33
|
-
add_line(:f1, :f2,
|
34
|
-
add_line(:f2, :f4,
|
35
|
-
add_line(:f4, :f3,
|
36
|
-
add_line(:f3, :f1,
|
33
|
+
add_line(:f1, :f2, hex_frustrum)
|
34
|
+
add_line(:f2, :f4, hex_frustrum)
|
35
|
+
add_line(:f4, :f3, hex_frustrum)
|
36
|
+
add_line(:f3, :f1, hex_frustrum)
|
37
37
|
|
38
38
|
# sides
|
39
39
|
|
40
|
-
add_line(:n1, :f1,
|
41
|
-
add_line(:n2, :f2,
|
42
|
-
add_line(:n3, :f3,
|
43
|
-
add_line(:n4, :f4,
|
40
|
+
add_line(:n1, :f1, hex_frustrum)
|
41
|
+
add_line(:n2, :f2, hex_frustrum)
|
42
|
+
add_line(:n3, :f3, hex_frustrum)
|
43
|
+
add_line(:n4, :f4, hex_frustrum)
|
44
44
|
|
45
45
|
# cone
|
46
46
|
|
47
|
-
add_line(:p, :n1,
|
48
|
-
add_line(:p, :n2,
|
49
|
-
add_line(:p, :n3,
|
50
|
-
add_line(:p, :n4,
|
47
|
+
add_line(:p, :n1, hex_cone)
|
48
|
+
add_line(:p, :n2, hex_cone)
|
49
|
+
add_line(:p, :n3, hex_cone)
|
50
|
+
add_line(:p, :n4, hex_cone)
|
51
51
|
|
52
52
|
# up
|
53
53
|
|
54
|
-
add_line(:u1, :u2,
|
55
|
-
add_line(:u2, :u3,
|
56
|
-
add_line(:u3, :u1,
|
54
|
+
add_line(:u1, :u2, hex_up)
|
55
|
+
add_line(:u2, :u3, hex_up)
|
56
|
+
add_line(:u3, :u1, hex_up)
|
57
57
|
|
58
58
|
# target
|
59
59
|
|
60
|
-
add_line(:c, :t,
|
61
|
-
add_line(:p, :c,
|
60
|
+
add_line(:c, :t, hex_target)
|
61
|
+
add_line(:p, :c, hex_cross)
|
62
62
|
|
63
63
|
# cross
|
64
64
|
|
65
|
-
add_line(:cn1, :cn2,
|
66
|
-
add_line(:cn3, :cn4,
|
65
|
+
add_line(:cn1, :cn2, hex_cross)
|
66
|
+
add_line(:cn3, :cn4, hex_cross)
|
67
67
|
|
68
|
-
add_line(:cf1, :cf2,
|
69
|
-
add_line(:cf3, :cf4,
|
68
|
+
add_line(:cf1, :cf2, hex_cross)
|
69
|
+
add_line(:cf3, :cf4, hex_cross)
|
70
70
|
|
71
71
|
super(@geometry, @material, LinePieces)
|
72
72
|
|
@@ -101,10 +101,10 @@ module Mittsu
|
|
101
101
|
|
102
102
|
# far
|
103
103
|
|
104
|
-
set_point(:f1, -w, -h,
|
105
|
-
set_point(:f2, w, -h,
|
106
|
-
set_point(:f3, -w, h,
|
107
|
-
set_point(:f4, w, h,
|
104
|
+
set_point(:f1, -w, -h, 1.0)
|
105
|
+
set_point(:f2, w, -h, 1.0)
|
106
|
+
set_point(:f3, -w, h, 1.0)
|
107
|
+
set_point(:f4, w, h, 1.0)
|
108
108
|
|
109
109
|
# up
|
110
110
|
|
@@ -119,10 +119,10 @@ module Mittsu
|
|
119
119
|
set_point(:cf3, 0.0, -h, 1.0)
|
120
120
|
set_point(:cf4, 0.0, h, 1.0)
|
121
121
|
|
122
|
-
set_point(:cn1, -w, 0.0, 1.0)
|
123
|
-
set_point(:cn2, w, 0.0, 1.0)
|
124
|
-
set_point(:cn3, 0.0, -h, 1.0)
|
125
|
-
set_point(:cn4, 0.0, h, 1.0)
|
122
|
+
set_point(:cn1, -w, 0.0, -1.0)
|
123
|
+
set_point(:cn2, w, 0.0, -1.0)
|
124
|
+
set_point(:cn3, 0.0, -h, -1.0)
|
125
|
+
set_point(:cn4, 0.0, h, -1.0)
|
126
126
|
|
127
127
|
@geometry.vertices_need_update = true
|
128
128
|
end
|
@@ -120,12 +120,16 @@ module Mittsu
|
|
120
120
|
light.shadow_cascade_offset.copy(@shadow_cascade_offset)
|
121
121
|
light.shadow_cascade_count = @shadow_cascade_count
|
122
122
|
|
123
|
-
|
124
|
-
|
125
|
-
|
123
|
+
light.shadow_cascade_bias = @shadow_cascade_bias.dup
|
124
|
+
light.shadow_cascade_width = @shadow_cascade_width.dup
|
125
|
+
light.shadow_cascade_height = @shadow_cascade_height.dup
|
126
126
|
|
127
|
-
|
128
|
-
|
127
|
+
light.shadow_cascade_near_z = @shadow_cascade_near_z.dup
|
128
|
+
light.shadow_cascade_far_z = @shadow_cascade_far_z.dup
|
129
|
+
end
|
130
|
+
|
131
|
+
def virtual?
|
132
|
+
false
|
129
133
|
end
|
130
134
|
|
131
135
|
protected
|
@@ -20,7 +20,7 @@ module Mittsu
|
|
20
20
|
:shadow_camera,
|
21
21
|
:shadow_matrix
|
22
22
|
|
23
|
-
def initialize(color = nil, intensity = 1.0, distance = 0.0, angle = (Math::PI / 3.0), exponent = 10.0, decay = 1.0)
|
23
|
+
def initialize(color = nil, intensity = 1.0, distance = 0.0, angle = (::Math::PI / 3.0), exponent = 10.0, decay = 1.0)
|
24
24
|
super(color)
|
25
25
|
|
26
26
|
@type = 'SpotLight'
|
@@ -151,8 +151,8 @@ module Mittsu
|
|
151
151
|
private
|
152
152
|
|
153
153
|
def nearest_pow2(n)
|
154
|
-
l = Math.log(n) / Math::LN2
|
155
|
-
Math.pow(2, Math.round(l))
|
154
|
+
l = ::Math.log(n) / Math::LN2
|
155
|
+
::Math.pow(2, ::Math.round(l))
|
156
156
|
end
|
157
157
|
|
158
158
|
def create_texture(where, name, source_file, repeat, offset, wrap, anisotropy)
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'securerandom'
|
2
|
-
require 'mittsu'
|
3
2
|
|
4
3
|
module Mittsu
|
5
4
|
class Material
|
@@ -7,9 +6,13 @@ module Mittsu
|
|
7
6
|
|
8
7
|
attr_reader :id, :uuid, :type
|
9
8
|
|
10
|
-
attr_accessor :name, :side, :opacity, :transparent, :blending, :blend_src, :blend_dst, :blend_equation, :blend_src_alpha,
|
9
|
+
attr_accessor :name, :side, :opacity, :transparent, :blending, :blend_src, :blend_dst, :blend_equation, :blend_src_alpha,
|
10
|
+
:blend_dst_alpha, :blend_equation_alpha, :depth_test, :depth_write, :color_write, :polygon_offset, :polygon_offset_factor,
|
11
|
+
:polygon_offset_units, :alpha_test, :overdraw, :visible, :attributes, :shading, :program
|
11
12
|
|
12
|
-
attr_accessor :map, :env_map, :light_map, :
|
13
|
+
attr_accessor :map, :env_map, :light_map, :normal_map, :specular_map, :alpha_map, :combine, :vertex_colors, :fog,
|
14
|
+
:size_attenuation, :skinning, :morph_targets, :morph_normals, :metal, :wrap_around, :defines, :lights, :color, :bump_map,
|
15
|
+
:reflectivity, :refraction_ratio, :wireframe, :default_attribute_values, :uniforms, :vertex_shader, :fragment_shader
|
13
16
|
|
14
17
|
def initialize
|
15
18
|
super
|
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/math/box2.rb
CHANGED
data/lib/mittsu/math/box3.rb
CHANGED
data/lib/mittsu/math/color.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'mittsu/math'
|
2
1
|
require 'mittsu/math/vector3'
|
3
2
|
|
4
3
|
module Mittsu
|
@@ -121,9 +120,9 @@ module Mittsu
|
|
121
120
|
end
|
122
121
|
|
123
122
|
def convert_linear_to_gamma
|
124
|
-
self.r = Math.sqrt(self.r)
|
125
|
-
self.g = Math.sqrt(self.g)
|
126
|
-
self.b = Math.sqrt(self.b)
|
123
|
+
self.r = ::Math.sqrt(self.r)
|
124
|
+
self.g = ::Math.sqrt(self.g)
|
125
|
+
self.b = ::Math.sqrt(self.b)
|
127
126
|
self
|
128
127
|
end
|
129
128
|
|
data/lib/mittsu/math/euler.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'mittsu/math'
|
2
|
-
|
3
1
|
module Mittsu
|
4
2
|
class Euler
|
5
3
|
RotationOrders = [ 'XYZ', 'YZX', 'ZXY', 'XZY', 'YXZ', 'ZYX' ]
|
@@ -9,6 +7,7 @@ module Mittsu
|
|
9
7
|
|
10
8
|
def initialize(x = 0.0, y = 0.0, z = 0.0, order = DefaultOrder)
|
11
9
|
@x, @y, @z, @order = x.to_f, y.to_f, z.to_f, order
|
10
|
+
@on_change_callback = nil
|
12
11
|
end
|
13
12
|
|
14
13
|
def set(x, y, z, order = nil)
|
@@ -57,57 +56,57 @@ module Mittsu
|
|
57
56
|
m31 = te[2]; m32 = te[6]; m33 = te[10]
|
58
57
|
order = order || @order
|
59
58
|
if order == 'XYZ'
|
60
|
-
@y = Math.asin(Math.clamp(m13, -1.0, 1.0))
|
59
|
+
@y = ::Math.asin(Math.clamp(m13, -1.0, 1.0))
|
61
60
|
if m13.abs < 0.99999
|
62
|
-
@x = Math.atan2(- m23, m33)
|
63
|
-
@z = Math.atan2(- m12, m11)
|
61
|
+
@x = ::Math.atan2(- m23, m33)
|
62
|
+
@z = ::Math.atan2(- m12, m11)
|
64
63
|
else
|
65
|
-
@x = Math.atan2(m32, m22)
|
64
|
+
@x = ::Math.atan2(m32, m22)
|
66
65
|
@z = 0.0
|
67
66
|
end
|
68
67
|
elsif order == 'YXZ'
|
69
|
-
@x = Math.asin(- Math.clamp(m23, -1.0, 1.0))
|
68
|
+
@x = ::Math.asin(- Math.clamp(m23, -1.0, 1.0))
|
70
69
|
if m23.abs < 0.99999
|
71
|
-
@y = Math.atan2(m13, m33)
|
72
|
-
@z = Math.atan2(m21, m22)
|
70
|
+
@y = ::Math.atan2(m13, m33)
|
71
|
+
@z = ::Math.atan2(m21, m22)
|
73
72
|
else
|
74
|
-
@y = Math.atan2(- m31, m11)
|
73
|
+
@y = ::Math.atan2(- m31, m11)
|
75
74
|
@z = 0.0
|
76
75
|
end
|
77
76
|
elsif order == 'ZXY'
|
78
|
-
@x = Math.asin(Math.clamp(m32, -1.0, 1.0))
|
77
|
+
@x = ::Math.asin(Math.clamp(m32, -1.0, 1.0))
|
79
78
|
if m32.abs < 0.99999
|
80
|
-
@y = Math.atan2(- m31, m33)
|
81
|
-
@z = Math.atan2(- m12, m22)
|
79
|
+
@y = ::Math.atan2(- m31, m33)
|
80
|
+
@z = ::Math.atan2(- m12, m22)
|
82
81
|
else
|
83
82
|
@y = 0.0
|
84
|
-
@z = Math.atan2(m21, m11)
|
83
|
+
@z = ::Math.atan2(m21, m11)
|
85
84
|
end
|
86
85
|
elsif order == 'ZYX'
|
87
|
-
@y = Math.asin(- Math.clamp(m31, -1.0, 1.0))
|
86
|
+
@y = ::Math.asin(- Math.clamp(m31, -1.0, 1.0))
|
88
87
|
if m31.abs < 0.99999
|
89
|
-
@x = Math.atan2(m32, m33)
|
90
|
-
@z = Math.atan2(m21, m11)
|
88
|
+
@x = ::Math.atan2(m32, m33)
|
89
|
+
@z = ::Math.atan2(m21, m11)
|
91
90
|
else
|
92
91
|
@x = 0.0
|
93
|
-
@z = Math.atan2(- m12, m22)
|
92
|
+
@z = ::Math.atan2(- m12, m22)
|
94
93
|
end
|
95
94
|
elsif order == 'YZX'
|
96
|
-
@z = Math.asin(Math.clamp(m21, -1.0, 1.0))
|
95
|
+
@z = ::Math.asin(Math.clamp(m21, -1.0, 1.0))
|
97
96
|
if m21.abs < 0.99999
|
98
|
-
@x = Math.atan2(- m23, m22)
|
99
|
-
@y = Math.atan2(- m31, m11)
|
97
|
+
@x = ::Math.atan2(- m23, m22)
|
98
|
+
@y = ::Math.atan2(- m31, m11)
|
100
99
|
else
|
101
100
|
@x = 0.0
|
102
|
-
@y = Math.atan2(m13, m33)
|
101
|
+
@y = ::Math.atan2(m13, m33)
|
103
102
|
end
|
104
103
|
elsif order == 'XZY'
|
105
|
-
@z = Math.asin(- Math.clamp(m12, -1.0, 1.0))
|
104
|
+
@z = ::Math.asin(- Math.clamp(m12, -1.0, 1.0))
|
106
105
|
if m12.abs < 0.99999
|
107
|
-
@x = Math.atan2(m32, m22)
|
108
|
-
@y = Math.atan2(m13, m11)
|
106
|
+
@x = ::Math.atan2(m32, m22)
|
107
|
+
@y = ::Math.atan2(m13, m11)
|
109
108
|
else
|
110
|
-
@x = Math.atan2(- m23, m33)
|
109
|
+
@x = ::Math.atan2(- m23, m33)
|
111
110
|
@y = 0.0
|
112
111
|
end
|
113
112
|
else
|