@@ -45,7 +45,7 @@ impl Globals {
45
45
46
46
let projection_matrix = {
47
47
// TODO: Here, just the fixed default value is used.
48
- // This should support variable values derived for each display object.
48
+ // This should support .transform.perspectiveProjection of each display object.
49
49
let field_of_view = 55.0 ;
50
50
51
51
let focal_length = {
@@ -54,31 +54,41 @@ impl Globals {
54
54
f64:: cos ( rad) / f64:: sin ( rad)
55
55
} ;
56
56
57
- let perspective_projection = {
58
- let mut m = Matrix3D :: IDENTITY ;
59
- m. raw_data [ 0 ] = focal_length;
60
- m. raw_data [ 5 ] = focal_length;
61
- m. raw_data [ 10 ] = focal_length;
62
- m. raw_data [ 11 ] = 1.0 ;
63
- m. raw_data [ 14 ] = 0.0 ;
64
- m. raw_data [ 15 ] = 0.0 ;
65
- m
57
+ let perspective_projection = Matrix3D {
58
+ raw_data : [
59
+ //
60
+ focal_length,
61
+ 0.0 ,
62
+ 0.0 ,
63
+ 0.0 ,
64
+ //
65
+ 0.0 ,
66
+ focal_length,
67
+ 0.0 ,
68
+ 0.0 ,
69
+ //
70
+ 0.0 ,
71
+ 0.0 ,
72
+ 1.0 ,
73
+ 1.0 ,
74
+ //
75
+ 0.0 ,
76
+ 0.0 ,
77
+ 0.0 ,
78
+ 0.0 ,
79
+ ] ,
66
80
} ;
81
+
82
+ // TODO: Consider PerspectiveProjection.projectionCenter.
83
+
67
84
let move_coord = {
68
85
// AS3 places Viewpoint at (0, 0, -focalLength).
69
-
70
86
let mut m = Matrix3D :: IDENTITY ;
71
87
m. raw_data [ 14 ] = focal_length;
72
- // TODO: Consider PerspectiveProjection.projectionCenter.
73
88
m
74
89
} ;
75
- let move_coord_back = {
76
- let mut m = Matrix3D :: IDENTITY ;
77
- m. raw_data [ 10 ] = 0.0 ;
78
- // TODO: Consider PerspectiveProjection.projectionCenter.
79
- m
80
- } ;
81
- move_coord_back * perspective_projection * move_coord
90
+
91
+ perspective_projection * move_coord
82
92
} ;
83
93
84
94
let matrix = projection_matrix * view_matrix;
0 commit comments