Skip to content

bounds, AABB and AABBLike #455

Answered by postspectacular
dennemark asked this question in Q&A
Discussion options

You must be logged in to vote

Hi Martin - the purpose of the AABBLike interface is a generalization for both 2D/3D cases and it's currently implemented by both the Rect (for 2D) and AABB (for 3D) classes. The bounds() function is polymorphic and dynamically chooses the right impl based on given inputs, but TypeScript only allows to specify a single return type (hence the AABBLike to satisfy both dimensions). In your case, bounds() will delegate to an implementation for points3 and does actually return an AABB shape instance, but again, the bounds() 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 …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@dennemark
Comment options

@postspectacular
Comment options

Answer selected by dennemark
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants