@@ -9,13 +9,6 @@ import type { Vector3 } from '@minecraft/server';
99import { VECTOR3_FORWARD , VECTOR3_ONE , VECTOR3_ZERO , Vector3Utils } from '../vector3/coreHelpers.js' ;
1010import { AABB , AABBUtils } from './coreHelpers.js' ;
1111
12- function expectVector3 ( expected : Vector3 , actual : Vector3 ) {
13- return expect (
14- Vector3Utils . equals ( expected , actual ) ,
15- `Expected ${ Vector3Utils . toString ( expected ) } but actual is ${ Vector3Utils . toString ( actual ) } `
16- ) ;
17- }
18-
1912describe ( 'AABB factories' , ( ) => {
2013 it ( 'successfully reports invalid AABB when created from identical corner points' , ( ) => {
2114 const aabb = AABBUtils . createFromCornerPoints ( VECTOR3_ONE , VECTOR3_ONE ) ;
@@ -165,42 +158,42 @@ describe('AABB BlockVolume operations', () => {
165158 it ( 'successfully creates a BlockVolume when AABB extents are VECTOR3_ONE' , ( ) => {
166159 const aabb : AABB = { center : VECTOR3_ZERO , extents : VECTOR3_ONE } ;
167160 const blockVolume = AABBUtils . getBlockVolume ( aabb ) ;
168- expectVector3 ( { x : - 1.0 , y : - 1.0 , z : - 1.0 } , blockVolume . from ) . toBe ( true ) ;
169- expectVector3 ( { x : 1.0 , y : 1.0 , z : 1.0 } , blockVolume . to ) . toBe ( true ) ;
161+ expect ( blockVolume . from ) . toEqual ( { x : - 1.0 , y : - 1.0 , z : - 1.0 } ) ;
162+ expect ( blockVolume . to ) . toEqual ( { x : 1.0 , y : 1.0 , z : 1.0 } ) ;
170163 } ) ;
171164
172165 it ( 'successfully creates a BlockVolume when AABB extents coords are 0.5' , ( ) => {
173166 const aabb : AABB = { center : VECTOR3_ZERO , extents : { x : 0.5 , y : 0.5 , z : 0.5 } } ;
174167 const blockVolume = AABBUtils . getBlockVolume ( aabb ) ;
175- expectVector3 ( { x : - 1.0 , y : - 1.0 , z : - 1.0 } , blockVolume . from ) . toBe ( true ) ;
176- expectVector3 ( { x : 1.0 , y : 1.0 , z : 1.0 } , blockVolume . to ) . toBe ( true ) ;
168+ expect ( blockVolume . from ) . toEqual ( { x : - 1.0 , y : - 1.0 , z : - 1.0 } ) ;
169+ expect ( blockVolume . to ) . toEqual ( { x : 1.0 , y : 1.0 , z : 1.0 } ) ;
177170 } ) ;
178171
179172 it ( 'successfully creates a BlockVolume when AABB center and extent coords are 0.5' , ( ) => {
180173 const aabb : AABB = { center : { x : 0.5 , y : 0.5 , z : 0.5 } , extents : { x : 0.5 , y : 0.5 , z : 0.5 } } ;
181174 const blockVolume = AABBUtils . getBlockVolume ( aabb ) ;
182- expectVector3 ( { x : 0.0 , y : 0.0 , z : 0.0 } , blockVolume . from ) . toBe ( true ) ;
183- expectVector3 ( { x : 1.0 , y : 1.0 , z : 1.0 } , blockVolume . to ) . toBe ( true ) ;
175+ expect ( blockVolume . from ) . toEqual ( { x : 0.0 , y : 0.0 , z : 0.0 } ) ;
176+ expect ( blockVolume . to ) . toEqual ( { x : 1.0 , y : 1.0 , z : 1.0 } ) ;
184177 } ) ;
185178
186179 it ( 'successfully creates a BlockVolume when AABB center coords are -0.5 and extent coords are 0.5' , ( ) => {
187180 const aabb : AABB = { center : { x : - 0.5 , y : - 0.5 , z : - 0.5 } , extents : { x : 0.5 , y : 0.5 , z : 0.5 } } ;
188181 const blockVolume = AABBUtils . getBlockVolume ( aabb ) ;
189- expectVector3 ( { x : - 1.0 , y : - 1.0 , z : - 1.0 } , blockVolume . from ) . toBe ( true ) ;
190- expectVector3 ( { x : 0.0 , y : 0.0 , z : 0.0 } , blockVolume . to ) . toBe ( true ) ;
182+ expect ( blockVolume . from ) . toEqual ( { x : - 1.0 , y : - 1.0 , z : - 1.0 } ) ;
183+ expect ( blockVolume . to ) . toEqual ( { x : - 0.0 , y : - 0.0 , z : - 0.0 } ) ;
191184 } ) ;
192185
193186 it ( 'successfully creates a BlockVolume when AABB extents are greater than VECTOR3_ZERO within epsilon' , ( ) => {
194187 const aabb : AABB = { center : VECTOR3_ZERO , extents : { x : 0.00001 , y : 0.00001 , z : 0.00001 } } ;
195188 const blockVolume = AABBUtils . getBlockVolume ( aabb ) ;
196- expectVector3 ( { x : 0.0 , y : 0.0 , z : 0.0 } , blockVolume . from ) . toBe ( true ) ;
197- expectVector3 ( { x : 0.0 , y : 0.0 , z : 0.0 } , blockVolume . to ) . toBe ( true ) ;
189+ expect ( blockVolume . from ) . toEqual ( { x : 0.0 , y : 0.0 , z : 0.0 } ) ;
190+ expect ( blockVolume . to ) . toEqual ( { x : 0.0 , y : 0.0 , z : 0.0 } ) ;
198191 } ) ;
199192
200193 it ( 'successfully creates a BlockVolume when AABB extents are greater than VECTOR3_ZERO exceeding epsilon' , ( ) => {
201194 const aabb : AABB = { center : VECTOR3_ZERO , extents : { x : 0.00002 , y : 0.00002 , z : 0.00002 } } ;
202195 const blockVolume = AABBUtils . getBlockVolume ( aabb ) ;
203- expectVector3 ( { x : - 1.0 , y : - 1.0 , z : - 1.0 } , blockVolume . from ) . toBe ( true ) ;
204- expectVector3 ( { x : 1.0 , y : 1.0 , z : 1.0 } , blockVolume . to ) . toBe ( true ) ;
196+ expect ( blockVolume . from ) . toEqual ( { x : - 1.0 , y : - 1.0 , z : - 1.0 } ) ;
197+ expect ( blockVolume . to ) . toEqual ( { x : 1.0 , y : 1.0 , z : 1.0 } ) ;
205198 } ) ;
206199} ) ;
0 commit comments