First pass on sprite 3D node (does not yet support perspective projections).
This commit is contained in:
36
packages/flutter/example/game/lib/node3d.dart
Normal file
36
packages/flutter/example/game/lib/node3d.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
part of sprites;
|
||||
|
||||
class Node3D extends Node {
|
||||
|
||||
double _rotationX = 0.0;
|
||||
|
||||
double get rotationX => _rotationX;
|
||||
|
||||
set rotationX(double rotationX) {
|
||||
_rotationX = rotationX;
|
||||
invalidateTransformMatrix();
|
||||
}
|
||||
|
||||
double _rotationY = 0.0;
|
||||
|
||||
double get rotationY => _rotationY;
|
||||
|
||||
set rotationY(double rotationY) {
|
||||
_rotationY = rotationY;
|
||||
invalidateTransformMatrix();
|
||||
}
|
||||
|
||||
Matrix4 computeTransformMatrix() {
|
||||
// Apply normal 2d transforms
|
||||
Matrix4 matrix = super.computeTransformMatrix();
|
||||
|
||||
|
||||
matrix.translate(0.0, 0.0, 500.0);
|
||||
|
||||
// Rotate around x and y axis
|
||||
matrix.rotateY(radians(_rotationY));
|
||||
matrix.rotateX(radians(_rotationX));
|
||||
|
||||
return matrix;
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ part 'action.dart';
|
||||
part 'color_secuence.dart';
|
||||
part 'image_map.dart';
|
||||
part 'node.dart';
|
||||
part 'node3d.dart';
|
||||
part 'node_with_size.dart';
|
||||
part 'particle_system.dart';
|
||||
part 'sprite.dart';
|
||||
|
||||
Reference in New Issue
Block a user