|
@@ -1,13 +1,71 @@
|
|
|
import { Vector3 } from './Vector3.js';
|
|
|
|
|
|
+const _points = [
|
|
|
+ /*@__PURE__*/ new Vector3(),
|
|
|
+ /*@__PURE__*/ new Vector3(),
|
|
|
+ /*@__PURE__*/ new Vector3(),
|
|
|
+ /*@__PURE__*/ new Vector3(),
|
|
|
+ /*@__PURE__*/ new Vector3(),
|
|
|
+ /*@__PURE__*/ new Vector3(),
|
|
|
+ /*@__PURE__*/ new Vector3(),
|
|
|
+ /*@__PURE__*/ new Vector3()
|
|
|
+];
|
|
|
+
|
|
|
+const _vector = /*@__PURE__*/ new Vector3();
|
|
|
+
|
|
|
+const _box = /*@__PURE__*/ new Box3();
|
|
|
+
|
|
|
+// triangle centered vertices
|
|
|
+
|
|
|
+const _v0 = /*@__PURE__*/ new Vector3();
|
|
|
+const _v1 = /*@__PURE__*/ new Vector3();
|
|
|
+const _v2 = /*@__PURE__*/ new Vector3();
|
|
|
+
|
|
|
+// triangle edge vectors
|
|
|
+
|
|
|
+const _f0 = /*@__PURE__*/ new Vector3();
|
|
|
+const _f1 = /*@__PURE__*/ new Vector3();
|
|
|
+const _f2 = /*@__PURE__*/ new Vector3();
|
|
|
+
|
|
|
+const _center = /*@__PURE__*/ new Vector3();
|
|
|
+const _extents = /*@__PURE__*/ new Vector3();
|
|
|
+const _triangleNormal = /*@__PURE__*/ new Vector3();
|
|
|
+const _testAxis = /*@__PURE__*/ new Vector3();
|
|
|
+
|
|
|
+function satForAxes( axes, v0, v1, v2, extents ) {
|
|
|
+
|
|
|
+ for ( let i = 0, j = axes.length - 3; i <= j; i += 3 ) {
|
|
|
+
|
|
|
+ _testAxis.fromArray( axes, i );
|
|
|
+ // project the aabb onto the seperating axis
|
|
|
+ const r = extents.x * Math.abs( _testAxis.x ) + extents.y * Math.abs( _testAxis.y ) + extents.z * Math.abs( _testAxis.z );
|
|
|
+ // project all 3 vertices of the triangle onto the seperating axis
|
|
|
+ const p0 = v0.dot( _testAxis );
|
|
|
+ const p1 = v1.dot( _testAxis );
|
|
|
+ const p2 = v2.dot( _testAxis );
|
|
|
+ // actual test, basically see if either of the most extreme of the triangle points intersects r
|
|
|
+ if ( Math.max( - Math.max( p0, p1, p2 ), Math.min( p0, p1, p2 ) ) > r ) {
|
|
|
+
|
|
|
+ // points of the projected triangle are outside the projected half-length of the aabb
|
|
|
+ // the axis is seperating and we can exit
|
|
|
+ return false;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
class Box3 {
|
|
|
|
|
|
- constructor( min, max ) {
|
|
|
+ constructor( min = new Vector3( + Infinity, + Infinity, + Infinity ), max = new Vector3( - Infinity, - Infinity, - Infinity ) ) {
|
|
|
|
|
|
this.isBox3 = true;
|
|
|
|
|
|
- this.min = ( min !== undefined ) ? min : new Vector3( + Infinity, + Infinity, + Infinity );
|
|
|
- this.max = ( max !== undefined ) ? max : new Vector3( - Infinity, - Infinity, - Infinity );
|
|
|
+ this.min = min;
|
|
|
+ this.max = max;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -492,63 +550,4 @@ class Box3 {
|
|
|
|
|
|
}
|
|
|
|
|
|
-function satForAxes( axes, v0, v1, v2, extents ) {
|
|
|
-
|
|
|
- for ( let i = 0, j = axes.length - 3; i <= j; i += 3 ) {
|
|
|
-
|
|
|
- _testAxis.fromArray( axes, i );
|
|
|
- // project the aabb onto the seperating axis
|
|
|
- const r = extents.x * Math.abs( _testAxis.x ) + extents.y * Math.abs( _testAxis.y ) + extents.z * Math.abs( _testAxis.z );
|
|
|
- // project all 3 vertices of the triangle onto the seperating axis
|
|
|
- const p0 = v0.dot( _testAxis );
|
|
|
- const p1 = v1.dot( _testAxis );
|
|
|
- const p2 = v2.dot( _testAxis );
|
|
|
- // actual test, basically see if either of the most extreme of the triangle points intersects r
|
|
|
- if ( Math.max( - Math.max( p0, p1, p2 ), Math.min( p0, p1, p2 ) ) > r ) {
|
|
|
-
|
|
|
- // points of the projected triangle are outside the projected half-length of the aabb
|
|
|
- // the axis is seperating and we can exit
|
|
|
- return false;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- return true;
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-const _points = [
|
|
|
- /*@__PURE__*/ new Vector3(),
|
|
|
- /*@__PURE__*/ new Vector3(),
|
|
|
- /*@__PURE__*/ new Vector3(),
|
|
|
- /*@__PURE__*/ new Vector3(),
|
|
|
- /*@__PURE__*/ new Vector3(),
|
|
|
- /*@__PURE__*/ new Vector3(),
|
|
|
- /*@__PURE__*/ new Vector3(),
|
|
|
- /*@__PURE__*/ new Vector3()
|
|
|
-];
|
|
|
-
|
|
|
-const _vector = /*@__PURE__*/ new Vector3();
|
|
|
-
|
|
|
-const _box = /*@__PURE__*/ new Box3();
|
|
|
-
|
|
|
-// triangle centered vertices
|
|
|
-
|
|
|
-const _v0 = /*@__PURE__*/ new Vector3();
|
|
|
-const _v1 = /*@__PURE__*/ new Vector3();
|
|
|
-const _v2 = /*@__PURE__*/ new Vector3();
|
|
|
-
|
|
|
-// triangle edge vectors
|
|
|
-
|
|
|
-const _f0 = /*@__PURE__*/ new Vector3();
|
|
|
-const _f1 = /*@__PURE__*/ new Vector3();
|
|
|
-const _f2 = /*@__PURE__*/ new Vector3();
|
|
|
-
|
|
|
-const _center = /*@__PURE__*/ new Vector3();
|
|
|
-const _extents = /*@__PURE__*/ new Vector3();
|
|
|
-const _triangleNormal = /*@__PURE__*/ new Vector3();
|
|
|
-const _testAxis = /*@__PURE__*/ new Vector3();
|
|
|
-
|
|
|
-
|
|
|
export { Box3 };
|