Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/vector_math/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.4.4

* Replaces dynamic multiplication in `TransformFilter.filterInplace` with `Matrix4.transform3` to fix an analyzer error on newer Dart SDKs.

## 2.4.3

* Documents the public `CircleGenerator` API.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ class TransformFilter extends InplaceGeometryFilter {
final VectorList<Vector>? position = mesh.getViewForAttrib('POSITION');
if (position is Vector3List) {
for (var i = 0; i < position.length; ++i) {
// multiplication always returns Vector3 here
// ignore: invalid_assignment
position[i] = transform * position[i];
position[i] = transform.transform3(position[i]);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vector_math/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: vector_math
description: A vector math library for 2D and 3D applications, supporting 2D, 3D, and 4D matrices.
repository: https://github.com/flutter/core-packages/tree/main/packages/vector_math
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+vector_math%22
version: 2.4.3
version: 2.4.4

environment:
sdk: ^3.10.0
Expand Down
14 changes: 14 additions & 0 deletions packages/vector_math/test/geometry_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@ void testTransformFilter() {
expect(position.storage[1].abs(), equals(2.0));
expect(position.storage[2].abs(), equals(2.0));
}

// Verify full affine transform (translation + per-axis scale).
final mesh = MeshGeometry(2, <VertexAttrib>[VertexAttrib('POSITION', 3, 'float')]);
final meshPositions = mesh.getViewForAttrib('POSITION')! as Vector3List;
meshPositions[0] = Vector3(1.0, 2.0, 3.0);
meshPositions[1] = Vector3(-4.0, 0.5, 2.0);

final affine = Matrix4.identity()
..translateByDouble(10.0, -5.0, 2.0, 1.0)
..scaleByDouble(2.0, 3.0, 0.5, 1.0);
TransformFilter(affine).filterInplace(mesh);

relativeTest(meshPositions[0], Vector3(12.0, 1.0, 3.5));
relativeTest(meshPositions[1], Vector3(2.0, -3.5, 3.0));
}

void testFlatShadeFilter() {
Expand Down
Loading