bounds, AABB and AABBLike #455
-
| Hi, Or is the main reason that I have to decide afterwards, if I want to have a rect (2D) or an aabb (3d) ? Kind regards! | 
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
| Hi Martin - the purpose of the  So to use the result with  intersectionAABB(
  <AABB>bounds(points3(myPoints)),
  <AABB>bounds(points3(myOtherPoints))
);I should update the  | 
Beta Was this translation helpful? Give feedback.
Hi Martin - the purpose of the
AABBLikeinterface is a generalization for both 2D/3D cases and it's currently implemented by both theRect(for 2D) andAABB(for 3D) classes. Thebounds()function is polymorphic and dynamically chooses the right impl based on given inputs, but TypeScript only allows to specify a single return type (hence theAABBLiketo satisfy both dimensions). In your case,bounds()will delegate to an implementation forpoints3and does actually return anAABBshape instance, but again, thebounds()function's return type is more general...So to use the result with
intersectionAABB()you just need to add a manual cast to<AABB>, but do not require a separate coercion …