computeTransformMatrix method

  1. @override
Matrix4 computeTransformMatrix()
override

Computes the transformation matrix of this node. This method can be overriden if a custom matrix is required. There is usually no reason to call this method directly.

Implementation

@override
Matrix4 computeTransformMatrix() {
  // Apply normal 2d transforms
  Matrix4 matrix = super.computeTransformMatrix();

  // Apply perspective projection
  Matrix4 projection = Matrix4(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0,
      0.0, 1.0, -1.0 / _projectionDepth, 0.0, 0.0, 0.0, 1.0);
  matrix.multiply(projection);

  // Rotate around x and y axis
  matrix.rotateY(radians(_rotationY));
  matrix.rotateX(radians(_rotationX));

  return matrix;
}