Matrix3D getTransformationMatrix3D(DisplayObject targetSpace)

The 3D transformation matrix relative to the given targetSpace.

Note: You can get the transformation matrix either with the getTransformationMatrix or the getTransformationMatrix3D method. You only need to use a 3D transformation matrix if you are working with 3D display objects.

Source

Matrix3D getTransformationMatrix3D(DisplayObject targetSpace) {

  if (targetSpace == null) return this.globalTransformationMatrix3D;
  if (targetSpace == this) return new Matrix3D.fromIdentity();

  var ancestor = _getCommonAncestor(targetSpace);
  if (ancestor == null) return null;

  var resultMatrix = new Matrix3D.fromIdentity();
  for (var obj = this; obj != ancestor; obj = obj.parent) {
    if (obj is DisplayObjectContainer3D) {
      resultMatrix.concat(obj.projectionMatrix3D);
    }
    resultMatrix.concat2D(obj.transformationMatrix);
  }

  if (identical(targetSpace, ancestor)) return resultMatrix;

  var targetMatrix = new Matrix3D.fromIdentity();
  for (var obj = targetSpace; obj != ancestor; obj = obj.parent) {
    if (obj is DisplayObjectContainer3D) {
      targetMatrix.concat(obj.projectionMatrix3D);
    }
    targetMatrix.concat2D(obj.transformationMatrix);
  }

  targetMatrix.invert();
  resultMatrix.concat(targetMatrix);
  return resultMatrix;
}