@@ -14,24 +14,23 @@ class Aabb3 {
1414 Vector3 get max => _max;
1515
1616 /// The center of the AABB.
17- Vector3 get center => _min.clone ()
18- ..add (_max)
19- ..scale (0.5 );
17+ Vector3 get center =>
18+ _min.clone ()
19+ ..add (_max)
20+ ..scale (0.5 );
2021
2122 /// Create a new AABB with [min] and [max] set to the origin.
22- Aabb3 ()
23- : _min = Vector3 .zero (),
24- _max = Vector3 .zero ();
23+ Aabb3 () : _min = Vector3 .zero (), _max = Vector3 .zero ();
2524
2625 /// Create a new AABB as a copy of [other] .
2726 Aabb3 .copy (Aabb3 other)
28- : _min = Vector3 .copy (other._min),
29- _max = Vector3 .copy (other._max);
27+ : _min = Vector3 .copy (other._min),
28+ _max = Vector3 .copy (other._max);
3029
3130 /// Create a new AABB with a [min] and [max] .
3231 Aabb3 .minMax (Vector3 min, Vector3 max)
33- : _min = Vector3 .copy (min),
34- _max = Vector3 .copy (max);
32+ : _min = Vector3 .copy (min),
33+ _max = Vector3 .copy (max);
3534
3635 /// Create a new AABB that encloses a [sphere] .
3736 factory Aabb3 .fromSphere (Sphere sphere) => Aabb3 ()..setSphere (sphere);
@@ -59,9 +58,11 @@ class Aabb3 {
5958 /// starting at [offset] . [offset] has to be multiple of
6059 /// [Float32List.bytesPerElement] .
6160 Aabb3 .fromBuffer (ByteBuffer buffer, int offset)
62- : _min = Vector3 .fromBuffer (buffer, offset),
63- _max = Vector3 .fromBuffer (
64- buffer, offset + Float32List .bytesPerElement * 3 );
61+ : _min = Vector3 .fromBuffer (buffer, offset),
62+ _max = Vector3 .fromBuffer (
63+ buffer,
64+ offset + Float32List .bytesPerElement * 3 ,
65+ );
6566
6667 /// Set the AABB by a [center] and [halfExtents] .
6768 void setCenterAndHalfExtents (Vector3 center, Vector3 halfExtents) {
@@ -86,41 +87,65 @@ class Aabb3 {
8687 /// Set the AABB to enclose a [triangle] .
8788 void setTriangle (Triangle triangle) {
8889 _min.setValues (
89- math.min (triangle._point0.x,
90- math.min (triangle._point1.x, triangle._point2.x)),
91- math.min (triangle._point0.y,
92- math.min (triangle._point1.y, triangle._point2.y)),
93- math.min (triangle._point0.z,
94- math.min (triangle._point1.z, triangle._point2.z)));
90+ math.min (
91+ triangle._point0.x,
92+ math.min (triangle._point1.x, triangle._point2.x),
93+ ),
94+ math.min (
95+ triangle._point0.y,
96+ math.min (triangle._point1.y, triangle._point2.y),
97+ ),
98+ math.min (
99+ triangle._point0.z,
100+ math.min (triangle._point1.z, triangle._point2.z),
101+ ),
102+ );
95103 _max.setValues (
96- math.max (triangle._point0.x,
97- math.max (triangle._point1.x, triangle._point2.x)),
98- math.max (triangle._point0.y,
99- math.max (triangle._point1.y, triangle._point2.y)),
100- math.max (triangle._point0.z,
101- math.max (triangle._point1.z, triangle._point2.z)));
104+ math.max (
105+ triangle._point0.x,
106+ math.max (triangle._point1.x, triangle._point2.x),
107+ ),
108+ math.max (
109+ triangle._point0.y,
110+ math.max (triangle._point1.y, triangle._point2.y),
111+ ),
112+ math.max (
113+ triangle._point0.z,
114+ math.max (triangle._point1.z, triangle._point2.z),
115+ ),
116+ );
102117 }
103118
104119 /// Set the AABB to enclose a [quad] .
105120 void setQuad (Quad quad) {
106121 _min.setValues (
107- math.min (quad._point0.x,
108- math.min (quad._point1.x, math.min (quad._point2.x, quad._point3.x))),
109- math.min (quad._point0.y,
110- math.min (quad._point1.y, math.min (quad._point2.y, quad._point3.y))),
111- math.min (
112- quad._point0.z,
113- math.min (
114- quad._point1.z, math.min (quad._point2.z, quad._point3.z))));
122+ math.min (
123+ quad._point0.x,
124+ math.min (quad._point1.x, math.min (quad._point2.x, quad._point3.x)),
125+ ),
126+ math.min (
127+ quad._point0.y,
128+ math.min (quad._point1.y, math.min (quad._point2.y, quad._point3.y)),
129+ ),
130+ math.min (
131+ quad._point0.z,
132+ math.min (quad._point1.z, math.min (quad._point2.z, quad._point3.z)),
133+ ),
134+ );
115135 _max.setValues (
116- math.max (quad._point0.x,
117- math.max (quad._point1.x, math.max (quad._point2.x, quad._point3.x))),
118- math.max (quad._point0.y,
119- math.max (quad._point1.y, math.max (quad._point2.y, quad._point3.y))),
120- math.max (
121- quad._point0.z,
122- math.max (
123- quad._point1.z, math.max (quad._point2.z, quad._point3.z))));
136+ math.max (
137+ quad._point0.x,
138+ math.max (quad._point1.x, math.max (quad._point2.x, quad._point3.x)),
139+ ),
140+ math.max (
141+ quad._point0.y,
142+ math.max (quad._point1.y, math.max (quad._point2.y, quad._point3.y)),
143+ ),
144+ math.max (
145+ quad._point0.z,
146+ math.max (quad._point1.z, math.max (quad._point2.z, quad._point3.z)),
147+ ),
148+ );
124149 }
125150
126151 /// Set the AABB to enclose a [obb] .
@@ -238,15 +263,17 @@ class Aabb3 {
238263
239264 /// Create a copy of this that is transformed by the transform [t] and store
240265 /// it in [out] .
241- Aabb3 transformed (Matrix4 t, Aabb3 out) => out
242- ..copyFrom (this )
243- ..transform (t);
266+ Aabb3 transformed (Matrix4 t, Aabb3 out) =>
267+ out
268+ ..copyFrom (this )
269+ ..transform (t);
244270
245271 /// Create a copy of this that is rotated by the rotation matrix [t] and
246272 /// store it in [out] .
247- Aabb3 rotated (Matrix4 t, Aabb3 out) => out
248- ..copyFrom (this )
249- ..rotate (t);
273+ Aabb3 rotated (Matrix4 t, Aabb3 out) =>
274+ out
275+ ..copyFrom (this )
276+ ..rotate (t);
250277
251278 void getPN (Vector3 planeNormal, Vector3 outP, Vector3 outN) {
252279 if (planeNormal.x < 0.0 ) {
@@ -393,8 +420,11 @@ class Aabb3 {
393420 /// be used for the test. If [result] is specified and an intersection is
394421 /// found, result is modified to contain more details about the type of
395422 /// intersection.
396- bool intersectsWithTriangle (Triangle other,
397- {double epsilon = 1e-3 , IntersectionResult ? result}) {
423+ bool intersectsWithTriangle (
424+ Triangle other, {
425+ double epsilon = 1e-3 ,
426+ IntersectionResult ? result,
427+ }) {
398428 double p0, p1, p2, r, len;
399429 double a;
400430
@@ -639,7 +669,8 @@ class Aabb3 {
639669 copyCenterAndHalfExtents (_aabbCenter, _aabbHalfExtents);
640670
641671 // Compute the projection interval radius of b onto L(t) = b.c + t * p.n
642- final r = _aabbHalfExtents[0 ] * other.normal[0 ].abs () +
672+ final r =
673+ _aabbHalfExtents[0 ] * other.normal[0 ].abs () +
643674 _aabbHalfExtents[1 ] * other.normal[1 ].abs () +
644675 _aabbHalfExtents[2 ] * other.normal[2 ].abs ();
645676 // Compute distance of box center from plane
0 commit comments