fix a number of lints (#214)
Ignore omit_local_variable_types – too many to fix for now
diff --git a/.travis.yml b/.travis.yml
index c7cf7e8..9c8e623 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,7 @@
language: dart
dart:
- - 2.1.0
+ - 2.3.0
- dev
script: ./tool/travis.sh
diff --git a/analysis_options.yaml b/analysis_options.yaml
index 9a02cf1..0509ed3 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -1,7 +1,11 @@
include: package:pedantic/analysis_options.yaml
+
analyzer:
# strong-mode:
# implicit-casts: false
+ errors:
+ omit_local_variable_types: ignore #1929 cases
+
linter:
rules:
- always_declare_return_types
diff --git a/benchmark/matrix4_tween_bench.dart b/benchmark/matrix4_tween_bench.dart
index 17b580c..7885013 100644
--- a/benchmark/matrix4_tween_bench.dart
+++ b/benchmark/matrix4_tween_bench.dart
@@ -22,11 +22,11 @@
@override
void run() {
- double sum_traces = 0;
- for (int i = 0; i <= 1024; i++) {
- double t = i / 1024.0;
- Matrix4 m1 = lerp(beginTransform, endTransform, t);
- Matrix4 m2 = lerp(endTransform, beginTransform, t);
+ var sum_traces = 0.0;
+ for (var i = 0; i <= 1024; i++) {
+ var t = i / 1024.0;
+ var m1 = lerp(beginTransform, endTransform, t);
+ var m2 = lerp(endTransform, beginTransform, t);
sum_traces += m1.trace();
sum_traces += m2.trace();
}
@@ -39,7 +39,7 @@
}
class Matrix4TweenBenchmark1 extends BenchmarkBase with Setup {
- Matrix4TweenBenchmark1() : super("Matrix4TweenBenchmark1");
+ Matrix4TweenBenchmark1() : super('Matrix4TweenBenchmark1');
@override
Matrix4 lerp(Matrix4 begin, Matrix4 end, double t) {
@@ -61,7 +61,7 @@
}
class Matrix4TweenBenchmark2 extends BenchmarkBase with Setup {
- Matrix4TweenBenchmark2() : super("Matrix4TweenBenchmark2");
+ Matrix4TweenBenchmark2() : super('Matrix4TweenBenchmark2');
@override
Matrix4 lerp(Matrix4 begin, Matrix4 end, double t) {
@@ -86,7 +86,7 @@
}
class Matrix4TweenBenchmark3 extends BenchmarkBase with Setup {
- Matrix4TweenBenchmark3() : super("Matrix4TweenBenchmark3");
+ Matrix4TweenBenchmark3() : super('Matrix4TweenBenchmark3');
@override
Matrix4 lerp(Matrix4 begin, Matrix4 end, double t) {
diff --git a/benchmark/matrix_bench.dart b/benchmark/matrix_bench.dart
index 247885d..6cc87bc 100644
--- a/benchmark/matrix_bench.dart
+++ b/benchmark/matrix_bench.dart
@@ -11,7 +11,7 @@
import 'package:benchmark_harness/benchmark_harness.dart';
class MatrixMultiplyBenchmark extends BenchmarkBase {
- MatrixMultiplyBenchmark() : super("MatrixMultiply");
+ MatrixMultiplyBenchmark() : super('MatrixMultiply');
final Float32List A = Float32List(16);
final Float32List B = Float32List(16);
final Float32List C = Float32List(16);
@@ -22,14 +22,14 @@
@override
void run() {
- for (int i = 0; i < 200; i++) {
+ for (var i = 0; i < 200; i++) {
Matrix44Operations.multiply(C, 0, A, 0, B, 0);
}
}
}
class SIMDMatrixMultiplyBenchmark extends BenchmarkBase {
- SIMDMatrixMultiplyBenchmark() : super("SIMDMatrixMultiply");
+ SIMDMatrixMultiplyBenchmark() : super('SIMDMatrixMultiply');
final Float32x4List A = Float32x4List(4);
final Float32x4List B = Float32x4List(4);
final Float32x4List C = Float32x4List(4);
@@ -40,14 +40,14 @@
@override
void run() {
- for (int i = 0; i < 200; i++) {
+ for (var i = 0; i < 200; i++) {
Matrix44SIMDOperations.multiply(C, 0, A, 0, B, 0);
}
}
}
class VectorTransformBenchmark extends BenchmarkBase {
- VectorTransformBenchmark() : super("VectorTransform");
+ VectorTransformBenchmark() : super('VectorTransform');
final Float32List A = Float32List(16);
final Float32List B = Float32List(4);
final Float32List C = Float32List(4);
@@ -58,14 +58,14 @@
@override
void run() {
- for (int i = 0; i < 200; i++) {
+ for (var i = 0; i < 200; i++) {
Matrix44Operations.transform4(C, 0, A, 0, B, 0);
}
}
}
class SIMDVectorTransformBenchmark extends BenchmarkBase {
- SIMDVectorTransformBenchmark() : super("SIMDVectorTransform");
+ SIMDVectorTransformBenchmark() : super('SIMDVectorTransform');
final Float32x4List A = Float32x4List(4);
final Float32x4List B = Float32x4List(1);
final Float32x4List C = Float32x4List(1);
@@ -76,14 +76,14 @@
@override
void run() {
- for (int i = 0; i < 200; i++) {
+ for (var i = 0; i < 200; i++) {
Matrix44SIMDOperations.transform4(C, 0, A, 0, B, 0);
}
}
}
class ViewMatrixBenchmark extends BenchmarkBase {
- ViewMatrixBenchmark() : super("setViewMatrix");
+ ViewMatrixBenchmark() : super('setViewMatrix');
final Matrix4 M = Matrix4.zero();
final Vector3 P = Vector3.zero();
@@ -96,14 +96,14 @@
@override
void run() {
- for (int i = 0; i < 100; i++) {
+ for (var i = 0; i < 100; i++) {
setViewMatrix(M, P, F, U);
}
}
}
class Aabb2TransformBenchmark extends BenchmarkBase {
- Aabb2TransformBenchmark() : super("aabb2Transform");
+ Aabb2TransformBenchmark() : super('aabb2Transform');
static final Matrix3 M = Matrix3.rotationZ(math.pi / 4);
static final Vector2 P1 = Vector2(10.0, 10.0);
@@ -120,7 +120,7 @@
@override
void run() {
- for (int i = 0; i < 100; i++) {
+ for (var i = 0; i < 100; i++) {
temp.copyFrom(B1);
temp.transform(M);
temp.copyFrom(B2);
@@ -132,7 +132,7 @@
}
class Aabb2RotateBenchmark extends BenchmarkBase {
- Aabb2RotateBenchmark() : super("aabb2Rotate");
+ Aabb2RotateBenchmark() : super('aabb2Rotate');
static final Matrix3 M = Matrix3.rotationZ(math.pi / 4);
static final Vector2 P1 = Vector2(10.0, 10.0);
@@ -149,7 +149,7 @@
@override
void run() {
- for (int i = 0; i < 100; i++) {
+ for (var i = 0; i < 100; i++) {
temp.copyFrom(B1);
temp.rotate(M);
temp.copyFrom(B2);
@@ -161,7 +161,7 @@
}
class Aabb3TransformBenchmark extends BenchmarkBase {
- Aabb3TransformBenchmark() : super("aabb3Transform");
+ Aabb3TransformBenchmark() : super('aabb3Transform');
static final Matrix4 M = Matrix4.rotationZ(math.pi / 4);
static final Vector3 P1 = Vector3(10.0, 10.0, 0.0);
@@ -178,7 +178,7 @@
@override
void run() {
- for (int i = 0; i < 100; i++) {
+ for (var i = 0; i < 100; i++) {
temp.copyFrom(B1);
temp.transform(M);
temp.copyFrom(B2);
@@ -190,7 +190,7 @@
}
class Aabb3RotateBenchmark extends BenchmarkBase {
- Aabb3RotateBenchmark() : super("aabb3Rotate");
+ Aabb3RotateBenchmark() : super('aabb3Rotate');
static final Matrix4 M = Matrix4.rotationZ(math.pi / 4);
static final Vector3 P1 = Vector3(10.0, 10.0, 0.0);
@@ -207,7 +207,7 @@
@override
void run() {
- for (int i = 0; i < 100; i++) {
+ for (var i = 0; i < 100; i++) {
temp.copyFrom(B1);
temp.rotate(M);
temp.copyFrom(B2);
@@ -219,7 +219,7 @@
}
class Matrix3DeterminantBenchmark extends BenchmarkBase {
- Matrix3DeterminantBenchmark() : super("Matrix3.determinant");
+ Matrix3DeterminantBenchmark() : super('Matrix3.determinant');
final Matrix3 MX = Matrix3.rotationX(math.pi / 4);
final Matrix3 MY = Matrix3.rotationY(math.pi / 4);
@@ -231,7 +231,7 @@
@override
void run() {
- for (int i = 0; i < 800; i++) {
+ for (var i = 0; i < 800; i++) {
MX.determinant();
MY.determinant();
MZ.determinant();
@@ -240,7 +240,7 @@
}
class Matrix3TransformVector3Benchmark extends BenchmarkBase {
- Matrix3TransformVector3Benchmark() : super("Matrix3.transform(Vector3)");
+ Matrix3TransformVector3Benchmark() : super('Matrix3.transform(Vector3)');
final Matrix3 MX = Matrix3.rotationX(math.pi / 4);
final Matrix3 MY = Matrix3.rotationY(math.pi / 4);
@@ -255,7 +255,7 @@
@override
void run() {
- for (int i = 0; i < 800; i++) {
+ for (var i = 0; i < 800; i++) {
MX.transform(V1);
MX.transform(V2);
MX.transform(V3);
@@ -270,7 +270,7 @@
}
class Matrix3TransformVector2Benchmark extends BenchmarkBase {
- Matrix3TransformVector2Benchmark() : super("Matrix3.transform(Vector2)");
+ Matrix3TransformVector2Benchmark() : super('Matrix3.transform(Vector2)');
final Matrix3 MX = Matrix3.rotationX(math.pi / 4);
final Matrix3 MY = Matrix3.rotationY(math.pi / 4);
@@ -285,7 +285,7 @@
@override
void run() {
- for (int i = 0; i < 800; i++) {
+ for (var i = 0; i < 800; i++) {
MX.transform2(V1);
MX.transform2(V2);
MX.transform2(V3);
@@ -300,7 +300,7 @@
}
class Matrix3TransposeMultiplyBenchmark extends BenchmarkBase {
- Matrix3TransposeMultiplyBenchmark() : super("Matrix3.transposeMultiply");
+ Matrix3TransposeMultiplyBenchmark() : super('Matrix3.transposeMultiply');
final Matrix3 MX = Matrix3.rotationX(math.pi / 4);
final Matrix3 MY = Matrix3.rotationY(math.pi / 4);
@@ -313,7 +313,7 @@
@override
void run() {
- for (int i = 0; i < 100; i++) {
+ for (var i = 0; i < 100; i++) {
temp.setIdentity();
temp.transposeMultiply(MX);
temp.transposeMultiply(MY);
diff --git a/changelog.md b/changelog.md
index 0213cc3..0884bd9 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,6 +1,6 @@
## 2.0.9
-- Update Dart SDK constraint to `>=2.1.0 <3.0.0`.
+- Update Dart SDK constraint to `>=2.3.0 <3.0.0`.
- Improve performance of Matrix4.decompose by reusing objects.
## v 2.0.8 - July 2018
diff --git a/lib/src/vector_math/aabb3.dart b/lib/src/vector_math/aabb3.dart
index 7102e2b..f3f21b1 100644
--- a/lib/src/vector_math/aabb3.dart
+++ b/lib/src/vector_math/aabb3.dart
@@ -341,10 +341,10 @@
bool intersectsWithSphere(Sphere other) {
final Vector3 center = other._center;
final double radius = other.radius;
- double d = 0.0;
- double e = 0.0;
+ var d = 0.0;
+ var e = 0.0;
- for (int i = 0; i < 3; ++i) {
+ for (var i = 0; i < 3; ++i) {
if ((e = center[i] - _min[i]) < 0.0) {
if (e < -radius) {
return false;
diff --git a/lib/src/vector_math/colors.dart b/lib/src/vector_math/colors.dart
index 614ad82..bbb14e4 100644
--- a/lib/src/vector_math/colors.dart
+++ b/lib/src/vector_math/colors.dart
@@ -168,7 +168,7 @@
final double d = max - min;
final double v = max;
final double s = max == 0.0 ? 0.0 : d / max;
- double h = 0.0;
+ var h = 0.0;
if (max != min) {
if (max == rgbColor.r) {
@@ -223,8 +223,8 @@
final double max = math.max(math.max(rgbColor.r, rgbColor.g), rgbColor.b);
final double min = math.min(math.min(rgbColor.r, rgbColor.g), rgbColor.b);
final double l = (max + min) / 2.0;
- double h = 0.0;
- double s = 0.0;
+ var h = 0.0;
+ var s = 0.0;
if (max != min) {
final double d = max - min;
diff --git a/lib/src/vector_math/matrix2.dart b/lib/src/vector_math/matrix2.dart
index dc61b10..e823b90 100644
--- a/lib/src/vector_math/matrix2.dart
+++ b/lib/src/vector_math/matrix2.dart
@@ -20,7 +20,7 @@
final double a22 = A.entry(1, 1);
final double bx = b.x;
final double by = b.y;
- double det = a11 * a22 - a12 * a21;
+ var det = a11 * a22 - a12 * a21;
if (det != 0.0) {
det = 1.0 / det;
@@ -292,7 +292,7 @@
/// Trace of the matrix.
double trace() {
- double t = 0.0;
+ var t = 0.0;
t += _m2storage[0];
t += _m2storage[3];
return t;
@@ -300,15 +300,15 @@
/// Returns infinity norm of the matrix. Used for numerical analysis.
double infinityNorm() {
- double norm = 0.0;
+ var norm = 0.0;
{
- double rowNorm = 0.0;
+ var rowNorm = 0.0;
rowNorm += _m2storage[0].abs();
rowNorm += _m2storage[1].abs();
norm = rowNorm > norm ? rowNorm : norm;
}
{
- double rowNorm = 0.0;
+ var rowNorm = 0.0;
rowNorm += _m2storage[2].abs();
rowNorm += _m2storage[3].abs();
norm = rowNorm > norm ? rowNorm : norm;
diff --git a/lib/src/vector_math/matrix3.dart b/lib/src/vector_math/matrix3.dart
index e695b0e..aacbb73 100644
--- a/lib/src/vector_math/matrix3.dart
+++ b/lib/src/vector_math/matrix3.dart
@@ -20,7 +20,7 @@
final double a22 = A.entry(1, 1);
final double bx = b.x - A.storage[6];
final double by = b.y - A.storage[7];
- double det = a11 * a22 - a12 * a21;
+ var det = a11 * a22 - a12 * a21;
if (det != 0.0) {
det = 1.0 / det;
@@ -437,7 +437,7 @@
/// Returns the trace of the matrix. The trace of a matrix is the sum of
/// the diagonal entries.
double trace() {
- double t = 0.0;
+ var t = 0.0;
t += _m3storage[0];
t += _m3storage[4];
t += _m3storage[8];
@@ -446,23 +446,23 @@
/// Returns infinity norm of the matrix. Used for numerical analysis.
double infinityNorm() {
- double norm = 0.0;
+ var norm = 0.0;
{
- double row_norm = 0.0;
+ var row_norm = 0.0;
row_norm += _m3storage[0].abs();
row_norm += _m3storage[1].abs();
row_norm += _m3storage[2].abs();
norm = row_norm > norm ? row_norm : norm;
}
{
- double row_norm = 0.0;
+ var row_norm = 0.0;
row_norm += _m3storage[3].abs();
row_norm += _m3storage[4].abs();
row_norm += _m3storage[5].abs();
norm = row_norm > norm ? row_norm : norm;
}
{
- double row_norm = 0.0;
+ var row_norm = 0.0;
row_norm += _m3storage[6].abs();
row_norm += _m3storage[7].abs();
row_norm += _m3storage[8].abs();
diff --git a/lib/src/vector_math/matrix4.dart b/lib/src/vector_math/matrix4.dart
index 776833c..9759d69 100644
--- a/lib/src/vector_math/matrix4.dart
+++ b/lib/src/vector_math/matrix4.dart
@@ -20,7 +20,7 @@
final double a22 = A.entry(1, 1);
final double bx = b.x - A._m4storage[8];
final double by = b.y - A._m4storage[9];
- double det = a11 * a22 - a12 * a21;
+ var det = a11 * a22 - a12 * a21;
if (det != 0.0) {
det = 1.0 / det;
@@ -118,7 +118,7 @@
final double bZ = b.storage[2];
final double bW = b.storage[3];
- double det =
+ var det =
b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
if (det != 0.0) {
@@ -1052,7 +1052,7 @@
/// Returns the trace of the matrix. The trace of a matrix is the sum of the
/// diagonal entries.
double trace() {
- double t = 0.0;
+ var t = 0.0;
t += _m4storage[0];
t += _m4storage[5];
t += _m4storage[10];
@@ -1062,9 +1062,9 @@
/// Returns infinity norm of the matrix. Used for numerical analysis.
double infinityNorm() {
- double norm = 0.0;
+ var norm = 0.0;
{
- double row_norm = 0.0;
+ var row_norm = 0.0;
row_norm += _m4storage[0].abs();
row_norm += _m4storage[1].abs();
row_norm += _m4storage[2].abs();
@@ -1072,7 +1072,7 @@
norm = row_norm > norm ? row_norm : norm;
}
{
- double row_norm = 0.0;
+ var row_norm = 0.0;
row_norm += _m4storage[4].abs();
row_norm += _m4storage[5].abs();
row_norm += _m4storage[6].abs();
@@ -1080,7 +1080,7 @@
norm = row_norm > norm ? row_norm : norm;
}
{
- double row_norm = 0.0;
+ var row_norm = 0.0;
row_norm += _m4storage[8].abs();
row_norm += _m4storage[9].abs();
row_norm += _m4storage[10].abs();
@@ -1088,7 +1088,7 @@
norm = row_norm > norm ? row_norm : norm;
}
{
- double row_norm = 0.0;
+ var row_norm = 0.0;
row_norm += _m4storage[12].abs();
row_norm += _m4storage[13].abs();
row_norm += _m4storage[14].abs();
@@ -1775,8 +1775,7 @@
/// Decomposes this into [translation], [rotation] and [scale] components.
void decompose(Vector3 translation, Quaternion rotation, Vector3 scale) {
final Vector3 v = _decomposeV ??= Vector3.zero();
- double sx =
- (v..setValues(_m4storage[0], _m4storage[1], _m4storage[2])).length;
+ var sx = (v..setValues(_m4storage[0], _m4storage[1], _m4storage[2])).length;
final double sy =
(v..setValues(_m4storage[4], _m4storage[5], _m4storage[6])).length;
final double sz =
diff --git a/lib/src/vector_math/obb3.dart b/lib/src/vector_math/obb3.dart
index 1d42bfe..e80b345 100644
--- a/lib/src/vector_math/obb3.dart
+++ b/lib/src/vector_math/obb3.dart
@@ -173,7 +173,7 @@
q.setFrom(_center);
- double dist = d.dot(_axis0);
+ var dist = d.dot(_axis0);
dist = dist.clamp(-_halfExtents.x, _halfExtents.x).toDouble();
q.addScaled(_axis0, dist);
@@ -216,8 +216,8 @@
// Compute common subexpressions. Add in an epsilon term to
// counteract arithmetic errors when two edges are parallel and
// their cross product is (near) null.
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 3; j++) {
+ for (var i = 0; i < 3; i++) {
+ for (var j = 0; j < 3; j++) {
_absR.setEntry(i, j, _r.entry(i, j).abs() + epsilon);
}
}
@@ -226,7 +226,7 @@
double rb;
// Test axes L = A0, L = A1, L = A2
- for (int i = 0; i < 3; i++) {
+ for (var i = 0; i < 3; i++) {
ra = _halfExtents[i];
rb = other._halfExtents[0] * _absR.entry(i, 0) +
other._halfExtents[1] * _absR.entry(i, 1) +
@@ -238,7 +238,7 @@
}
// Test axes L = B0, L = B1, L = B2
- for (int i = 0; i < 3; i++) {
+ for (var i = 0; i < 3; i++) {
ra = _halfExtents[0] * _absR.entry(0, i) +
_halfExtents[1] * _absR.entry(1, i) +
_halfExtents[2] * _absR.entry(2, i);
diff --git a/lib/src/vector_math/opengl.dart b/lib/src/vector_math/opengl.dart
index 6d93fb1..d5565e8 100644
--- a/lib/src/vector_math/opengl.dart
+++ b/lib/src/vector_math/opengl.dart
@@ -264,7 +264,7 @@
final Vector4 v = Vector4(planeNormal.storage[0], planeNormal.storage[1],
planeNormal.storage[2], 0.0);
final Matrix4 outer = Matrix4.outer(v, v);
- Matrix4 r = Matrix4.zero();
+ var r = Matrix4.zero();
r = r - outer;
final Vector3 scaledNormal =
planeNormal.scaled(dot3(planePoint, planeNormal));
@@ -280,7 +280,7 @@
final Vector4 v = Vector4(planeNormal.storage[0], planeNormal.storage[1],
planeNormal.storage[2], 0.0);
final Matrix4 outer = Matrix4.outer(v, v)..scale(2.0);
- Matrix4 r = Matrix4.zero();
+ var r = Matrix4.zero();
r = r - outer;
final double scale = 2.0 * planePoint.dot(planeNormal);
final Vector3 scaledNormal = planeNormal.scaled(scale);
diff --git a/lib/src/vector_math/quaternion.dart b/lib/src/vector_math/quaternion.dart
index 79e6b53..cd942d6 100644
--- a/lib/src/vector_math/quaternion.dart
+++ b/lib/src/vector_math/quaternion.dart
@@ -126,7 +126,7 @@
final Float32List rotationMatrixStorage = rotationMatrix.storage;
final double trace = rotationMatrix.trace();
if (trace > 0.0) {
- double s = math.sqrt(trace + 1.0);
+ var s = math.sqrt(trace + 1.0);
_qStorage[3] = s * 0.5;
s = 0.5 / s;
_qStorage[0] = (rotationMatrixStorage[5] - rotationMatrixStorage[7]) * s;
@@ -138,7 +138,7 @@
: (rotationMatrixStorage[0] < rotationMatrixStorage[8] ? 2 : 0);
final int j = (i + 1) % 3;
final int k = (i + 2) % 3;
- double s = math.sqrt(rotationMatrixStorage[rotationMatrix.index(i, i)] -
+ var s = math.sqrt(rotationMatrixStorage[rotationMatrix.index(i, i)] -
rotationMatrixStorage[rotationMatrix.index(j, j)] -
rotationMatrixStorage[rotationMatrix.index(k, k)] +
1.0);
@@ -161,8 +161,8 @@
final Vector3 v2 = b.normalized();
final double c = v1.dot(v2);
- double angle = math.acos(c);
- Vector3 axis = v1.cross(v2);
+ var angle = math.acos(c);
+ var axis = v1.cross(v2);
if ((1.0 + c).abs() < 0.0005) {
// c \approx -1 indicates 180 degree rotation
diff --git a/lib/src/vector_math/ray.dart b/lib/src/vector_math/ray.dart
index d4ee7da..b91394a 100644
--- a/lib/src/vector_math/ray.dart
+++ b/lib/src/vector_math/ray.dart
@@ -128,9 +128,9 @@
const double epsilon = 10e-6;
// First triangle
- Vector3 point0 = other._point0;
- Vector3 point1 = other._point1;
- Vector3 point2 = other._point2;
+ var point0 = other._point0;
+ var point1 = other._point1;
+ var point2 = other._point2;
_e1
..setFrom(point1)
@@ -204,17 +204,17 @@
final Vector3 otherMin = other.min;
final Vector3 otherMax = other.max;
- double tNear = -double.maxFinite;
- double tFar = double.maxFinite;
+ var tNear = -double.maxFinite;
+ var tFar = double.maxFinite;
- for (int i = 0; i < 3; ++i) {
+ for (var i = 0; i < 3; ++i) {
if (_direction[i] == 0.0) {
if (_origin[i] < otherMin[i] || _origin[i] > otherMax[i]) {
return null;
}
} else {
- double t1 = (otherMin[i] - _origin[i]) / _direction[i];
- double t2 = (otherMax[i] - _origin[i]) / _direction[i];
+ var t1 = (otherMin[i] - _origin[i]) / _direction[i];
+ var t2 = (otherMax[i] - _origin[i]) / _direction[i];
if (t1 > t2) {
final double temp = t1;
diff --git a/lib/src/vector_math/third_party/noise.dart b/lib/src/vector_math/third_party/noise.dart
index 101d183..1931ae1 100644
--- a/lib/src/vector_math/third_party/noise.dart
+++ b/lib/src/vector_math/third_party/noise.dart
@@ -146,7 +146,7 @@
final int gi1 = _permMod12[ii + i1 + _perm[jj + j1]];
final int gi2 = _permMod12[ii + 1 + _perm[jj + 1]];
// Calculate the contribution from the three corners
- double t0 = 0.5 - x0 * x0 - y0 * y0;
+ var t0 = 0.5 - x0 * x0 - y0 * y0;
if (t0 < 0) {
n0 = 0.0;
} else {
@@ -155,14 +155,14 @@
t0 *
_dot2(_grad3[gi0], x0, y0); // (x,y) of grad3 used for 2D gradient
}
- double t1 = 0.5 - x1 * x1 - y1 * y1;
+ var t1 = 0.5 - x1 * x1 - y1 * y1;
if (t1 < 0) {
n1 = 0.0;
} else {
t1 *= t1;
n1 = t1 * t1 * _dot2(_grad3[gi1], x1, y1);
}
- double t2 = 0.5 - x2 * x2 - y2 * y2;
+ var t2 = 0.5 - x2 * x2 - y2 * y2;
if (t2 < 0) {
n2 = 0.0;
} else {
@@ -271,28 +271,28 @@
final int gi2 = _permMod12[ii + i2 + _perm[jj + j2 + _perm[kk + k2]]];
final int gi3 = _permMod12[ii + 1 + _perm[jj + 1 + _perm[kk + 1]]];
// Calculate the contribution from the four corners
- double t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0;
+ var t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0;
if (t0 < 0) {
n0 = 0.0;
} else {
t0 *= t0;
n0 = t0 * t0 * _dot3(_grad3[gi0], x0, y0, z0);
}
- double t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1;
+ var t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1;
if (t1 < 0) {
n1 = 0.0;
} else {
t1 *= t1;
n1 = t1 * t1 * _dot3(_grad3[gi1], x1, y1, z1);
}
- double t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2;
+ var t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2;
if (t2 < 0) {
n2 = 0.0;
} else {
t2 *= t2;
n2 = t2 * t2 * _dot3(_grad3[gi2], x2, y2, z2);
}
- double t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3;
+ var t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3;
if (t3 < 0) {
n3 = 0.0;
} else {
@@ -327,10 +327,10 @@
// determine the magnitude ordering of x0, y0, z0 and w0.
// Six pair-wise comparisons are performed between each possible pair
// of the four coordinates, and the results are used to rank the numbers.
- int rankx = 0;
- int ranky = 0;
- int rankz = 0;
- int rankw = 0;
+ var rankx = 0;
+ var ranky = 0;
+ var rankz = 0;
+ var rankw = 0;
if (x0 > y0) {
rankx++;
} else {
@@ -419,35 +419,35 @@
final int gi4 =
_perm[ii + 1 + _perm[jj + 1 + _perm[kk + 1 + _perm[ll + 1]]]] % 32;
// Calculate the contribution from the five corners
- double t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0;
+ var t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0;
if (t0 < 0) {
n0 = 0.0;
} else {
t0 *= t0;
n0 = t0 * t0 * _dot4(_grad4[gi0], x0, y0, z0, w0);
}
- double t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1;
+ var t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1;
if (t1 < 0) {
n1 = 0.0;
} else {
t1 *= t1;
n1 = t1 * t1 * _dot4(_grad4[gi1], x1, y1, z1, w1);
}
- double t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2;
+ var t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2;
if (t2 < 0) {
n2 = 0.0;
} else {
t2 *= t2;
n2 = t2 * t2 * _dot4(_grad4[gi2], x2, y2, z2, w2);
}
- double t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3;
+ var t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3;
if (t3 < 0) {
n3 = 0.0;
} else {
t3 *= t3;
n3 = t3 * t3 * _dot4(_grad4[gi3], x3, y3, z3, w3);
}
- double t4 = 0.6 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4;
+ var t4 = 0.6 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4;
if (t4 < 0) {
n4 = 0.0;
} else {
diff --git a/lib/src/vector_math/vector2.dart b/lib/src/vector_math/vector2.dart
index a0df4c8..3eda468 100644
--- a/lib/src/vector_math/vector2.dart
+++ b/lib/src/vector_math/vector2.dart
@@ -133,7 +133,7 @@
if (value == 0.0) {
setZero();
} else {
- double l = length;
+ var l = length;
if (l == 0.0) {
return;
}
@@ -273,7 +273,7 @@
/// True if any component is infinite.
bool get isInfinite {
- bool is_infinite = false;
+ var is_infinite = false;
is_infinite = is_infinite || _v2storage[0].isInfinite;
is_infinite = is_infinite || _v2storage[1].isInfinite;
return is_infinite;
@@ -281,7 +281,7 @@
/// True if any component is NaN.
bool get isNaN {
- bool is_nan = false;
+ var is_nan = false;
is_nan = is_nan || _v2storage[0].isNaN;
is_nan = is_nan || _v2storage[1].isNaN;
return is_nan;
diff --git a/lib/src/vector_math/vector3.dart b/lib/src/vector_math/vector3.dart
index 89b50e1..2f8811e 100644
--- a/lib/src/vector_math/vector3.dart
+++ b/lib/src/vector_math/vector3.dart
@@ -142,7 +142,7 @@
if (value == 0.0) {
setZero();
} else {
- double l = length;
+ var l = length;
if (l == 0.0) {
return;
}
@@ -394,7 +394,7 @@
/// True if any component is infinite.
bool get isInfinite {
- bool is_infinite = false;
+ var is_infinite = false;
is_infinite = is_infinite || _v3storage[0].isInfinite;
is_infinite = is_infinite || _v3storage[1].isInfinite;
is_infinite = is_infinite || _v3storage[2].isInfinite;
@@ -403,7 +403,7 @@
/// True if any component is NaN.
bool get isNaN {
- bool isNan = false;
+ var isNan = false;
isNan = isNan || _v3storage[0].isNaN;
isNan = isNan || _v3storage[1].isNaN;
isNan = isNan || _v3storage[2].isNaN;
diff --git a/lib/src/vector_math/vector4.dart b/lib/src/vector_math/vector4.dart
index d870e38..3075296 100644
--- a/lib/src/vector_math/vector4.dart
+++ b/lib/src/vector_math/vector4.dart
@@ -163,7 +163,7 @@
if (value == 0.0) {
setZero();
} else {
- double l = length;
+ var l = length;
if (l == 0.0) {
return;
}
@@ -280,7 +280,7 @@
/// True if any component is infinite.
bool get isInfinite {
- bool is_infinite = false;
+ var is_infinite = false;
is_infinite = is_infinite || _v4storage[0].isInfinite;
is_infinite = is_infinite || _v4storage[1].isInfinite;
is_infinite = is_infinite || _v4storage[2].isInfinite;
@@ -290,7 +290,7 @@
/// True if any component is NaN.
bool get isNaN {
- bool is_nan = false;
+ var is_nan = false;
is_nan = is_nan || _v4storage[0].isNaN;
is_nan = is_nan || _v4storage[1].isNaN;
is_nan = is_nan || _v4storage[2].isNaN;
diff --git a/lib/src/vector_math_64/aabb3.dart b/lib/src/vector_math_64/aabb3.dart
index ab5cc5c..cc8b10d 100644
--- a/lib/src/vector_math_64/aabb3.dart
+++ b/lib/src/vector_math_64/aabb3.dart
@@ -341,10 +341,10 @@
bool intersectsWithSphere(Sphere other) {
final Vector3 center = other._center;
final double radius = other.radius;
- double d = 0.0;
- double e = 0.0;
+ var d = 0.0;
+ var e = 0.0;
- for (int i = 0; i < 3; ++i) {
+ for (var i = 0; i < 3; ++i) {
if ((e = center[i] - _min[i]) < 0.0) {
if (e < -radius) {
return false;
diff --git a/lib/src/vector_math_64/colors.dart b/lib/src/vector_math_64/colors.dart
index 1653de0..38cfc12 100644
--- a/lib/src/vector_math_64/colors.dart
+++ b/lib/src/vector_math_64/colors.dart
@@ -168,7 +168,7 @@
final double d = max - min;
final double v = max;
final double s = max == 0.0 ? 0.0 : d / max;
- double h = 0.0;
+ var h = 0.0;
if (max != min) {
if (max == rgbColor.r) {
@@ -223,8 +223,8 @@
final double max = math.max(math.max(rgbColor.r, rgbColor.g), rgbColor.b);
final double min = math.min(math.min(rgbColor.r, rgbColor.g), rgbColor.b);
final double l = (max + min) / 2.0;
- double h = 0.0;
- double s = 0.0;
+ var h = 0.0;
+ var s = 0.0;
if (max != min) {
final double d = max - min;
diff --git a/lib/src/vector_math_64/matrix2.dart b/lib/src/vector_math_64/matrix2.dart
index e727472..9d8c785 100644
--- a/lib/src/vector_math_64/matrix2.dart
+++ b/lib/src/vector_math_64/matrix2.dart
@@ -20,7 +20,7 @@
final double a22 = A.entry(1, 1);
final double bx = b.x;
final double by = b.y;
- double det = a11 * a22 - a12 * a21;
+ var det = a11 * a22 - a12 * a21;
if (det != 0.0) {
det = 1.0 / det;
@@ -292,7 +292,7 @@
/// Trace of the matrix.
double trace() {
- double t = 0.0;
+ var t = 0.0;
t += _m2storage[0];
t += _m2storage[3];
return t;
@@ -300,15 +300,15 @@
/// Returns infinity norm of the matrix. Used for numerical analysis.
double infinityNorm() {
- double norm = 0.0;
+ var norm = 0.0;
{
- double rowNorm = 0.0;
+ var rowNorm = 0.0;
rowNorm += _m2storage[0].abs();
rowNorm += _m2storage[1].abs();
norm = rowNorm > norm ? rowNorm : norm;
}
{
- double rowNorm = 0.0;
+ var rowNorm = 0.0;
rowNorm += _m2storage[2].abs();
rowNorm += _m2storage[3].abs();
norm = rowNorm > norm ? rowNorm : norm;
diff --git a/lib/src/vector_math_64/matrix3.dart b/lib/src/vector_math_64/matrix3.dart
index e490490..117dc8b 100644
--- a/lib/src/vector_math_64/matrix3.dart
+++ b/lib/src/vector_math_64/matrix3.dart
@@ -20,7 +20,7 @@
final double a22 = A.entry(1, 1);
final double bx = b.x - A.storage[6];
final double by = b.y - A.storage[7];
- double det = a11 * a22 - a12 * a21;
+ var det = a11 * a22 - a12 * a21;
if (det != 0.0) {
det = 1.0 / det;
@@ -437,7 +437,7 @@
/// Returns the trace of the matrix. The trace of a matrix is the sum of
/// the diagonal entries.
double trace() {
- double t = 0.0;
+ var t = 0.0;
t += _m3storage[0];
t += _m3storage[4];
t += _m3storage[8];
@@ -446,23 +446,23 @@
/// Returns infinity norm of the matrix. Used for numerical analysis.
double infinityNorm() {
- double norm = 0.0;
+ var norm = 0.0;
{
- double row_norm = 0.0;
+ var row_norm = 0.0;
row_norm += _m3storage[0].abs();
row_norm += _m3storage[1].abs();
row_norm += _m3storage[2].abs();
norm = row_norm > norm ? row_norm : norm;
}
{
- double row_norm = 0.0;
+ var row_norm = 0.0;
row_norm += _m3storage[3].abs();
row_norm += _m3storage[4].abs();
row_norm += _m3storage[5].abs();
norm = row_norm > norm ? row_norm : norm;
}
{
- double row_norm = 0.0;
+ var row_norm = 0.0;
row_norm += _m3storage[6].abs();
row_norm += _m3storage[7].abs();
row_norm += _m3storage[8].abs();
diff --git a/lib/src/vector_math_64/matrix4.dart b/lib/src/vector_math_64/matrix4.dart
index 35f98ff..838d6d9 100644
--- a/lib/src/vector_math_64/matrix4.dart
+++ b/lib/src/vector_math_64/matrix4.dart
@@ -20,7 +20,7 @@
final double a22 = A.entry(1, 1);
final double bx = b.x - A._m4storage[8];
final double by = b.y - A._m4storage[9];
- double det = a11 * a22 - a12 * a21;
+ var det = a11 * a22 - a12 * a21;
if (det != 0.0) {
det = 1.0 / det;
@@ -118,7 +118,7 @@
final double bZ = b.storage[2];
final double bW = b.storage[3];
- double det =
+ var det =
b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
if (det != 0.0) {
@@ -1052,7 +1052,7 @@
/// Returns the trace of the matrix. The trace of a matrix is the sum of the
/// diagonal entries.
double trace() {
- double t = 0.0;
+ var t = 0.0;
t += _m4storage[0];
t += _m4storage[5];
t += _m4storage[10];
@@ -1062,9 +1062,9 @@
/// Returns infinity norm of the matrix. Used for numerical analysis.
double infinityNorm() {
- double norm = 0.0;
+ var norm = 0.0;
{
- double row_norm = 0.0;
+ var row_norm = 0.0;
row_norm += _m4storage[0].abs();
row_norm += _m4storage[1].abs();
row_norm += _m4storage[2].abs();
@@ -1072,7 +1072,7 @@
norm = row_norm > norm ? row_norm : norm;
}
{
- double row_norm = 0.0;
+ var row_norm = 0.0;
row_norm += _m4storage[4].abs();
row_norm += _m4storage[5].abs();
row_norm += _m4storage[6].abs();
@@ -1080,7 +1080,7 @@
norm = row_norm > norm ? row_norm : norm;
}
{
- double row_norm = 0.0;
+ var row_norm = 0.0;
row_norm += _m4storage[8].abs();
row_norm += _m4storage[9].abs();
row_norm += _m4storage[10].abs();
@@ -1088,7 +1088,7 @@
norm = row_norm > norm ? row_norm : norm;
}
{
- double row_norm = 0.0;
+ var row_norm = 0.0;
row_norm += _m4storage[12].abs();
row_norm += _m4storage[13].abs();
row_norm += _m4storage[14].abs();
@@ -1775,8 +1775,7 @@
/// Decomposes this into [translation], [rotation] and [scale] components.
void decompose(Vector3 translation, Quaternion rotation, Vector3 scale) {
final Vector3 v = _decomposeV ??= Vector3.zero();
- double sx =
- (v..setValues(_m4storage[0], _m4storage[1], _m4storage[2])).length;
+ var sx = (v..setValues(_m4storage[0], _m4storage[1], _m4storage[2])).length;
final double sy =
(v..setValues(_m4storage[4], _m4storage[5], _m4storage[6])).length;
final double sz =
diff --git a/lib/src/vector_math_64/obb3.dart b/lib/src/vector_math_64/obb3.dart
index 49059dc..3cb5eca 100644
--- a/lib/src/vector_math_64/obb3.dart
+++ b/lib/src/vector_math_64/obb3.dart
@@ -173,7 +173,7 @@
q.setFrom(_center);
- double dist = d.dot(_axis0);
+ var dist = d.dot(_axis0);
dist = dist.clamp(-_halfExtents.x, _halfExtents.x).toDouble();
q.addScaled(_axis0, dist);
@@ -216,8 +216,8 @@
// Compute common subexpressions. Add in an epsilon term to
// counteract arithmetic errors when two edges are parallel and
// their cross product is (near) null.
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 3; j++) {
+ for (var i = 0; i < 3; i++) {
+ for (var j = 0; j < 3; j++) {
_absR.setEntry(i, j, _r.entry(i, j).abs() + epsilon);
}
}
@@ -226,7 +226,7 @@
double rb;
// Test axes L = A0, L = A1, L = A2
- for (int i = 0; i < 3; i++) {
+ for (var i = 0; i < 3; i++) {
ra = _halfExtents[i];
rb = other._halfExtents[0] * _absR.entry(i, 0) +
other._halfExtents[1] * _absR.entry(i, 1) +
@@ -238,7 +238,7 @@
}
// Test axes L = B0, L = B1, L = B2
- for (int i = 0; i < 3; i++) {
+ for (var i = 0; i < 3; i++) {
ra = _halfExtents[0] * _absR.entry(0, i) +
_halfExtents[1] * _absR.entry(1, i) +
_halfExtents[2] * _absR.entry(2, i);
diff --git a/lib/src/vector_math_64/opengl.dart b/lib/src/vector_math_64/opengl.dart
index c34e5ed..b9160a0 100644
--- a/lib/src/vector_math_64/opengl.dart
+++ b/lib/src/vector_math_64/opengl.dart
@@ -264,7 +264,7 @@
final Vector4 v = Vector4(planeNormal.storage[0], planeNormal.storage[1],
planeNormal.storage[2], 0.0);
final Matrix4 outer = Matrix4.outer(v, v);
- Matrix4 r = Matrix4.zero();
+ var r = Matrix4.zero();
r = r - outer;
final Vector3 scaledNormal =
planeNormal.scaled(dot3(planePoint, planeNormal));
@@ -280,7 +280,7 @@
final Vector4 v = Vector4(planeNormal.storage[0], planeNormal.storage[1],
planeNormal.storage[2], 0.0);
final Matrix4 outer = Matrix4.outer(v, v)..scale(2.0);
- Matrix4 r = Matrix4.zero();
+ var r = Matrix4.zero();
r = r - outer;
final double scale = 2.0 * planePoint.dot(planeNormal);
final Vector3 scaledNormal = planeNormal.scaled(scale);
diff --git a/lib/src/vector_math_64/quaternion.dart b/lib/src/vector_math_64/quaternion.dart
index 85da6ec..d6508e6 100644
--- a/lib/src/vector_math_64/quaternion.dart
+++ b/lib/src/vector_math_64/quaternion.dart
@@ -126,7 +126,7 @@
final Float64List rotationMatrixStorage = rotationMatrix.storage;
final double trace = rotationMatrix.trace();
if (trace > 0.0) {
- double s = math.sqrt(trace + 1.0);
+ var s = math.sqrt(trace + 1.0);
_qStorage[3] = s * 0.5;
s = 0.5 / s;
_qStorage[0] = (rotationMatrixStorage[5] - rotationMatrixStorage[7]) * s;
@@ -138,7 +138,7 @@
: (rotationMatrixStorage[0] < rotationMatrixStorage[8] ? 2 : 0);
final int j = (i + 1) % 3;
final int k = (i + 2) % 3;
- double s = math.sqrt(rotationMatrixStorage[rotationMatrix.index(i, i)] -
+ var s = math.sqrt(rotationMatrixStorage[rotationMatrix.index(i, i)] -
rotationMatrixStorage[rotationMatrix.index(j, j)] -
rotationMatrixStorage[rotationMatrix.index(k, k)] +
1.0);
@@ -161,8 +161,8 @@
final Vector3 v2 = b.normalized();
final double c = v1.dot(v2);
- double angle = math.acos(c);
- Vector3 axis = v1.cross(v2);
+ var angle = math.acos(c);
+ var axis = v1.cross(v2);
if ((1.0 + c).abs() < 0.0005) {
// c \approx -1 indicates 180 degree rotation
diff --git a/lib/src/vector_math_64/ray.dart b/lib/src/vector_math_64/ray.dart
index 7148275..26fd754 100644
--- a/lib/src/vector_math_64/ray.dart
+++ b/lib/src/vector_math_64/ray.dart
@@ -128,9 +128,9 @@
const double epsilon = 10e-6;
// First triangle
- Vector3 point0 = other._point0;
- Vector3 point1 = other._point1;
- Vector3 point2 = other._point2;
+ var point0 = other._point0;
+ var point1 = other._point1;
+ var point2 = other._point2;
_e1
..setFrom(point1)
@@ -204,17 +204,17 @@
final Vector3 otherMin = other.min;
final Vector3 otherMax = other.max;
- double tNear = -double.maxFinite;
- double tFar = double.maxFinite;
+ var tNear = -double.maxFinite;
+ var tFar = double.maxFinite;
- for (int i = 0; i < 3; ++i) {
+ for (var i = 0; i < 3; ++i) {
if (_direction[i] == 0.0) {
if (_origin[i] < otherMin[i] || _origin[i] > otherMax[i]) {
return null;
}
} else {
- double t1 = (otherMin[i] - _origin[i]) / _direction[i];
- double t2 = (otherMax[i] - _origin[i]) / _direction[i];
+ var t1 = (otherMin[i] - _origin[i]) / _direction[i];
+ var t2 = (otherMax[i] - _origin[i]) / _direction[i];
if (t1 > t2) {
final double temp = t1;
diff --git a/lib/src/vector_math_64/third_party/noise.dart b/lib/src/vector_math_64/third_party/noise.dart
index 98cd4ab..53bd877 100644
--- a/lib/src/vector_math_64/third_party/noise.dart
+++ b/lib/src/vector_math_64/third_party/noise.dart
@@ -146,7 +146,7 @@
final int gi1 = _permMod12[ii + i1 + _perm[jj + j1]];
final int gi2 = _permMod12[ii + 1 + _perm[jj + 1]];
// Calculate the contribution from the three corners
- double t0 = 0.5 - x0 * x0 - y0 * y0;
+ var t0 = 0.5 - x0 * x0 - y0 * y0;
if (t0 < 0) {
n0 = 0.0;
} else {
@@ -155,14 +155,14 @@
t0 *
_dot2(_grad3[gi0], x0, y0); // (x,y) of grad3 used for 2D gradient
}
- double t1 = 0.5 - x1 * x1 - y1 * y1;
+ var t1 = 0.5 - x1 * x1 - y1 * y1;
if (t1 < 0) {
n1 = 0.0;
} else {
t1 *= t1;
n1 = t1 * t1 * _dot2(_grad3[gi1], x1, y1);
}
- double t2 = 0.5 - x2 * x2 - y2 * y2;
+ var t2 = 0.5 - x2 * x2 - y2 * y2;
if (t2 < 0) {
n2 = 0.0;
} else {
@@ -271,28 +271,28 @@
final int gi2 = _permMod12[ii + i2 + _perm[jj + j2 + _perm[kk + k2]]];
final int gi3 = _permMod12[ii + 1 + _perm[jj + 1 + _perm[kk + 1]]];
// Calculate the contribution from the four corners
- double t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0;
+ var t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0;
if (t0 < 0) {
n0 = 0.0;
} else {
t0 *= t0;
n0 = t0 * t0 * _dot3(_grad3[gi0], x0, y0, z0);
}
- double t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1;
+ var t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1;
if (t1 < 0) {
n1 = 0.0;
} else {
t1 *= t1;
n1 = t1 * t1 * _dot3(_grad3[gi1], x1, y1, z1);
}
- double t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2;
+ var t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2;
if (t2 < 0) {
n2 = 0.0;
} else {
t2 *= t2;
n2 = t2 * t2 * _dot3(_grad3[gi2], x2, y2, z2);
}
- double t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3;
+ var t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3;
if (t3 < 0) {
n3 = 0.0;
} else {
@@ -327,10 +327,10 @@
// determine the magnitude ordering of x0, y0, z0 and w0.
// Six pair-wise comparisons are performed between each possible pair
// of the four coordinates, and the results are used to rank the numbers.
- int rankx = 0;
- int ranky = 0;
- int rankz = 0;
- int rankw = 0;
+ var rankx = 0;
+ var ranky = 0;
+ var rankz = 0;
+ var rankw = 0;
if (x0 > y0) {
rankx++;
} else {
@@ -419,35 +419,35 @@
final int gi4 =
_perm[ii + 1 + _perm[jj + 1 + _perm[kk + 1 + _perm[ll + 1]]]] % 32;
// Calculate the contribution from the five corners
- double t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0;
+ var t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0;
if (t0 < 0) {
n0 = 0.0;
} else {
t0 *= t0;
n0 = t0 * t0 * _dot4(_grad4[gi0], x0, y0, z0, w0);
}
- double t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1;
+ var t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1;
if (t1 < 0) {
n1 = 0.0;
} else {
t1 *= t1;
n1 = t1 * t1 * _dot4(_grad4[gi1], x1, y1, z1, w1);
}
- double t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2;
+ var t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2;
if (t2 < 0) {
n2 = 0.0;
} else {
t2 *= t2;
n2 = t2 * t2 * _dot4(_grad4[gi2], x2, y2, z2, w2);
}
- double t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3;
+ var t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3;
if (t3 < 0) {
n3 = 0.0;
} else {
t3 *= t3;
n3 = t3 * t3 * _dot4(_grad4[gi3], x3, y3, z3, w3);
}
- double t4 = 0.6 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4;
+ var t4 = 0.6 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4;
if (t4 < 0) {
n4 = 0.0;
} else {
diff --git a/lib/src/vector_math_64/vector2.dart b/lib/src/vector_math_64/vector2.dart
index 1dc2161..06aeb30 100644
--- a/lib/src/vector_math_64/vector2.dart
+++ b/lib/src/vector_math_64/vector2.dart
@@ -133,7 +133,7 @@
if (value == 0.0) {
setZero();
} else {
- double l = length;
+ var l = length;
if (l == 0.0) {
return;
}
@@ -273,7 +273,7 @@
/// True if any component is infinite.
bool get isInfinite {
- bool is_infinite = false;
+ var is_infinite = false;
is_infinite = is_infinite || _v2storage[0].isInfinite;
is_infinite = is_infinite || _v2storage[1].isInfinite;
return is_infinite;
@@ -281,7 +281,7 @@
/// True if any component is NaN.
bool get isNaN {
- bool is_nan = false;
+ var is_nan = false;
is_nan = is_nan || _v2storage[0].isNaN;
is_nan = is_nan || _v2storage[1].isNaN;
return is_nan;
diff --git a/lib/src/vector_math_64/vector3.dart b/lib/src/vector_math_64/vector3.dart
index 649acd1..b341a51 100644
--- a/lib/src/vector_math_64/vector3.dart
+++ b/lib/src/vector_math_64/vector3.dart
@@ -142,7 +142,7 @@
if (value == 0.0) {
setZero();
} else {
- double l = length;
+ var l = length;
if (l == 0.0) {
return;
}
@@ -394,7 +394,7 @@
/// True if any component is infinite.
bool get isInfinite {
- bool is_infinite = false;
+ var is_infinite = false;
is_infinite = is_infinite || _v3storage[0].isInfinite;
is_infinite = is_infinite || _v3storage[1].isInfinite;
is_infinite = is_infinite || _v3storage[2].isInfinite;
@@ -403,7 +403,7 @@
/// True if any component is NaN.
bool get isNaN {
- bool isNan = false;
+ var isNan = false;
isNan = isNan || _v3storage[0].isNaN;
isNan = isNan || _v3storage[1].isNaN;
isNan = isNan || _v3storage[2].isNaN;
diff --git a/lib/src/vector_math_64/vector4.dart b/lib/src/vector_math_64/vector4.dart
index 38ba021..9514983 100644
--- a/lib/src/vector_math_64/vector4.dart
+++ b/lib/src/vector_math_64/vector4.dart
@@ -163,7 +163,7 @@
if (value == 0.0) {
setZero();
} else {
- double l = length;
+ var l = length;
if (l == 0.0) {
return;
}
@@ -280,7 +280,7 @@
/// True if any component is infinite.
bool get isInfinite {
- bool is_infinite = false;
+ var is_infinite = false;
is_infinite = is_infinite || _v4storage[0].isInfinite;
is_infinite = is_infinite || _v4storage[1].isInfinite;
is_infinite = is_infinite || _v4storage[2].isInfinite;
@@ -290,7 +290,7 @@
/// True if any component is NaN.
bool get isNaN {
- bool is_nan = false;
+ var is_nan = false;
is_nan = is_nan || _v4storage[0].isNaN;
is_nan = is_nan || _v4storage[1].isNaN;
is_nan = is_nan || _v4storage[2].isNaN;
diff --git a/lib/src/vector_math_geometry/filters/barycentric_filter.dart b/lib/src/vector_math_geometry/filters/barycentric_filter.dart
index 7253e3b..689becd 100644
--- a/lib/src/vector_math_geometry/filters/barycentric_filter.dart
+++ b/lib/src/vector_math_geometry/filters/barycentric_filter.dart
@@ -31,7 +31,7 @@
final List<VectorList<Vector>> srcAttribs = <VectorList<Vector>>[];
final List<VectorList<Vector>> destAttribs = <VectorList<Vector>>[];
- for (VertexAttrib attrib in mesh.attribs) {
+ for (var attrib in mesh.attribs) {
if (attrib.name == 'BARYCENTRIC') {
continue;
}
@@ -46,7 +46,7 @@
int i0, i1, i2;
- for (int i = 0; i < output.length; i += 3) {
+ for (var i = 0; i < output.length; i += 3) {
if (mesh.indices != null) {
i0 = mesh.indices[i];
i1 = mesh.indices[i + 1];
@@ -62,7 +62,7 @@
barycentricCoords[i + 2] = b2;
// Copy the remaining attributes over
- for (int j = 0; j < srcAttribs.length; ++j) {
+ for (var j = 0; j < srcAttribs.length; ++j) {
destAttribs[j][i] = srcAttribs[j][i0];
destAttribs[j][i + 1] = srcAttribs[j][i1];
destAttribs[j][i + 2] = srcAttribs[j][i2];
diff --git a/lib/src/vector_math_geometry/filters/color_filter.dart b/lib/src/vector_math_geometry/filters/color_filter.dart
index 7822356..823c18b 100644
--- a/lib/src/vector_math_geometry/filters/color_filter.dart
+++ b/lib/src/vector_math_geometry/filters/color_filter.dart
@@ -17,8 +17,7 @@
MeshGeometry filter(MeshGeometry mesh) {
MeshGeometry output;
if (mesh.getAttrib('COLOR') == null) {
- final List<VertexAttrib> attributes = <VertexAttrib>[]
- ..addAll(mesh.attribs)
+ final attributes = <VertexAttrib>[...mesh.attribs]
..add(VertexAttrib('COLOR', 4, 'float'));
output = MeshGeometry.resetAttribs(mesh, attributes);
} else {
@@ -27,7 +26,7 @@
final VectorList<Vector> colors = output.getViewForAttrib('COLOR');
if (colors is Vector4List) {
- for (int i = 0; i < colors.length; ++i) {
+ for (var i = 0; i < colors.length; ++i) {
colors[i] = color;
}
return output;
diff --git a/lib/src/vector_math_geometry/filters/flat_shade_filter.dart b/lib/src/vector_math_geometry/filters/flat_shade_filter.dart
index afa4def..2dabe78 100644
--- a/lib/src/vector_math_geometry/filters/flat_shade_filter.dart
+++ b/lib/src/vector_math_geometry/filters/flat_shade_filter.dart
@@ -39,7 +39,7 @@
final List<VectorList<Vector>> srcAttribs = <VectorList<Vector>>[];
final List<VectorList<Vector>> destAttribs = <VectorList<Vector>>[];
- for (VertexAttrib attrib in mesh.attribs) {
+ for (var attrib in mesh.attribs) {
if (attrib.name == 'POSITION' || attrib.name == 'NORMAL') {
continue;
}
@@ -48,7 +48,7 @@
destAttribs.add(output.getViewForAttrib(attrib.name));
}
- for (int i = 0; i < output.length; i += 3) {
+ for (var i = 0; i < output.length; i += 3) {
final int i0 = mesh.indices[i];
final int i1 = mesh.indices[i + 1];
final int i2 = mesh.indices[i + 2];
@@ -69,7 +69,7 @@
normals[i + 2] = p0;
// Copy the remaining attributes over
- for (int j = 0; j < srcAttribs.length; ++j) {
+ for (var j = 0; j < srcAttribs.length; ++j) {
destAttribs[j][i] = srcAttribs[j][i0];
destAttribs[j][i + 1] = srcAttribs[j][i1];
destAttribs[j][i + 2] = srcAttribs[j][i2];
diff --git a/lib/src/vector_math_geometry/filters/invert_filter.dart b/lib/src/vector_math_geometry/filters/invert_filter.dart
index 8d2e6bc..1e63f6c 100644
--- a/lib/src/vector_math_geometry/filters/invert_filter.dart
+++ b/lib/src/vector_math_geometry/filters/invert_filter.dart
@@ -12,7 +12,7 @@
// to return a new geometry?
// Swap all the triangle indices
- for (int i = 0; i < mesh.indices.length; i += 3) {
+ for (var i = 0; i < mesh.indices.length; i += 3) {
final int tmp = mesh.indices[i];
mesh.indices[i] = mesh.indices[i + 2];
mesh.indices[i + 2] = tmp;
@@ -20,7 +20,7 @@
final VectorList<Vector> normals = mesh.getViewForAttrib('NORMAL');
if (normals is Vector3List) {
- for (int i = 0; i < normals.length; ++i) {
+ for (var i = 0; i < normals.length; ++i) {
normals[i] = -normals[i];
}
}
diff --git a/lib/src/vector_math_geometry/filters/transform_filter.dart b/lib/src/vector_math_geometry/filters/transform_filter.dart
index be6ed70..669cbec 100644
--- a/lib/src/vector_math_geometry/filters/transform_filter.dart
+++ b/lib/src/vector_math_geometry/filters/transform_filter.dart
@@ -17,7 +17,7 @@
void filterInplace(MeshGeometry mesh) {
final VectorList<Vector> position = mesh.getViewForAttrib('POSITION');
if (position is Vector3List) {
- for (int i = 0; i < position.length; ++i) {
+ for (var i = 0; i < position.length; ++i) {
// multiplication always returns Vector3 here
// ignore: invalid_assignment
position[i] = transform * position[i];
diff --git a/lib/src/vector_math_geometry/generators/attribute_generators.dart b/lib/src/vector_math_geometry/generators/attribute_generators.dart
index e4795fa..436b4b0 100644
--- a/lib/src/vector_math_geometry/generators/attribute_generators.dart
+++ b/lib/src/vector_math_geometry/generators/attribute_generators.dart
@@ -16,7 +16,7 @@
// Loop through every polygon, find it's normal, and add that to the vertex
// normals.
- for (int i = 0; i < indices.length; i += 3) {
+ for (var i = 0; i < indices.length; i += 3) {
final int i0 = indices[i], i1 = indices[i + 1], i2 = indices[i + 2];
positions..load(i0, p0)..load(i1, p1)..load(i2, p2);
@@ -38,7 +38,7 @@
}
// Loop through all the normals and normalize them.
- for (int i = 0; i < normals.length; ++i) {
+ for (var i = 0; i < normals.length; ++i) {
normals.load(i, norm);
normals[i] = norm..normalize();
}
@@ -74,7 +74,7 @@
final Vector3List tan0 = Vector3List(positions.length),
tan1 = Vector3List(positions.length);
- for (int i = 0; i < indices.length; i += 3) {
+ for (var i = 0; i < indices.length; i += 3) {
final int i0 = indices[i], i1 = indices[i + 1], i2 = indices[i + 2];
positions..load(i0, p0)..load(i1, p1)..load(i2, p2);
@@ -108,7 +108,7 @@
tan1[i2] = p0..add(vdir);
}
- for (int i = 0; i < tangents.length; ++i) {
+ for (var i = 0; i < tangents.length; ++i) {
normals.load(i, n);
tan0.load(i, t);
diff --git a/lib/src/vector_math_geometry/generators/circle_generator.dart b/lib/src/vector_math_geometry/generators/circle_generator.dart
index 54e3bff..1aeb9bc 100644
--- a/lib/src/vector_math_geometry/generators/circle_generator.dart
+++ b/lib/src/vector_math_geometry/generators/circle_generator.dart
@@ -33,8 +33,8 @@
void generateVertexPositions(Vector3List positions, Uint16List indices) {
final Vector3 v = Vector3.zero();
positions[0] = v;
- int index = 1;
- for (int i = 0; i <= _segments; i++) {
+ var index = 1;
+ for (var i = 0; i <= _segments; i++) {
final double percent = i / _segments;
v
..x = _radius * math.cos(_thetaStart + percent * _thetaLength)
@@ -50,8 +50,8 @@
Vector2List texCoords, Vector3List positions, Uint16List indices) {
final Vector2 v = Vector2(0.5, 0.5);
texCoords[0] = v;
- int index = 1;
- for (int i = 0; i <= _segments; i++) {
+ var index = 1;
+ for (var i = 0; i <= _segments; i++) {
final Vector3 position = positions[index];
final double x = (position.x / (_radius + 1.0)) * 0.5;
final double y = (position.z / (_radius + 1.0)) * 0.5;
@@ -66,8 +66,8 @@
@override
void generateIndices(Uint16List indices) {
- int index = 0;
- for (int i = 1; i <= _segments; i++) {
+ var index = 0;
+ for (var i = 1; i <= _segments; i++) {
indices[index] = i;
indices[index + 1] = i + 1;
indices[index + 2] = 0;
diff --git a/lib/src/vector_math_geometry/generators/cylinder_generator.dart b/lib/src/vector_math_geometry/generators/cylinder_generator.dart
index bdb8143..b840f30 100644
--- a/lib/src/vector_math_geometry/generators/cylinder_generator.dart
+++ b/lib/src/vector_math_geometry/generators/cylinder_generator.dart
@@ -30,12 +30,12 @@
@override
void generateIndices(Uint16List indices) {
- int i = 0;
+ var i = 0;
// Sides
- int base1 = 0;
+ var base1 = 0;
final int base2 = _segments + 1;
- for (int x = 0; x < _segments; ++x) {
+ for (var x = 0; x < _segments; ++x) {
indices[i++] = base1 + x;
indices[i++] = base1 + x + 1;
indices[i++] = base2 + x;
@@ -47,7 +47,7 @@
// Top cap
base1 = (_segments + 1) * 2;
- for (int x = 1; x < _segments - 1; ++x) {
+ for (var x = 1; x < _segments - 1; ++x) {
indices[i++] = base1;
indices[i++] = base1 + x + 1;
indices[i++] = base1 + x;
@@ -55,7 +55,7 @@
// Bottom cap
base1 = (_segments + 1) * 2 + _segments;
- for (int x = 1; x < _segments - 1; ++x) {
+ for (var x = 1; x < _segments - 1; ++x) {
indices[i++] = base1;
indices[i++] = base1 + x;
indices[i++] = base1 + x + 1;
@@ -64,10 +64,10 @@
@override
void generateVertexPositions(Vector3List positions, Uint16List indices) {
- int i = 0;
+ var i = 0;
// Top
- for (int x = 0; x <= _segments; ++x) {
+ for (var x = 0; x <= _segments; ++x) {
final double u = x / _segments;
positions[i++] = Vector3(_topRadius * math.cos(u * math.pi * 2.0),
@@ -75,7 +75,7 @@
}
// Bottom
- for (int x = 0; x <= _segments; ++x) {
+ for (var x = 0; x <= _segments; ++x) {
final double u = x / _segments;
positions[i++] = Vector3(_bottomRadius * math.cos(u * math.pi * 2.0),
@@ -83,7 +83,7 @@
}
// Top cap
- for (int x = 0; x < _segments; ++x) {
+ for (var x = 0; x < _segments; ++x) {
final double u = x / _segments;
positions[i++] = Vector3(_topRadius * math.cos(u * math.pi * 2.0),
@@ -91,7 +91,7 @@
}
// Bottom cap
- for (int x = 0; x < _segments; ++x) {
+ for (var x = 0; x < _segments; ++x) {
final double u = x / _segments;
positions[i++] = Vector3(_bottomRadius * math.cos(u * math.pi * 2.0),
@@ -102,29 +102,29 @@
@override
void generateVertexTexCoords(
Vector2List texCoords, Vector3List positions, Uint16List indices) {
- int i = 0;
+ var i = 0;
// Cylinder top
- for (int x = 0; x <= _segments; ++x) {
+ for (var x = 0; x <= _segments; ++x) {
final double u = 1.0 - (x / _segments);
texCoords[i++] = Vector2(u, 0.0);
}
// Cylinder bottom
- for (int x = 0; x <= _segments; ++x) {
+ for (var x = 0; x <= _segments; ++x) {
final double u = 1.0 - (x / _segments);
texCoords[i++] = Vector2(u, 1.0);
}
// Top cap
- for (int x = 0; x < _segments; ++x) {
+ for (var x = 0; x < _segments; ++x) {
final double r = (x / _segments) * math.pi * 2.0;
texCoords[i++] =
Vector2(math.cos(r) * 0.5 + 0.5, math.sin(r) * 0.5 + 0.5);
}
// Bottom cap
- for (int x = 0; x < _segments; ++x) {
+ for (var x = 0; x < _segments; ++x) {
final double r = (x / _segments) * math.pi * 2.0;
texCoords[i++] =
Vector2(math.cos(r) * 0.5 + 0.5, math.sin(r) * 0.5 + 0.5);
diff --git a/lib/src/vector_math_geometry/generators/geometry_generator.dart b/lib/src/vector_math_geometry/generators/geometry_generator.dart
index c863ecc..d7553b8 100644
--- a/lib/src/vector_math_geometry/generators/geometry_generator.dart
+++ b/lib/src/vector_math_geometry/generators/geometry_generator.dart
@@ -51,11 +51,11 @@
attribs.add(tangentAttrib);
}
- MeshGeometry mesh = MeshGeometry(vertexCount, attribs)
+ var mesh = MeshGeometry(vertexCount, attribs)
..indices = Uint16List(indexCount);
generateIndices(mesh.indices);
- VectorList<Vector> view = mesh.getViewForAttrib('POSITION');
+ var view = mesh.getViewForAttrib('POSITION');
if (view is Vector3List) {
positionView = view;
generateVertexPositions(positionView, mesh.indices);
@@ -87,7 +87,7 @@
}
if (filters != null) {
- for (GeometryFilter filter in filters) {
+ for (var filter in filters) {
if (filter.inplace && filter is InplaceGeometryFilter) {
filter.filterInplace(mesh);
} else {
@@ -105,7 +105,7 @@
void generateVertexTexCoords(
Vector2List texCoords, Vector3List positions, Uint16List indices) {
- for (int i = 0; i < positions.length; ++i) {
+ for (var i = 0; i < positions.length; ++i) {
final Vector3 p = positions[i];
// These are TERRIBLE texture coords, but it's better than nothing.
diff --git a/lib/src/vector_math_geometry/generators/ring_generator.dart b/lib/src/vector_math_geometry/generators/ring_generator.dart
index 2e62801..0dc0924 100644
--- a/lib/src/vector_math_geometry/generators/ring_generator.dart
+++ b/lib/src/vector_math_geometry/generators/ring_generator.dart
@@ -37,8 +37,8 @@
@override
void generateVertexPositions(Vector3List positions, Uint16List indices) {
final Vector3 v = Vector3.zero();
- int index = 0;
- for (int i = 0; i <= _segments; i++) {
+ var index = 0;
+ for (var i = 0; i <= _segments; i++) {
final double percent = i / _segments;
v
..x = _innerRadius * math.cos(_thetaStart + percent * _thetaLength)
@@ -59,8 +59,8 @@
Vector2List texCoords, Vector3List positions, Uint16List indices) {
if (_stripTextureCoordinates) {
final Vector2 v = Vector2.zero();
- int index = 0;
- for (int i = 0; i <= _segments; i++) {
+ var index = 0;
+ for (var i = 0; i <= _segments; i++) {
final double percent = i / _segments;
v
..x = 0.0
@@ -75,11 +75,11 @@
}
} else {
final Vector2 v = Vector2.zero();
- int index = 0;
- for (int i = 0; i <= _segments; i++) {
- Vector3 position = positions[index];
- double x = (position.x / (_outerRadius + 1.0)) * 0.5;
- double y = (position.z / (_outerRadius + 1.0)) * 0.5;
+ var index = 0;
+ for (var i = 0; i <= _segments; i++) {
+ var position = positions[index];
+ var x = (position.x / (_outerRadius + 1.0)) * 0.5;
+ var y = (position.z / (_outerRadius + 1.0)) * 0.5;
v
..x = x + 0.5
..y = y + 0.5;
@@ -100,9 +100,9 @@
@override
void generateIndices(Uint16List indices) {
- int index = 0;
+ var index = 0;
final int length = _segments * 2;
- for (int i = 0; i < length; i += 2) {
+ for (var i = 0; i < length; i += 2) {
indices[index + 0] = i + 0;
indices[index + 1] = i + 1;
indices[index + 2] = i + 3;
diff --git a/lib/src/vector_math_geometry/generators/sphere_generator.dart b/lib/src/vector_math_geometry/generators/sphere_generator.dart
index b5bf36d..f0ee15b 100644
--- a/lib/src/vector_math_geometry/generators/sphere_generator.dart
+++ b/lib/src/vector_math_geometry/generators/sphere_generator.dart
@@ -29,12 +29,12 @@
@override
void generateIndices(Uint16List indices) {
- int i = 0;
- for (int y = 0; y < _latSegments; ++y) {
+ var i = 0;
+ for (var y = 0; y < _latSegments; ++y) {
final int base1 = (_lonSegments + 1) * y;
final int base2 = (_lonSegments + 1) * (y + 1);
- for (int x = 0; x < _lonSegments; ++x) {
+ for (var x = 0; x < _lonSegments; ++x) {
indices[i++] = base1 + x;
indices[i++] = base1 + x + 1;
indices[i++] = base2 + x;
@@ -48,13 +48,13 @@
@override
void generateVertexPositions(Vector3List positions, Uint16List indices) {
- int i = 0;
- for (int y = 0; y <= _latSegments; ++y) {
+ var i = 0;
+ for (var y = 0; y <= _latSegments; ++y) {
final double v = y / _latSegments;
final double sv = math.sin(v * math.pi);
final double cv = math.cos(v * math.pi);
- for (int x = 0; x <= _lonSegments; ++x) {
+ for (var x = 0; x <= _lonSegments; ++x) {
final double u = x / _lonSegments;
positions[i++] = Vector3(_radius * math.cos(u * math.pi * 2.0) * sv,
@@ -66,11 +66,11 @@
@override
void generateVertexTexCoords(
Vector2List texCoords, Vector3List positions, Uint16List indices) {
- int i = 0;
- for (int y = 0; y <= _latSegments; ++y) {
+ var i = 0;
+ for (var y = 0; y <= _latSegments; ++y) {
final double v = y / _latSegments;
- for (int x = 0; x <= _lonSegments; ++x) {
+ for (var x = 0; x <= _lonSegments; ++x) {
final double u = x / _lonSegments;
texCoords[i++] = Vector2(u, v);
}
@@ -80,13 +80,13 @@
@override
void generateVertexNormals(
Vector3List normals, Vector3List positions, Uint16List indices) {
- int i = 0;
- for (int y = 0; y <= _latSegments; ++y) {
+ var i = 0;
+ for (var y = 0; y <= _latSegments; ++y) {
final double v = y / _latSegments;
final double sv = math.sin(v * math.pi);
final double cv = math.cos(v * math.pi);
- for (int x = 0; x <= _lonSegments; ++x) {
+ for (var x = 0; x <= _lonSegments; ++x) {
final double u = x / _lonSegments;
normals[i++] = Vector3(math.cos(u * math.pi * 2.0) * sv, cv,
diff --git a/lib/src/vector_math_geometry/mesh_geometry.dart b/lib/src/vector_math_geometry/mesh_geometry.dart
index c533b04..5062cfa 100644
--- a/lib/src/vector_math_geometry/mesh_geometry.dart
+++ b/lib/src/vector_math_geometry/mesh_geometry.dart
@@ -79,13 +79,13 @@
final int stride;
factory MeshGeometry(int length, List<VertexAttrib> attributes) {
- int stride = 0;
- for (VertexAttrib a in attributes) {
+ var stride = 0;
+ for (var a in attributes) {
stride += a.elementSize * a.size;
}
- int offset = 0;
+ var offset = 0;
final List<VertexAttrib> attribs = <VertexAttrib>[];
- for (VertexAttrib a in attributes) {
+ for (var a in attributes) {
attribs.add(VertexAttrib._resetStrideOffset(a, stride, offset));
offset += a.elementSize * a.size;
}
@@ -116,7 +116,7 @@
factory MeshGeometry.fromJson(Map<String, Object> json) {
Float32List buffer;
- final Object jsonBuffer = json["buffer"];
+ final Object jsonBuffer = json['buffer'];
if (jsonBuffer is List<double>) {
buffer = Float32List.fromList(jsonBuffer);
} else {
@@ -124,7 +124,7 @@
jsonBuffer, 'json["buffer"]', 'Value type must be List<double>');
}
- final Object jsonAttribs = json["attribs"];
+ final Object jsonAttribs = json['attribs'];
Map<String, Object> jsonAttribsMap;
if (jsonAttribs is Map<String, Object>) {
jsonAttribsMap = jsonAttribs;
@@ -133,8 +133,8 @@
'Value type must be Map<String, Object>');
}
List<VertexAttrib> attribs;
- int stride = 0;
- for (String key in jsonAttribsMap.keys) {
+ var stride = 0;
+ for (var key in jsonAttribsMap.keys) {
VertexAttrib attrib;
final Object jsonAttrib = jsonAttribsMap[key];
if (jsonAttrib is Map<String, Object>) {
@@ -149,7 +149,7 @@
final MeshGeometry mesh = MeshGeometry._internal(
buffer.lengthInBytes ~/ stride, stride, attribs, buffer);
- final Object jsonIndices = json["indices"];
+ final Object jsonIndices = json['indices'];
if (jsonIndices is List<int>) {
mesh.indices = Uint16List.fromList(jsonIndices);
}
@@ -163,13 +163,13 @@
..indices = inputMesh.indices;
// Copy over the attributes that were specified
- for (VertexAttrib attrib in mesh.attribs) {
+ for (var attrib in mesh.attribs) {
final VertexAttrib inputAttrib = inputMesh.getAttrib(attrib.name);
if (inputAttrib != null) {
if (inputAttrib.size != attrib.size ||
inputAttrib.type != attrib.type) {
throw Exception(
- "Attributes size or type is mismatched: ${attrib.name}");
+ 'Attributes size or type is mismatched: ${attrib.name}');
}
final VectorList<Vector> inputView =
@@ -186,18 +186,18 @@
factory MeshGeometry.combine(List<MeshGeometry> meshes) {
if (meshes == null || meshes.length < 2) {
throw Exception(
- "Must provide at least two MeshGeometry instances to combine.");
+ 'Must provide at least two MeshGeometry instances to combine.');
}
// When combining meshes they must all have a matching set of VertexAttribs
final MeshGeometry firstMesh = meshes[0];
- int totalVerts = firstMesh.length;
- int totalIndices = firstMesh.indices != null ? firstMesh.indices.length : 0;
- for (int i = 1; i < meshes.length; ++i) {
+ var totalVerts = firstMesh.length;
+ var totalIndices = firstMesh.indices != null ? firstMesh.indices.length : 0;
+ for (var i = 1; i < meshes.length; ++i) {
final MeshGeometry srcMesh = meshes[i];
if (!firstMesh.attribsAreCompatible(srcMesh)) {
throw Exception(
- "All meshes must have identical attributes to combine.");
+ 'All meshes must have identical attributes to combine.');
}
totalVerts += srcMesh.length;
totalIndices += srcMesh.indices != null ? srcMesh.indices.length : 0;
@@ -211,15 +211,15 @@
}
// Copy over the buffer data:
- int bufferOffset = 0;
- int indexOffset = 0;
- int vertexOffset = 0;
- for (int i = 0; i < meshes.length; ++i) {
+ var bufferOffset = 0;
+ var indexOffset = 0;
+ var vertexOffset = 0;
+ for (var i = 0; i < meshes.length; ++i) {
final MeshGeometry srcMesh = meshes[i];
mesh.buffer.setAll(bufferOffset, srcMesh.buffer);
if (totalIndices > 0) {
- for (int j = 0; j < srcMesh.indices.length; ++j) {
+ for (var j = 0; j < srcMesh.indices.length; ++j) {
mesh.indices[j + indexOffset] = srcMesh.indices[j] + vertexOffset;
}
vertexOffset += srcMesh.length;
@@ -243,10 +243,10 @@
}
static VertexAttrib attribFromJson(String name, Map<String, Object> json) {
- final Object jsonSize = json["size"];
- final Object jsonType = json["type"];
- final Object jsonStride = json["stride"];
- final Object jsonOffset = json["offset"];
+ final Object jsonSize = json['size'];
+ final Object jsonType = json['type'];
+ final Object jsonStride = json['stride'];
+ final Object jsonOffset = json['offset'];
if (jsonSize is int &&
jsonType is String &&
jsonStride is int &&
@@ -259,7 +259,7 @@
}
VertexAttrib getAttrib(String name) {
- for (VertexAttrib attrib in attribs) {
+ for (var attrib in attribs) {
if (attrib.name == name) {
return attrib;
}
@@ -268,7 +268,7 @@
}
VectorList<Vector> getViewForAttrib(String name) {
- for (VertexAttrib attrib in attribs) {
+ for (var attrib in attribs) {
if (attrib.name == name) {
return attrib.getView(buffer);
}
@@ -281,7 +281,7 @@
return false;
}
- for (VertexAttrib attrib in attribs) {
+ for (var attrib in attribs) {
final VertexAttrib otherAttrib = mesh.getAttrib(attrib.name);
if (otherAttrib == null) {
return false;
diff --git a/lib/src/vector_math_lists/scalar_list_view.dart b/lib/src/vector_math_lists/scalar_list_view.dart
index 5390380..4cd5f51 100644
--- a/lib/src/vector_math_lists/scalar_list_view.dart
+++ b/lib/src/vector_math_lists/scalar_list_view.dart
@@ -43,7 +43,7 @@
_length = list.length,
_buffer =
Float32List(offset + list.length * (stride == 0 ? 1 : stride)) {
- for (int i = 0; i < _length; i++) {
+ for (var i = 0; i < _length; i++) {
this[i] = list[i];
}
}
diff --git a/lib/src/vector_math_lists/vector_list.dart b/lib/src/vector_math_lists/vector_list.dart
index 9127fbd..2c338b2 100644
--- a/lib/src/vector_math_lists/vector_list.dart
+++ b/lib/src/vector_math_lists/vector_list.dart
@@ -53,7 +53,7 @@
if (_stride < _vectorLength) {
throw ArgumentError('Stride cannot be smaller than the vector size.');
}
- for (int i = 0; i < _length; i++) {
+ for (var i = 0; i < _length; i++) {
store(i, list[i]);
}
}
@@ -93,10 +93,10 @@
count = math.min(length - offset, src.length - srcOffset);
}
final int minVectorLength = math.min(_vectorLength, src._vectorLength);
- for (int i = 0; i < count; i++) {
- int index = _vectorIndexToBufferIndex(i + offset);
- int srcIndex = src._vectorIndexToBufferIndex(i + srcOffset);
- for (int j = 0; j < minVectorLength; j++) {
+ for (var i = 0; i < count; i++) {
+ var index = _vectorIndexToBufferIndex(i + offset);
+ var srcIndex = src._vectorIndexToBufferIndex(i + srcOffset);
+ for (var j = 0; j < minVectorLength; j++) {
_buffer[index++] = src._buffer[srcIndex++];
}
}
diff --git a/lib/src/vector_math_operations/matrix.dart b/lib/src/vector_math_operations/matrix.dart
index 514419c..18b9362 100644
--- a/lib/src/vector_math_operations/matrix.dart
+++ b/lib/src/vector_math_operations/matrix.dart
@@ -152,10 +152,10 @@
final double a32 = a[aOffset++];
final double a33 = a[aOffset++];
- double b0 = b[bOffset++];
- double b1 = b[bOffset++];
- double b2 = b[bOffset++];
- double b3 = b[bOffset++];
+ var b0 = b[bOffset++];
+ var b1 = b[bOffset++];
+ var b2 = b[bOffset++];
+ var b3 = b[bOffset++];
out[outOffset++] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
out[outOffset++] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
out[outOffset++] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
@@ -298,7 +298,7 @@
int matrixOffset, Float32x4List vector, int vectorOffset) {
final Float32x4 v = vector[vectorOffset];
final Float32x4 xxxx = v.shuffle(Float32x4.xxxx);
- Float32x4 z = Float32x4.zero();
+ var z = Float32x4.zero();
z += xxxx * matrix[0 + matrixOffset];
final Float32x4 yyyy = v.shuffle(Float32x4.yyyy);
z += yyyy * matrix[1 + matrixOffset];
diff --git a/pubspec.yaml b/pubspec.yaml
index 882f9b6..6a4b6b0 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -5,7 +5,7 @@
homepage: https://github.com/google/vector_math.dart
environment:
- sdk: '>=2.1.0 <3.0.0'
+ sdk: '>=2.3.0 <3.0.0'
dev_dependencies:
benchmark_harness: any
diff --git a/test/geometry_test.dart b/test/geometry_test.dart
index 124a290..3074307 100644
--- a/test/geometry_test.dart
+++ b/test/geometry_test.dart
@@ -24,7 +24,7 @@
final Uint16List indices = Uint16List.fromList([0, 1, 2, 3, 2, 1]);
- Vector3List normals = Vector3List(positions.length);
+ var normals = Vector3List(positions.length);
generateNormals(normals, positions, indices);
@@ -58,7 +58,7 @@
final Uint16List indices = Uint16List.fromList([0, 1, 2, 3, 2, 1]);
- Vector4List tangents = Vector4List(positions.length);
+ var tangents = Vector4List(positions.length);
generateTangents(tangents, positions, normals, texCoords, indices);
@@ -69,20 +69,20 @@
}
MeshGeometry filterUnitCube(GeometryFilter filter) {
- CubeGenerator generator = CubeGenerator();
+ var generator = CubeGenerator();
return generator.createCube(1.0, 1.0, 1.0, filters: [filter]);
}
void testTransformFilter() {
- Matrix4 scaleMat = Matrix4.identity();
+ var scaleMat = Matrix4.identity();
scaleMat.scale(2.0, 2.0, 2.0);
- TransformFilter filter = TransformFilter(scaleMat);
- MeshGeometry cube = filterUnitCube(filter);
+ var filter = TransformFilter(scaleMat);
+ var cube = filterUnitCube(filter);
// Check to ensure all the vertices were properly scaled
- Vector3List positions = cube.getViewForAttrib("POSITION") as Vector3List;
- for (int i = 0; i < positions.length; ++i) {
- Vector3 position = positions[i];
+ var positions = cube.getViewForAttrib('POSITION') as Vector3List;
+ for (var i = 0; i < positions.length; ++i) {
+ var position = positions[i];
expect(position.storage[0].abs(), equals(2.0));
expect(position.storage[1].abs(), equals(2.0));
expect(position.storage[2].abs(), equals(2.0));
@@ -90,8 +90,8 @@
}
void testFlatShadeFilter() {
- FlatShadeFilter filter = FlatShadeFilter();
- MeshGeometry cube = filterUnitCube(filter);
+ var filter = FlatShadeFilter();
+ var cube = filterUnitCube(filter);
// Flat shading removes indices and duplicates vertices
expect(cube.indices, equals(null));
@@ -99,39 +99,39 @@
}
void testBarycentricFilter() {
- BarycentricFilter filter = BarycentricFilter();
- MeshGeometry cube = filterUnitCube(filter);
+ var filter = BarycentricFilter();
+ var cube = filterUnitCube(filter);
// Generating barycentric coords removes indices and duplicates vertices
expect(cube.indices, equals(null));
expect(cube.length, equals(36));
- expect(cube.getViewForAttrib("BARYCENTRIC"), isNotNull);
+ expect(cube.getViewForAttrib('BARYCENTRIC'), isNotNull);
}
void testColorFilter() {
- Vector4 filterColor = Vector4(1.0, 0.0, 0.0, 1.0);
- ColorFilter filter = ColorFilter(filterColor);
- MeshGeometry cube = filterUnitCube(filter);
+ var filterColor = Vector4(1.0, 0.0, 0.0, 1.0);
+ var filter = ColorFilter(filterColor);
+ var cube = filterUnitCube(filter);
// Ensure that the same color was applied to all vertices
- Vector4List colors = cube.getViewForAttrib("COLOR") as Vector4List;
- for (int i = 0; i < colors.length; ++i) {
- Vector4 color = colors[i];
+ var colors = cube.getViewForAttrib('COLOR') as Vector4List;
+ for (var i = 0; i < colors.length; ++i) {
+ var color = colors[i];
relativeTest(color, filterColor);
}
}
void testCombineIndices() {
// Combining two meshes should generate indices that are not out of range.
- SphereGenerator sphereGenerator = SphereGenerator();
+ var sphereGenerator = SphereGenerator();
- MeshGeometry sphere0 =
+ var sphere0 =
sphereGenerator.createSphere(10.0, latSegments: 8, lonSegments: 8);
- MeshGeometry sphere1 =
+ var sphere1 =
sphereGenerator.createSphere(10.0, latSegments: 8, lonSegments: 8);
- MeshGeometry combined = MeshGeometry.combine([sphere0, sphere1]);
+ var combined = MeshGeometry.combine([sphere0, sphere1]);
expect(combined.indices, everyElement(lessThan(combined.length)));
}
diff --git a/test/matrix2_test.dart b/test/matrix2_test.dart
index d860263..fa1dd82 100644
--- a/test/matrix2_test.dart
+++ b/test/matrix2_test.dart
@@ -28,7 +28,7 @@
assert(input.length == expectedOutput.length);
- for (int i = 0; i < input.length; i++) {
+ for (var i = 0; i < input.length; i++) {
var output = input[i].clone();
output.scaleAdjoint(1.0);
relativeTest(output, expectedOutput[i]);
@@ -37,7 +37,7 @@
void testMatrix2Determinant() {
var input = <Matrix2>[];
- List<double> expectedOutput = <double>[];
+ var expectedOutput = <double>[];
input.add(parseMatrix<Matrix2>('''0.830828627896291 0.549723608291140
0.585264091152724 0.917193663829810'''));
@@ -45,8 +45,8 @@
assert(input.length == expectedOutput.length);
- for (int i = 0; i < input.length; i++) {
- double output = input[i].determinant();
+ for (var i = 0; i < input.length; i++) {
+ var output = input[i].determinant();
//print('${input[i].cols}x${input[i].rows} = $output');
relativeTest(output, expectedOutput[i]);
}
@@ -69,9 +69,9 @@
}
void testMatrix2Inversion() {
- Matrix2 m = Matrix2(4.0, 3.0, 3.0, 2.0);
- Matrix2 result = Matrix2.zero();
- double det = result.copyInverse(m);
+ var m = Matrix2(4.0, 3.0, 3.0, 2.0);
+ var result = Matrix2.zero();
+ var det = result.copyInverse(m);
expect(det, -1.0);
expect(result.entry(0, 0), -2.0);
expect(result.entry(1, 0), 3.0);
diff --git a/test/matrix3_test.dart b/test/matrix3_test.dart
index 2d191b3..fea1469 100644
--- a/test/matrix3_test.dart
+++ b/test/matrix3_test.dart
@@ -41,7 +41,7 @@
assert(input.length == expectedOutput.length);
- for (int i = 0; i < input.length; i++) {
+ for (var i = 0; i < input.length; i++) {
dynamic output = input[i].clone();
output.scaleAdjoint(1.0);
relativeTest(output, expectedOutput[i]);
@@ -50,7 +50,7 @@
void testMatrix3Determinant() {
var input = <Matrix3>[];
- List<double> expectedOutput = <double>[];
+ var expectedOutput = <double>[];
input.add(parseMatrix<Matrix3>(
'''0.285839018820374 0.380445846975357 0.053950118666607
@@ -60,8 +60,8 @@
assert(input.length == expectedOutput.length);
- for (int i = 0; i < input.length; i++) {
- double output = input[i].determinant();
+ for (var i = 0; i < input.length; i++) {
+ var output = input[i].determinant();
//print('${input[i].cols}x${input[i].rows} = $output');
relativeTest(output, expectedOutput[i]);
}
@@ -100,7 +100,7 @@
assert(inputA.length == inputB.length);
assert(inputB.length == expectedOutput.length);
- for (int i = 0; i < inputA.length; i++) {
+ for (var i = 0; i < inputA.length; i++) {
var output = inputA[i].clone();
output.transposeMultiply(inputB[i]);
relativeTest(output, expectedOutput[i]);
@@ -140,7 +140,7 @@
assert(inputA.length == inputB.length);
assert(inputB.length == expectedOutput.length);
- for (int i = 0; i < inputA.length; i++) {
+ for (var i = 0; i < inputA.length; i++) {
var output = inputA[i].clone();
output.multiply(inputB[i]);
relativeTest(output, expectedOutput[i]);
@@ -180,7 +180,7 @@
assert(inputA.length == inputB.length);
assert(inputB.length == expectedOutput.length);
- for (int i = 0; i < inputA.length; i++) {
+ for (var i = 0; i < inputA.length; i++) {
var output = inputA[i].clone();
output.multiplyTranspose(inputB[i]);
relativeTest(output, expectedOutput[i]);
@@ -188,9 +188,9 @@
}
void testMatrix3Transform() {
- Matrix3 rotX = Matrix3.rotationX(math.pi / 4);
- Matrix3 rotY = Matrix3.rotationY(math.pi / 4);
- Matrix3 rotZ = Matrix3.rotationZ(math.pi / 4);
+ var rotX = Matrix3.rotationX(math.pi / 4);
+ var rotY = Matrix3.rotationY(math.pi / 4);
+ var rotZ = Matrix3.rotationZ(math.pi / 4);
final input = Vector3(1.0, 0.0, 0.0);
relativeTest(rotX.transformed(input), input);
@@ -201,10 +201,9 @@
}
void testMatrix3Transform2() {
- Matrix3 rotZ = Matrix3.rotationZ(math.pi / 4);
- Matrix3 trans = Matrix3(1.0, 0.0, 3.0, 0.0, 1.0, 2.0, 3.0, 2.0, 1.0);
- Matrix3 transB =
- Matrix3.fromList([1.0, 0.0, 3.0, 0.0, 1.0, 2.0, 3.0, 2.0, 1.0]);
+ var rotZ = Matrix3.rotationZ(math.pi / 4);
+ var trans = Matrix3(1.0, 0.0, 3.0, 0.0, 1.0, 2.0, 3.0, 2.0, 1.0);
+ var transB = Matrix3.fromList([1.0, 0.0, 3.0, 0.0, 1.0, 2.0, 3.0, 2.0, 1.0]);
expect(trans, equals(transB));
final input = Vector2(1.0, 0.0);
@@ -216,8 +215,8 @@
}
void testMatrix3AbsoluteRotate2() {
- Matrix3 rotZ = Matrix3.rotationZ(-math.pi / 4);
- Matrix3 rotZcw = Matrix3.rotationZ(math.pi / 4);
+ var rotZ = Matrix3.rotationZ(-math.pi / 4);
+ var rotZcw = Matrix3.rotationZ(math.pi / 4);
// Add translation
rotZ.setEntry(2, 0, 3.0);
rotZ.setEntry(2, 1, 2.0);
@@ -235,7 +234,7 @@
var a = Vector3(1.0, 2.0, 3.0);
var b = Vector3(4.0, 5.0, 6.0);
var c = Vector3(7.0, 8.0, 9.0);
- Matrix3 m = Matrix3.columns(a, b, c);
+ var m = Matrix3.columns(a, b, c);
expect(m.entry(0, 0), 1.0);
expect(m.entry(2, 2), 9.0);
c.z = 5.0;
@@ -245,9 +244,9 @@
}
void testMatrix3Inversion() {
- Matrix3 m = Matrix3(1.0, 0.0, 5.0, 2.0, 1.0, 6.0, 3.0, 4.0, 0.0);
- Matrix3 result = Matrix3.zero();
- double det = result.copyInverse(m);
+ var m = Matrix3(1.0, 0.0, 5.0, 2.0, 1.0, 6.0, 3.0, 4.0, 0.0);
+ var result = Matrix3.zero();
+ var det = result.copyInverse(m);
expect(det, 1.0);
expect(result.entry(0, 0), -24.0);
expect(result.entry(1, 0), 20.0);
diff --git a/test/matrix4_test.dart b/test/matrix4_test.dart
index f7a4383..8d99438 100644
--- a/test/matrix4_test.dart
+++ b/test/matrix4_test.dart
@@ -127,7 +127,7 @@
0.111202755293787 0.403912145588115 0.956134540229802 0.353158571222071'''));
expectedOutput.add(inputA[0].transposed());
- for (int i = 0; i < inputA.length; i++) {
+ for (var i = 0; i < inputA.length; i++) {
inputA[i].transpose();
relativeTest(inputA[i], expectedOutput[i]);
}
@@ -155,7 +155,7 @@
assert(inputA.length == inputB.length);
assert(expectedOutput.length == inputB.length);
- for (int i = 0; i < inputA.length; i++) {
+ for (var i = 0; i < inputA.length; i++) {
var output = inputA[i] * inputB[i] as Vector4;
relativeTest(output, expectedOutput[i]);
}
@@ -185,7 +185,7 @@
assert(inputA.length == inputB.length);
assert(expectedOutput.length == inputB.length);
- for (int i = 0; i < inputA.length; i++) {
+ for (var i = 0; i < inputA.length; i++) {
var output = inputA[i] * inputB[i] as Matrix4;
//print('${inputA[i].cols}x${inputA[i].rows} * ${inputB[i].cols}x${inputB[i].rows} = ${output.cols}x${output.rows}');
relativeTest(output, expectedOutput[i]);
@@ -228,7 +228,7 @@
assert(input.length == expectedOutput.length);
- for (int i = 0; i < input.length; i++) {
+ for (var i = 0; i < input.length; i++) {
var output = input[i].clone();
output.scaleAdjoint(1.0);
relativeTest(output, expectedOutput[i]);
@@ -237,7 +237,7 @@
void testMatrix4Determinant() {
var input = <Matrix4>[];
- List<double> expectedOutput = <double>[];
+ var expectedOutput = <double>[];
input.add(parseMatrix<Matrix4>(
'''0.046171390631154 0.317099480060861 0.381558457093008 0.489764395788231
0.097131781235848 0.950222048838355 0.765516788149002 0.445586200710899
@@ -260,8 +260,8 @@
expectedOutput.add(0.117969860982876);
assert(input.length == expectedOutput.length);
- for (int i = 0; i < input.length; i++) {
- double output = input[i].determinant();
+ for (var i = 0; i < input.length; i++) {
+ var output = input[i].determinant();
//print('${input[i].cols}x${input[i].rows} = $output');
relativeTest(output, expectedOutput[i]);
}
@@ -291,7 +291,7 @@
assert(inputA.length == inputB.length);
assert(inputB.length == expectedOutput.length);
- for (int i = 0; i < inputA.length; i++) {
+ for (var i = 0; i < inputA.length; i++) {
var output = inputA[i].clone();
output.transposeMultiply(inputB[i]);
relativeTest(output, expectedOutput[i]);
@@ -322,7 +322,7 @@
assert(inputA.length == inputB.length);
assert(inputB.length == expectedOutput.length);
- for (int i = 0; i < inputA.length; i++) {
+ for (var i = 0; i < inputA.length; i++) {
var output = inputA[i].clone();
output.multiply(inputB[i]);
relativeTest(output, expectedOutput[i]);
@@ -353,7 +353,7 @@
assert(inputA.length == inputB.length);
assert(inputB.length == expectedOutput.length);
- for (int i = 0; i < inputA.length; i++) {
+ for (var i = 0; i < inputA.length; i++) {
var output = inputA[i].clone();
output.multiplyTranspose(inputB[i]);
relativeTest(output, expectedOutput[i]);
@@ -374,7 +374,7 @@
assert(inputA.length == inputB.length);
assert(output1.length == output2.length);
- for (int i = 0; i < inputA.length; i++) {
+ for (var i = 0; i < inputA.length; i++) {
relativeTest(output1[i], output2[i]);
}
}
@@ -393,7 +393,7 @@
assert(inputA.length == inputB.length);
assert(output1.length == output2.length);
- for (int i = 0; i < inputA.length; i++) {
+ for (var i = 0; i < inputA.length; i++) {
relativeTest(output1[i], output2[i]);
}
}
@@ -410,18 +410,18 @@
{
var axis = Vector3(1.1, 1.1, 1.1);
axis.normalize();
- double angle = 1.5;
+ var angle = 1.5;
- Quaternion q = Quaternion.axisAngle(axis, angle);
- Matrix3 R = q.asRotationMatrix();
- Matrix4 T = Matrix4.identity();
+ var q = Quaternion.axisAngle(axis, angle);
+ var R = q.asRotationMatrix();
+ var T = Matrix4.identity();
T.setRotation(R);
output1.add(T);
output2.add(Matrix4.identity()..rotate(axis, angle));
}
assert(output1.length == output2.length);
- for (int i = 0; i < output1.length; i++) {
+ for (var i = 0; i < output1.length; i++) {
relativeTest(output1[i], output2[i]);
}
return;
@@ -440,7 +440,7 @@
}
void testMatrix4Column() {
- Matrix4 I = Matrix4.zero();
+ var I = Matrix4.zero();
expect(I[0], 0.0);
var c0 = Vector4(1.0, 2.0, 3.0, 4.0);
I.setColumn(0, c0);
@@ -451,10 +451,10 @@
}
void testMatrix4Inversion() {
- Matrix4 m = Matrix4(1.0, 0.0, 2.0, 2.0, 0.0, 2.0, 1.0, 0.0, 0.0, 1.0, 0.0,
- 1.0, 1.0, 2.0, 1.0, 4.0);
- Matrix4 result = Matrix4.zero();
- double det = result.copyInverse(m);
+ var m = Matrix4(1.0, 0.0, 2.0, 2.0, 0.0, 2.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0,
+ 1.0, 2.0, 1.0, 4.0);
+ var result = Matrix4.zero();
+ var det = result.copyInverse(m);
expect(det, 2.0);
expect(result.entry(0, 0), -2.0);
expect(result.entry(1, 0), 1.0);
@@ -599,7 +599,7 @@
}
void testMatrix4InvertConstructor() {
- bool exception = false;
+ var exception = false;
try {
Matrix4.inverted(Matrix4.zero());
expect(false, isTrue); // don't hit here.
diff --git a/test/noise_test.dart b/test/noise_test.dart
index a013352..dff3375 100644
--- a/test/noise_test.dart
+++ b/test/noise_test.dart
@@ -11,11 +11,11 @@
void testSimplexNoise() {
final SimplexNoise noise = SimplexNoise();
- List<double> values2D = List<double>(10);
- List<double> values3D = List<double>(10);
+ var values2D = List<double>(10);
+ var values3D = List<double>(10);
// Cache several values at known coordinates
- for (int i = 0; i < values2D.length; ++i) {
+ for (var i = 0; i < values2D.length; ++i) {
values2D[i] = noise.noise2D(i.toDouble(), i.toDouble());
values3D[i] = noise.noise3D(i.toDouble(), i.toDouble(), i.toDouble());
}
diff --git a/test/opengl_matrix_test.dart b/test/opengl_matrix_test.dart
index e48fc4f..02dcf8b 100644
--- a/test/opengl_matrix_test.dart
+++ b/test/opengl_matrix_test.dart
@@ -12,28 +12,28 @@
import 'test_utils.dart';
void testUnproject() {
- Vector3 position = Vector3(0.0, 0.0, 0.0);
- Vector3 focusPosition = Vector3(0.0, 0.0, -1.0);
- Vector3 upDirection = Vector3(0.0, 1.0, 0.0);
- Matrix4 lookat = makeViewMatrix(position, focusPosition, upDirection);
- double n = 0.1;
- double f = 1000.0;
- double l = -10.0;
- double r = 10.0;
- double b = -10.0;
- double t = 10.0;
- Matrix4 frustum = makeFrustumMatrix(l, r, b, t, n, f);
- Matrix4 C = frustum * lookat as Matrix4;
- Vector3 re = Vector3.zero();
+ var position = Vector3(0.0, 0.0, 0.0);
+ var focusPosition = Vector3(0.0, 0.0, -1.0);
+ var upDirection = Vector3(0.0, 1.0, 0.0);
+ var lookat = makeViewMatrix(position, focusPosition, upDirection);
+ var n = 0.1;
+ var f = 1000.0;
+ var l = -10.0;
+ var r = 10.0;
+ var b = -10.0;
+ var t = 10.0;
+ var frustum = makeFrustumMatrix(l, r, b, t, n, f);
+ var C = frustum * lookat as Matrix4;
+ var re = Vector3.zero();
unproject(C, 0.0, 100.0, 0.0, 100.0, 50.0, 50.0, 1.0, re);
}
void testLookAt() {
- Vector3 eyePosition = Vector3(0.0, 0.0, 0.0);
- Vector3 lookAtPosition = Vector3(0.0, 0.0, -1.0);
- Vector3 upDirection = Vector3(0.0, 1.0, 0.0);
+ var eyePosition = Vector3(0.0, 0.0, 0.0);
+ var lookAtPosition = Vector3(0.0, 0.0, -1.0);
+ var upDirection = Vector3(0.0, 1.0, 0.0);
- Matrix4 lookat = makeViewMatrix(eyePosition, lookAtPosition, upDirection);
+ var lookat = makeViewMatrix(eyePosition, lookAtPosition, upDirection);
assert(lookat.getColumn(0).w == 0.0);
assert(lookat.getColumn(1).w == 0.0);
assert(lookat.getColumn(2).w == 0.0);
@@ -45,13 +45,13 @@
}
void testFrustumMatrix() {
- double n = 0.1;
- double f = 1000.0;
- double l = -1.0;
- double r = 1.0;
- double b = -1.0;
- double t = 1.0;
- Matrix4 frustum = makeFrustumMatrix(l, r, b, t, n, f);
+ var n = 0.1;
+ var f = 1000.0;
+ var l = -1.0;
+ var r = 1.0;
+ var b = -1.0;
+ var t = 1.0;
+ var frustum = makeFrustumMatrix(l, r, b, t, n, f);
relativeTest(frustum.getColumn(0), Vector4(2 * n / (r - l), 0.0, 0.0, 0.0));
relativeTest(frustum.getColumn(1), Vector4(0.0, 2 * n / (t - b), 0.0, 0.0));
relativeTest(frustum.getColumn(2),
@@ -66,7 +66,7 @@
final double zNear = 1.0;
final double zFar = 100.0;
- Matrix4 perspective = makePerspectiveMatrix(fov, aspectRatio, zNear, zFar);
+ var perspective = makePerspectiveMatrix(fov, aspectRatio, zNear, zFar);
relativeTest(perspective.getColumn(0), Vector4(0.5, 0.0, 0.0, 0.0));
relativeTest(perspective.getColumn(1), Vector4(0.0, 1.0, 0.0, 0.0));
relativeTest(
@@ -79,7 +79,7 @@
final double aspectRatio = 2.0;
final double zNear = 1.0;
- Matrix4 infinite = makeInfiniteMatrix(fov, aspectRatio, zNear);
+ var infinite = makeInfiniteMatrix(fov, aspectRatio, zNear);
relativeTest(infinite.getColumn(0), Vector4(0.5, 0.0, 0.0, 0.0));
relativeTest(infinite.getColumn(1), Vector4(0.0, 1.0, 0.0, 0.0));
relativeTest(infinite.getColumn(2), Vector4(0.0, 0.0, -1.0, -1.0));
@@ -87,13 +87,13 @@
}
void testOrthographicMatrix() {
- double n = 0.1;
- double f = 1000.0;
- double l = -1.0;
- double r = 1.0;
- double b = -1.0;
- double t = 1.0;
- Matrix4 ortho = makeOrthographicMatrix(l, r, b, t, n, f);
+ var n = 0.1;
+ var f = 1000.0;
+ var l = -1.0;
+ var r = 1.0;
+ var b = -1.0;
+ var t = 1.0;
+ var ortho = makeOrthographicMatrix(l, r, b, t, n, f);
relativeTest(ortho.getColumn(0), Vector4(2 / (r - l), 0.0, 0.0, 0.0));
relativeTest(ortho.getColumn(1), Vector4(0.0, 2 / (t - b), 0.0, 0.0));
relativeTest(ortho.getColumn(2), Vector4(0.0, 0.0, -2 / (f - n), 0.0));
@@ -102,25 +102,25 @@
}
void testModelMatrix() {
- Matrix4 view = Matrix4.zero();
- Vector3 position = Vector3(1.0, 1.0, 1.0);
- Vector3 focus = Vector3(0.0, 0.0, -1.0);
- Vector3 up = Vector3(0.0, 1.0, 0.0);
+ var view = Matrix4.zero();
+ var position = Vector3(1.0, 1.0, 1.0);
+ var focus = Vector3(0.0, 0.0, -1.0);
+ var up = Vector3(0.0, 1.0, 0.0);
setViewMatrix(view, position, focus, up);
- Matrix4 model = Matrix4.zero();
+ var model = Matrix4.zero();
- Vector3 forward = focus.clone();
+ var forward = focus.clone();
forward.sub(position);
forward.normalize();
- Vector3 right = forward.cross(up).normalized();
- Vector3 u = right.cross(forward).normalized();
+ var right = forward.cross(up).normalized();
+ var u = right.cross(forward).normalized();
setModelMatrix(model, forward, u, position.x, position.y, position.z);
- Matrix4 result1 = view.clone();
+ var result1 = view.clone();
result1.multiply(model);
relativeTest(result1, Matrix4.identity());
diff --git a/test/quaternion_test.dart b/test/quaternion_test.dart
index 2c8afef..9c2568a 100644
--- a/test/quaternion_test.dart
+++ b/test/quaternion_test.dart
@@ -43,24 +43,24 @@
void testConjugate(List<Quaternion> input, List<Quaternion> expectedOutput) {
assert(input.length == expectedOutput.length);
- for (int i = 0; i < input.length; i++) {
- Quaternion output = input[i]..conjugate();
+ for (var i = 0; i < input.length; i++) {
+ var output = input[i]..conjugate();
relativeTest(output, expectedOutput[i]);
}
}
void testQuaternionMatrixRoundTrip(List<Quaternion> input) {
- for (int i = 0; i < input.length; i++) {
- Matrix3 R = input[i].asRotationMatrix();
- Quaternion output = Quaternion.fromRotation(R);
+ for (var i = 0; i < input.length; i++) {
+ var R = input[i].asRotationMatrix();
+ var output = Quaternion.fromRotation(R);
relativeTest(output, input[i]);
}
}
void testQuaternionMultiply(List<Quaternion> inputA, List<Quaternion> inputB,
List<Quaternion> expectedOutput) {
- for (int i = 0; i < inputA.length; i++) {
- Quaternion output = inputA[i] * inputB[i];
+ for (var i = 0; i < inputA.length; i++) {
+ var output = inputA[i] * inputB[i];
relativeTest(output, expectedOutput[i]);
}
}
@@ -69,18 +69,18 @@
List<Vector3> expectedOutput) {
assert((inputA.length == inputB.length) &&
(inputB.length == expectedOutput.length));
- for (int i = 0; i < inputA.length; i++) {
- Vector3 output = inputA[i].rotate(inputB[i]);
+ for (var i = 0; i < inputA.length; i++) {
+ var output = inputA[i].rotate(inputB[i]);
relativeTest(output, expectedOutput[i]);
}
}
void testQuaternionConjugate() {
- List<Quaternion> input = <Quaternion>[];
+ var input = <Quaternion>[];
input.add(Quaternion.identity());
input.add(Quaternion(0.18260, 0.54770, 0.73030, 0.36510));
input.add(Quaternion(0.9889, 0.0, 0.0, 0.14834));
- List<Quaternion> expectedOutput = <Quaternion>[];
+ var expectedOutput = <Quaternion>[];
expectedOutput.add(Quaternion(-0.0, -0.0, -0.0, 1.0));
expectedOutput.add(Quaternion(-0.18260, -0.54770, -0.73030, 0.36510));
expectedOutput.add(Quaternion(-0.9889, -0.0, -0.0, 0.1483));
@@ -88,7 +88,7 @@
}
void testQuaternionMatrixQuaternionRoundTrip() {
- List<Quaternion> input = <Quaternion>[];
+ var input = <Quaternion>[];
input.add(Quaternion.identity()..normalize());
input.add(Quaternion(0.18260, 0.54770, 0.73030, 0.36510)..normalize());
input.add(Quaternion(0.9889, 0.0, 0.0, 0.14834)..normalize());
@@ -100,22 +100,22 @@
}
void testQuaternionMultiplying() {
- List<Quaternion> inputA = <Quaternion>[];
+ var inputA = <Quaternion>[];
inputA.add(Quaternion(0.18260, 0.54770, 0.73030, 0.36510));
inputA.add(Quaternion(0.9889, 0.0, 0.0, 0.14834));
- List<Quaternion> inputB = <Quaternion>[];
+ var inputB = <Quaternion>[];
inputB.add(Quaternion(0.9889, 0.0, 0.0, 0.14834));
inputB.add(Quaternion(0.18260, 0.54770, 0.73030, 0.36510));
- List<Quaternion> expectedOutput = <Quaternion>[];
+ var expectedOutput = <Quaternion>[];
expectedOutput.add(Quaternion(0.388127, 0.803418, -0.433317, -0.126429));
expectedOutput.add(Quaternion(0.388127, -0.64097, 0.649924, -0.126429));
testQuaternionMultiply(inputA, inputB, expectedOutput);
}
void testQuaternionNormalize() {
- List<Quaternion> inputA = <Quaternion>[];
- List<Vector3> inputB = <Vector3>[];
- List<Vector3> expectedOutput = <Vector3>[];
+ var inputA = <Quaternion>[];
+ var inputB = <Vector3>[];
+ var expectedOutput = <Vector3>[];
inputA.add(Quaternion(0.0, 1.0, 0.0, 1.0)..normalize());
inputB.add(Vector3(1.0, 1.0, 1.0));
@@ -177,14 +177,14 @@
void testQuaternionAxisAngle() {
// Test conversion to and from axis-angle representation
{
- Quaternion q = Quaternion.axisAngle(Vector3(0.0, 1.0, 0.0), 0.5 * math.pi);
+ var q = Quaternion.axisAngle(Vector3(0.0, 1.0, 0.0), 0.5 * math.pi);
relativeTest(q.radians, 0.5 * math.pi);
relativeTest(q.axis, Vector3(0.0, 1.0, 0.0));
}
{
// Degenerate test: 0-angle
- Quaternion q = Quaternion.axisAngle(Vector3(1.0, 0.0, 0.0), 0.0);
+ var q = Quaternion.axisAngle(Vector3(1.0, 0.0, 0.0), 0.0);
relativeTest(q.radians, 0.0);
}
}
@@ -192,25 +192,25 @@
void testFromTwoVectors() {
{
// "Normal" test case
- Vector3 a = Vector3(1.0, 0.0, 0.0);
- Vector3 b = Vector3(0.0, 1.0, 0.0);
- Quaternion q = Quaternion.fromTwoVectors(a, b);
+ var a = Vector3(1.0, 0.0, 0.0);
+ var b = Vector3(0.0, 1.0, 0.0);
+ var q = Quaternion.fromTwoVectors(a, b);
relativeTest(q.radians, 0.5 * math.pi);
relativeTest(q.axis, Vector3(0.0, 0.0, 1.0));
}
{
// Degenerate null rotation
- Vector3 a = Vector3(1.0, 0.0, 0.0);
- Vector3 b = Vector3(1.0, 0.0, 0.0);
- Quaternion q = Quaternion.fromTwoVectors(a, b);
+ var a = Vector3(1.0, 0.0, 0.0);
+ var b = Vector3(1.0, 0.0, 0.0);
+ var q = Quaternion.fromTwoVectors(a, b);
relativeTest(q.radians, 0.0);
// Axis can be arbitrary
}
{
// Parallel vectors in opposite direction
- Vector3 a = Vector3(1.0, 0.0, 0.0);
- Vector3 b = Vector3(-1.0, 0.0, 0.0);
- Quaternion q = Quaternion.fromTwoVectors(a, b);
+ var a = Vector3(1.0, 0.0, 0.0);
+ var b = Vector3(-1.0, 0.0, 0.0);
+ var q = Quaternion.fromTwoVectors(a, b);
relativeTest(q.radians, math.pi);
}
}
diff --git a/test/scalar_list_view_test.dart b/test/scalar_list_view_test.dart
index b2d9319..c5df6bf 100644
--- a/test/scalar_list_view_test.dart
+++ b/test/scalar_list_view_test.dart
@@ -40,7 +40,7 @@
}
void testScalarListViewFromList() {
- List<double> input = List<double>(3);
+ var input = List<double>(3);
input[0] = 1.0;
input[1] = 4.0;
input[2] = 7.0;
diff --git a/test/test_utils.dart b/test/test_utils.dart
index 904360a..65300a1 100644
--- a/test/test_utils.dart
+++ b/test/test_utils.dart
@@ -48,17 +48,17 @@
T parseMatrix<T>(String input) {
input = input.trim();
- List<String> rows = input.split("\n");
- List<double> values = <double>[];
- int col_count = 0;
- for (int i = 0; i < rows.length; i++) {
+ var rows = input.split('\n');
+ var values = <double>[];
+ var col_count = 0;
+ for (var i = 0; i < rows.length; i++) {
rows[i] = rows[i].trim();
- List<String> cols = rows[i].split(" ");
- for (int j = 0; j < cols.length; j++) {
+ var cols = rows[i].split(' ');
+ for (var j = 0; j < cols.length; j++) {
cols[j] = cols[j].trim();
}
- for (int j = 0; j < cols.length; j++) {
+ for (var j = 0; j < cols.length; j++) {
if (cols[j].isEmpty) {
continue;
}
@@ -70,8 +70,8 @@
}
dynamic m = makeMatrix(rows.length, col_count);
- for (int j = 0; j < rows.length; j++) {
- for (int i = 0; i < col_count; i++) {
+ for (var j = 0; j < rows.length; j++) {
+ for (var i = 0; i < col_count; i++) {
m[m.index(j, i)] = values[j * col_count + i];
//m[i][j] = values[j*col_count+i];
}
@@ -83,9 +83,9 @@
T parseVector<T extends Vector>(String v) {
v = v.trim();
Pattern pattern = RegExp('[\\s]+', multiLine: true, caseSensitive: false);
- List<String> rows = v.split(pattern);
- List<double> values = <double>[];
- for (int i = 0; i < rows.length; i++) {
+ var rows = v.split(pattern);
+ var values = <double>[];
+ for (var i = 0; i < rows.length; i++) {
rows[i] = rows[i].trim();
if (rows[i].isEmpty) {
continue;
diff --git a/test/vector2_list_test.dart b/test/vector2_list_test.dart
index 6fc957d..238b5a5 100644
--- a/test/vector2_list_test.dart
+++ b/test/vector2_list_test.dart
@@ -14,7 +14,7 @@
import 'test_utils.dart';
void testVector2ListWithOffset() {
- Vector2List list = Vector2List(10, 1);
+ var list = Vector2List(10, 1);
list[0] = Vector2(1.0, 2.0);
relativeTest(list[0].x, 1.0);
relativeTest(list[0].y, 2.0);
@@ -25,8 +25,8 @@
}
void testVector2ListView() {
- Float32List buffer = Float32List(8);
- Vector2List list = Vector2List.view(buffer, 1, 3);
+ var buffer = Float32List(8);
+ var list = Vector2List.view(buffer, 1, 3);
// The list length should be (8 - 1) ~/ 3 == 2.
expect(list.length, 2);
list[0] = Vector2(1.0, 2.0);
@@ -42,8 +42,8 @@
}
void testVector2ListViewTightFit() {
- Float32List buffer = Float32List(8);
- Vector2List list = Vector2List.view(buffer, 2, 4);
+ var buffer = Float32List(8);
+ var list = Vector2List.view(buffer, 2, 4);
// The list length should be (8 - 2) ~/ 2 == 2 as the stride of the last
// element is negligible.
expect(list.length, 2);
@@ -60,11 +60,11 @@
}
void testVector2ListFromList() {
- List<Vector2> input = List<Vector2>(3);
+ var input = List<Vector2>(3);
input[0] = Vector2(1.0, 2.0);
input[1] = Vector2(3.0, 4.0);
input[2] = Vector2(5.0, 6.0);
- Vector2List list = Vector2List.fromList(input, 2, 5);
+ var list = Vector2List.fromList(input, 2, 5);
expect(list.buffer.length, 17);
expect(list.buffer[0], 0.0);
expect(list.buffer[1], 0.0);
diff --git a/test/vector2_test.dart b/test/vector2_test.dart
index c5bfc0f..4298c81 100644
--- a/test/vector2_test.dart
+++ b/test/vector2_test.dart
@@ -50,7 +50,7 @@
final Vector2 a = Vector2(5.0, 7.0);
final Vector2 b = Vector2(3.0, 8.0);
- Vector2 result = Vector2.zero();
+ var result = Vector2.zero();
Vector2.min(a, b, result);
expect(result.x, equals(3.0));
@@ -65,7 +65,7 @@
final Vector2 a = Vector2(5.0, 7.0);
final Vector2 b = Vector2(3.0, 8.0);
- Vector2 result = Vector2.zero();
+ var result = Vector2.zero();
Vector2.mix(a, b, 0.5, result);
expect(result.x, equals(4.0));
@@ -89,15 +89,15 @@
}
void testVector2Postmultiplication() {
- Matrix2 inputMatrix = Matrix2.rotation(.2);
- Vector2 inputVector = Vector2(1.0, 0.0);
- Matrix2 inputInv = Matrix2.copy(inputMatrix);
+ var inputMatrix = Matrix2.rotation(.2);
+ var inputVector = Vector2(1.0, 0.0);
+ var inputInv = Matrix2.copy(inputMatrix);
inputInv.invert();
// print("input $inputMatrix");
// print("input $inputInv");
- Vector2 resultOld = inputMatrix.transposed() * inputVector as Vector2;
- Vector2 resultOldvInv = inputInv * inputVector as Vector2;
- Vector2 resultNew = inputVector..postmultiply(inputMatrix);
+ var resultOld = inputMatrix.transposed() * inputVector as Vector2;
+ var resultOldvInv = inputInv * inputVector as Vector2;
+ var resultNew = inputVector..postmultiply(inputMatrix);
expect(resultNew.x, equals(resultOld.x));
expect(resultNew.y, equals(resultOld.y));
//matrix inversion can introduce a small error
@@ -107,7 +107,7 @@
void testVector2CrossProduct() {
final Vector2 inputA = Vector2(0.417267069084370, 0.049654430325742);
final Vector2 inputB = Vector2(0.944787189721646, 0.490864092468080);
- double expectedOutputCross = inputA.x * inputB.y - inputA.y * inputB.x;
+ var expectedOutputCross = inputA.x * inputB.y - inputA.y * inputB.x;
dynamic result;
result = cross2(inputA, inputB);
relativeTest(result, expectedOutputCross);
diff --git a/test/vector3_list_test.dart b/test/vector3_list_test.dart
index 61b19be..5ff6c45 100644
--- a/test/vector3_list_test.dart
+++ b/test/vector3_list_test.dart
@@ -14,7 +14,7 @@
import 'test_utils.dart';
void testVector3ListWithOffset() {
- Vector3List list = Vector3List(10, 1);
+ var list = Vector3List(10, 1);
list[0] = Vector3(1.0, 2.0, 3.0);
relativeTest(list[0].x, 1.0);
relativeTest(list[0].y, 2.0);
@@ -27,8 +27,8 @@
}
void testVector3ListView() {
- Float32List buffer = Float32List(10);
- Vector3List list = Vector3List.view(buffer, 1, 4);
+ var buffer = Float32List(10);
+ var list = Vector3List.view(buffer, 1, 4);
// The list length should be (10 - 1) ~/ 4 == 2.
expect(list.length, 2);
list[0] = Vector3(1.0, 2.0, 3.0);
@@ -46,8 +46,8 @@
}
void testVector3ListViewTightFit() {
- Float32List buffer = Float32List(10);
- Vector3List list = Vector3List.view(buffer, 2, 5);
+ var buffer = Float32List(10);
+ var list = Vector3List.view(buffer, 2, 5);
// The list length should be (10 - 2) ~/ 4 == 2 as the stride of the last
// element is negligible.
expect(list.length, 2);
@@ -66,11 +66,11 @@
}
void testVector3ListFromList() {
- List<Vector3> input = List<Vector3>(3);
+ var input = List<Vector3>(3);
input[0] = Vector3(1.0, 2.0, 3.0);
input[1] = Vector3(4.0, 5.0, 6.0);
input[2] = Vector3(7.0, 8.0, 9.0);
- Vector3List list = Vector3List.fromList(input, 2, 5);
+ var list = Vector3List.fromList(input, 2, 5);
expect(list.buffer.length, 17);
expect(list.buffer[0], 0.0);
expect(list.buffer[1], 0.0);
diff --git a/test/vector3_test.dart b/test/vector3_test.dart
index 135324f..7aec380 100644
--- a/test/vector3_test.dart
+++ b/test/vector3_test.dart
@@ -56,7 +56,7 @@
final Vector3 a = Vector3(5.0, 7.0, -3.0);
final Vector3 b = Vector3(3.0, 8.0, 2.0);
- Vector3 result = Vector3.zero();
+ var result = Vector3.zero();
Vector3.min(a, b, result);
expect(result.x, equals(3.0));
@@ -73,7 +73,7 @@
final Vector3 a = Vector3(5.0, 7.0, 3.0);
final Vector3 b = Vector3(3.0, 8.0, 2.0);
- Vector3 result = Vector3.zero();
+ var result = Vector3.zero();
Vector3.mix(a, b, 0.5, result);
expect(result.x, equals(4.0));
@@ -92,9 +92,9 @@
}
void testVector3DotProduct() {
- List<Vector3> inputA = <Vector3>[];
- List<Vector3> inputB = <Vector3>[];
- List<double> expectedOutput = <double>[];
+ var inputA = <Vector3>[];
+ var inputB = <Vector3>[];
+ var expectedOutput = <double>[];
inputA.add(parseVector<Vector3>('''0.417267069084370
0.049654430325742
0.902716109915281'''));
@@ -104,23 +104,23 @@
expectedOutput.add(0.860258396944727);
assert(inputA.length == inputB.length);
assert(inputB.length == expectedOutput.length);
- for (int i = 0; i < inputA.length; i++) {
- double output1 = dot3(inputA[i], inputB[i]);
- double output2 = dot3(inputB[i], inputA[i]);
+ for (var i = 0; i < inputA.length; i++) {
+ var output1 = dot3(inputA[i], inputB[i]);
+ var output2 = dot3(inputB[i], inputA[i]);
relativeTest(output1, expectedOutput[i]);
relativeTest(output2, expectedOutput[i]);
}
}
void testVector3Postmultiplication() {
- Matrix3 inputMatrix =
+ var inputMatrix =
(Matrix3.rotationX(.4)) * (Matrix3.rotationZ(.5)) as Matrix3;
- Vector3 inputVector = Vector3(1.0, 2.0, 3.0);
- Matrix3 inputInv = Matrix3.copy(inputMatrix);
+ var inputVector = Vector3(1.0, 2.0, 3.0);
+ var inputInv = Matrix3.copy(inputMatrix);
inputInv.invert();
- Vector3 resultOld = inputMatrix.transposed() * inputVector as Vector3;
- Vector3 resultOldvInv = inputInv * inputVector as Vector3;
- Vector3 resultNew = inputVector..postmultiply(inputMatrix);
+ var resultOld = inputMatrix.transposed() * inputVector as Vector3;
+ var resultOldvInv = inputInv * inputVector as Vector3;
+ var resultNew = inputVector..postmultiply(inputMatrix);
expect(resultNew.x, equals(resultOld.x));
expect(resultNew.y, equals(resultOld.y));
@@ -131,9 +131,9 @@
}
void testVector3CrossProduct() {
- List<Vector3> inputA = <Vector3>[];
- List<Vector3> inputB = <Vector3>[];
- List<Vector3> expectedOutput = <Vector3>[];
+ var inputA = <Vector3>[];
+ var inputB = <Vector3>[];
+ var expectedOutput = <Vector3>[];
inputA.add(parseVector<Vector3>('''0.417267069084370
0.049654430325742
@@ -158,16 +158,16 @@
assert(inputA.length == inputB.length);
assert(inputB.length == expectedOutput.length);
- for (int i = 0; i < inputA.length; i++) {
- Vector3 output = Vector3.zero();
+ for (var i = 0; i < inputA.length; i++) {
+ var output = Vector3.zero();
cross3(inputA[i], inputB[i], output);
relativeTest(output, expectedOutput[i]);
}
{
- Vector3 x = Vector3(1.0, 0.0, 0.0);
- Vector3 y = Vector3(0.0, 1.0, 0.0);
- Vector3 z = Vector3(0.0, 0.0, 1.0);
+ var x = Vector3(1.0, 0.0, 0.0);
+ var y = Vector3(0.0, 1.0, 0.0);
+ var z = Vector3(0.0, 0.0, 1.0);
Vector3 output;
output = x.cross(y);
diff --git a/test/vector4_list_test.dart b/test/vector4_list_test.dart
index f684dfa..8dc2ef9 100644
--- a/test/vector4_list_test.dart
+++ b/test/vector4_list_test.dart
@@ -14,7 +14,7 @@
import 'test_utils.dart';
void testVector4ListWithOffset() {
- Vector4List list = Vector4List(12, 1);
+ var list = Vector4List(12, 1);
list[0] = Vector4(1.0, 2.0, 3.0, 4.0);
relativeTest(list[0].x, 1.0);
relativeTest(list[0].y, 2.0);
@@ -29,8 +29,8 @@
}
void testVector4ListView() {
- Float32List buffer = Float32List(12);
- Vector4List list = Vector4List.view(buffer, 1, 5);
+ var buffer = Float32List(12);
+ var list = Vector4List.view(buffer, 1, 5);
// The list length should be (12 - 1) ~/ 5 == 2.
expect(list.length, 2);
list[0] = Vector4(1.0, 2.0, 3.0, 4.0);
@@ -50,8 +50,8 @@
}
void testVector4ListViewTightFit() {
- Float32List buffer = Float32List(12);
- Vector4List list = Vector4List.view(buffer, 2, 5);
+ var buffer = Float32List(12);
+ var list = Vector4List.view(buffer, 2, 5);
// The list length should be (12 - 2) ~/ 5 == 2 as the stride of the last
// element is negligible.
expect(list.length, 2);
@@ -72,11 +72,11 @@
}
void testVector4ListFromList() {
- List<Vector4> input = List<Vector4>(3);
+ var input = List<Vector4>(3);
input[0] = Vector4(1.0, 2.0, 3.0, 4.0);
input[1] = Vector4(5.0, 6.0, 7.0, 8.0);
input[2] = Vector4(9.0, 10.0, 11.0, 12.0);
- Vector4List list = Vector4List.fromList(input, 2, 5);
+ var list = Vector4List.fromList(input, 2, 5);
expect(list.buffer.length, 17);
expect(list.buffer[0], 0.0);
expect(list.buffer[1], 0.0);
diff --git a/test/vector4_test.dart b/test/vector4_test.dart
index 5762bbc..d916603 100644
--- a/test/vector4_test.dart
+++ b/test/vector4_test.dart
@@ -60,7 +60,7 @@
final Vector4 a = Vector4(5.0, 7.0, -3.0, 10.0);
final Vector4 b = Vector4(3.0, 8.0, 2.0, 2.0);
- Vector4 result = Vector4.zero();
+ var result = Vector4.zero();
Vector4.min(a, b, result);
expect(result.x, equals(3.0));
@@ -79,7 +79,7 @@
final Vector4 a = Vector4(5.0, 7.0, 3.0, 10.0);
final Vector4 b = Vector4(3.0, 8.0, 2.0, 2.0);
- Vector4 result = Vector4.zero();
+ var result = Vector4.zero();
Vector4.mix(a, b, 0.5, result);
expect(result.x, equals(4.0));