Skip to content

Commit

Permalink
refactor(geom): dedupe union() impls
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jun 20, 2024
1 parent 159cd56 commit c1880c8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/geom/src/union.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ export type UnionFn = {
*/
export const union = <UnionFn>defmulti<any, any, IShape>(
__dispatch,
{},
{
rect: "aabb",
},
{
aabb: (a: AABB, b: AABB) =>
new AABB(...__unionBounds(a.pos, a.size, b.pos, b.size)),

rect: (a: Rect, b: Rect) =>
new Rect(...__unionBounds(a.pos, a.size, b.pos, b.size)),
new (<any>a.constructor)(
...__unionBounds(a.pos, a.size, b.pos, b.size)
),
}
);

0 comments on commit c1880c8

Please sign in to comment.