-
-
Notifications
You must be signed in to change notification settings - Fork 932
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(flame_3d): Add helpful extension functions to Vector
- Loading branch information
1 parent
e434baf
commit 2fcf59d
Showing
6 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:flame_3d/extensions.dart'; | ||
import 'package:flame_3d/game.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
group('Vector2 extensions', () { | ||
test('can convert back and forth to mutable', () { | ||
final src = Vector2(1, 2); | ||
|
||
final immutable = src.immutable; | ||
expect(immutable.x, 1); | ||
expect(immutable.y, 2); | ||
expect(immutable.storage, [1, 2]); | ||
|
||
final mutable = immutable.mutable; | ||
expect(mutable.x, 1); | ||
expect(mutable.y, 2); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'package:flame_3d/extensions.dart'; | ||
import 'package:flame_3d/game.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
group('Vector3 extensions', () { | ||
test('can convert back and forth to mutable', () { | ||
final src = Vector3(1, 2, 3); | ||
|
||
final immutable = src.immutable; | ||
expect(immutable.x, 1); | ||
expect(immutable.y, 2); | ||
expect(immutable.z, 3); | ||
expect(immutable.storage, [1, 2, 3]); | ||
|
||
final mutable = immutable.mutable; | ||
expect(mutable.x, 1); | ||
expect(mutable.y, 2); | ||
expect(mutable.z, 3); | ||
}); | ||
|
||
test('can subtract immutable vector3', () { | ||
final a = Vector3(0, 10, 0).immutable; | ||
final b = Vector3(1, 2, 3); | ||
|
||
expect((a - b).storage, [-1, 8, -3]); | ||
expect((a - b.immutable).storage, [-1, 8, -3]); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:flame_3d/extensions.dart'; | ||
import 'package:flame_3d/game.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
group('Vector4 extensions', () { | ||
test('can convert back and forth to mutable', () { | ||
final src = Vector4(1, 2, 3, 4); | ||
|
||
final immutable = src.immutable; | ||
expect(immutable.x, 1); | ||
expect(immutable.y, 2); | ||
expect(immutable.z, 3); | ||
expect(immutable.w, 4); | ||
expect(immutable.storage, [1, 2, 3, 4]); | ||
|
||
final mutable = immutable.mutable; | ||
expect(mutable.x, 1); | ||
expect(mutable.y, 2); | ||
expect(mutable.z, 3); | ||
expect(mutable.w, 4); | ||
}); | ||
}); | ||
} |