Skip to content

Commit 01d26fe

Browse files
committed
Merge pull request flutter#443 from vlidholt/master
First pass on sprite 3D node
2 parents 15d169b + 9274ddc commit 01d26fe

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
part of sprites;
2+
3+
class Node3D extends Node {
4+
5+
double _rotationX = 0.0;
6+
7+
double get rotationX => _rotationX;
8+
9+
set rotationX(double rotationX) {
10+
_rotationX = rotationX;
11+
invalidateTransformMatrix();
12+
}
13+
14+
double _rotationY = 0.0;
15+
16+
double get rotationY => _rotationY;
17+
18+
set rotationY(double rotationY) {
19+
_rotationY = rotationY;
20+
invalidateTransformMatrix();
21+
}
22+
23+
Matrix4 computeTransformMatrix() {
24+
// Apply normal 2d transforms
25+
Matrix4 matrix = super.computeTransformMatrix();
26+
27+
28+
matrix.translate(0.0, 0.0, 500.0);
29+
30+
// Rotate around x and y axis
31+
matrix.rotateY(radians(_rotationY));
32+
matrix.rotateX(radians(_rotationX));
33+
34+
return matrix;
35+
}
36+
}

sky/packages/sky/example/game/lib/sprites.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ part 'action.dart';
2222
part 'color_secuence.dart';
2323
part 'image_map.dart';
2424
part 'node.dart';
25+
part 'node3d.dart';
2526
part 'node_with_size.dart';
2627
part 'particle_system.dart';
2728
part 'sprite.dart';

0 commit comments

Comments
 (0)